@@ -95,7 +95,7 @@ msgpack_unpack_func(msgpack_unpack_object, _data)(msgpack_unpack_struct(_context
9595}
9696
9797
98- msgpack_unpack_func (int , _execute )(msgpack_unpack_struct (_context )* ctx , const char * data , size_t len , size_t * off )
98+ msgpack_unpack_func (int , _execute )(msgpack_unpack_struct (_context )* ctx , const char * data , size_t len , size_t * off , bool construct )
9999{
100100 assert (len >= * off );
101101
@@ -117,14 +117,17 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
117117
118118 int ret ;
119119
120+ #define construct_cb (name ) \
121+ construct && msgpack_unpack_callback(name)
122+
120123#define push_simple_value (func ) \
121- if(msgpack_unpack_callback (func)(user, &obj) < 0) { goto _failed; } \
124+ if(construct_cb (func)(user, &obj) < 0) { goto _failed; } \
122125 goto _push
123126#define push_fixed_value (func , arg ) \
124- if(msgpack_unpack_callback (func)(user, arg, &obj) < 0) { goto _failed; } \
127+ if(construct_cb (func)(user, arg, &obj) < 0) { goto _failed; } \
125128 goto _push
126129#define push_variable_value (func , base , pos , len ) \
127- if(msgpack_unpack_callback (func)(user, \
130+ if(construct_cb (func)(user, \
128131 (const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
129132 goto _push
130133
@@ -140,9 +143,9 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
140143
141144#define start_container (func , count_ , ct_ ) \
142145 if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
143- if (msgpack_unpack_callback (func )(user , count_ , & stack [top ].obj ) < 0 ) { goto _failed ; } \
146+ if (construct_cb (func )(user , count_ , & stack [top ].obj ) < 0 ) { goto _failed ; } \
144147 if ((count_ ) == 0 ) { obj = stack [top ].obj ; \
145- msgpack_unpack_callback (func ##_end )(user , & obj ); \
148+ construct_cb (func ##_end )(user , & obj ); \
146149 goto _push ; } \
147150 stack [top ].ct = ct_ ; \
148151 stack [top ].size = count_ ; \
@@ -340,10 +343,10 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
340343 c = & stack [top - 1 ];
341344 switch (c -> ct ) {
342345 case CT_ARRAY_ITEM :
343- if (msgpack_unpack_callback (_array_item )(user , c -> count , & c -> obj , obj ) < 0 ) { goto _failed ; }
346+ if (construct_cb (_array_item )(user , c -> count , & c -> obj , obj ) < 0 ) { goto _failed ; }
344347 if (++ c -> count == c -> size ) {
345348 obj = c -> obj ;
346- msgpack_unpack_callback (_array_end )(user , & obj );
349+ construct_cb (_array_end )(user , & obj );
347350 -- top ;
348351 /*printf("stack pop %d\n", top);*/
349352 goto _push ;
@@ -354,10 +357,10 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
354357 c -> ct = CT_MAP_VALUE ;
355358 goto _header_again ;
356359 case CT_MAP_VALUE :
357- if (msgpack_unpack_callback (_map_item )(user , & c -> obj , c -> map_key , obj ) < 0 ) { goto _failed ; }
360+ if (construct_cb (_map_item )(user , & c -> obj , c -> map_key , obj ) < 0 ) { goto _failed ; }
358361 if (++ c -> count == c -> size ) {
359362 obj = c -> obj ;
360- msgpack_unpack_callback (_map_end )(user , & obj );
363+ construct_cb (_map_end )(user , & obj );
361364 -- top ;
362365 /*printf("stack pop %d\n", top);*/
363366 goto _push ;
@@ -399,6 +402,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
399402 * off = p - (const unsigned char * )data ;
400403
401404 return ret ;
405+ #undef construct_cb
402406}
403407
404408
0 commit comments