mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 02:09:59 +00:00
lang/c/msgpack: removed string type
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@54 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
f41c20a250
commit
249d3e9c90
9 changed files with 29 additions and 44 deletions
|
|
@ -20,5 +20,5 @@ msgpack_object msgpack_unpack_array_start(msgpack_unpack_context* x, unsigned in
|
|||
msgpack_object msgpack_unpack_map_start(msgpack_unpack_context* x, unsigned int n);
|
||||
void msgpack_unpack_map_item(msgpack_unpack_context* x, msgpack_object c, msgpack_object k, msgpack_object v);
|
||||
msgpack_object msgpack_unpack_string(msgpack_unpack_context* x, const void* b, size_t l);
|
||||
msgpack_object msgpack_unpack_raw(msgpack_unpack_context* x, const void* b, size_t l);
|
||||
msgpack_object msgpack_unpack_raw(msgpack_unpack_context* x, const void* b, const void* p, size_t l);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ typedef struct {
|
|||
size_t count;
|
||||
unsigned int ct;
|
||||
union {
|
||||
const unsigned char* terminal_trail_start;
|
||||
/*const unsigned char* terminal_trail_start;*/
|
||||
msgpack_object map_key;
|
||||
} tmp;
|
||||
} msgpack_unpacker_stack;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ static inline uint64_t betoh64(uint64_t x) {
|
|||
typedef enum {
|
||||
CS_HEADER = 0x00, // nil
|
||||
|
||||
CS_STRING = 0x01,
|
||||
//CS_STRING = 0x01,
|
||||
//CS_ = 0x02, // false
|
||||
//CS_ = 0x03, // true
|
||||
|
||||
|
|
@ -186,15 +186,17 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
obj = func(user, arg); \
|
||||
/*printf("obj %d\n",obj);*/ \
|
||||
goto _push
|
||||
#define push_variable_value(func, arg, arglen) \
|
||||
obj = func(user, arg, arglen); \
|
||||
#define push_variable_value(func, base, pos, len) \
|
||||
obj = func(user, (const void*)base, (const void*)pos, len); \
|
||||
/*printf("obj %d\n",obj);*/ \
|
||||
goto _push
|
||||
|
||||
/*
|
||||
#define again_terminal_trail(_cs, from) \
|
||||
cs = _cs; \
|
||||
stack[top].tmp.terminal_trail_start = from; \
|
||||
goto _terminal_trail_again
|
||||
*/
|
||||
#define again_fixed_trail(_cs, trail_len) \
|
||||
trail = trail_len; \
|
||||
cs = _cs; \
|
||||
|
|
@ -237,8 +239,8 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
switch(*p) {
|
||||
case 0xc0: // nil
|
||||
push_simple_value(msgpack_unpack_nil);
|
||||
case 0xc1: // string
|
||||
again_terminal_trail(NEXT_CS(p), p+1);
|
||||
//case 0xc1: // string
|
||||
// again_terminal_trail(NEXT_CS(p), p+1);
|
||||
case 0xc2: // false
|
||||
push_simple_value(msgpack_unpack_false);
|
||||
case 0xc3: // true
|
||||
|
|
@ -289,16 +291,16 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
// end CS_HEADER
|
||||
|
||||
|
||||
_terminal_trail_again:
|
||||
++p;
|
||||
//_terminal_trail_again:
|
||||
// ++p;
|
||||
|
||||
case CS_STRING:
|
||||
if(*p == 0) {
|
||||
const unsigned char* start = stack[top].tmp.terminal_trail_start;
|
||||
obj = msgpack_unpack_string(user, start, p-start);
|
||||
goto _push;
|
||||
}
|
||||
goto _terminal_trail_again;
|
||||
//case CS_STRING:
|
||||
// if(*p == 0) {
|
||||
// const unsigned char* start = stack[top].tmp.terminal_trail_start;
|
||||
// obj = msgpack_unpack_string(user, start, p-start);
|
||||
// goto _push;
|
||||
// }
|
||||
// goto _terminal_trail_again;
|
||||
|
||||
|
||||
_fixed_trail_again:
|
||||
|
|
@ -343,7 +345,7 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
//case ACS_BIG_INT_VALUE:
|
||||
//_big_int_zero:
|
||||
// // FIXME
|
||||
// push_variable_value(msgpack_unpack_big_int, n, trail);
|
||||
// push_variable_value(msgpack_unpack_big_int, data, n, trail);
|
||||
|
||||
//case CS_BIG_FLOAT_16:
|
||||
// again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint16_t)PTR_CAST_16(n), _big_float_zero);
|
||||
|
|
@ -352,7 +354,7 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
//case ACS_BIG_FLOAT_VALUE:
|
||||
//_big_float_zero:
|
||||
// // FIXME
|
||||
// push_variable_value(msgpack_unpack_big_float, n, trail);
|
||||
// push_variable_value(msgpack_unpack_big_float, data, n, trail);
|
||||
|
||||
case CS_RAW_16:
|
||||
again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint16_t)PTR_CAST_16(n), _raw_zero);
|
||||
|
|
@ -360,7 +362,7 @@ int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len
|
|||
again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint32_t)PTR_CAST_32(n), _raw_zero);
|
||||
case ACS_RAW_VALUE:
|
||||
_raw_zero:
|
||||
push_variable_value(msgpack_unpack_raw, n, trail);
|
||||
push_variable_value(msgpack_unpack_raw, data, n, trail);
|
||||
|
||||
case CS_ARRAY_16:
|
||||
start_container(msgpack_unpack_array_start, (uint16_t)PTR_CAST_16(n), CT_ARRAY_ITEM);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue