diff options
author | INADA Naoki <songofacandy@gmail.com> | 2012-06-26 15:19:59 +0900 |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2012-06-26 15:19:59 +0900 |
commit | 188da01777d83e4024c3c7799892a492e4ec25e8 (patch) | |
tree | cc37273212f123b58dcc8446c6172b0cd6e9a0c2 | |
parent | 812c8bcff42a5b77f9ddfce70289bf754cca108c (diff) | |
download | msgpack-python-188da01777d83e4024c3c7799892a492e4ec25e8.tar.gz |
Fix new version of msgpack.
-rw-r--r-- | msgpack/unpack.h | 2 | ||||
-rw-r--r-- | msgpack/unpack_template.h | 17 | ||||
-rwxr-xr-x | setup.py | 1 |
3 files changed, 14 insertions, 6 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h index 2659a97..a106f9c 100644 --- a/msgpack/unpack.h +++ b/msgpack/unpack.h @@ -16,7 +16,7 @@ * limitations under the License. */ -#define MSGPACK_MAX_STACK_SIZE (1024) +#define MSGPACK_EMBED_STACK_SIZE (1024) #include "unpack_define.h" typedef struct unpack_user { diff --git a/msgpack/unpack_template.h b/msgpack/unpack_template.h index 711b163..b844a24 100644 --- a/msgpack/unpack_template.h +++ b/msgpack/unpack_template.h @@ -48,6 +48,7 @@ msgpack_unpack_struct_decl(_stack) { msgpack_unpack_object obj; + size_t size; size_t count; unsigned int ct; msgpack_unpack_object map_key; @@ -140,9 +141,12 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c #define start_container(func, count_, ct_) \ if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \ if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \ - if((count_) == 0) { obj = stack[top].obj; goto _push; } \ + if((count_) == 0) { obj = stack[top].obj; \ + msgpack_unpack_callback(func##_end)(user, &obj); \ + goto _push; } \ stack[top].ct = ct_; \ - stack[top].count = count_; \ + stack[top].size = count_; \ + stack[top].count = 0; \ ++top; \ /*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \ /*printf("stack push %d\n", top);*/ \ @@ -336,9 +340,10 @@ _push: c = &stack[top-1]; switch(c->ct) { case CT_ARRAY_ITEM: - if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; } - if(--c->count == 0) { + if(msgpack_unpack_callback(_array_item)(user, c->count, &c->obj, obj) < 0) { goto _failed; } + if(++c->count == c->size) { obj = c->obj; + msgpack_unpack_callback(_array_end)(user, &obj); --top; /*printf("stack pop %d\n", top);*/ goto _push; @@ -350,8 +355,9 @@ _push: goto _header_again; case CT_MAP_VALUE: if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; } - if(--c->count == 0) { + if(++c->count == c->size) { obj = c->obj; + msgpack_unpack_callback(_map_end)(user, &obj); --top; /*printf("stack pop %d\n", top);*/ goto _push; @@ -411,3 +417,4 @@ _end: #undef NEXT_CS +/* vim: set ts=4 sw=4 noexpandtab */ @@ -52,6 +52,7 @@ if sys.platform == 'win32': msgpack_mod = Extension('msgpack._msgpack', sources=sources, libraries=libraries, + include_dirs=['.'], ) del sources, libraries |