summaryrefslogtreecommitdiff
path: root/msgpack/unpack_template.h
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2012-06-26 15:19:59 +0900
committerINADA Naoki <songofacandy@gmail.com>2012-06-26 15:19:59 +0900
commit188da01777d83e4024c3c7799892a492e4ec25e8 (patch)
treecc37273212f123b58dcc8446c6172b0cd6e9a0c2 /msgpack/unpack_template.h
parent812c8bcff42a5b77f9ddfce70289bf754cca108c (diff)
downloadmsgpack-python-188da01777d83e4024c3c7799892a492e4ec25e8.tar.gz
Fix new version of msgpack.
Diffstat (limited to 'msgpack/unpack_template.h')
-rw-r--r--msgpack/unpack_template.h17
1 files changed, 12 insertions, 5 deletions
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 */