Changeset 18598

Show
Ignore:
Timestamp:
09/02/08 00:07:12 (4 months ago)
Author:
frsyuki
Message:

lang/c/msgpack: uint64_t, int64_t support for ruby

Location:
lang/c/msgpack/trunk/ruby
Files:
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • lang/c/msgpack/trunk/ruby/pack.c

    r17708 r18598  
    6363} 
    6464 
     65 
     66#ifndef RBIGNUM_SIGN  // Ruby 1.8 
     67#define RBIGNUM_SIGN(b) (RBIGNUM(b)->sign) 
     68#endif 
     69 
     70static VALUE MessagePack_Bignum_to_msgpack(int argc, VALUE *argv, VALUE self) 
     71{ 
     72        ARG_BUFFER(out, argc, argv); 
     73        // FIXME bignum 
     74        if(RBIGNUM_SIGN(self)) {  // positive 
     75                msgpack_pack_unsigned_int_64(out, rb_big2ull(self)); 
     76        } else {  // negative 
     77                msgpack_pack_signed_int_64(out, rb_big2ll(self)); 
     78        } 
     79        return out; 
     80} 
     81 
    6582static VALUE MessagePack_Float_to_msgpack(int argc, VALUE *argv, VALUE self) 
    6683{ 
     
    123140        rb_define_method_id(rb_cFalseClass, s_to_msgpack, MessagePack_FalseClass_to_msgpack, -1); 
    124141        rb_define_method_id(rb_cFixnum, s_to_msgpack, MessagePack_Fixnum_to_msgpack, -1); 
     142        rb_define_method_id(rb_cBignum, s_to_msgpack, MessagePack_Bignum_to_msgpack, -1); 
    125143        rb_define_method_id(rb_cFloat,  s_to_msgpack, MessagePack_Float_to_msgpack, -1); 
    126144        rb_define_method_id(rb_cString, s_to_msgpack, MessagePack_String_to_msgpack, -1); 
  • lang/c/msgpack/trunk/ruby/unpack_inline.c

    r17708 r18598  
    3131 
    3232static inline VALUE msgpack_unpack_unsigned_int_64(msgpack_unpack_context* x, uint64_t d) 
    33 { return UINT2NUM(d); }  // FIXME 
     33{ return rb_ull2inum(d); } 
    3434 
    3535static inline VALUE msgpack_unpack_signed_int_8(msgpack_unpack_context* x, int8_t d) 
     
    4343 
    4444static inline VALUE msgpack_unpack_signed_int_64(msgpack_unpack_context* x, int64_t d) 
    45 { return INT2NUM(d); }  // FIXME 
     45{ return rb_ll2inum(d); } 
    4646 
    4747static inline VALUE msgpack_unpack_float(msgpack_unpack_context* x, float d) 
     
    6464 
    6565static inline void msgpack_unpack_array_item(msgpack_unpack_context* x, VALUE c, VALUE o) 
    66 { rb_ary_push(c, o); } 
     66{ rb_ary_push(c, o); }  // FIXME set value directry RARRAY_PTR(obj)[RARRAY_LEN(obj)++] 
    6767 
    6868static inline VALUE msgpack_unpack_map_start(msgpack_unpack_context* x, unsigned int n)