mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-14 18:10:30 +01:00
lang/c/msgpack: uint64_t, int64_t support for ruby
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@49 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
269cda016d
commit
9f460f17d7
153
ruby/Makefile
153
ruby/Makefile
@ -1,153 +0,0 @@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = .
|
||||
topdir = /Users/frsyuki/ports/lib/ruby/1.8/i686-darwin9.1.0
|
||||
hdrdir = $(topdir)
|
||||
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
||||
prefix = $(DESTDIR)/Users/frsyuki/ports
|
||||
exec_prefix = $(prefix)
|
||||
sitedir = $(prefix)/lib/ruby/site_ruby
|
||||
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
||||
docdir = $(datarootdir)/doc/$(PACKAGE)
|
||||
dvidir = $(docdir)
|
||||
datarootdir = $(prefix)/share
|
||||
archdir = $(rubylibdir)/$(arch)
|
||||
sbindir = $(exec_prefix)/sbin
|
||||
psdir = $(docdir)
|
||||
vendordir = $(prefix)/lib/ruby/vendor_ruby
|
||||
localedir = $(datarootdir)/locale
|
||||
htmldir = $(docdir)
|
||||
datadir = $(datarootdir)
|
||||
includedir = $(prefix)/include
|
||||
infodir = $(datarootdir)/info
|
||||
sysconfdir = $(prefix)/etc
|
||||
mandir = $(DESTDIR)/Users/frsyuki/ports/share/man
|
||||
libdir = $(exec_prefix)/lib
|
||||
sharedstatedir = $(prefix)/com
|
||||
oldincludedir = $(DESTDIR)/usr/include
|
||||
pdfdir = $(docdir)
|
||||
sitearchdir = $(sitelibdir)/$(sitearch)
|
||||
vendorarchdir = $(vendorlibdir)/$(vendorarch)
|
||||
bindir = $(exec_prefix)/bin
|
||||
localstatedir = $(prefix)/var
|
||||
vendorlibdir = $(vendordir)/$(ruby_version)
|
||||
sitelibdir = $(sitedir)/$(ruby_version)
|
||||
libexecdir = $(exec_prefix)/libexec
|
||||
|
||||
CC = /usr/bin/gcc-4.0
|
||||
LIBRUBY = $(LIBRUBY_SO)
|
||||
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
||||
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
||||
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
||||
|
||||
RUBY_EXTCONF_H =
|
||||
CFLAGS = -fno-common -O2 -fno-common -pipe -fno-common -I.. -Wall -O9
|
||||
INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
|
||||
CPPFLAGS = -I/Users/frsyuki/ports/include
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
DLDFLAGS = -L. -L/Users/frsyuki/ports/lib
|
||||
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
|
||||
AR = ar
|
||||
EXEEXT =
|
||||
|
||||
RUBY_INSTALL_NAME = ruby
|
||||
RUBY_SO_NAME = ruby
|
||||
arch = i686-darwin9.1.0
|
||||
sitearch = i686-darwin9.1.0
|
||||
vendorarch = i686-darwin9.1.0
|
||||
ruby_version = 1.8
|
||||
ruby = /Users/frsyuki/ports/bin/ruby
|
||||
RUBY = $(ruby)
|
||||
RM = rm -f
|
||||
MAKEDIRS = mkdir -p
|
||||
INSTALL = /usr/bin/install
|
||||
INSTALL_PROG = $(INSTALL) -m 0755
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
COPY = cp
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
preload =
|
||||
|
||||
libpath = . $(libdir)
|
||||
LIBPATH = -L"." -L"$(libdir)"
|
||||
DEFFILE =
|
||||
|
||||
CLEANFILES = mkmf.log
|
||||
DISTCLEANFILES =
|
||||
|
||||
extout =
|
||||
extout_prefix =
|
||||
target_prefix =
|
||||
LOCAL_LIBS =
|
||||
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
|
||||
SRCS = pack.c rbinit.c unpack.c unpack_inline.c
|
||||
OBJS = pack.o rbinit.o unpack.o unpack_inline.o
|
||||
TARGET = msgpack
|
||||
DLLIB = $(TARGET).bundle
|
||||
EXTSTATIC =
|
||||
STATIC_LIB =
|
||||
|
||||
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
||||
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
||||
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
||||
|
||||
TARGET_SO = $(DLLIB)
|
||||
CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
|
||||
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
||||
|
||||
all: $(DLLIB)
|
||||
static: $(STATIC_LIB)
|
||||
|
||||
clean:
|
||||
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
||||
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
||||
|
||||
realclean: distclean
|
||||
install: install-so install-rb
|
||||
|
||||
install-so: $(RUBYARCHDIR)
|
||||
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
||||
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
||||
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
||||
install-rb: pre-install-rb install-rb-default
|
||||
install-rb-default: pre-install-rb-default
|
||||
pre-install-rb: Makefile
|
||||
pre-install-rb-default: Makefile
|
||||
$(RUBYARCHDIR):
|
||||
$(MAKEDIRS) $@
|
||||
|
||||
site-install: site-install-so site-install-rb
|
||||
site-install-so: install-so
|
||||
site-install-rb: install-rb
|
||||
|
||||
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
||||
|
||||
.cc.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.C.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
$(DLLIB): $(OBJS)
|
||||
@-$(RM) $@
|
||||
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
||||
|
||||
|
||||
|
||||
$(OBJS): ruby.h defines.h
|
18
ruby/pack.c
18
ruby/pack.c
@ -62,6 +62,23 @@ static VALUE MessagePack_Fixnum_to_msgpack(int argc, VALUE *argv, VALUE self)
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
#ifndef RBIGNUM_SIGN // Ruby 1.8
|
||||
#define RBIGNUM_SIGN(b) (RBIGNUM(b)->sign)
|
||||
#endif
|
||||
|
||||
static VALUE MessagePack_Bignum_to_msgpack(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
ARG_BUFFER(out, argc, argv);
|
||||
// FIXME bignum
|
||||
if(RBIGNUM_SIGN(self)) { // positive
|
||||
msgpack_pack_unsigned_int_64(out, rb_big2ull(self));
|
||||
} else { // negative
|
||||
msgpack_pack_signed_int_64(out, rb_big2ll(self));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Float_to_msgpack(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
ARG_BUFFER(out, argc, argv);
|
||||
@ -122,6 +139,7 @@ void Init_msgpack_pack(VALUE mMessagePack)
|
||||
rb_define_method_id(rb_cTrueClass, s_to_msgpack, MessagePack_TrueClass_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cFalseClass, s_to_msgpack, MessagePack_FalseClass_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cFixnum, s_to_msgpack, MessagePack_Fixnum_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cBignum, s_to_msgpack, MessagePack_Bignum_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cFloat, s_to_msgpack, MessagePack_Float_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cString, s_to_msgpack, MessagePack_String_to_msgpack, -1);
|
||||
rb_define_method_id(rb_cArray, s_to_msgpack, MessagePack_Array_to_msgpack, -1);
|
||||
|
@ -30,7 +30,7 @@ static inline VALUE msgpack_unpack_unsigned_int_32(msgpack_unpack_context* x, ui
|
||||
{ return UINT2NUM(d); }
|
||||
|
||||
static inline VALUE msgpack_unpack_unsigned_int_64(msgpack_unpack_context* x, uint64_t d)
|
||||
{ return UINT2NUM(d); } // FIXME
|
||||
{ return rb_ull2inum(d); }
|
||||
|
||||
static inline VALUE msgpack_unpack_signed_int_8(msgpack_unpack_context* x, int8_t d)
|
||||
{ return INT2FIX((long)d); }
|
||||
@ -42,7 +42,7 @@ static inline VALUE msgpack_unpack_signed_int_32(msgpack_unpack_context* x, int3
|
||||
{ return INT2NUM((long)d); }
|
||||
|
||||
static inline VALUE msgpack_unpack_signed_int_64(msgpack_unpack_context* x, int64_t d)
|
||||
{ return INT2NUM(d); } // FIXME
|
||||
{ return rb_ll2inum(d); }
|
||||
|
||||
static inline VALUE msgpack_unpack_float(msgpack_unpack_context* x, float d)
|
||||
{ return rb_float_new(d); }
|
||||
@ -63,7 +63,7 @@ static inline VALUE msgpack_unpack_array_start(msgpack_unpack_context* x, unsign
|
||||
{ return rb_ary_new2(n); }
|
||||
|
||||
static inline void msgpack_unpack_array_item(msgpack_unpack_context* x, VALUE c, VALUE o)
|
||||
{ rb_ary_push(c, o); }
|
||||
{ rb_ary_push(c, o); } // FIXME set value directry RARRAY_PTR(obj)[RARRAY_LEN(obj)++]
|
||||
|
||||
static inline VALUE msgpack_unpack_map_start(msgpack_unpack_context* x, unsigned int n)
|
||||
{ return rb_hash_new(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user