bytebuffers => binary w/ subtype 2
This commit is contained in:
parent
24e695b40d
commit
5e1f827b09
|
@ -162,9 +162,11 @@ static int write_element(VALUE key, VALUE value, VALUE extra) {
|
||||||
{
|
{
|
||||||
// TODO there has to be a better way to do these checks...
|
// TODO there has to be a better way to do these checks...
|
||||||
const char* cls = rb_class2name(RBASIC(value)->klass);
|
const char* cls = rb_class2name(RBASIC(value)->klass);
|
||||||
if (strcmp(cls, "XGen::Mongo::Driver::Binary") == 0) {
|
if (strcmp(cls, "XGen::Mongo::Driver::Binary") == 0 ||
|
||||||
|
strcmp(cls, "ByteBuffer") == 0) {
|
||||||
write_name_and_type(buffer, key, 0x05);
|
write_name_and_type(buffer, key, 0x05);
|
||||||
const char subtype = (const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0));
|
const char subtype = strcmp(cls, "ByteBuffer") ?
|
||||||
|
(const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0)) : 2;
|
||||||
VALUE string_data = rb_funcall(value, rb_intern("to_s"), 0);
|
VALUE string_data = rb_funcall(value, rb_intern("to_s"), 0);
|
||||||
int length = RSTRING(string_data)->len;
|
int length = RSTRING(string_data)->len;
|
||||||
if (subtype == 2) {
|
if (subtype == 2) {
|
||||||
|
|
Loading…
Reference in New Issue