mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 17:59:52 +00:00
merge 0.2.2
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@94 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
cbf2be8db4
commit
823add403e
5 changed files with 27 additions and 5 deletions
|
|
@ -2,7 +2,7 @@ module MessagePack
|
|||
module VERSION #:nodoc:
|
||||
MAJOR = 0
|
||||
MINOR = 2
|
||||
TINY = 1
|
||||
TINY = 2
|
||||
|
||||
STRING = [MAJOR, MINOR, TINY].join('.')
|
||||
end
|
||||
|
|
|
|||
11
ruby/msgpack.gemspec
Executable file
11
ruby/msgpack.gemspec
Executable file
|
|
@ -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
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue