@@ -95,7 +95,7 @@ msgpack_unpack_func(msgpack_unpack_object, _data)(msgpack_unpack_struct(_context
95
95
}
96
96
97
97
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 )
99
99
{
100
100
assert (len >= * off );
101
101
@@ -117,14 +117,17 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
117
117
118
118
int ret ;
119
119
120
+ #define construct_cb (name ) \
121
+ construct && msgpack_unpack_callback(name)
122
+
120
123
#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; } \
122
125
goto _push
123
126
#define push_fixed_value (func , a
8000
rg ) \
124
- if(msgpack_unpack_callback (func)(user, arg, &obj) < 0) { goto _failed; } \
127
+ if(construct_cb (func)(user, arg, &obj) < 0) { goto _failed; } \
125
128
goto _push
126
129
#define push_variable_value (func , base , pos , len ) \
127
- if(msgpack_unpack_callback (func)(user, \
130
+ if(construct_cb (func)(user, \
128
131
(const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
129
132
goto _push
130
133
@@ -140,9 +143,9 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
140
143
141
144
#define start_container (func , count_ , ct_ ) \
142
145
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 ; } \
144
147
if ((count_ ) == 0 ) { obj = stack [top ].obj ; \
145
- msgpack_unpack_callback (func ##_end )(user , & obj ); \
148
+ construct_cb (func ##_end )(user , & obj ); \
146
149
goto _push ; } \
147
150
stack [top ].ct = ct_ ; \
148
151
stack [top ].size = count_ ; \
@@ -340,10 +343,10 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
340
343
c = & stack [top - 1 ];
341
344
switch (c -> ct ) {
342
345
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 ; }
344
347
if (++ c -> count == c -> size ) {
345
348
obj = c -> obj ;
346
- msgpack_unpack_callback (_array_end )(user , & obj );
349
+ construct_cb (_array_end )(user , & obj );
347
350
-- top ;
348
351
/*printf("stack pop %d\n", top);*/
349
352
goto _push ;
@@ -354,10 +357,10 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
354
357
c -> ct = CT_MAP_VALUE ;
355
358
goto _header_again ;
356
359
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 ; }
358
361
if (++ c -> count == c -> size ) {
359
362
obj = c -> obj ;
360
- msgpack_unpack_callback (_map_end )(user , & obj );
363
+ construct_cb (_map_end )(user , & obj );
361
364
-- top ;
362
365
/*printf("stack pop %d\n", top);*/
363
366
goto _push ;
@@ -399,6 +402,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
399
402
* off = p - (const unsigned char * )data ;
400
403
401
404
return ret ;
405
+ #undef construct_cb
402
406
}
403
407
404
408
0 commit comments