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:
frsyuki
2009-02-15 09:10:01 +00:00
parent cbf2be8db4
commit 823add403e
5 changed files with 27 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
AC_INIT(msgpack/unpack_template.h) AC_INIT(msgpack/unpack_template.h)
AM_INIT_AUTOMAKE(msgpack, 0.2.1) AM_INIT_AUTOMAKE(msgpack, 0.2.2)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
AC_PROG_LIBTOOL AC_PROG_LIBTOOL

View File

@@ -22,8 +22,10 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <arpa/inet.h>
#include <stdio.h> #include <stdio.h>
#ifndef __WIN32__
#include <arpa/inet.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -2,7 +2,7 @@ module MessagePack
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 0 MAJOR = 0
MINOR = 2 MINOR = 2
TINY = 1 TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.') STRING = [MAJOR, MINOR, TINY].join('.')
end end

11
ruby/msgpack.gemspec Executable file
View 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

View File

@@ -21,6 +21,7 @@
typedef struct { typedef struct {
int finished; int finished;
VALUE origstr;
} msgpack_unpack_context; } 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); } { 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) 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" #include "msgpack/unpack_template.h"
@@ -152,8 +153,9 @@ static VALUE MessagePack_Unpacker_alloc(VALUE klass)
static VALUE MessagePack_Unpacker_reset(VALUE self) static VALUE MessagePack_Unpacker_reset(VALUE self)
{ {
UNPACKER(self, mp); UNPACKER(self, mp);
mp->user.finished = 0;
msgpack_unpacker_init(mp); msgpack_unpacker_init(mp);
msgpack_unpack_context ctx = {0, Qnil};
mp->user = ctx;
return self; return self;
} }
@@ -179,7 +181,9 @@ static VALUE MessagePack_Unpacker_execute_impl(VALUE args)
rb_raise(eUnpackError, "offset is bigger than data buffer size."); rb_raise(eUnpackError, "offset is bigger than data buffer size.");
} }
mp->user.origstr = data;
ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from);
mp->user.origstr = Qnil;
if(ret < 0) { if(ret < 0) {
rb_raise(eUnpackError, "parse error."); rb_raise(eUnpackError, "parse error.");
@@ -239,7 +243,9 @@ static VALUE MessagePack_unpack_impl(VALUE args)
long dlen = RSTRING_LEN(data); long dlen = RSTRING_LEN(data);
int ret; int ret;
mp->user.origstr = data;
ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from); ret = msgpack_unpacker_execute(mp, dptr, (size_t)dlen, &from);
mp->user.origstr = Qnil;
if(ret < 0) { if(ret < 0) {
rb_raise(eUnpackError, "parse error."); rb_raise(eUnpackError, "parse error.");
@@ -268,6 +274,9 @@ static VALUE MessagePack_unpack(VALUE self, VALUE data)
CHECK_STRING_TYPE(data); CHECK_STRING_TYPE(data);
msgpack_unpacker mp; msgpack_unpacker mp;
msgpack_unpacker_init(&mp); msgpack_unpacker_init(&mp);
msgpack_unpack_context ctx = {0, Qnil};
mp.user = ctx;
rb_gc_disable(); rb_gc_disable();
VALUE args[2] = {(VALUE)&mp, data}; VALUE args[2] = {(VALUE)&mp, data};
VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args, VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args,