write values as code
This commit is contained in:
parent
1a52281b4e
commit
380a3aa3a1
@ -121,6 +121,9 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO do this somewhere else, not in the c code...
|
||||||
|
int is_code = !strcmp("$where", RSTRING(key)->ptr);
|
||||||
|
|
||||||
switch(TYPE(value)) {
|
switch(TYPE(value)) {
|
||||||
case T_FIXNUM:
|
case T_FIXNUM:
|
||||||
write_name_and_type(buffer, key, 0x10);
|
write_name_and_type(buffer, key, 0x10);
|
||||||
@ -171,7 +174,11 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|||||||
memcpy(buffer->buffer + length_location, &obj_length, 4);
|
memcpy(buffer->buffer + length_location, &obj_length, 4);
|
||||||
break;
|
break;
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
|
if (is_code) {
|
||||||
|
write_name_and_type(buffer, key, 0x0D);
|
||||||
|
} else {
|
||||||
write_name_and_type(buffer, key, 0x02);
|
write_name_and_type(buffer, key, 0x02);
|
||||||
|
}
|
||||||
int length = RSTRING(value)->len + 1;
|
int length = RSTRING(value)->len + 1;
|
||||||
buffer_write_bytes(buffer, (char*)&length, 4);
|
buffer_write_bytes(buffer, (char*)&length, 4);
|
||||||
buffer_write_bytes(buffer, RSTRING(value)->ptr, length - 1);
|
buffer_write_bytes(buffer, RSTRING(value)->ptr, length - 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user