diff --git a/src/msgpack/unpack.hpp b/src/msgpack/unpack.hpp index 44eec64b..a842ba76 100644 --- a/src/msgpack/unpack.hpp +++ b/src/msgpack/unpack.hpp @@ -60,48 +60,48 @@ private: bool referenced_; }; -inline bool template_callback_uint8(unpack_user&, uint8_t d, object& o) -{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } +inline void template_callback_uint8(unpack_user&, uint8_t d, object& o) +{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } -inline bool template_callback_uint16(unpack_user&, uint16_t d, object& o) -{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } +inline void template_callback_uint16(unpack_user&, uint16_t d, object& o) +{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } -inline bool template_callback_uint32(unpack_user&, uint32_t d, object& o) -{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } +inline void template_callback_uint32(unpack_user&, uint32_t d, object& o) +{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } -inline bool template_callback_uint64(unpack_user&, uint64_t d, object& o) -{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } +inline void template_callback_uint64(unpack_user&, uint64_t d, object& o) +{ o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } -inline bool template_callback_int8(unpack_user&, int8_t d, object& o) -{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } - else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; return true; } } +inline void template_callback_int8(unpack_user&, int8_t d, object& o) +{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } + else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; } } -inline bool template_callback_int16(unpack_user&, int16_t d, object& o) -{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } - else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; return true; } } +inline void template_callback_int16(unpack_user&, int16_t d, object& o) +{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } + else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; } } -inline bool template_callback_int32(unpack_user&, int32_t d, object& o) -{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } - else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; return true; } } +inline void template_callback_int32(unpack_user&, int32_t d, object& o) +{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } + else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; } } -inline bool template_callback_int64(unpack_user&, int64_t d, object& o) -{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; return true; } - else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; return true; } } +inline void template_callback_int64(unpack_user&, int64_t d, object& o) +{ if(d >= 0) { o.type = type::POSITIVE_INTEGER; o.via.u64 = d; } + else { o.type = type::NEGATIVE_INTEGER; o.via.i64 = d; } } -inline bool template_callback_float(unpack_user&, float d, object& o) -{ o.type = type::DOUBLE; o.via.dec = d; return true; } +inline void template_callback_float(unpack_user&, float d, object& o) +{ o.type = type::DOUBLE; o.via.dec = d; } -inline bool template_callback_double(unpack_user&, double d, object& o) -{ o.type = type::DOUBLE; o.via.dec = d; return true; } +inline void template_callback_double(unpack_user&, double d, object& o) +{ o.type = type::DOUBLE; o.via.dec = d; } -inline bool template_callback_nil(unpack_user&, object& o) -{ o.type = type::NIL; return true; } +inline void template_callback_nil(unpack_user&, object& o) +{ o.type = type::NIL; } -inline bool template_callback_true(unpack_user&, object& o) -{ o.type = type::BOOLEAN; o.via.boolean = true; return true; } +inline void template_callback_true(unpack_user&, object& o) +{ o.type = type::BOOLEAN; o.via.boolean = true; } -inline bool template_callback_false(unpack_user&, object& o) -{ o.type = type::BOOLEAN; o.via.boolean = false; return true; } +inline void template_callback_false(unpack_user&, object& o) +{ o.type = type::BOOLEAN; o.via.boolean = false; } inline bool template_callback_array(unpack_user&u, unsigned int n, object& o) { @@ -112,8 +112,8 @@ inline bool template_callback_array(unpack_user&u, unsigned int n, object& o) return true; } -inline bool template_callback_array_item(unpack_user&, object& c, object const& o) -{ c.via.array.ptr[c.via.array.size++] = o; return true; } +inline void template_callback_array_item(unpack_user&, object& c, object const& o) +{ c.via.array.ptr[c.via.array.size++] = o; } inline bool template_callback_map(unpack_user& u, unsigned int n, object& o) { @@ -124,21 +124,19 @@ inline bool template_callback_map(unpack_user& u, unsigned int n, object& o) return true; } -inline bool template_callback_map_item(unpack_user&, object& c, object const& k, object const& v) +inline void template_callback_map_item(unpack_user&, object& c, object const& k, object const& v) { c.via.map.ptr[c.via.map.size].key = k; c.via.map.ptr[c.via.map.size].val = v; ++c.via.map.size; - return true; } -inline bool template_callback_raw(unpack_user& u, const char* b, const char* p, unsigned int l, object& o) +inline void template_callback_raw(unpack_user& u, const char* b, const char* p, unsigned int l, object& o) { o.type = type::RAW; o.via.raw.ptr = p; o.via.raw.size = l; u.set_referenced(true); - return true; } @@ -240,23 +238,23 @@ public: case CS_HEADER: if (0) { } else if(0x00 <= *p && *p <= 0x7f) { // Positive Fixnum - if(!template_callback_uint8(user_, *(uint8_t*)p, obj)) { goto _failed; } + template_callback_uint8(user_, *(uint8_t*)p, obj); goto _push; } else if(0xe0 <= *p && *p <= 0xff) { // Negative Fixnum - if(!template_callback_int8(user_, *(int8_t*)p, obj)) { goto _failed; } + template_callback_int8(user_, *(int8_t*)p, obj); goto _push; } else if(0xc0 <= *p && *p <= 0xdf) { // Variable switch(*p) { case 0xc0: // nil - if(!template_callback_nil(user_, obj)) { goto _failed; } + template_callback_nil(user_, obj); goto _push; //case 0xc1: // string // again_terminal_trail(next_cs(p), p+1); case 0xc2: // false - if(!template_callback_false(user_, obj)) { goto _failed; } + template_callback_false(user_, obj); goto _push; case 0xc3: // true - if(!template_callback_true(user_, obj)) { goto _failed; } + template_callback_true(user_, obj); goto _push; case 0xc4: // bin 8 case 0xc5: // bin 16 @@ -344,7 +342,7 @@ _fixed_trail_again: case CS_FLOAT: { union { uint32_t i; float f; } mem; mem.i = _msgpack_load32(uint32_t,n); - if(!template_callback_float(user_, mem.f, obj)) { goto _failed; } + template_callback_float(user_, mem.f, obj); goto _push; } case CS_DOUBLE: { union { uint64_t i; double f; } mem; @@ -353,32 +351,32 @@ _fixed_trail_again: // https://github.com/msgpack/msgpack-perl/pull/1 mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL); #endif - if(!template_callback_double(user_, mem.f, obj)) { goto _failed; } + template_callback_double(user_, mem.f, obj); goto _push; } case CS_UINT_8: - if(!template_callback_uint8(user_, *(uint8_t*)n, obj)) { goto _failed; } + template_callback_uint8(user_, *(uint8_t*)n, obj); goto _push; case CS_UINT_16: - if(!template_callback_uint16(user_, _msgpack_load16(uint16_t,n), obj)) { goto _failed; } + template_callback_uint16(user_, _msgpack_load16(uint16_t,n), obj); goto _push; case CS_UINT_32: - if(!template_callback_uint32(user_, _msgpack_load32(uint32_t,n), obj)) { goto _failed; } + template_callback_uint32(user_, _msgpack_load32(uint32_t,n), obj); goto _push; case CS_UINT_64: - if(!template_callback_uint64(user_, _msgpack_load64(uint64_t,n), obj)) { goto _failed; } + template_callback_uint64(user_, _msgpack_load64(uint64_t,n), obj); goto _push; case CS_INT_8: - if(!template_callback_int8(user_, *(int8_t*)n, obj)) { goto _failed; } + template_callback_int8(user_, *(int8_t*)n, obj); goto _push; case CS_INT_16: - if(!template_callback_int16(user_, _msgpack_load16(int16_t,n), obj)) { goto _failed; } + template_callback_int16(user_, _msgpack_load16(int16_t,n), obj); goto _push; case CS_INT_32: - if(!template_callback_int32(user_, _msgpack_load32(int32_t,n), obj)) { goto _failed; } + template_callback_int32(user_, _msgpack_load32(int32_t,n), obj); goto _push; case CS_INT_64: - if(!template_callback_int64(user_, _msgpack_load64(int64_t,n), obj)) { goto _failed; } + template_callback_int64(user_, _msgpack_load64(int64_t,n), obj); goto _push; case CS_BIN_8: @@ -401,7 +399,7 @@ _fixed_trail_again: goto _fixed_trail_again; case ACS_RAW_VALUE: _raw_zero: - if(!template_callback_raw(user_, (const char*)data, (const char*)n, trail, obj)) { goto _failed; } + template_callback_raw(user_, (const char*)data, (const char*)n, trail, obj); goto _push; case CS_ARRAY_16: if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ @@ -449,7 +447,7 @@ _push: c = &stack[top-1]; switch(c->ct()) { case CT_ARRAY_ITEM: - if(!template_callback_array_item(user_, c->obj(), obj)) { goto _failed; } + template_callback_array_item(user_, c->obj(), obj); if(c->decl_count() == 0) { obj = c->obj(); --top; @@ -462,7 +460,7 @@ _push: c->set_ct(CT_MAP_VALUE); goto _header_again; case CT_MAP_VALUE: - if(!template_callback_map_item(user_, c->obj(), c->map_key(), obj)) { goto _failed; } + template_callback_map_item(user_, c->obj(), c->map_key(), obj); if(c->decl_count() == 0) { obj = c->obj(); --top;