diff options
| author | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:10:01 +0000 |
|---|---|---|
| committer | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:10:01 +0000 |
| commit | 823add403e5f0d905fc0003023c2b270adb22897 (patch) | |
| tree | a764e408d25c3f7637985300c58bd9e3d084f089 /ruby | |
| parent | cbf2be8db4f6bc18e1ec3002534da06774561a4d (diff) | |
| download | msgpack-python-823add403e5f0d905fc0003023c2b270adb22897.tar.gz | |
merge 0.2.2
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@94 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
Diffstat (limited to 'ruby')
| -rw-r--r-- | ruby/gem/lib/msgpack/version.rb | 2 | ||||
| -rwxr-xr-x | ruby/msgpack.gemspec | 11 | ||||
| -rw-r--r-- | ruby/unpack.c | 13 |
3 files changed, 23 insertions, 3 deletions
diff --git a/ruby/gem/lib/msgpack/version.rb b/ruby/gem/lib/msgpack/version.rb index 229c746..488e0b2 100644 --- a/ruby/gem/lib/msgpack/version.rb +++ b/ruby/gem/lib/msgpack/version.rb @@ -2,7 +2,7 @@ module MessagePack module VERSION #:nodoc: MAJOR = 0 MINOR = 2 - TINY = 1 + TINY = 2 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/ruby/msgpack.gemspec b/ruby/msgpack.gemspec new file mode 100755 index 0000000..db2fcd5 --- /dev/null +++ b/ruby/msgpack.gemspec @@ -0,0 +1,11 @@ +Gem::Specification.new do |s|
+ s.platform = Gem::Platform::CURRENT
+ s.name = "msgpack"
+ s.version = "0.2.2"
+ s.summary = "MessagePack"
+ s.author = "FURUHASHI Sadayuki"
+ s.email = "frsyuki _at_ users.sourceforge.jp"
+ s.homepage = "https://launchpad.net/msgpack/"
+ s.require_paths = ["lib", "ext"]
+ s.files = ["lib/**/*", "ext/**/*"].map {|g| Dir.glob(g) }.flatten
+end diff --git a/ruby/unpack.c b/ruby/unpack.c index 8ab425c..df72246 100644 --- a/ruby/unpack.c +++ b/ruby/unpack.c @@ -21,6 +21,7 @@ typedef struct { int finished; + VALUE origstr; } msgpack_unpack_context; @@ -104,7 +105,7 @@ static inline void template_callback_map_item(msgpack_unpack_context* x, VALUE* { rb_hash_aset(*c, k, v); } static inline VALUE template_callback_raw(msgpack_unpack_context* x, const char* b, const char* p, unsigned int l) -{ return rb_str_new(p, l); } +{ return l == 0 ? rb_str_new(0,0) : rb_str_substr(x->origstr, p - b, l); } #include "msgpack/unpack_template.h" @@ -152,8 +153,9 @@ static VALUE MessagePack_Unpacker_alloc(VALUE klass) static VALUE MessagePack_Unpacker_reset(VALUE self) { UNPACKER(self, mp); - mp->user.finished = 0; msgpack_unpacker_init(mp); + msgpack_unpack_context ctx = {0, Qnil}; + mp->user = ctx; return self; } @@ -179,7 +181,9 @@ static VALUE MessagePack_Unpacker_execute_impl(VALUE args) rb_raise(eUnpackError, "offset is bigger than data buffer size."); } + mp->user.origstr = data; ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); + mp->user.origstr = Qnil; if(ret < 0) { rb_raise(eUnpackError, "parse error."); @@ -239,7 +243,9 @@ static VALUE MessagePack_unpack_impl(VALUE args) long dlen = RSTRING_LEN(data); int ret; + mp->user.origstr = data; ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); + mp->user.origstr = Qnil; if(ret < 0) { rb_raise(eUnpackError, "parse error."); @@ -268,6 +274,9 @@ static VALUE MessagePack_unpack(VALUE self, VALUE data) CHECK_STRING_TYPE(data); msgpack_unpacker mp; msgpack_unpacker_init(&mp); + msgpack_unpack_context ctx = {0, Qnil}; + mp.user = ctx; + rb_gc_disable(); VALUE args[2] = {(VALUE)&mp, data}; VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args, |
