diff options
| author | frsyuki <frsyuki@users.sourceforge.jp> | 2010-08-31 09:29:01 +0900 |
|---|---|---|
| committer | frsyuki <frsyuki@users.sourceforge.jp> | 2010-08-31 09:29:01 +0900 |
| commit | 71a1cb01842787e2fa897f023addd88337542915 (patch) | |
| tree | e70a347a42cb071c4ae9e38e7c5a21723bea7161 /ruby | |
| parent | 09b47cc536ebd951c231fd5e09b4382a25b98020 (diff) | |
| download | msgpack-python-71a1cb01842787e2fa897f023addd88337542915.tar.gz | |
fixes compatibility with Rubinius
Diffstat (limited to 'ruby')
| -rw-r--r-- | ruby/compat.h | 17 | ||||
| -rw-r--r-- | ruby/extconf.rb | 2 | ||||
| -rw-r--r-- | ruby/pack.c | 8 |
3 files changed, 20 insertions, 7 deletions
diff --git a/ruby/compat.h b/ruby/compat.h index 98c8881..d7a2ca7 100644 --- a/ruby/compat.h +++ b/ruby/compat.h @@ -35,6 +35,23 @@ extern VALUE s_enc_utf8_value; #endif +/* ruby 1.8 and Rubinius */ +#ifndef RBIGNUM_POSITIVE_P +# ifdef RUBINIUS +# define RBIGNUM_POSITIVE_P(b) (rb_funcall(b, rb_intern(">="), 1, INT2FIX(0)) == Qtrue) +# else +# define RBIGNUM_POSITIVE_P(b) (RBIGNUM(b)->sign) +# endif +#endif + + +/* Rubinius */ +#ifdef RUBINIUS +static inline void rb_gc_enable() { return; } +static inline void rb_gc_disable() { return; } +#endif + + /* ruby 1.8.5 */ #ifndef RSTRING_PTR #define RSTRING_PTR(s) (RSTRING(s)->ptr) diff --git a/ruby/extconf.rb b/ruby/extconf.rb index eb6a389..f1d44ec 100644 --- a/ruby/extconf.rb +++ b/ruby/extconf.rb @@ -1,5 +1,5 @@ require 'mkmf' require './version.rb' -$CFLAGS << %[ -I.. -Wall -O4 -DMESSAGEPACK_VERSION=\\"#{MessagePack::VERSION}\\"] +$CFLAGS << %[ -I.. -Wall -O4 -DMESSAGEPACK_VERSION=\\"#{MessagePack::VERSION}\\" -g] create_makefile('msgpack') diff --git a/ruby/pack.c b/ruby/pack.c index 49b69fc..8ce46aa 100644 --- a/ruby/pack.c +++ b/ruby/pack.c @@ -118,10 +118,6 @@ static VALUE MessagePack_Fixnum_to_msgpack(int argc, VALUE *argv, VALUE self) } -#ifndef RBIGNUM_SIGN // Ruby 1.8 -#define RBIGNUM_SIGN(b) (RBIGNUM(b)->sign) -#endif - /* * Document-method: Bignum#to_msgpack * @@ -133,9 +129,9 @@ static VALUE MessagePack_Fixnum_to_msgpack(int argc, VALUE *argv, VALUE self) static VALUE MessagePack_Bignum_to_msgpack(int argc, VALUE *argv, VALUE self) { ARG_BUFFER(out, argc, argv); - if(RBIGNUM_SIGN(self)) { // positive + if(RBIGNUM_POSITIVE_P(self)) { msgpack_pack_uint64(out, rb_big2ull(self)); - } else { // negative + } else { msgpack_pack_int64(out, rb_big2ll(self)); } return out; |
