change msgpack to 3.1.0 to remove boost dependency

This commit is contained in:
qicosmos
2021-06-29 23:00:52 +08:00
parent b7936d83c5
commit 98262e4b0a
472 changed files with 49491 additions and 1011 deletions
+20 -29
View File
@@ -15,18 +15,16 @@
#include "msgpack/object.hpp"
#include "msgpack/zone.hpp"
#include "msgpack/unpack_exception.hpp"
#include "msgpack/unpack_define.hpp"
#include "msgpack/unpack_define.h"
#include "msgpack/cpp_config.hpp"
#include "msgpack/sysdep.hpp"
#include "msgpack/sysdep.h"
#include <memory>
#if !defined(MSGPACK_USE_CPP03)
#include <atomic>
#endif
#include <boost/assert.hpp>
#if defined(_MSC_VER)
// avoiding confliction std::max, std::min, and macro in windows.h
@@ -80,19 +78,19 @@ inline void unpack_uint64(uint64_t d, msgpack::object& o)
{ o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
inline void unpack_int8(int8_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int16(int16_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int32(int32_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int64(int64_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_float(float d, msgpack::object& o)
@@ -115,13 +113,10 @@ struct unpack_array {
if (n > u.limit().array()) throw msgpack::array_size_overflow("array size overflow");
o.type = msgpack::type::ARRAY;
o.via.array.size = 0;
#if SIZE_MAX == UINT_MAX
if (n > SIZE_MAX/sizeof(msgpack::object))
throw msgpack::array_size_overflow("array size overflow");
#endif // SIZE_MAX == UINT_MAX
size_t size = n*sizeof(msgpack::object);
if (size / sizeof(msgpack::object) != n) {
throw msgpack::array_size_overflow("array size overflow");
}
o.via.array.ptr = static_cast<msgpack::object*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
}
};
@@ -130,7 +125,6 @@ inline void unpack_array_item(msgpack::object& c, msgpack::object const& o)
{
#if defined(__GNUC__) && !defined(__clang__)
std::memcpy(&c.via.array.ptr[c.via.array.size++], &o, sizeof(msgpack::object));
#else /* __GNUC__ && !__clang__ */
c.via.array.ptr[c.via.array.size++] = o;
#endif /* __GNUC__ && !__clang__ */
@@ -141,13 +135,10 @@ struct unpack_map {
if (n > u.limit().map()) throw msgpack::map_size_overflow("map size overflow");
o.type = msgpack::type::MAP;
o.via.map.size = 0;
#if SIZE_MAX == UINT_MAX
if (n > SIZE_MAX/sizeof(msgpack::object_kv))
throw msgpack::map_size_overflow("map size overflow");
#endif // SIZE_MAX == UINT_MAX
size_t size = n*sizeof(msgpack::object_kv);
if (size / sizeof(msgpack::object_kv) != n) {
throw msgpack::map_size_overflow("map size overflow");
}
o.via.map.ptr = static_cast<msgpack::object_kv*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
}
};
@@ -427,10 +418,10 @@ private:
m_stack[0].set_obj(obj);
++m_current;
/*printf("-- finish --\n"); */
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
}
else if (ret < 0) {
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
}
else {
m_cs = MSGPACK_CS_HEADER;
@@ -460,7 +451,7 @@ inline void context::check_ext_size<4>(std::size_t size) {
inline int context::execute(const char* data, std::size_t len, std::size_t& off)
{
BOOST_ASSERT(len >= off);
assert(len >= off);
m_start = data;
m_current = data + off;
@@ -470,7 +461,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
msgpack::object obj;
if(m_current == pe) {
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
return 0;
}
bool fixed_trail_again = false;
@@ -553,7 +544,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
int ret = push_proc(obj, off);
if (ret != 0) return ret;
} else {
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
return -1;
}
// end MSGPACK_CS_HEADER
@@ -564,7 +555,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
fixed_trail_again = false;
}
if(static_cast<std::size_t>(pe - m_current) < m_trail) {
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
return 0;
}
n = m_current;
@@ -839,13 +830,13 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
if (ret != 0) return ret;
} break;
default:
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
return -1;
}
}
} while(m_current != pe);
off = static_cast<std::size_t>(m_current - m_start);
off = m_current - m_start;
return 0;
}