From 3ef1a6dfa81787bb693e9da27dc1e3b5bce89ca7 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Thu, 5 Mar 2009 17:03:49 -0500 Subject: [PATCH] support for bignum --- ext/cbson/cbson.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/cbson/cbson.c b/ext/cbson/cbson.c index 8d5b674..f81bf58 100644 --- a/ext/cbson/cbson.c +++ b/ext/cbson/cbson.c @@ -125,9 +125,15 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow int is_code = !strcmp("$where", RSTRING(key)->ptr); switch(TYPE(value)) { + case T_BIGNUM: + write_name_and_type(buffer, key, 0x10); + VALUE as_f = rb_funcall(value, rb_intern("to_f"), 0); + int int_value = NUM2LL(as_f); + buffer_write_bytes(buffer, (char*)&int_value, 4); + break; case T_FIXNUM: write_name_and_type(buffer, key, 0x10); - int int_value = FIX2INT(value); + int_value = FIX2INT(value); buffer_write_bytes(buffer, (char*)&int_value, 4); break; case T_TRUE: