mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-19 04:47:37 +02:00
Fixed #463.
Added lacked include files. Added a test. Added MSVC build settings on appveyor. Added old MSVC workaround. Fixed a variable definition point to meet ANSI-C.
This commit is contained in:
parent
068041f05e
commit
e6f82cf2bb
44
appveyor.yml
44
appveyor.yml
@ -1,11 +1,35 @@
|
||||
version: 1.1.0.{build}
|
||||
before_build:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
msvc: '"Visual Studio 10 2010"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
msvc: '"Visual Studio 11 2012"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
msvc: '"Visual Studio 12 2013"'
|
||||
- cpp11: -DMSGPACK_CXX11=ON
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
msvc: '"Visual Studio 14 2015"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
msvc: '"Visual Studio 14 2015"'
|
||||
- cpp11: -DMSGPACK_CXX11=ON
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 14 2015"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 14 2015"'
|
||||
build_script:
|
||||
- appveyor DownloadFile http://googletest.googlecode.com/files/gtest-1.7.0.zip -FileName gtest-1.7.0.zip
|
||||
- 7z x gtest-1.7.0.zip > NUL
|
||||
- cd gtest-1.7.0
|
||||
- md build
|
||||
- cd build
|
||||
- cmake -DBUILD_SHARED_LIBS=ON ..
|
||||
- cmake -G %msvc% -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 ..
|
||||
- cmake --build . --config Release
|
||||
- cd ..
|
||||
- cd ..
|
||||
@ -15,26 +39,14 @@ before_build:
|
||||
- cd zlib-1.2.8
|
||||
- md build
|
||||
- cd build
|
||||
- cmake ..
|
||||
- cmake -G %msvc% ..
|
||||
- cmake --build . --config Release
|
||||
- copy zconf.h ..
|
||||
- cd ..
|
||||
- cd ..
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- cpp11: -DMSGPACK_CXX11=ON
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
- cpp11: -DMSGPACK_CXX11=ON
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
build_script:
|
||||
- md build
|
||||
- cd build
|
||||
- cmake %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_58_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 ..
|
||||
- cmake -G %msvc% %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_60_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
|
||||
- cmake --build . --config Release
|
||||
|
||||
test_script:
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
@ -44,13 +44,14 @@ size_t receiver_recv(receiver *r, char* buf, size_t try_size) {
|
||||
size_t receiver_to_unpacker(receiver* r, size_t request_size,
|
||||
msgpack_unpacker *unpacker)
|
||||
{
|
||||
size_t recv_len;
|
||||
// make sure there's enough room, or expand the unpacker accordingly
|
||||
if (msgpack_unpacker_buffer_capacity(unpacker) < request_size) {
|
||||
msgpack_unpacker_reserve_buffer(unpacker, request_size);
|
||||
assert(msgpack_unpacker_buffer_capacity(unpacker) >= request_size);
|
||||
}
|
||||
size_t recv_len = receiver_recv(r, msgpack_unpacker_buffer(unpacker),
|
||||
request_size);
|
||||
recv_len = receiver_recv(r, msgpack_unpacker_buffer(unpacker),
|
||||
request_size);
|
||||
msgpack_unpacker_buffer_consumed(unpacker, recv_len);
|
||||
return recv_len;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/pack.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
|
@ -82,6 +82,17 @@ struct basic_variant :
|
||||
basic_variant() {}
|
||||
template <typename T>
|
||||
basic_variant(T const& t):base(t) {}
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
// The following redundant functions are required to avoid MSVC
|
||||
// See https://svn.boost.org/trac/boost/ticket/592
|
||||
basic_variant(basic_variant const& other):base(static_cast<base const&>(other)) {}
|
||||
basic_variant& operator=(basic_variant const& other) {
|
||||
*static_cast<base*>(this) = static_cast<base const&>(other);
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(_MSC_VER) && _MSC_VER < 1700
|
||||
|
||||
basic_variant(char const* p):base(std::string(p)) {}
|
||||
basic_variant(char v) {
|
||||
int_init(v);
|
||||
@ -104,51 +115,51 @@ struct basic_variant :
|
||||
basic_variant(unsigned long long v):base(uint64_t(v)) {}
|
||||
|
||||
bool is_nil() const {
|
||||
return boost::get<msgpack::type::nil_t>(this);
|
||||
return boost::get<msgpack::type::nil_t>(this) != nullptr;
|
||||
}
|
||||
bool is_bool() const {
|
||||
return boost::get<bool>(this);
|
||||
return boost::get<bool>(this) != nullptr;
|
||||
}
|
||||
bool is_int64_t() const {
|
||||
return boost::get<int64_t>(this);
|
||||
return boost::get<int64_t>(this) != nullptr;
|
||||
}
|
||||
bool is_uint64_t() const {
|
||||
return boost::get<uint64_t>(this);
|
||||
return boost::get<uint64_t>(this) != nullptr;
|
||||
}
|
||||
bool is_double() const {
|
||||
return boost::get<double>(this);
|
||||
return boost::get<double>(this) != nullptr;
|
||||
}
|
||||
bool is_string() const {
|
||||
return boost::get<std::string>(this);
|
||||
return boost::get<std::string>(this) != nullptr;
|
||||
}
|
||||
#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
|
||||
bool is_boost_string_ref() const {
|
||||
return boost::get<boost::string_ref>(this);
|
||||
return boost::get<boost::string_ref>(this) != nullptr;
|
||||
}
|
||||
#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
|
||||
bool is_vector_char() const {
|
||||
return boost::get<std::vector<char> >(this);
|
||||
return boost::get<std::vector<char> >(this) != nullptr;
|
||||
}
|
||||
bool is_vector_char() {
|
||||
return boost::get<std::vector<char> >(this);
|
||||
return boost::get<std::vector<char> >(this) != nullptr;
|
||||
}
|
||||
bool is_raw_ref() const {
|
||||
return boost::get<raw_ref>(this);
|
||||
return boost::get<raw_ref>(this) != nullptr;
|
||||
}
|
||||
bool is_ext() const {
|
||||
return boost::get<ext>(this);
|
||||
return boost::get<ext>(this) != nullptr;
|
||||
}
|
||||
bool is_ext_ref() const {
|
||||
return boost::get<ext_ref>(this);
|
||||
return boost::get<ext_ref>(this) != nullptr;
|
||||
}
|
||||
bool is_vector() const {
|
||||
return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(this);
|
||||
return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(this) != nullptr;
|
||||
}
|
||||
bool is_map() const {
|
||||
return boost::get<std::map<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this);
|
||||
return boost::get<std::map<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this) != nullptr;
|
||||
}
|
||||
bool is_multimap() const {
|
||||
return boost::get<std::multimap<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this);
|
||||
return boost::get<std::multimap<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >(this) != nullptr;
|
||||
}
|
||||
|
||||
bool as_bool() const {
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#define MSGPACK_V1_TYPE_INT_HPP
|
||||
|
||||
#include "msgpack/v1/adaptor/int_decl.hpp"
|
||||
#include "msgpack/object.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace msgpack {
|
||||
|
@ -14,6 +14,7 @@ LIST (APPEND check_PROGRAMS
|
||||
convert.cpp
|
||||
fixint.cpp
|
||||
fixint_c.cpp
|
||||
inc_adaptor_define.cpp
|
||||
json.cpp
|
||||
limit.cpp
|
||||
msgpack_basic.cpp
|
||||
|
@ -9,6 +9,7 @@ check_PROGRAMS = \
|
||||
convert \
|
||||
fixint \
|
||||
fixint_c \
|
||||
inc_adaptor_define \
|
||||
json \
|
||||
limit \
|
||||
msgpack_basic \
|
||||
@ -54,6 +55,7 @@ cases_SOURCES = cases.cpp
|
||||
convert_SOURCES = convert.cpp
|
||||
fixint_SOURCES = fixint.cpp
|
||||
fixint_c_SOURCES = fixint_c.cpp
|
||||
inc_adaptor_define_SOURCES = inc_adaptor_define.cpp
|
||||
json_SOURCES = json.cpp
|
||||
limit_SOURCES = limit.cpp
|
||||
msgpack_basic_SOURCES = msgpack_basic.cpp
|
||||
|
3
test/inc_adaptor_define.cpp
Normal file
3
test/inc_adaptor_define.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include <msgpack/adaptor/define.hpp>
|
||||
|
||||
int main() {}
|
@ -143,6 +143,8 @@ TEST(MSGPACK, simple_buffer_int64)
|
||||
GEN_TEST(int64_t);
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
TEST(MSGPACK, simple_buffer_float)
|
||||
{
|
||||
vector<float> v;
|
||||
@ -185,6 +187,8 @@ TEST(MSGPACK, simple_buffer_float)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
namespace {
|
||||
template<typename F, typename I>
|
||||
struct TypePair {
|
||||
@ -232,6 +236,8 @@ INSTANTIATE_TYPED_TEST_CASE_P(IntegerToFloatingPointTestInstance,
|
||||
IntegerToFloatingPointTest,
|
||||
IntegerToFloatingPointTestTypes);
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
TEST(MSGPACK, simple_buffer_double)
|
||||
{
|
||||
vector<double> v;
|
||||
@ -278,6 +284,8 @@ TEST(MSGPACK, simple_buffer_double)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
TEST(MSGPACK, simple_buffer_nil)
|
||||
{
|
||||
msgpack::sbuffer sbuf;
|
||||
|
@ -185,6 +185,8 @@ TEST(MSGPACKC, simple_buffer_int64)
|
||||
GEN_TEST_SIGNED(int64_t, int64);
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
TEST(MSGPACKC, simple_buffer_float)
|
||||
{
|
||||
vector<float> v;
|
||||
@ -315,6 +317,8 @@ TEST(MSGPACKC, simple_buffer_double)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(_MSC_VER) || _MSC_VER >=1800
|
||||
|
||||
TEST(MSGPACKC, simple_buffer_nil)
|
||||
{
|
||||
msgpack_sbuffer sbuf;
|
||||
|
Loading…
x
Reference in New Issue
Block a user