Compare commits

..

1605 Commits

Author SHA1 Message Date
Nobuyuki Kubota
62be3f1212 version 1.0.0 2015-03-10 21:42:47 +09:00
Nobuyuki Kubota
8dbe25a51d Add missing headers and files for make dist 2015-03-10 21:35:55 +09:00
Takatoshi Kondo
7cfd4bb1d8 Updated version to 1.0.0 2015-03-10 21:25:34 +09:00
Nobuyuki Kubota
037a108c49 Merge pull request #238 from redboltz/move_serialize_operator
Moved serialize operator.
2015-03-10 21:14:24 +09:00
Takatoshi Kondo
79a127a8b6 Moved serialize operator. 2015-03-10 21:14:20 +09:00
Nobuyuki Kubota
ace27f6238 Merge pull request #237 from redboltz/add_version_revision
Added version revision prototype declaration.
2015-03-10 21:08:37 +09:00
Nobuyuki Kubota
cc2ded6338 Merge pull request #236 from redboltz/add_depth_limit2
Added depth limit on unpack.
2015-03-10 21:08:01 +09:00
Takatoshi Kondo
13a746f6fa Added msgpack prefix. 2015-03-10 21:08:22 +09:00
Nobuyuki Kubota
b0ff2802d2 Add msgpack prefix to type_errors 2015-03-10 20:59:34 +09:00
Nobuyuki Kubota
4b0c90fc90 Merge branch 'add_msgpack_prefix'
Conflicts:
	include/msgpack/adaptor/char_ptr.hpp
	include/msgpack/adaptor/cpp11/array.hpp
	include/msgpack/adaptor/cpp11/array_char.hpp
	include/msgpack/adaptor/cpp11/tuple.hpp
	include/msgpack/adaptor/cpp11/unordered_map.hpp
	include/msgpack/adaptor/cpp11/unordered_set.hpp
	include/msgpack/adaptor/deque.hpp
	include/msgpack/adaptor/list.hpp
	include/msgpack/adaptor/map.hpp
	include/msgpack/adaptor/set.hpp
	include/msgpack/adaptor/string.hpp
	include/msgpack/adaptor/tr1/unordered_map.hpp
	include/msgpack/adaptor/tr1/unordered_set.hpp
	include/msgpack/adaptor/vector.hpp
	include/msgpack/adaptor/vector_char.hpp
	include/msgpack/object.hpp
	include/msgpack/unpack.hpp
2015-03-10 20:57:55 +09:00
Takatoshi Kondo
4b11fb32cd Added version revision prototype declaration. 2015-03-10 20:41:59 +09:00
Nobuyuki Kubota
f707c6b47c Add missing msgpack prefix 2015-03-10 20:38:58 +09:00
Takatoshi Kondo
081ee0e99a Added depth limit on unpack. 2015-03-10 20:30:22 +09:00
Nobuyuki Kubota
8eaa2e9e74 Merge pull request #199 from redboltz/fix_issue_198
Fix issue 198
2015-03-10 19:31:09 +09:00
Nobuyuki Kubota
ac1eb6e1d3 Merge branch 'reference-args' 2015-03-10 19:16:37 +09:00
Nobuyuki Kubota
343ceabe9a Fix msgpack_object to be passed by reference 2015-03-10 19:12:25 +09:00
Takatoshi Kondo
eb765d21f2 Fixed MSVC++ warning about int to bool conversion. 2015-03-10 19:04:51 +09:00
Takatoshi Kondo
2d5c68055c Added explicit cast to vector<bool> internal type. 2015-03-10 19:04:23 +09:00
Nobuyuki Kubota
de68fbd6d0 Merge branch 'support_cpp11_atomic' 2015-03-10 18:53:14 +09:00
Takatoshi Kondo
118cf7270c Fixed a compile error on clang++ 3.4.1 on FreeBSD and Yosemite. 2015-03-10 18:37:36 +09:00
Nobuyuki Kubota
cf1487f8ba Merge branch 'fix_decrement_typo'
Conflicts:
	include/msgpack/unpack.hpp
2015-03-10 18:25:38 +09:00
Nobuyuki Kubota
e4cd479bf3 Merge branch 'master' of github.com:msgpack/msgpack-c 2015-03-10 17:35:39 +09:00
Nobuyuki Kubota
8dae63e4c1 Merge branch 'add_std_prefix'
Conflicts:
	include/msgpack/adaptor/char_ptr.hpp
	include/msgpack/adaptor/string.hpp
2015-03-10 17:34:36 +09:00
Nobuyuki Kubota
a3f350842c Merge pull request #231 from redboltz/remove_double_underscore
Removed double underscore.
2015-03-10 17:23:15 +09:00
Nobuyuki Kubota
c1e9f92d7f Merge branch 'fix_issue_226_author_fixed'
Conflicts:
	include/msgpack/unpack.hpp
2015-03-10 17:21:58 +09:00
Nobuyuki Kubota
582fe38e78 Merge branch 'fix_issue_167' 2015-03-10 16:55:46 +09:00
Nobuyuki Kubota
6443738f66 Add serialization test of non-const char* 2015-03-10 16:54:45 +09:00
Nobuyuki Kubota
45eb2ad0c7 Merge branch 'redboltz_fix_issue_220'
Conflicts:
	include/msgpack/unpack.hpp
2015-03-10 00:48:32 -07:00
Nobuyuki Kubota
37593400c3 Replace a MACRO with const size_t and undef some MACROs 2015-03-10 00:39:56 -07:00
Nobuyuki Kubota
60648fc3a8 Merge pull request #218 from redboltz/replace_embed_stack_with_vector
Replaced m_stack legacy array with std::vector.
2015-03-10 16:03:59 +09:00
Takatoshi Kondo
0482e4fcd1 Supported the C++11 atomic. 2015-03-09 16:02:03 +09:00
Takatoshi Kondo
82a10cba5c Fixed typo.
Replaced 'decl' with 'decr'.
2015-03-09 14:49:18 +09:00
Takatoshi Kondo
0d9a21ea08 Added msgpack prefix to packer. 2015-03-08 20:49:40 +09:00
Takatoshi Kondo
f399ec8c30 Added msgpack prefix to support API versioning. 2015-03-07 22:58:45 +09:00
Takatoshi Kondo
8ad9ce059b Fixed #226.
Suppressed warnings on MSVC++ 64bit environment.
Added container size limit check.
2015-03-05 07:36:56 +09:00
Takatoshi Kondo
a4aa14d1e2 Added std prefix. 2015-03-04 22:50:47 +09:00
Takatoshi Kondo
f7f2d4b990 Removed double underscore. 2015-03-04 22:44:11 +09:00
Takatoshi Kondo
c675881f3b Fixed #220.
Added MSGPACK_ prefix to unpack macros.
2015-02-19 17:44:42 +09:00
Takatoshi Kondo
f6d0cd9a4b Merge pull request #222 from jszakmeister/fix-byteswap-freebsd-and-openbsd
Don't include byteswap.h and FreeBSD and OpenBSD.
2015-02-19 16:53:20 +09:00
John Szakmeister
4ef5894856 Don't include byteswap.h and FreeBSD and OpenBSD. 2015-02-17 17:33:49 -05:00
Nobuyuki Kubota
07ddfa1430 Add a list of contributors in README.md and remove AUTHORS file
This commit also adds AUTHORS and ChangeLog to .gitignore.
ChangeLog is only used by autoconf/automake and it has a quite
strict format. Since msgpack-c's change log is now written in
Markdown, it's difficult to follow the ChangeLog format.
So, unlike README.md, bootstrap doesn't copy CHANGELOG.md
to ChangeLog.
2015-02-15 16:52:27 -08:00
Nobuyuki Kubota
252d66a4b2 Merge branch 'master' of https://github.com/haneefmubarak/msgpack-c into general-repo-clean-up 2015-02-15 16:08:38 -08:00
Takatoshi Kondo
b4eba4ba09 Merge pull request #219 from redboltz/fix_issue_209
Fixed #209
2015-02-07 21:56:00 +09:00
Takatoshi Kondo
2266505eed Fixed #209
Added conditional include stdbool.h based on @equalsraf comment.
2015-02-07 21:25:49 +09:00
Takatoshi Kondo
46e2398e02 Replaced m_stack legacy array with std::vector. 2015-02-04 23:15:32 +09:00
Takatoshi Kondo
3662a17e81 Merge pull request #212 from redboltz/add_zone_reuse_example
Added an unpacking msgpack::object on an existing zone example.
2015-02-03 21:52:09 +09:00
Takatoshi Kondo
66f221d088 Merge pull request #211 from redboltz/add_cpp11_container_example
Added a C++11 container example.
2015-02-03 21:51:56 +09:00
Takatoshi Kondo
9ed4e443fb Added an unpacking msgpack::object on an existing zone example. 2015-02-03 21:20:34 +09:00
Takatoshi Kondo
15aec0493d Added a C++11 container example. 2015-02-03 20:40:44 +09:00
Takatoshi Kondo
d6a7bd1995 Merge pull request #207 from redboltz/refine_examples
Refine examples
2015-02-02 21:56:41 +09:00
Takatoshi Kondo
ff86d61799 Replaced auto& with auto const& for msgpack::object.
Replaced auto with auto const& for msgpack::object.
Avoided msgpack::object conversion in EXPECT_EQ.
2015-02-02 15:27:15 +09:00
Mizuki Hirata
97886c50e7 Fixed iterator test case. 2015-02-02 15:27:15 +09:00
Mizuki Hirata
327b0db626 Added versioning namespace and test case to iterator. 2015-02-02 15:27:15 +09:00
Mizuki Hirata
994144dac2 Add range-based for loop support. 2015-02-02 15:27:15 +09:00
Takatoshi Kondo
023f81ae9c Added char* support. 2015-02-01 22:30:21 +09:00
Takatoshi Kondo
83fac26762 Added enum examples.
Added converting to zone with or without zone.
2015-02-01 22:10:13 +09:00
Takatoshi Kondo
213ba44b65 Added copylight text.
Refined examples.
2015-02-01 21:35:48 +09:00
Takatoshi Kondo
fa231139d7 Merge pull request #205 from redboltz/fix_issue_204
Fixed #204, #202.
2015-02-01 21:20:31 +09:00
Takatoshi Kondo
5cd1c6bfa1 Merge pull request #201 from redboltz/fix_issue_184
Added unpack function using existing zone.
2015-02-01 21:18:05 +09:00
Takatoshi Kondo
c4fb47c00d Fixed #204, #202.
enum support had been incomplete.
This fix made enum support complete.

Replaced int with auto on c++11 scoped enum.
Replaced template specializations with function overloads on operator<< and operator>> for enum.

enum can convert to object with and without zone.

When you want to adapt enum, you need to write as follows:

// NOT msgpack.hpp

enum yourenum {
    elem
};

MSGPACK_ADD_ENUM(yourenum);

// msgpack.hpp should be included after MSGPACK_ADD_ENUM(...)

int main() {
    msgpack::object obj(yourenum::elem);
}
2015-01-31 22:19:31 +09:00
Takatoshi Kondo
70e50d9679 Added unpack function using existing zone.
Removed redundant inline keyword form declarations.
2015-01-30 22:57:27 +09:00
Takatoshi Kondo
978e6b9057 Merge pull request #200 from anton-sergeev/master
Fix cmake for subproject usage
2015-01-30 21:58:32 +09:00
Anton Sergeev
571f1a27a2 Fix cmake for subproject usage
Signed-off-by: Anton Sergeev <Anton.Sergeev@elecard.ru>
2015-01-26 20:32:31 +06:00
Takatoshi Kondo
c3518c0666 Included vector header. 2015-01-25 22:25:35 +09:00
Takatoshi Kondo
64ac09c492 Fixed #198.
Added a conversion support from msgpack::object to std::vector<bool>.
2015-01-25 21:59:39 +09:00
Takatoshi Kondo
414da4e8c6 Merge pull request #195 from nobu-k/configure-version-fix
Support OS X's sed in configure.in
2015-01-17 23:43:20 +09:00
Nobuyuki Kubota
3eadb124fc Support OS X's sed in configure.in 2015-01-16 22:15:05 +09:00
Nobuyuki Kubota
fd9eb26688 Add static inline to msgpack_zone_malloc_no_align 2015-01-16 21:47:49 +09:00
Nobuyuki Kubota
6c59e5195a Merge branch 'fix_issue_191'
Conflicts:
	test/streaming_c.cpp
2015-01-16 21:47:13 +09:00
Nobuyuki Kubota
3bdf646cc6 Merge pull request #192 from redboltz/fix_issue_190
Fixed #190.
2015-01-16 20:05:39 +09:00
Nobuyuki Kubota
2bbf10a324 Merge pull request #181 from redboltz/change_zone_align_default
Modified the default value of MSGPACK_ZONE_ALIGN from sizeof(int) to siz...
2015-01-16 19:53:27 +09:00
Takatoshi Kondo
737e6703df Fixed #191.
The names of float format family are changed.

old                      new
dec                   -> f64
MSGPACK_OBJECT_DOUBLE -> MSGPACK_OBJECT_FLOAT
msgpack::type::DOUBLE -> msgpack::type::FLOAT

Client codes could have compile errors when it use dec, MSGPACK_OBJECT_DOUBLE or msgpack::type::DOUBLE.
The best way to fix such errors, update client code. If it can't, set MSGPACK_USE_LEGACY_NAME_AS_FLOAT macro.
Then both old names and new names are available.
2015-01-16 00:20:43 +09:00
Takatoshi Kondo
7f48ddc85e Fixed #190.
Supressed warnings on MSVC.
2015-01-15 20:42:33 +09:00
Takatoshi Kondo
a84f444ce2 Merge pull request #185 from bajamircea/master
Fix one more memory size calculation.
2015-01-06 10:20:07 +09:00
Mircea Baja
7e597779e4 Fix one more memory size calculation.
See https://github.com/msgpack/msgpack-c/issues/149
and the commit d6cc5494a9
2015-01-05 21:55:57 +00:00
Takatoshi Kondo
bf8c830eef Merge pull request #183 from spatz/patch-3
Comment unused variable name
2015-01-05 09:55:37 +09:00
Dror Levin
5f52ec5030 Comment unused variable name
Prevents unused parameter error from gcc when compiled with -Wextra.
2015-01-04 13:43:55 +02:00
Haneef Mubarak
c71ce9eb49 minor markdown error 2015-01-02 23:14:16 -08:00
Haneef Mubarak
f105b4bbb0 misc top level directory cleanup 2015-01-02 23:09:44 -08:00
Haneef Mubarak
f64be3b2d0 add all contributors to AUTHORS file 2015-01-02 23:05:25 -08:00
Haneef Mubarak
abac9fe90a add links to QUICKSTART 2015-01-02 22:31:59 -08:00
Haneef Mubarak
5798fa0e47 rewrite and cleanup README 2015-01-02 22:27:55 -08:00
Takatoshi Kondo
fe4af1125d Modified the default value of MSGPACK_ZONE_ALIGN from sizeof(int) to sizeof(void*).
On the x64 environment, sizeof(int) == 4 but pointer size is 8. The latter is suitable for the default value.
2015-01-03 10:22:58 +09:00
Nobuyuki Kubota
ce96ca8bfc Merge pull request #175 from redboltz/add_limit
- Added unpack limit.
2015-01-02 12:22:03 -08:00
Nobuyuki Kubota
57732f0c1b Merge pull request #171 from redboltz/fixed_zone_alignment
Fixed zone alignment
2015-01-02 11:37:01 -08:00
Nobuyuki Kubota
7ccef5b787 Merge pull request #170 from redboltz/fixed_typo
Fixed typos.
2015-01-02 11:01:58 -08:00
Takatoshi Kondo
1a116fb644 Merge pull request #180 from spatz/patch-2
Add missing break to prevent segfault
2015-01-02 18:10:06 +09:00
Takatoshi Kondo
f79fd82953 Merge pull request #179 from spatz/patch-1
Move constructors and operator= should be noexcept
2015-01-02 17:53:47 +09:00
Dror Levin
b9a80697bc Add missing break to prevent segfault
When printing objects with extension, falling through to type ARRAY may cause segmentation fault.
2015-01-01 15:15:47 +02:00
Dror Levin
467822c97a Move constructors and operator= should be noexcept 2014-12-30 18:30:11 +02:00
Takatoshi Kondo
7ab7eaf61b Merge pull request #177 from redboltz/fix_issue_176
Fixed https://github.com/msgpack/msgpack-c/issues/176
2014-12-22 11:27:25 +09:00
Takatoshi Kondo
3ed6b673d4 Fixed https://github.com/msgpack/msgpack-c/issues/176
byteswap.h is no longer included on Solaris.
2014-12-20 18:38:49 +09:00
Takatoshi Kondo
469040be6b Fixed exceptions' interface. On the C++11, both const char* and const std::string& are supported.
Updated all exceptions relate to unpack take a message parameter. It is better to explain the exceptional situation in detail. So far, just passing the exceptions name.
2014-12-15 10:12:55 +09:00
Takatoshi Kondo
309e96087a - Added unpack limit.
- Added new exceptions to explain limit over errors.

- Fixed ext maximum size problem.
Problem:
The type of m_trail was uint32_t but when parsing ext, it could be 0xffffffff + 1. +1 means type. See https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family

Solution:
Modified the type of m_trail as std::size_t. If sizeof(std::size_t) == 4, 0xffffffff size of ext is an error. If sizeof(std::size_t) == 8, 0xffffffff size of ext is not an error. m_trail is 0xffffffff + 1.

Design cohice:
I chose std::size_t as the m_trail's type instead of uint64_t intentionally. On 64 addressing bit environment, there is no problem. On 32 bit environment, there is no problem except ext with maximum size. There is only one exception in the all msgpack format. Using uint64_t to support that, it's very expensive. On 32 addressing bit environment, allocating 0xffffffff + 1 bytes of memory couldn't succeed, so I believe that throwing an exception is a reasonable design choice in the case.
2014-12-14 19:10:46 +09:00
Takatoshi Kondo
2d61fdf865 Merge pull request #172 from bajamircea/master
Added check for already defined NOMINMAX
2014-12-09 22:40:36 +09:00
Mircea Baja
6e560e345a Added check for already defined NOMINMAX 2014-12-08 21:36:26 +00:00
Takatoshi Kondo
8b796dc788 Added zone alignment tests. 2014-12-05 22:08:31 +09:00
Takatoshi Kondo
240b02174d Fixed zone allocate alignment problem. 2014-12-05 20:46:56 +09:00
Takatoshi Kondo
38a380684e Fixed typos.
The typos have been pointed out by https://github.com/msgpack/msgpack-c/pull/130
Thank you @jpetso !
2014-12-05 17:18:24 +09:00
Nobuyuki Kubota
1a615af437 Merge pull request #169 from redboltz/fix_issue_168
Added adaptors for the C++11 version of unordered containers.
2014-12-05 17:13:51 +09:00
Takatoshi Kondo
9162610682 Added adaptors for the C++11 version of unordered containers.
(Fixed https://github.com/msgpack/msgpack-c/issues/168)
2014-12-05 15:40:33 +09:00
Nobuyuki Kubota
c52a58b322 Merge pull request #163 from redboltz/fix_144
Fixed https://github.com/msgpack/msgpack-c/issues/144
2014-11-26 14:21:50 -08:00
Nobuyuki Kubota
ac3433f5dd Merge pull request #165 from redboltz/implement_non_copyable
Made copy constructors and copy assignment operators private for classes...
2014-11-26 14:10:10 -08:00
Takatoshi Kondo
dab725624e Made copy constructors and copy assignment operators private for classes that should be noncopyable. 2014-11-23 20:42:38 +09:00
Takatoshi Kondo
037b1c22dc Fixed https://github.com/msgpack/msgpack-c/issues/144
This fix is ogirinally from https://github.com/msgpack/msgpack-c/pull/133

I removed raw support and added str, bin, and ext support.
2014-11-17 12:51:34 +09:00
Nobuyuki Kubota
0de0b434b3 Merge branch 'refine_non_intrusive_example' 2014-11-15 17:43:23 -08:00
Nobuyuki Kubota
7eb3d2aa59 Change the type of the return value to a const reference 2014-11-15 17:41:43 -08:00
Nobuyuki Kubota
0827d08cd7 Merge pull request #162 from redboltz/msvc_test_supported
Supported dll export for msvc.
2014-11-15 17:22:51 -08:00
Nobuyuki Kubota
3d20ec6f21 Merge pull request #160 from redboltz/fix_memory_allocation
Fixed memory size caluclation problem.
2014-11-15 17:12:23 -08:00
Takatoshi Kondo
bcdbf78542 Updated infinity test better way.
Added NaN tests.
2014-11-03 10:03:05 +09:00
Takatoshi Kondo
a4af97b32c Supported dll export for msvc.
Supported tests for msvc.
2014-11-02 20:16:20 +09:00
Takatoshi Kondo
e00b299fe0 Refined the non-intrusive example. The target class no longer needs public data members. 2014-11-01 22:42:36 +09:00
Takatoshi Kondo
d6cc5494a9 Fixed memory size caluclation problem.
See https://github.com/msgpack/msgpack-c/issues/149
2014-11-01 19:41:47 +09:00
Takatoshi Kondo
96c688708c Merge pull request #158 from redboltz/update_examples
Moved examples.
2014-11-01 18:28:15 +09:00
Takatoshi Kondo
79e7a9810c Moved examples.
Added intrusive and non-intrusive versions of packing and unpacking examples.
2014-11-01 18:13:52 +09:00
Takatoshi Kondo
a0ae0289dc Merge pull request #157 from redboltz/fix_vc2008_warnings
Added warnings suppress option.
2014-11-01 17:04:51 +09:00
Takatoshi Kondo
31a3d34b49 Added warnings suppress option.
Changed buffer type from char to unsigned char.
2014-11-01 16:36:40 +09:00
Takatoshi Kondo
1c54d804f5 Merge pull request #156 from redboltz/fix_example_issue_155
Fixed return type.
2014-11-01 13:40:14 +09:00
Takatoshi Kondo
111efdf50f Fixed return type. 2014-11-01 13:18:17 +09:00
Takatoshi Kondo
dac8f6290d Merge pull request #154 from redboltz/fix_issue_153
Fixed https://github.com/msgpack/msgpack-c/issues/153
2014-10-31 16:23:23 +09:00
Takatoshi Kondo
3bfd142660 Fixed https://github.com/msgpack/msgpack-c/issues/153 2014-10-31 15:50:57 +09:00
Takatoshi Kondo
d031162d96 Merge pull request #146 from redboltz/fixed_char_pack
Fixed char packing support.
2014-10-31 12:51:53 +09:00
Takatoshi Kondo
8e24d9206a Merge pull request #152 from redboltz/fix_inttypes_on_vc2010
https://github.com/msgpack/msgpack-c/issues/147
Fixed MSVC2010 doesn't have inttypes.h problem.
2014-10-31 11:31:17 +09:00
Takatoshi Kondo
b78b49a7bd Fixed MSVC2010 doesn't have inttypes.h problem. 2014-10-31 10:50:19 +09:00
Takatoshi Kondo
561e9ba105 Merge pull request #150 from redboltz/fix_fprintf_macro
Fixed https://github.com/msgpack/msgpack-c/issues/148
2014-10-31 10:17:24 +09:00
Takatoshi Kondo
6e84266043 Merge pull request #151 from redboltz/fix_build_vc2010
Fixed https://github.com/msgpack/msgpack-c/issues/147
2014-10-31 10:17:13 +09:00
Takatoshi Kondo
151c92d08d Fixed https://github.com/msgpack/msgpack-c/issues/147
On VC9 (Visual Studio 2008) and VC10 (Visual Studio 2010), .c files are compiled as C++. Otherwise the files are compiled as C.
2014-10-31 00:04:44 +09:00
Takatoshi Kondo
1285470c21 Fixed https://github.com/msgpack/msgpack-c/issues/148
Fixed inttypes.h inclusion problem on MSVC.
Fixed msgpack_object_print implementation using PRIi8, PRIi64, and PRIu64.
If 64bit print is not supported on fprintf, dispatch to fallback print.
2014-10-30 23:54:33 +09:00
Takatoshi Kondo
837c5ecfc3 Fixed char packing support.
See https://github.com/msgpack/msgpack-c/issues/57#issuecomment-60670037
2014-10-28 10:48:49 +09:00
Takatoshi Kondo
04aa309f24 Merge pull request #145 from redboltz/add_help_comments_for_compile_error
Added help comments for compile error.
2014-10-27 20:12:44 +09:00
Takatoshi Kondo
69b2ea4002 Added help comments for compile error. 2014-10-27 17:41:06 +09:00
Takatoshi Kondo
8ddc219365 Merge pull request #143 from redboltz/solve_conflicts_on_readme
Solved conflicts on README.md.
2014-10-27 13:00:40 +09:00
Takatoshi Kondo
a9cf916b82 Solved conflicts on README.md. 2014-10-27 11:09:49 +09:00
Takatoshi Kondo
8455a2eb70 Merge branch 'redboltz-poc/0.6' 2014-10-26 15:40:41 +09:00
Takatoshi Kondo
5c0f1db25c Merge branch 'poc/0.6' of https://github.com/redboltz/msgpack-c into redboltz-poc/0.6
Conflicts:
	.travis.yml
	CMakeLists.txt
	README.md
	ci/build_autotools.sh
	ci/build_cmake.sh
	src/msgpack/object.hpp
	src/msgpack/type/fixint.hpp
	src/msgpack/type/int.hpp
	src/msgpack/type/tr1/unordered_map.hpp
	src/msgpack/type/tr1/unordered_set.hpp
	test/msgpack_test.cpp
	test/object.cc
2014-10-26 15:40:22 +09:00
Takatoshi Kondo
466986b519 Merge branch 'redboltz-api_versioning' into poc/0.6 2014-10-26 13:28:03 +09:00
Takatoshi Kondo
a6aac482dd Merge branch 'api_versioning' of https://github.com/redboltz/msgpack-c into redboltz-api_versioning
Conflicts:
	include/msgpack/unpack.hpp
2014-10-26 09:43:36 +09:00
Takatoshi Kondo
bb984d3445 Merge pull request #141 from redboltz/add_32bit_test_for_travisci
Added a 32bit environment tests for travis-ci.
2014-10-26 09:33:05 +09:00
Takatoshi Kondo
f8e2766d28 Added a 32bit environment tests for travis-ci. 2014-10-26 09:06:01 +09:00
Takatoshi Kondo
2d5d12f9a6 Merge pull request #140 from redboltz/fix_issue95_on_poc0.6
Fixed https://github.com/msgpack/msgpack-c/pull/95 on poc/0.6 branch.
2014-10-24 22:37:37 +09:00
Takatoshi Kondo
11a2a1b8ec Fixed https://github.com/msgpack/msgpack-c/pull/95 on poc/0.6 branch. 2014-10-21 22:13:53 +09:00
Takatoshi Kondo
b5e66150e9 Minimized header files dependency.
Added help comments for typical compile error.
2014-10-19 21:18:30 +09:00
Takatoshi Kondo
e21e3245db Merge pull request #138 from redboltz/move_byteswap
Moved include byteswap.h to sysdep.h.
2014-10-19 19:42:38 +09:00
Takatoshi Kondo
07e7ad6b7e Merge pull request #137 from redboltz/remove_tr1_from_test
Removed wrong tr1:: from unordered containers.
2014-10-19 19:37:10 +09:00
Takatoshi Kondo
44b524529d Merge pull request #136 from redboltz/replace_uint64_t_with_apropriate_types
Replaced uint64_t with apropriate types.
2014-10-19 19:26:42 +09:00
Takatoshi Kondo
fc65bc0682 Replaced tuple with std::tuple.
Added include file int_fwd.hpp for MSGPACK_ADD_ENUM.
2014-10-16 14:07:53 +09:00
Takatoshi Kondo
ca12e6d39d Added packer_serializer class template declaration to object_fwd.hpp 2014-10-16 14:06:57 +09:00
Takatoshi Kondo
db8578a62b Separated adaptor functions' definitions and declarations. 2014-10-16 11:21:26 +09:00
Takatoshi Kondo
4a292193f2 Moved include byteswap.h to sysdep.h.
When compiling on Mac, byteswap.h is not included.
2014-10-12 01:22:10 +09:00
Takatoshi Kondo
1e7fbc0349 Removed wrong tr1:: from unordered containers. 2014-10-12 00:20:54 +09:00
Takatoshi Kondo
479d50bd93 Replaced uint64_t with apropriate types. 2014-10-11 23:45:21 +09:00
Nobuyuki Kubota
982787865f Merge pull request #127 from redboltz/clear_set_map
Fixed https://github.com/msgpack/msgpack-c/issues/76
2014-10-06 15:12:20 -07:00
Nobuyuki Kubota
bf4a57da34 Merge branch 'object-with-zone-copy' 2014-10-06 14:07:06 -07:00
Nobuyuki Kubota
2fcbe6116d Replace C-style casts with C++-style ones 2014-10-06 14:06:21 -07:00
Takatoshi Kondo
4c00f448aa Added a minimal forward declaration header file for pack/unpack overloading. 2014-10-01 14:33:02 +09:00
Takatoshi Kondo
3ddeb08e6e Added API versioning. 2014-10-12 23:21:25 +09:00
Takatoshi Kondo
0176dd760a Merge pull request #131 from shafik/master
Fixing undefined behavior introduced by the incorrect use of comma
2014-09-20 17:39:44 +09:00
Jakob Petsovits
d30548af3f Add support for copying an object to an object::with_zone.
With test.
2014-09-20 00:13:40 -04:00
Jakob Petsovits
ab12b2b2b9 Specialize operator<<(packer, T) also for object::with_zone.
It already existed for T = object, but if trying to pass an
object::with_zone it would match the generic operator<<() instead.
That operator calls o.msgpack_pack(), which doesn't exist and
causes a compile error.

(Re-)Using the overload for object is a better way to handle this.
2014-09-19 22:48:24 -04:00
Takatoshi Kondo
7ce69a362f Merge pull request #130 from jpetso/master
Support std::unordered_map/set even if using libstdc++ from GCC.
2014-09-20 00:06:51 +09:00
Takatoshi Kondo
cc08146b1c Merge pull request #132 from redboltz/support_travis_ci
Added travis-ci support.
2014-09-19 23:57:40 +09:00
Takatoshi Kondo
6896cc602f Added travis-ci support. 2014-09-19 23:42:07 +09:00
Shafik Yaghmour
d8f366daf2 Fixing undefined behavior introduced by the incorrect use of comma operator with the conditional operator. The middle expression in a conditional operator between the ? and : is implicitly parenthesized but the end expression is not. Since the comma operator as he lowest precendence( http://en.cppreference.com/w/cpp/language/operator_precedence) this means the conditional operator will be evaluated first and then the expression on the right hand side of the comma operator will be evaluated. This leads to undefined behavior because the last member of the union being updated will not be the member that will be used next which is strictly undefined in C++ although gcc and clang aloow this type punning as an extension but is clearly not portable behavior nor was this the intended behavior. instead of parenthesising the end expression I choose to use an if/else which is not subject to such easy to miss precdence issues. This Coliru live code demonstrates the bug with simple example: http://coliru.stacked-crooked.com/a/1041aaa8380feeaa the code also demonstrates the using the right warning flags gcc will generate a warning for this code. 2014-09-18 14:29:11 -04:00
Jakob Petsovits
ef649009e4 Support std::unordered_map/set even if using libstdc++ from GCC.
When passing the appropriate compiler flags, libstdc++ has
supported std::unordered_map and std::unordered_set for a
long time, even without the tr1 namespace. There's no reason to
limit support of non-tr1 containers to libc++ (clang) and MSVC.
2014-09-17 16:52:33 -04:00
Nobuyuki Kubota
cd03ab62f8 Merge pull request #128 from redboltz/cpp11_unpacked_return
Added additional unpack() APIs to support C++11 style programming.
2014-09-16 10:06:31 -07:00
Nobuyuki Kubota
44e41efa0c Merge pull request #126 from redboltz/add_zero_size_tuple_support
Added zero size tuple support.
2014-09-16 09:23:31 -07:00
Takatoshi Kondo
ecf4b09acd Merge pull request #129 from tarruda/fix-ext-8-16-32
Fix size packing/unpacking for EXT 8/16/32
2014-09-16 08:52:48 +09:00
Thiago de Arruda
d6122b4a18 Fix size packing/unpacking for EXT 8/16/32
For EXT 8/16/32, the "size" field was being incremented by 1 to account for the
type field, but according to the specification the size should only consider the
length of the data field.
2014-09-15 15:37:02 -03:00
Takatoshi Kondo
4fcb4777f3 Added additional unpack() APIs to support C++11 style programming. 2014-09-15 22:33:23 +09:00
Takatoshi Kondo
03ed30ce03 Fixed https://github.com/msgpack/msgpack-c/issues/76
Clear deserialized target containers.
As the result of this fix, all containers' deserialized behaviors become consistent.
2014-09-15 18:16:37 +09:00
Takatoshi Kondo
6e810df2a4 Added zero size tuple support. 2014-09-14 20:50:57 +09:00
Takatoshi Kondo
847a7852e5 Merge branch 'jpetso-master' 2014-09-10 10:59:49 +09:00
Jakob Petsovits
e265beef91 Install version.h even if doing an out-of-source build. 2014-09-09 16:21:38 -04:00
Takatoshi Kondo
0335df55e1 Merge pull request #123 from redboltz/add_memory_check
Add memory check
2014-09-09 14:53:23 +09:00
Takatoshi Kondo
dd4043a616 Removed unused variables. 2014-09-09 14:29:10 +09:00
Takatoshi Kondo
6a8412d6de Separated msgpack_test.cpp.
Renamed test files.
Decreased test's loop counter to avoid travis-ci no output timeout.
The number of loops is not so meaningful.
2014-09-09 14:15:21 +09:00
Takatoshi Kondo
7491c1996a Added memory checking for travis-ci cmake build. 2014-09-09 13:38:07 +09:00
Takatoshi Kondo
0ab14b4138 Merge pull request #121 from redboltz/fix_cmake_binary_dir
Fixed the path of the msgpack.pc to support structured build.
2014-09-09 10:27:52 +09:00
Takatoshi Kondo
6e77c6df11 Merge pull request #122 from redboltz/add_install_test
Added 'make install' as a test target.
2014-09-09 10:14:24 +09:00
Takatoshi Kondo
bcc91d78e9 Merge branch 'tarruda-ext-support-for-c' into poc/0.6 2014-09-09 10:09:02 +09:00
Takatoshi Kondo
32b65dba47 Added 'make install' as a test target. 2014-09-09 07:37:29 +09:00
Takatoshi Kondo
aa75e6ecd3 Fixed the path of the msgpack.pc to support structured build. 2014-09-09 06:28:52 +09:00
Takatoshi Kondo
dc679a2572 Merge pull request #119 from davidchappelle/master
Amendment to cmake changes for out of source builds
2014-09-09 06:21:38 +09:00
David Chappelle
b6bc7f7ecb Merge remote-tracking branch 'upstream/master'
Conflicts:
	CMakeLists.txt
2014-09-08 15:57:43 -04:00
Thiago de Arruda
896dead7cc Adapt msgpack_test.cpp EXT cases to msgpackc_test.cpp 2014-09-08 12:11:39 -03:00
Thiago de Arruda
dfa277a9e0 Add EXT support to C library 2014-09-08 12:11:38 -03:00
Jason Newton
501260eb54 correct paths for x86_64/generic installations 2014-09-08 22:27:38 +09:00
Takatoshi Kondo
370a9251f5 Merge pull request #117 from redboltz/removed_unused_member_variable
Removed unused member variable.
2014-09-08 17:27:16 +09:00
Takatoshi Kondo
7737f1cb77 Removed unused member variable. 2014-09-08 17:14:56 +09:00
Takatoshi Kondo
f72022037c Merge pull request #116 from redboltz/limited_travis_target
Limited branches for travis-ci.
2014-09-08 17:08:16 +09:00
Takatoshi Kondo
865528f778 Limited branches for travis-ci. 2014-09-08 17:01:04 +09:00
Takatoshi Kondo
d54048eabe Merge pull request #114 from redboltz/poc/0.6
Added travis-ci support.
2014-09-08 16:36:12 +09:00
Takatoshi Kondo
103a6c56e4 Added travis-ci support. 2014-09-08 16:38:44 +09:00
Takatoshi Kondo
11f1d5fbbd Fixed https://github.com/msgpack/msgpack-c/pull/113
When the original PR was applied, the resource leak had been fixed, but a dual free problem had been happened.

When msgpack_unpacker_next returns MSGPACK_UNPACK_CONTINUE, msgpack_unpacked::zone is not replaced. Then mespack_zone_free is called twice with the same object. msgpack_unpacked_destroy frees msgpack::zone when it is not NULL and set it to NULL.

Also, fixed memory leak (msgpack_sbuffer) on the test code.
2014-09-07 13:56:07 +09:00
Takatoshi Kondo
7ebdb63131 Merge pull request #113 from tarruda/fix-memory-leak
Fix memory leak in msgpack_unpacker_next
2014-09-07 12:45:23 +09:00
Thiago de Arruda
a186725213 Fix memory leak in msgpack_unpacker_next 2014-09-06 20:01:52 -03:00
David Chappelle
8615358515 Fixed out of source cmake builds to work correctly.
The out of source cmake build was not working correctly. In particular,
the main CMakeLists.txt was not installing from the correct location.
In the case of msgpack.pc, it was trying to install from the top repo
directory instead of from the cmake build directory. So you can now
build as follows:

    $ cd msgpack-c
    $ mkdir build
    $ cd build
    $ cmake ../
    $ make
    $ make install
2014-09-05 19:22:04 +00:00
Takatoshi Kondo
86ad026f11 Renamed the last digit of version string from RELEASE to REVISION.
Added REVISION macro and getting API.
2014-09-03 13:26:34 +09:00
Jason Newton
93d0f0bd00 inline default_reference_func to avoid multiple definition errors 2014-09-03 10:26:09 +09:00
Jason Newton
a0f5392876 correct paths for x86_64/generic installations 2014-09-03 10:26:09 +09:00
Takatoshi Kondo
5896ff3746 Fixed -Wextra warnings on gcc. 2014-09-02 18:15:58 +09:00
Takatoshi Kondo
d15e49cb73 Updated version getting mechanism.
Versions are gotten from version_master.h
2014-09-02 16:42:05 +09:00
Takatoshi Kondo
2103c12e05 Added char* packing support. char* is packed to STR similar as std::string.
See https://github.com/msgpack/msgpack-c/issues/110
2014-09-01 22:42:08 +09:00
Takatoshi Kondo
f0a12a23a1 Merge branch 'tarruda-poc/0.6' into poc/0.6 2014-09-01 13:20:01 +09:00
Thiago de Arruda
30b946ee85 Support out-of-tree builds with cmake
This changes the location of msgpack.pc to support out-of-tree builds.
2014-08-31 10:42:27 -03:00
Takatoshi Kondo
a388000d47 Fixed autotools AC_INIT with external information implemantation.
See:
http://stackoverflow.com/questions/22871340/using-a-variable-in-ac-init
2014-08-31 20:38:52 +09:00
Takatoshi Kondo
4c888294b5 Merge pull request #107 from redboltz/fix_105_for_poc0.6
Fixed operator>>(object const& o, various types& v) return type and valu...
2014-08-31 17:23:18 +09:00
Takatoshi Kondo
68bf4acb4b Fixed operator>>(object const& o, various types& v) return type and value problem.
https://github.com/msgpack/msgpack-c/issues/105
2014-08-29 00:43:18 +09:00
Takatoshi Kondo
2c2df64427 Fixed C++03 and C++11 conditional tests building problem on cmake. 2014-08-29 00:38:44 +09:00
Takatoshi Kondo
4d6e9d6c05 Removed referenced member from msgpack::unpacked.
Added a referenced parameter to msgpack::unpack() and msgpack::unpacker::next().

msgpack::unpacked is a kind of handler that holds msgpack::object and msgpack::zone, so the size of msgpack::unpacked should be small. There is no reason to have referenced in msgpack::unpacked. msgpack user can get the same information using msgpack::unpack() and msgpack::unpacker::next().
2014-08-11 15:50:51 +09:00
Takatoshi Kondo
f969f6f39c Replaced zone* member variable in object with zone&.
Added msgpack::object::with_zone tests.
Added tuples operator<<'s parameter to const.
Fixed array object::with_zone pointer and size unset problem.
Fixed forward_list object::with_zone pointer and size unset problem.
2014-08-11 13:23:27 +09:00
Takatoshi Kondo
8920c49597 Unified test files extension as cpp. 2014-08-11 09:01:17 +09:00
Takatoshi Kondo
e18102d16f Replaced size() with std::distance. 2014-08-11 07:48:30 +09:00
Takatoshi Kondo
ea23bf843e Added std::forward_list support.
Fixed cmake filename typo.
2014-08-10 23:45:50 +09:00
Takatoshi Kondo
e217e72c22 Fixed msgpack::object type EXT comparison problem.
Added msgpack::object type EXT ostream minimal output.
2014-08-10 23:23:52 +09:00
Takatoshi Kondo
0bc4b3f599 Added the C++11 std::array support.
std::array<char, N> is mapped to BIN. That is the same mannar as std::vector.
2014-08-10 23:06:30 +09:00
Takatoshi Kondo
b2f5893669 Added reference to return value. 2014-08-10 22:04:31 +09:00
Takatoshi Kondo
9a1ccaf155 Merge pull request #100 from redboltz/add_vector_char_as_bin
vector<char> is mapped to BIN
2014-08-10 21:52:02 +09:00
Takatoshi Kondo
0201c21b9a Added minimum copy/reference threshold.
Even if ref_size is given on vrefbuffer's constructor, the minimum size of vrefbuffer::ref_buffer is 10.
Because int64, uint64, and double's msgpack expression size equals 9, and those buffer is allocated on the stack internally.
2014-08-08 14:28:03 +09:00
Takatoshi Kondo
dee68403df Replaced obsolete interface with recommended one on the example code. 2014-08-08 12:13:34 +09:00
Takatoshi Kondo
0a99b9f933 Fixed the problem that reference function doesn't pass correctly.
Fixed referenced flag writing timing on next(). It should place before flush.
Added msgpack_tuple test for CMakeLists.txt
Untabified CMakeLists.txt
Added reference function test.
2014-08-07 23:26:09 +09:00
Takatoshi Kondo
17e696fc0d Removed redundant memory allocation from zone.
Removed zone::create and zone::destroy.
We can use zone as follows:
   zone z; // on stack
   zone* z = new zone; // on heap

Fixed a resource leak when zone::push_finalizer(msgpack::unique_ptr<T>) is called.
2014-08-07 15:23:34 +09:00
Takatoshi Kondo
b5b459cfca Reordered unpack selector sequence. 2014-08-07 10:40:21 +09:00
Takatoshi Kondo
7822bc787d Replaced switch-case and bit calculation with a table. 2014-08-07 10:28:18 +09:00
Takatoshi Kondo
1f5d6b9cac Added EXT support.
Removed obsolete unpack functions.
Updated examples that no longer use obsolete functions.
Added reference checking function to unpacked. ( unpacked::referenced() )
Added std:: namespace.
Added reference or copy choice function and default behavior:
  When you use unpacker, default behavior is:
    STR, BIN, EXT types are always held by reference.
  When you don't use unpacker, default behavior is:
    STR, BIN, EXT types are always held by copy.
    The memory is allocated from zone.
  You can customize the behavior passing your custom judging function to unpack() or unpacker's constructor.
2014-08-06 16:18:37 +09:00
Takatoshi Kondo
ce21ab0ebf Fixed zone allocating functions always throw std::bad_alloc() if allocation is failed. 2014-08-06 12:16:28 +09:00
Takatoshi Kondo
5af6d36341 Added a link to wiki. 2014-08-04 16:39:17 +09:00
Takatoshi Kondo
15a0d61a64 Added the new mapping:
std::vector<char> is mapped to BIN.

So, currently BIN, STR, and ARRAY mappings are as follows:
  std::vector<char> is mapped to BIN
  std::string       is mapped to STR
  std::vector<T>    is mapped to ARRAY // T is not char
2014-08-04 15:14:39 +09:00
Takatoshi Kondo
66014eebc0 Updated test codes using recommended interface.
They used to use obsolete interfaces.
2014-08-04 01:08:05 +09:00
Takatoshi Kondo
fd566afeb4 Added reference version of unpacker::next(). 2014-08-04 00:52:04 +09:00
Takatoshi Kondo
e4d32b176e Use const char* version of msgpack::unpack_error to avoid std::string memory allocation when usr C++11 compiler.
See http://www.cplusplus.com/reference/stdexcept/runtime_error/?kw=runtime_error
2014-08-03 17:04:46 +09:00
Takatoshi Kondo
b27c87c9ed Replaced C-Style cast with static_cast. 2014-08-03 16:38:58 +09:00
Takatoshi Kondo
3729f334a1 Replaced size_t with std::size_t. 2014-08-03 16:34:47 +09:00
Takatoshi Kondo
55bf279a7c Removed obsolete unpack interface from test codes. 2014-08-03 08:08:08 +09:00
Takatoshi Kondo
78e8cbdfb5 Cleaned up pointer and reference versions of unpack(). 2014-08-03 07:09:03 +09:00
Nobuyuki Kubota
dd083ca933 Merge pull request #95 from ueno/int-float-test
Fix test failure regarding int->float conversion
2014-07-30 21:25:42 -07:00
Takatoshi Kondo
23d670f3bd Merge pull request #97 from splinterofchaos/ostream
Add inline for ODR compliance.
2014-07-25 09:19:55 +09:00
Scott Prager
6fab3594a2 Add inline for ODR compliance. 2014-07-24 15:04:33 -04:00
Takatoshi Kondo
421aeb5021 Fixed missing copy operation for zone.hpp 2014-07-24 23:49:35 +09:00
Takatoshi Kondo
47f4ffe9f3 Added cpp11 include files to install files.
Sorted C++ install files to avoid overlooking.
2014-07-24 10:54:54 +09:00
Takatoshi Kondo
09325ed846 Re-implemented msgpack::unpacker's move operations.
I refered to the following article and comments.
http://scottmeyers.blogspot.jp/2014/06/the-drawbacks-of-implementing-move.html

msgpack::detail::context back to copiable.
msgpack::detail::context doen't have any resource ownership, so there is
no strong reason to avoid copy.
2014-07-24 10:38:24 +09:00
Takatoshi Kondo
bfa428ab13 Added cpp_config.hpp to install files. 2014-07-24 07:52:20 +09:00
Takatoshi Kondo
ecdeec9948 Fixed the move assign operator implementation. 2014-07-24 07:41:23 +09:00
Takatoshi Kondo
f11a811114 Added a move constructor and a move assign operator for unpacker and context.
https://github.com/msgpack/msgpack-c/issues/96
2014-07-23 21:32:45 +09:00
Daiki Ueno
c203928fae Fix test failure regarding int->float conversion
Supply only small integers (< 1^23) to int->float conversion tests,
so they can roundtrip without error.
2014-07-17 18:51:59 +09:00
Takatoshi Kondo
59b111e026 Removed the contents in 'install from package' section. It is not supported for this branch.
Updated the description of the cmake.
2014-07-16 08:49:27 +09:00
Takatoshi Kondo
2a694f8c20 Fixed markdown format. 2014-07-16 08:26:36 +09:00
Takatoshi Kondo
0380215982 Fixed https://github.com/msgpack/msgpack-c/issues/88
Added examples for the following updated functions:

msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* result);

msgpack_unpack_return
msgpack_unpack_next(msgpack_unpacked* result,
        const char* data, size_t len, size_t* off);
2014-07-13 09:35:58 +09:00
Takatoshi Kondo
0e48f65a4b Fixed https://github.com/msgpack/msgpack-c/issues/94
Added a private copy assign operator to unpacker.
2014-07-12 00:41:33 +09:00
Takatoshi Kondo
aa79fc2ff4 Updated versions. 2014-07-12 00:33:06 +09:00
Takatoshi Kondo
cc571b8bb1 Replaced std::auto_ptr with msgpack::unique_ptr. 2014-07-12 00:21:35 +09:00
Takatoshi Kondo
b0df21295c Untabified.
Adjust line break positions.
2014-07-12 00:17:31 +09:00
Takatoshi Kondo
0889e6117e Renamed member variables name. 2014-07-11 23:37:43 +09:00
Takatoshi Kondo
212f025f00 Supported the C++11's enum class. 2014-07-08 19:31:02 +09:00
Takatoshi Kondo
f6a5402194 Supported the C++11 tuple. 2014-07-08 19:18:43 +09:00
Takatoshi Kondo
6a349d0b28 Fixed zero size string in the array problem. 2014-07-07 16:31:29 +09:00
Takatoshi Kondo
dac5c60608 Replaced bit shift with memcpy on load. 2014-07-07 16:31:29 +09:00
Takatoshi Kondo
bc33317b7e Reorganized tree. 2014-07-07 16:31:29 +09:00
Takatoshi Kondo
754b1682a5 Replaced C-style casts with C++ style casts. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
cb9eed8ccc Renamed from ct to container_type. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
862905742f Renamed z with zone. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
ba98315f65 The same fix as follows on C++ code.
https://github.com/msgpack/msgpack-c/pull/38
2014-07-07 16:19:31 +09:00
Takatoshi Kondo
124a871923 Removed redundant parameter. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
378f6afccd Mapped std::stirng to STR instead of BIN for benchmark. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
1320863cb3 Replaced function arguments with data members. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
a951ea90b8 Fixed delete free mismatch problem in C++11 version. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
3b7a2f8f32 Updated test codes using reference version of unpack functions. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
038c3e3518 Replaced unsigned int to size_t. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
c08439ff41 Added STR to std::string conversion. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
59d994ea5f Define nullptr macro only if it is not previously defined. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
ed51d23335 Refined tuple implementation. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
2be892bfda Removed a redundant null pointer check. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
723d900098 Added 'template' keyword. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
13404a7444 Supported placement new. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
a20594dfdc Added line breaks. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
bff4cadeff Added C++ separate version and C++11 description. 2014-07-07 16:19:31 +09:00
Takatoshi Kondo
6515577dc3 Added null pointer check for C++ separated code. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
beebccd323 Renamed zone::malloc familiy functions. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
d70c44b723 Added bin and str families support. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
33d3192ca2 Added static_cast to char. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
0d13931844 Fixed freed memory accessing bug in the C++ code.
(Issue #32)
2014-07-07 16:17:59 +09:00
Takatoshi Kondo
293c839a22 Supported 'plain' char.
msgpack used to only support signed char and unsigned char.
2014-07-07 16:17:59 +09:00
Takatoshi Kondo
f187ae35d9 Added a nested array example. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
74013e7e7d Added array of array example. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
e2026c0507 Renamed the classes named template_*.
Removed template_ from them because they are no longer template.
2014-07-07 16:17:59 +09:00
Takatoshi Kondo
c375e14705 Renamed a member function name from setObj to set_obj. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
fade0644c7 Added comments that how to compile and run it. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
5fedaf285b Removed C-style casts. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
fe82444db1 Replaced NULL with nullptr. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
f7692691ca Removed local variables top, cs, and user and access directly member variables top_, cs_, and user_.
The local variable trail is preserved to suppourt register optimization.
Other variables don't contribute increasing speed even though they are on registers.
2014-07-07 16:17:59 +09:00
Takatoshi Kondo
7fba3484c5 Renamed template callback functions.
Moved aggregate unpacking and pushing procedure to the function push_aggregate.
2014-07-07 16:17:59 +09:00
Takatoshi Kondo
561b6b583d Modified data members initialize sequence to fix a warning. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
7675c15fa9 Added a comment. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
99971abc9b Cleaned up template_context::execute(). 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
b7a1ba9ba0 Modified the offset parameter of template_context::execute() from pointer to reference. 2014-07-07 16:17:59 +09:00
Takatoshi Kondo
63c26cd58b Modified return type from bool to void in functions that always return true. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
f8fc03b482 Modified template functions' return value from int to bool. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
b0b1a0e9a7 Removed template_callback_root. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
4d2a9c23af Added inline keyword. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
c41154989a Used the reference version of convert instead of pointer version. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
541ece13c0 Added inline for constructors and a destructor. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
b6b2ef5e57 Removed the last comma at enum definitions to support C++03 strictly. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
4ef69da25d Restored the test cases using pointer based interfaces.
It assures that we can use the same interfaces as the original version(0.5.6).
To support both C++03 and C++11, I introduced msgpack::unique_ptr and msgpack::move() in test codes.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
9bd339baf8 Restored pointer based interfaces to maintain compatibility. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
616be1aa60 Modified type classes' interfaces parameters 'object' from passed by value to passed by reference. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
415b14335f Modified the parameter of object::convert() from pointer to reference. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
1fb707f93f Renamed functions from pack_real_* to pack_imp_*. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
aa4ed82b66 Replaced TAKE8_* macros with inline function named take8_*.
Modified byte stream using char instead of unsigned char.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
7ce8abe5d6 Tabified.
Indent adjusted.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
27629a8dd6 Modified 'unpacked' interface using references instead of pointers.
Added speed test for 'unpacked' based unpack() function.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
521a4f4190 Modified unpack_user* to unpack_user&.
Removed redundant 'static'.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
bad3801eae Modified zone* to zone&. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
72b3064a67 Removed redundant try-catch, zone's constructor never throw.
In the C++11 version, added noexcept.
In the C++03 version, added throw() as comments because actual throw() introduces some overhead.
Untabified.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
7593e5ce0e Removed object copy in implicit conversion class.
Removed redundant function prototype declaration.
Adjusted tab position.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
8a08548f36 Modified passed by value of object to const reference of object.
Removed C function call in operator==.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
56b0ad6809 Modified passed by value of object to const reference of object.
Modified object pointers to object references.
This modification has increased unpack speed.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
f8561fbfd5 Added map packing speed test. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
e80cbd4437 Tests for msgpack::type::tuple C++11 expansion moved to __cplusplus >= 201103. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
da601e4589 Added member fucntion version of msgpack::type::tuple::get().
Added support functions for msgpack::type::tuple as same as std::tuple.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
36a87b6968 Replaced C-style casts with C++ stype casts in C++ codes. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
e0b42939ba Cleaned up include guards. 2014-07-07 16:17:58 +09:00
Takatoshi Kondo
7d731f83a4 Moved the codes in pack_template.h to pack.hpp.
pack_template.h is still needed for the C version of msgpack.
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
40ad7da455 Moved gcc atomic functions from source file to header file.
Moved ostream operator << from object.cpp to object.hpp
Removed object.cpp
Modernize configure.in
2014-07-07 16:17:58 +09:00
Takatoshi Kondo
e0d1e5c722 Modified tuple's get calling from member function to free function. 2014-07-07 16:16:29 +09:00
Takatoshi Kondo
5b3a168b86 Supported C++03. 2014-07-07 16:16:29 +09:00
Takatoshi Kondo
11afd4820f Modified unpack functions to class member functions. 2014-07-07 16:16:29 +09:00
Takatoshi Kondo
ec5c1194fc Removed redundant namespace scope resolutions. 2014-07-07 16:16:29 +09:00
Takatoshi Kondo
7eccd1029a Modified from ::msgpack to msgpack 2014-07-07 16:16:29 +09:00
Takatoshi Kondo
c2ca709d68 Added header files that use c++11 variadic templates instead of ruby code generation.
When the compiler configured to support C++11 (e.g. CXXFLAG contains -std=c++11 is given),
those files are used.
Decoupled unpacker and msgpack_unpacker.
This modification introduced C++11 dependency such as nullptr and unique_ptr.
I will support C++11 and C++03, finally.

Decoupled msgpack.hpp and msgpack.h.

Decoupled sbuffer from msgpack_sbuffer.

Decoupled vrefbuffer from msgpack_vrefbuffer.

Decoupled zbuffer from msgpack_zbuffer.

Added some z_stream initialization.

Removed unpack macros.

Removed CTX_CAST and CTX_REFERENCED.

Embed ctx_ as a member variable (not a pointer).

Modified zone free using C++ way.
2014-07-07 16:16:29 +09:00
Nobuyuki Kubota
197ed8c983 Merge pull request #92 from nobu-k/version0.5.9
version 0.5.9
2014-07-03 11:45:20 +09:00
Nobuyuki Kubota
990860fe65 Change CMAKE_MINIMUM_REQUIRED to 2.8.6 for SET_PROPERTY APPEND_STRING 2014-07-03 11:39:43 +09:00
Nobuyuki Kubota
dbeb6e61c6 version 0.5.9 2014-07-02 18:44:07 +09:00
Nobuyuki Kubota
2b3f37f9e0 Add fbuffer.h and fbuffer.hpp to CMakeLists.txt and msgpack_vc.postbuild.bat 2014-07-02 18:07:07 +09:00
Nobuyuki Kubota
f50148a9cc Merge branch 'fbuffer' 2014-07-02 17:53:18 +09:00
Takatoshi Kondo
9fc8ec5b61 Merge branch 'tbeu-fix-bool-and-inline-for-C-compilation-with-MSVC' 2014-07-02 17:44:18 +09:00
Takatoshi Kondo
751a6f98fe Moved bool and inline definition from msgpack.h to sysdep.h.
Set compile settiong on MSVC. ".c" files are compliled as C, not C++. (msgpack_vc8.vcproj, CMakeLists.txt)
Fixed msgpack root object initialization problem on MSVC. {} initialization is not supported on MSVC.
2014-07-02 17:43:07 +09:00
Nobuyuki Kubota
9d8e6b92fc Add fclose to fbuffer's tests 2014-07-02 17:35:15 +09:00
Nobuyuki Kubota
c868da2879 Fix Makefile.am to install fbuffer.h and fbuffer.hpp 2014-07-02 17:32:41 +09:00
tbeu
e0c40c1c59 fix type bool and inline specifier
For a pure C compilation with MSVC type bool is not available. Not tested with other targets (Mingw, cygwin). Thats why only active of ```_MSC_VER``` is defined. So not sure if the bool fix should be also applied to other targets.

For MSVC the inline specifier is not valid and must be named __inline (or _inline).
2014-07-02 17:13:31 +09:00
Nobuyuki Kubota
f185284776 Merge branch 'mpapierski-cmake' 2014-07-02 16:22:33 +09:00
Takatoshi Kondo
1656ef0111 Merge pull request #90 from tbeu/fix-c-compilation
Fix pure C compilation
2014-06-23 21:43:56 +09:00
tbeu
3cb2e4f7c6 Fix pure C compilation 2014-06-23 13:55:25 +02:00
Takatoshi Kondo
3104f7e451 Added -O3 -g option for gcc and clang. Improved compiler checking method. 2014-06-21 19:00:59 +09:00
Takatoshi Kondo
ab8e7ea822 Added -DPIC option on shared library. 2014-06-21 11:27:33 +09:00
Takatoshi Kondo
6daef66ea7 Added warning flags. 2014-06-21 11:11:32 +09:00
Takatoshi Kondo
04286eb9dc Modified the way to install msgpack headers. 2014-06-12 11:18:06 +09:00
Takatoshi Kondo
d15e30bf4a Fixed major_version and minor_version.
Fixed relase_version.
Added msgpack.pc creating proccess.
2014-06-08 15:25:24 +00:00
Takatoshi Kondo
fb1d480faf Added the SOVERSION same as autotools.
Set CMAKE_MINIMUM_REQUIRED to 2.6.4.
2014-06-08 14:05:33 +00:00
Takatoshi Kondo
c8fa0be345 Supported make install.
Removed vc2008 files from make dist.
2014-06-07 14:39:59 +00:00
Takatoshi Kondo
643b0c9523 Supported shared library on cmake.
Updated the documentation.
2014-06-07 00:13:23 +09:00
Takatoshi Kondo
06930616b2 Added cmake files.
https://github.com/msgpack/msgpack-c/pull/20
Removed 'preprocess' from original CMakeLists.txt.
Removed file copy from original CMakeLists.txt.

Removed 'preprocess' from bootstrap.
Removed file copy from bootstrap.

Added erb generated files. Ruby is no longer required.
Moved cases.mpac, cases_compact.mpa, pack_define.h,
pack_template.h, unpack_define.h, unpack_template.h,
and sysdep.h to apropriate location.

If you want to re-generate zone.hpp, define.hpp, and tuple.hpp,
then you execute preprocess.
2014-06-05 20:49:15 +00:00
Nobuyuki Kubota
6e5fc6d396 Merge pull request #83 from redboltz/fixed_readme
Fixed https://github.com/msgpack/msgpack-c/issues/82
2014-06-01 19:16:10 +09:00
Takatoshi Kondo
17b0753023 Fixed linking order. 2014-06-01 19:03:51 +00:00
Nobuyuki Kubota
7491348d40 Merge branch 'philix-Wconversion' 2014-06-01 19:09:02 +09:00
Nobuyuki Kubota
eef2036c36 Remove implicit type conversions from (un)pack_template.h 2014-06-01 19:06:40 +09:00
Nobuyuki Kubota
fbec8f4470 Merge pull request #80 from redboltz/fix_enum_member_test
Fixed dereferencing type-punned pointer will break strict-aliasing rules warning
2014-06-01 18:22:46 +09:00
Felipe Oliveira Carvalho
8e0137e1d2 Fix to allow projects to compile with -Wconversion
Projects that use -Wconversion don't compile due to errors in msgpack header
files. This commit fixes all the errors in msgpack-c for when -Wconversion is
enabled.

Now I can even compile msgpack-c itself with -Wconversion and all my projects:

    CFLAGS=-Wconversion ./configure
		make
2014-05-19 15:30:14 -03:00
Takatoshi Kondo
1dac3f890a Fixed https://github.com/msgpack/msgpack-c/issues/82 2014-04-24 22:39:01 +00:00
Nobuyuki Kubota
9f33266f23 Merge pull request #81 from watsonsong/master
fix compile error on Linux by gcc 4.7
2014-04-07 10:37:54 +09:00
Frank Watson Song
d8c7fd5161 fix compile error on Linux by gcc 4.7 2014-04-01 17:34:28 +08:00
Nobuyuki Kubota
731bc643d0 Merge pull request #79 from redboltz/add_inline
Fixed https://github.com/msgpack/msgpack-c/issues/77
2014-03-31 17:36:06 +09:00
Takatoshi Kondo
12e8615ac5 Fixed dereferencing type-punned pointer will break strict-aliasing rules warning. 2014-03-31 16:37:29 +09:00
Takatoshi Kondo
22703d2cdb Fixed https://github.com/msgpack/msgpack-c/issues/77 2014-03-30 18:42:15 +00:00
Takatoshi Kondo
cb518f472a Merge pull request #73 from ovz/master
Fixed failing test zone_allocate_constructor.
2014-03-30 18:46:15 +09:00
Takatoshi Kondo
271f1fa319 Merge pull request #75 from mogemimi/fix/typo
Fix typo in QUICKSTART-CPP
2014-03-30 18:21:34 +09:00
mogemimi
9ecc4f0a1e Fix typo in QUICKSTART-CPP 2014-03-24 23:07:10 +09:00
ovz
977eab7c4a Fixed failing test zone_allocate_constructor.
Corrected a typo in definition of myclass constructor with parameters.
2014-03-18 14:25:55 -07:00
Vladimir Volodko
c9f342f4b2 Make fbuffer's constructor explicit. 2014-03-03 10:21:03 +07:00
Nobuyuki Kubota
126e4d8414 Merge pull request #70 from redboltz/remove_cxx11_features
Removed C++11 features
2014-03-02 16:58:16 +09:00
Takatoshi Kondo
14ee1e5827 Removed C++11 features 2014-03-02 14:14:04 +00:00
Nobuyuki Kubota
ecbb9055a2 Merge branch 'vvolodko/improve-define' 2014-02-28 16:15:20 +09:00
Nobuyuki Kubota
862f04104d Changed the format a little 2014-02-28 16:14:49 +09:00
Vladimir Volodko
d47f72be0c Refactor define::msgpack_unpack() to use 'switch' instead of several if's.
convert.benchmark test show some improvement.
2014-02-28 16:14:33 +09:00
Nobuyuki Kubota
98c5767372 Merge branch 'redboltz/add_integer_to_float_conv' 2014-02-28 15:53:11 +09:00
Nobuyuki Kubota
97a7b7545a Refactored test cases with type parameterized test 2014-02-28 15:52:36 +09:00
Nobuyuki Kubota
caf5616573 Merge pull request #69 from redboltz/support_libcpp_and_vcxx_unordered
Support libcpp and vcxx unordered
2014-02-28 15:22:27 +09:00
Takatoshi Kondo
b8076fa71f Supported VC++. Fixed testing macro for tr1 containers. 2014-02-27 23:54:48 +00:00
Takatoshi Kondo
2360466aa9 Added unordered containers support for libc++. 2014-02-22 20:43:18 +00:00
Nobuyuki Kubota
28370b36aa Replaced deprecated functions in example/stream.cc 2014-02-07 20:16:51 +09:00
Nobuyuki Kubota
9d82356ea9 Merge pull request #62 from redboltz/remove_redundant_null_check
Removed a redundant null check.
2014-02-07 20:05:49 +09:00
Nobuyuki Kubota
ca24e040c4 Merge pull request #61 from redboltz/fix_delete_free_mismatch
Fixed the free and delete mismatch problem.
2014-02-07 20:04:57 +09:00
Takatoshi Kondo
0fd629857d Removed a redundant null check. 2014-02-03 09:34:48 +00:00
Takatoshi Kondo
8eff14db11 Removed redundant null check. 2014-02-02 16:22:07 +00:00
Takatoshi Kondo
81e26fe9b9 Fixed the free and delete mismatch problem.
https://github.com/msgpack/msgpack-c/issues/52
2014-02-02 00:07:45 +00:00
Takatoshi Kondo
9eb4583dd5 Merge pull request #59 from redboltz/add_null_check
Added null pointer check.
2014-01-27 17:53:19 -08:00
Takatoshi Kondo
5a23c86dc1 Added null pointer check. 2014-01-28 10:54:57 +09:00
Takatoshi Kondo
ffd0525607 Replaced types of length from unsigned int to size_t. 2014-01-26 11:29:19 +00:00
Drew Crawford
3dc636bf3e This patch fixes a type conversion warning in clang 5 when compiling for arm64 targets.
```
$ clang --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

In file included from /Users/drew/Dropbox/Code/caffeine-ios/ext/msgpack/src/msgpack/pack.h:120:
/Users/drew/Dropbox/Code/caffeine-ios/ext/msgpack/src/msgpack/pack_template.h:773:57: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
        msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /Users/drew/Dropbox/Code/caffeine-ios/ext/msgpack/src/objectc.c:19:
/Users/drew/Dropbox/Code/caffeine-ios/ext/msgpack/src/msgpack/pack.h:118:61: note: expanded from macro 'msgpack_pack_append_buffer'
        return (*(user)->callback)((user)->data, (const char*)buf, len)
                                                                   ^
1 warning generated.
```

This patch is provided under the Apache License version 2.
2014-01-24 12:41:13 -06:00
Takatoshi Kondo
260ce4aa1d Added object that has integer to float and double converter. 2014-01-21 21:12:13 +00:00
Takatoshi Kondo
8bc827ebf5 Merge pull request #51 from xunzhang/master
update type.hpp
2014-01-13 18:10:49 -08:00
xunzhang
a97f764088 update type.hpp, support std::tr1::unordered_map and std::tr1::unordered_set 2014-01-13 14:12:17 +08:00
Nobuyuki Kubota
143b90af3e Merge branch 'claws/readme_overhaul' 2013-12-22 21:12:04 -08:00
Nobuyuki Kubota
4e0a6ae624 Fixed some URL syntaxes 2013-12-22 21:04:53 -08:00
Nobuyuki Kubota
0c60cfc5c0 Merge pull request #47 from nobu-k/version-0.5.8
version 0.5.8
2013-12-22 20:35:16 -08:00
Nobuyuki Kubota
deb6b0e334 version 0.5.8 2013-12-22 20:24:49 -08:00
Nobuyuki Kubota
27777dcd31 Merge pull request #46 from redboltz/fixed_size_type
Fixed size types based on snej's pull request.
2013-12-22 11:55:05 -08:00
Nobuyuki Kubota
bdb397e043 Merge pull request #36 from redboltz/support_plain_char
Supported 'plain' char.
2013-12-22 11:19:19 -08:00
Takatoshi Kondo
cb4d851761 Fixed size types based on snej's pull request.
1784e7a3f3
2013-12-22 15:13:48 +00:00
Chris Laws
17aa517e41 Fix up README, include accurate instructions 2013-12-17 08:53:15 +10:30
Takatoshi Kondo
7ac16f4834 Replaced const [un]signed long long int& with [un]signed long long int in sevral function's arguments to unify the interface. No performance issue is observed. 2013-12-16 13:39:12 +09:00
Takatoshi Kondo
bf7fece440 Merge pull request #43 from redboltz/add_test_and_example_for_37
Added a test and speed test examples for #37.
2013-12-15 20:25:46 -08:00
Takatoshi Kondo
c04ef9efe5 Merge pull request #38 from redboltz/copy_msgpack_object_by_memcpy
Fixed issue #37.
2013-12-15 20:25:15 -08:00
Takatoshi Kondo
b774c07d19 When the compiler is gcc, use memcpy, otherwise use an assignment operator.
The memcpy approach is a workaround for gcc's bug. The speed performance on gcc is the same between both approach. But on clang, the memcpy approach is 10% slower than an assignment approach. Hence I added the switching approach code using compiler checked macro.

Note: __GNUC__ is defined both gcc and clang. So I use __GNUC__ && !__clang__
2013-12-16 13:25:09 +09:00
Takatoshi Kondo
229467cb29 Added a test and speed test examples for #37. 2013-12-08 10:39:13 +00:00
Takatoshi Kondo
949b472f7e Merge pull request #41 from redboltz/old_compiler_bus_error_workaround
Fixed an unused function warning.
2013-11-26 17:31:02 -08:00
Takatoshi Kondo
be67d3e362 Fixed an unused function warning.
This fix is a part of issue #33.
35ba41c245
2013-11-27 10:33:52 +09:00
Vladimir Volodko
2c1a1fd4f8 Add C/C++ FILE* buffer adaptor.
* add function msgpack_fbuffer_write();
* add class msgpack::fbuffer;
* add tests buffer.fbuffer and buffer.fbuffer_c .
2013-11-22 12:57:30 +07:00
Takatoshi Kondo
3e2ae7cc78 Fixed issue #37.
It seems to be gcc's bug.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416
2013-11-11 09:51:04 +00:00
Nobuyuki Kubota
505660e1fa Merge pull request #35 from redboltz/add_libgtest
Added libgtest.a for make check
2013-10-30 21:44:57 -07:00
Takatoshi Kondo
09d90e1231 Supported 'plain' char.
Note: char, signed char, and unsigned char are three different types.
2013-10-31 13:19:22 +09:00
Takatoshi Kondo
5a9f89ae1f Added libgtest.a for make check 2013-10-29 13:35:26 +09:00
Jens Alfke
6f56345dd8 Fixed unused-function warnings
The function bodies in header files should be declared static inline.
2013-10-22 21:52:13 +00:00
Takatoshi Kondo
edef040688 Merge pull request #34 from redboltz/fix_freed_mem_access
Fixed freed memory accessing bug.
2013-10-22 05:11:42 -07:00
Takatoshi Kondo
9fc196e750 Fixed freed memory accessing bug.
(Issue #32)
2013-10-22 12:46:06 +00:00
Takatoshi Kondo
dc1698eaf4 Merge pull request #31 from redboltz/fix_buffer_leak
Fixed buffer leak bug.

In the case of the function next() returns true:
Whichever the argument result is holding the zone or not, the ownership of the zone always should be delegated from 'unpacker' to 'unpacked'.

In the case of the function next() returns false:
Whichever the argument result is holding the zone or not, the members of 'unpacked' should be reset.
2013-10-14 23:59:04 -07:00
Takatoshi Kondo
53ded063a0 Fixed buffer leak bug. 2013-10-15 11:03:47 +09:00
Takatoshi Kondo
8a2c50c374 Merge pull request #28 from redboltz/solve_narrow_conversion
Added the casts for the byte data.
2013-08-29 21:10:03 -07:00
Takatoshi Kondo
f71148f3a6 Merge pull request #29 from redboltz/add_copyright
Added copyright.
2013-08-29 21:09:08 -07:00
Takatoshi Kondo
172105828c Added copyright. 2013-08-30 13:07:42 +09:00
Takatoshi Kondo
6cca6cb20d Added the casts for the byte data. 2013-08-30 12:57:20 +09:00
Takatoshi Kondo
b7336f817c Merge pull request #27 from redboltz/malloc_free_match
Fixed malloc delete unmatch bug.
2013-08-26 18:56:26 -07:00
Takatoshi Kondo
88356b79be Fixed malloc delete unmatch bug. 2013-08-27 09:37:42 +09:00
Takatoshi Kondo
ce9e543882 Merge pull request #26 from redboltz/add_throw
added return value checking.
2013-08-23 00:34:21 -07:00
Takatoshi Kondo
3ff3ba83f4 added return value checking. 2013-08-23 16:28:02 +09:00
Takatoshi Kondo
edb525a030 Merge pull request #25 from redboltz/typo_fix
fixed a typo in a comment
2013-08-20 17:42:54 -07:00
Takatoshi Kondo
ea5314f076 fixed a typo in a comment 2013-08-21 09:32:51 +09:00
Nobuyuki Kubota
be8e53163b Updated wiki links and removed old message 2013-08-17 19:00:16 +09:00
Nobuyuki Kubota
79151f517f Imported quickstarts from wiki 2013-08-17 18:51:56 +09:00
Nobuyuki Kubota
e8ffe7ef96 Merge pull request #23 from ulikoehler/master
Add README syntax highlighting
2013-08-17 02:32:36 -07:00
Nobuyuki Kubota
b5a7b5e277 Fixed a compile error caused by MSGPACK_ADD_ENUM with msgpack::packer 2013-08-17 18:20:32 +09:00
Nobuyuki Kubota
85b5e1088f str 8 and bin 8/16/32 support in deserializer 2013-08-17 17:24:50 +09:00
Uli Köhler
680ddb1557 Add README syntax highlighting 2013-08-17 03:11:15 +02:00
Nobuyuki Kubota
44fff522bd Merge pull request #17 from grynko/patch-1
Update README.md
2013-07-29 03:33:29 -07:00
grynko
90815f0d27 Update README.md
fix typos
2013-07-02 12:06:14 +03:00
Nobuyuki Kubota
f07950c60a add the same test as commit:764bfdcb9f for __gnu_cxx::__exchange_and_add
refs #8
2013-04-09 18:14:23 -07:00
Nobuyuki Kubota
f8c4125892 Merge branch '__sync_check' of github.com:nori0428/msgpack-c into nori0428-__sync_check 2013-04-09 17:50:08 -07:00
Nobuyuki Kubota
1f30cc203a Temporary fix for a compilation error on OS X
fixes #3
fixes #15
2013-04-09 17:38:49 -07:00
nori0428
764bfdcb9f check whether exists __sync_{sub, add}_and_fetch 2013-03-01 11:08:37 +09:00
Vasily Titskiy
f290814f64 Fix implementation of atomic functions for GCC 3.x
__gnu_cxx::__exchange_and_add returns OLD, not NEW value
2013-01-03 19:28:00 -08:00
Hans Duedal
3a2508545d Fix for mismatched free() / delete / delete[]
When doing streaming deserialization, valgrind complains about mismatched free()...
It's caused by calls to auto_ptr::free for zones that are null pointers.
2013-01-03 19:27:17 -08:00
Nicolas Despres
79a06a338a Remove unused variables. 2013-01-03 19:26:06 -08:00
Nicolas Despres
509f27eee1 cpp: Fix convert.enum_member test (issue #50).
The patch add serialization operator for the given enum to avoid the use
of a cast which leads to strict-aliasing warnings and the test to fail.

Solution suggested by qehgt.
2013-01-03 19:20:07 -08:00
Nobuyuki Kubota
e511c32a36 Imported .gitignore from the original MessagePack git repository
This commit includes a pull request from polrop(ignore-cpp-bootstrapped-files branch).
2013-01-03 19:17:36 -08:00
FURUHASHI Sadayuki
b463d9b687 reorganized tree 2013-01-03 19:13:28 -08:00
FURUHASHI Sadayuki
e96e20ccfd make C/C++ implementation independent from other language implementations 2013-01-03 19:08:11 -08:00
FURUHASHI Sadayuki
06ebdbfd37 updated README.md 2013-01-03 19:04:51 -08:00
FURUHASHI Sadayuki
df9fd047b4 fixed previous commit 2013-01-03 19:00:20 -08:00
FURUHASHI Sadayuki
85d65c59d2 MessagePack for Ruby moved to https://github.com/msgpack/msgpack 2012-12-20 10:39:47 -08:00
FURUHASHI Sadayuki
754126644f ruby: v0.4.8 2012-12-16 17:17:11 -08:00
FURUHASHI Sadayuki
220436f4f9 Merge pull request #123 from brixen/patch-1
Update ruby/compat.h
2012-12-16 16:39:58 -08:00
Brian Ford
b62a6ae1d0 Update ruby/compat.h
The exceptions for Rubinius are unnecessary now and are actually
causing msgpack not to install due to the incorrect function prototypes
that are in this file. In MRI, this is the prototype

  VALUE rb_gc_enable();

Anyway, these are unnecessary for Rubinius.
2012-12-16 16:27:05 -08:00
INADA Naoki
eae0532b8c Split msgpack-php repository. 2012-08-20 22:04:44 +09:00
UENISHI Kota
d642487f99 MessagePack for Erlang moved to https://github.com/msgpack/msgpack-erlang 2012-07-17 22:39:31 +09:00
FURUHASHI Sadayuki
320510506b MessagePack for OCaml moved to https://github.com/msgpack/msgpack-ocaml 2012-07-04 17:40:11 -07:00
FURUHASHI Sadayuki
b2839ac78b MessagePack for Haskell moved to https://github.com/msgpack/msgpack-haskell 2012-07-03 19:14:45 -07:00
FURUHASHI Sadayuki
834d5a0e72 MessagePack for Scala moved to https://github.com/msgpack/msgpack/tree/master/scala 2012-07-03 19:10:28 -07:00
FURUHASHI Sadayuki
13ce808c47 MessagePack for C# was moved to https://github.com/msgpack/msgpack-cli 2012-06-25 18:23:24 -07:00
FURUHASHI Sadayuki
980a6529c1 ruby 0.4.7 2012-05-05 19:40:48 -07:00
FURUHASHI Sadayuki
c92384fe68 ruby: fix ruby/st.h on ruby 1.8 2012-05-05 19:39:50 -07:00
FURUHASHI Sadayuki
9f563f87b9 ruby: fix ruby/st.h on ruby 1.8 2012-05-05 19:26:26 -07:00
INADA Naoki
44f37b8d1b Merge branch 'master' of github.com:msgpack/msgpack 2012-05-01 03:03:21 +09:00
INADA Naoki
5f41c1cf3f Split msgpack-go repository 2012-05-01 03:02:49 +09:00
INADA Naoki
2a664b9ae6 Merge pull request #89 from ngmoco/master
Go string support
2012-04-30 10:05:16 -07:00
INADA Naoki
5456814199 Merge branch 'master' of https://github.com/dgryski/msgpack into go
Conflicts:
	go/pack.go
2012-05-01 01:44:27 +09:00
INADA Naoki
33ceaeb208 Merge pull request #104 from ericliang/master
For go1 release compatiblity with some trivial code refactorations.
2012-04-30 09:37:52 -07:00
FURUHASHI Sadayuki
b33e60b3ae Merge pull request #108 from kou/support-pkg-config
c: supports pkg-config
2012-04-20 19:40:42 -07:00
advect
9dd0a6eb86 php: supported 5.4.x version 2012-04-20 15:29:20 +09:00
Kouhei Sutou
ed6faf4e65 c: supports pkg-config
About pkg-config:

  From http://www.freedesktop.org/wiki/Software/pkg-config

  pkg-config is a helper tool used when compiling applications and
  libraries. It helps you insert the correct compiler options on the
  command line so an application can use gcc -o test test.c
  `pkg-config --libs --cflags glib-2.0` for instance, rather than
  hard-coding values on where to find glib (or other libraries). It is
  language-agnostic, so it can be used for defining the location of
  documentation tools, for instance.

pkg-config is a widely used build helper tool. Major build tools such
as GNU Autoconf, CMake and so on support pkg-config.

MessagePack users can build their software more easily.
2012-04-15 19:21:55 +09:00
Eric Liang
df2ee5de49 fix ENOENT from os to syscall, ditto. 2012-03-31 00:36:47 +08:00
Eric Liang
36fef91a67 fix error for go1 compatiblity 2012-03-31 00:34:23 +08:00
FURUHASHI Sadayuki
3399148d75 Merge pull request #99 from kou/support-mingw
c: supports DLL generation by MinGW
2012-03-21 00:10:49 -07:00
FURUHASHI Sadayuki
0eea92de66 cpp: fixed template generation logic for 0-length classes #101 2012-03-21 00:10:26 -07:00
Masahiro Nakagawa
92975bb21d Merge pull request #103 from dbussink/rubinius_support
Improve Rubinius support for msgpack Ruby gem
2012-03-19 08:12:08 -07:00
Dirkjan Bussink
bf18e04134 Detect whether st.h is present and don't use RUBY_VM as the condition 2012-03-17 12:43:26 +01:00
Dirkjan Bussink
4a0d7f18fd Explicitly state msgpack doesn't modify char* buffers from RSTRING_PTR
From what I could investigate, msgpack doesn't modify char* buffers
obtained from RSTRING_PTR. This means that on Rubinius we don't have to
copy back and forth the buffer to make sure it's also updated on the
Ruby side.

This copying of buffers is a similar problem as the RARRAY_PTR problem,
because it is not safe to expose GC'ed memory on Rubinius to extensions
since it can move due to Rubinius having a moving GC.
2012-03-17 12:40:29 +01:00
Dirkjan Bussink
65c360a2ca Don't use MRI internals in the Ruby extension
Using internals of MRI by using RARRAY_PTR makes it necessary for other
implementations such as Rubinius to continuously copy the structure
returned by RARRAY_PTR back and forth since in Rubinius objects are
layed out differently internally.

Extensions should not depend and use these internal MRI structures if
this is not necessary and when there are API methods that can provide
the same functionality. This makes sure other implementations can also
use the extension without any big problems.

For this reason I also removed the FIXME comment, since that change
would also heavily depend on the internal memory layout of objects on
MRI.
2012-03-17 11:28:19 +01:00
Damian Gryski
71919f7523 go: update unit tests for fixbytes packing bug 2012-02-29 10:36:58 +01:00
Damian Gryski
31a49db68b go: Fix length mask error in []byte packing. 2012-02-28 22:54:54 +01:00
Kouhei Sutou
0d615442ba c: supports DLL generation by MinGW
libtool requires -no-undefined link option to generate a DLL
by MinGW. A DLL should not have any unresolved symbols and
-no-undefined link option declares that the library doesn't
depends on any libraries other than the ones listed on the
command line.

See also: description about -no-undefined option at
http://www.gnu.org/software/libtool/manual/libtool.html#Link-mode
2012-02-27 14:31:37 +09:00
Damian Gryski
8f35dbc306 go: README with installation instructions 2012-02-25 03:11:37 +01:00
Damian Gryski
154bcbc4f7 go: Makefiles not needed any more. 2012-02-25 03:10:06 +01:00
Damian Gryski
c96a39d315 go: Fix unit test for non-deterministic map ordering 2012-02-24 22:52:37 +01:00
Damian Gryski
06ba74c366 go: Updated for weekly.2012-02-22 2012-02-24 22:51:39 +01:00
Muga Nishizawa
8786a8e6e0 deleted .settings directory and .gitignore file 2012-02-09 02:23:25 +09:00
Muga Nishizawa
748236fef0 MessagePack for Java was moved to https://github.com/msgpack/msgpack-java. 2012-02-09 02:21:43 +09:00
INADA Naoki
ae1b06f20b Fix bug on unpacking empty array. 2012-01-28 02:20:39 +09:00
Hideyuki Tanaka
b8aa93ce30 fix decode on bigendian systems 2012-01-26 16:38:27 +09:00
Hideyuki Tanaka
49d40a42f1 fix bug 2011-11-18 17:49:22 +09:00
Hideyuki Tanaka
1845f34b81 change auto-derive behaviour 2011-11-18 16:49:12 +09:00
Hideyuki Tanaka
43903d446a version bump 2011-11-17 18:29:01 +09:00
Hideyuki Tanaka
256da2124b support auto-derive parameterized type 2011-11-17 18:27:37 +09:00
Hideyuki Tanaka
7869e96bac change behaviour of auto-deriver 2011-11-17 17:40:10 +09:00
Hideyuki Tanaka
79b51a6e4b improve and change user data auto-deriver 2011-11-17 17:15:05 +09:00
Hideyuki Tanaka
cad9f6d46e fix dependencies 2011-11-16 14:49:01 +09:00
Scott White
da2960880a adding support for encoding string types and fixed the Pack test. 2011-10-17 13:29:50 -07:00
Fuji Goro
0eacc58e29 Merge branch 'master' of git://github.com/msgpack/msgpack 2011-10-10 16:02:19 -07:00
Fuji Goro
3bec736aee Fix pack/unpack for double on arm-oabi 2011-10-10 10:38:49 -07:00
Hideyuki Tanaka
3241ffd1b4 version bump 2011-08-30 13:58:16 -07:00
INADA Naoki
d0d7b266bc Split msgpack-python to separated repository. 2011-08-21 18:55:16 +09:00
advect
c24948258b php: 0.5.1
Merge pull request #81
Fixed include path for version check. (Contributed by duedal)
2011-08-20 16:40:48 +09:00
Fuji Goro
d36666bd98 Move perl/ to https://github.com/msgpack/msgpack-perl 2011-08-19 12:37:03 +09:00
Fuji Goro
2794b1d310 perl: tiny tweaks 2011-08-19 11:33:46 +09:00
Fuji Goro
f456fa03da perl: encourage to inlining 2011-08-19 11:15:09 +09:00
Fuji Goro
356b7b43f8 perl: add JSON.pm-like interface: Data::MessagePack->new->encode(...) 2011-08-19 10:54:30 +09:00
Fuji Goro
92718e2140 perl: Refactor config vars 2011-08-19 10:49:59 +09:00
Fuji Goro
4021160a64 perl: Performance tweaks for $Canonical 2011-08-19 10:22:28 +09:00
Fuji, Goro
6f043e3326 Merge pull request #82 from cho45/canonical
perl: Implemented canonical mode.
2011-08-18 18:06:54 -07:00
cho45
74b0b1da21 perl: Implemented canonical mode. 2011-08-17 18:32:43 +09:00
Muga Nishizawa
3a5f676687 fixed bug, which is cause of CannotCompileException during compiling primitive-type fields annotated by Nullable 2011-08-09 18:35:42 +09:00
FURUHASHI Sadayuki
4fa7cffc37 fixed sysdep.h 2011-08-09 03:30:56 +09:00
FURUHASHI Sadayuki
79b83e78a5 cpp: version 0.5.7 2011-08-08 23:52:09 +09:00
FURUHASHI Sadayuki
048a3835e7 cpp: -O3 -> -O4 2011-08-08 23:51:12 +09:00
FURUHASHI Sadayuki
4a4891036a ruby: 0.4.6 2011-08-08 23:50:25 +09:00
FURUHASHI Sadayuki
ff00c83f15 ruby: -O4 -> -O3 2011-08-08 23:49:19 +09:00
FURUHASHI Sadayuki
79d31b7452 Merge pull request #76 from bketelsen/master
Update Go support to latest release version (R58)
2011-08-07 12:57:09 -07:00
Fuji, Goro
20cc6f7463 Revert "Changelogging"
This reverts commit ba7183a5b4.
2011-08-07 18:51:34 +09:00
Fuji, Goro
8acabaa135 Revert "SVs with POK and IOK/NOK should be packed as numbers, not strings"
This reverts commit 28f4338a6c.
2011-08-07 18:51:16 +09:00
Fuji, Goro
ba7183a5b4 Changelogging 2011-08-07 18:40:52 +09:00
Fuji, Goro
28f4338a6c SVs with POK and IOK/NOK should be packed as numbers, not strings 2011-08-07 18:36:50 +09:00
Fuji, Goro
800a93a859 Update .gitignore and MANIFEST.SKIP 2011-08-07 18:36:34 +09:00
advect
2e969e3a0a php: 0.5.0
Fix ZEND_DECLARE_MODULE_GLOBALS
Add unpack of template converter (Merge pull request #57 #58 from enfinity/msgpackr)
2011-07-28 08:15:38 +09:00
Muga Nishizawa
3fb31f651d scala: fixed bug within reflection-based beans template builder 2011-07-22 20:36:31 +09:00
Brian Ketelsen
682d25b551 fixed author and updated to r58 or higher 2011-07-21 12:33:44 -04:00
Muga Nishizawa
bcad8d4c4c MSGPACK-27: appended \'synchronized\' to modifiers of TemplateRegistry#unregister ( ) 2011-06-30 10:36:01 +09:00
Muga Nishizawa
96bab8e02e java: Added utilities for unit testing 2011-06-27 11:49:17 +09:00
Muga Nishizawa
fa4a615d0f java: Updated versions of dependencies, which are junit, slf4j-api and slf4j-log4j12 2011-06-27 11:37:48 +09:00
Muga Nishizawa
f1265c4fed java: Merged file in .settings manually 2011-06-27 10:54:32 +09:00
Muga Nishizawa
df01cd9a09 java: changed setting files for Eclipse IDE 2011-06-27 10:51:33 +09:00
FURUHASHI Sadayuki
255bac642d Merge branch 'master' of github.com:msgpack/msgpack 2011-06-26 22:52:06 +09:00
FURUHASHI Sadayuki
6d8c3bd13d use larger buffer size on MessagePack.pack 2011-06-26 22:48:42 +09:00
INADA Naoki
75b8272710 Merge remote-tracking branch 'origin/master' 2011-06-24 00:05:04 +09:00
INADA Naoki
2f80e154f2 (python) Fix typo in ChangeLog 2011-06-24 00:04:43 +09:00
FURUHASHI Sadayuki
cc0114c482 cpp: fixed configure.in for gcc 3.x support 2011-06-12 15:16:13 +09:00
FURUHASHI Sadayuki
e5e2b9095c updated README.md 2011-06-12 14:47:29 +09:00
FURUHASHI Sadayuki
6977edc032 Merge branch 'master' of github.com:msgpack/msgpack 2011-06-12 14:46:39 +09:00
Kazuki Ohta
177cc55ee5 s/msgpack.sourceforge.net/msgpack.org/ 2011-06-12 14:44:57 +09:00
FURUHASHI Sadayuki
feb7ec03ba Merge branch 'master' of github.com:msgpack/msgpack 2011-06-12 14:37:51 +09:00
FURUHASHI Sadayuki
6630a643d3 Merge pull request #51 from polrop/fix-cpp-check-when-builddir-diff-srcdir
Fix make check when builddir != srcdir.
2011-06-11 22:36:25 -07:00
Muga Nishizawa
d70e64a434 Merge branch 'master' of git@github.com:msgpack/msgpack 2011-06-12 02:48:42 +09:00
Muga Nishizawa
896ad51102 java: add missing dependencies for Ant/Ivy builds 2011-06-12 02:48:14 +09:00
inada-n
be6d6560a7 (python) make test pass with Python 2.5 2011-06-01 18:30:43 +09:00
INADA Naoki
709d0cc33e Revert "(python) Change error message for unicode is passed but no encoding is"
This reverts commit bd73742552.
2011-05-31 15:40:11 +09:00
INADA Naoki
bd73742552 (python) Change error message for unicode is passed but no encoding is
specified.
2011-05-31 14:10:46 +09:00
INADA Naoki
ed4518e09a Merge branch 'pyunicode' of https://github.com/tailhook/msgpack 2011-05-31 13:03:41 +09:00
Vasily Titskiy
6c8301eae8 Merge branch 'gcc-3.x-support' 2011-05-26 13:31:59 -04:00
Vasily Titskiy
6e30d504e3 Merge branch 'fix-unaligned-access' 2011-05-26 13:31:37 -04:00
Vasily Titskiy
cee09a0261 Add support for GCC 3.x (no _sync* atomic builtins)
Use atomic routines from libstdc++ instead.
2011-05-26 13:27:25 -04:00
Vasily Titskiy
76a72558b3 Fix all unaligned writes on ARM platform 2011-05-26 13:03:57 -04:00
FURUHASHI Sadayuki
22124a33ce java: DefaultTemplate: uses lookupType.toString() instead of lookupType.getClass().getName() 2011-05-18 02:09:29 +09:00
FURUHASHI Sadayuki
3731373de1 ruby: 0.4.5 2011-05-09 22:35:35 +09:00
FURUHASHI Sadayuki
bbaf8c2f67 ruby: FIXNUM_P(self) may be false in Fixnum on JRuby 2011-05-09 22:06:12 +09:00
FURUHASHI Sadayuki
f50694cc96 ruby: improves compatibility with JRuby 2011-05-09 21:59:55 +09:00
Nicolas Despres
4930ea7dab Fix make check when builddir != srcdir.
make check was not able to compile test programs when the builddir is not
the same than the srcdir, because relative path were used.
2011-04-28 16:11:24 +02:00
takeshita
96bb4cf49d pom.xmlを修正 2011-04-27 12:24:47 +09:00
takeshita
5e7563ac5b Merge branch 'master' of git://github.com/msgpack/msgpack
Conflicts:
	java/pom.xml
2011-04-27 01:07:17 +09:00
takeshita
f199b80453 Fix big bug.
I had gotten order of MessagePackObject field from order of reflection methods.But it changes depends on order of calling in some environment(Scala's optimization or Java's specification?).
So I change to get it from order of reflection fields.
2011-04-27 01:04:49 +09:00
Kazuki Oikawa
5de8eec206 Merge branch 'master' of git://github.com/kazuki/msgpack 2011-04-24 02:02:35 +09:00
frsyuki
076bd07f39 cpp: version 0.5.6 2011-04-24 00:23:08 +09:00
FURUHASHI Sadayuki
00e897503b java: fixes typo on CHANGES.txt 2011-04-24 00:11:34 +09:00
FURUHASHI Sadayuki
2f3c47f385 java: version 0.5.2-devel 2011-04-23 23:57:27 +09:00
Muga Nishizawa
2b28211701 MSGPACK-6 added new TemplatePrecompiler function 2011-04-23 22:47:44 +09:00
Muga Nishizawa
46c794fc2e java: added test program for TemplatePrecompiler 2011-04-23 22:37:08 +09:00
Muga Nishizawa
0408738b48 java: write test program for TemplatePrecompiler 2011-04-23 19:19:05 +09:00
Kazuki Oikawa
6cfea98501 csharp: add license, rename filename/namespace. 2011-04-23 14:44:22 +09:00
Kazuki Oikawa
33498d3673 csharp: Refactoring IL code generator & add two compiled packer implementation (dynamic-method, method-builder) 2011-04-23 14:14:12 +09:00
takeshita
ed3ead06fe Implement array message pack 2011-04-20 20:35:23 +09:00
frsyuki
eb8a338a0e cpp: unpacker::release_zone() calls msgpack_unpacker_release_zone() #42 2011-04-17 08:25:55 +09:00
frsyuki
23480bfe8a cpp: fixed missing ctx.user.z = z and release_zone uses pointer swapp instead of copying #42 2011-04-17 08:24:33 +09:00
frsyuki
3384dbc92d cpp: fixes test/streaming_c.cc #42 2011-04-17 08:21:52 +09:00
frsyuki
8446549ed8 Merge branch 'master' of github.com:msgpack/msgpack 2011-04-17 06:49:36 +09:00
frsyuki
6a9f3ae71d c: fixed a double-free problem on msgpack_unpacker_release_zone #42 (aikar++) 2011-04-17 06:48:36 +09:00
Kazuki Oikawa
94e5b0d78f csharp: fix char pack/unpack problem on Mono 2011-04-17 00:33:37 +09:00
Kazuki Oikawa
0812eb1c04 add System.Reflection.Emit based CompiledPacker implementation 2011-04-16 21:12:04 +09:00
tailhook
8cb5ccad99 Implemented encoding for strings
* Packer by default uses `utf-8` encoding by default
* Unpacker uses `None` by default, so no decoding is done
* Both pack and unpack has `encoding` and `unicode_errors` arguments,
  if `encoding` is `None` no encoding/decoding is done, otherwise
  it is python codec. `unicode_errors` is supplied as `errors`
  parameter to codec
2011-04-15 18:39:17 +03:00
takeshita
743d69ec0b Change property ordering based on getter methods to setter methods.
Add test to confirm field order.
2011-04-14 16:34:52 +09:00
takeshita
f6de4c9479 Merge branch 'master' of git://github.com/msgpack/msgpack 2011-04-14 15:44:46 +09:00
takeshita
fb59927d32 scala:Fix bug when companion class does not have apply() method, scala message pack throws exception. 2011-04-14 15:44:22 +09:00
FURUHASHI Sadayuki
c58ce1a975 MSGPACK-7 added -source 1.5 -target 1.5 options to javac 2011-04-12 18:41:08 +09:00
FURUHASHI Sadayuki
c6d9bbd7b0 MSGPACK-7 fixed test cases; iteration order of HashMap is not defined by JDK 5/6 specification 2011-04-12 18:39:54 +09:00
Kazuki Oikawa
08974f00ed Merge branch 'master' of github.com:kazuki/msgpack 2011-04-10 14:24:26 +09:00
Kazuki Oikawa
60643f023f csharp: add ObjectPacker 2011-04-10 12:52:14 +09:00
Muga Nishizawa
65ddd1a455 java: add test program for TemplatePrecompiler 2011-04-10 02:33:46 +09:00
Kazuki Oikawa
68a98d3dd0 csharp: remove reference Microsoft.VisualStudio.QualityTools.UnitTestFramework 2011-04-10 02:03:40 +09:00
Kazuki Oikawa
ca9015452e csharp: add Makefile 2011-04-10 01:38:03 +09:00
Kazuki Oikawa
05ac2603e6 csharp: add BoxingPacker tests 2011-04-10 01:06:26 +09:00
Kazuki Oikawa
8e923777b8 csharp: fix fixraw prefix 2011-04-09 22:16:24 +09:00
Kazuki Oikawa
8949551c2e Add MsgPackReader/MsgPackWriter unit tests 2011-04-09 22:12:44 +09:00
Kazuki Oikawa
0b45e9442b csharp: add type check helper 2011-04-09 21:22:15 +09:00
Kazuki Oikawa
1d1a9d7933 import C# implementation 2011-04-09 21:17:05 +09:00
Muga Nishizawa
58c0fe0f91 java: Refactored template builders again 2011-04-09 21:10:15 +09:00
Muga Nishizawa
b96b62f2ac scala: deleted the AUTHORS file 2011-04-08 16:20:28 +09:00
Muga Nishizawa
43fc0a52a6 scala: added a new AUTHORS file and edited pom.xml 2011-04-08 16:17:25 +09:00
Muga Nishizawa
4f3d9a1ded Refactored programs related to TemplateBuilder.java 2011-04-08 16:13:29 +09:00
FURUHASHI Sadayuki
b50ff920f0 MSGPACK-5 added test cases for Unpacker.unpackXxx() methods 2011-04-07 23:21:56 +09:00
FURUHASHI Sadayuki
983ae0c5a2 MSGPACK-4 BufferedUnapckerImpl.unpackInt: more(4)+advance(4) -> more(5)+advance(5) 2011-04-07 23:21:30 +09:00
FURUHASHI Sadayuki
9d4db84987 MSGPACK-4 BufferedUnpackerImpl.unpackLong: more(4)+advance(4) -> more(5)+advance(5) 2011-04-07 22:32:59 +09:00
takeshita
1f372cf0cc Merge branch 'master' of github.com:geishatokyo/msgpack
Conflicts:
	java/src/main/java/org/msgpack/template/TemplateClassWriter.java
2011-04-07 01:07:10 +09:00
takeshita
c43d597aa9 pom.xmlファイルを修正。 2011-04-07 01:04:29 +09:00
Muga Nishizawa
dfaa281476 java: Fixed TemplateClassWriter.java but, it doesn't work. 2011-04-07 00:38:21 +09:00
takeshita
df14629a25 Fix compile error.
This is a workaround.Please fix correctly in the future.
2011-04-07 00:07:49 +09:00
Muga Nishizawa
c1c25c455c scala: Modified pom.xml. I changed version of 'MessagePack for Java' from 0.5.1-devel to 0.5.2-SNAPSHOT 2011-04-06 08:52:14 +09:00
Muga Nishizawa
e65197f386 Merge branch 'master' of https://github.com/watabiki/msgpack 2011-04-06 01:18:12 +09:00
Muga Nishizawa
ecbb8f8711 java: Merged takezoux2's branch for 'MessagePack for Scala' 2011-04-06 00:50:58 +09:00
Watabiki Naoya
03aa736199 java: update BigDecimalTemplate, TestPackConvert and TestPackUnpack 2011-04-05 23:26:53 +09:00
Muga Nishizawa
821b1f0384 Merge branch 'master' of git@github.com:msgpack/msgpack 2011-04-05 03:35:08 +09:00
Muga Nishizawa
233ad3aaff java: Updated several property files in .settings 2011-04-05 03:34:11 +09:00
Muga Nishizawa
9c4812f4d4 java: Fixed RawType's bug that hash values of same byte arrays (raw data) are different 2011-04-05 03:30:43 +09:00
Muga Nishizawa
337cc9fa78 java: Fixed a bug that NullPointerException occurs within DefaultTemplate.java 2011-04-05 01:27:51 +09:00
Muga Nishizawa
dfe29a0329 Merge branch 'master' of git@github.com:msgpack/msgpack 2011-04-05 00:52:30 +09:00
Muga Nishizawa
85e90aa81e java: Improved DefaultTemplate.java. It allows displaying details of exception messages 2011-04-05 00:51:53 +09:00
Hideyuki Tanaka
86d30fe571 haskell: reduce dependency of template-haskell 2011-04-04 23:33:02 +09:00
mzp
173302267f ocaml: upadte build file 2011-04-04 18:28:37 +09:00
Muga Nishizawa
8e3ea8d26c java: edit TemplateRegistry.java 2011-04-04 02:28:24 +09:00
Muga Nishizawa
cb065563c2 Merge branch 'master' of git@github.com:msgpack/msgpack 2011-04-04 01:59:34 +09:00
Muga Nishizawa
27b89b237b java: prototyped TemplateClassWriter, which is program for writing class file of generated tmplate class 2011-04-04 01:59:13 +09:00
takeshita
21f0d0bfc4 Delete moved class.
(TemplateBuilder.java is moved to org.msgpack.template.builder)
2011-04-04 01:46:29 +09:00
takeshita
d5e583b09e Implement Scala MessagePack.
Change Java MessagePack to fit Scala's.
Minor version up for Java's MessagePack.
2011-04-04 01:37:24 +09:00
UENISHI Kota
15fb9bbcb2 Merge branch 'master' of https://github.com/moriyoshi/msgpack 2011-04-03 19:52:34 +09:00
Muga Nishizawa
a03418ab12 java: edit BuiltInTemplateLoader.java 2011-04-03 19:42:43 +09:00
Muga Nishizawa
035513844d Merge branch 'master' of git@github.com:msgpack/msgpack 2011-04-03 19:11:56 +09:00
Muga Nishizawa
193906b8ce java: insert codes for initializing BigDecimalTemplate and DateTemplate instances to Templates.java 2011-04-03 19:10:34 +09:00
Moriyoshi Koizumi
d354f2e8c2 Documentation. 2011-04-03 19:09:14 +09:00
Watabiki Naoya
24a8ee436f add DateTemplate and BigDecimalTemplate 2011-04-03 18:39:41 +09:00
mzp
6e5f9404b7 ocaml: initial commit 2011-04-03 17:11:53 +09:00
Moriyoshi Koizumi
64fe90aabb Add TestUnpackFloat(). 2011-04-03 15:34:37 +09:00
Moriyoshi Koizumi
7e31d487e0 float type was gone from go language at some time I don't know. 2011-04-03 14:06:08 +09:00
moriyoshi
ee16e2eb30 Handle unsupported typecode 2011-04-03 11:14:49 +09:00
moriyoshi
003fb3392f Byte arrays in Go should not be serialized as arrays. 2011-04-03 11:14:49 +09:00
moriyoshi
0e82278cd5 Fix: InterfaceValue wasnt' correctly unwrapped when passed to PackValue() 2011-04-03 11:14:49 +09:00
moriyoshi
5b544248bc Add new API function UnpackReflected() that returns multiple reflect.Value for unpacked elements of arrays or maps. 2011-04-03 11:14:49 +09:00
moriyoshi
d4d7495c0a Forgot to support map16 / map32 2011-04-03 11:14:48 +09:00
moriyoshi
8325cce44c Adapt to new reflection API (notified by mattn. thanks) 2011-04-03 11:14:48 +09:00
moriyoshi
ee0debc5b3 Add .gitignore 2011-04-03 11:14:48 +09:00
moriyoshi
8f1bd12a17 Improve testsuite. 2011-04-03 11:14:10 +09:00
moriyoshi
fccf1016e4 Fix bugs in unpacker. 2011-04-03 11:14:10 +09:00
moriyoshi
1b010a082b Add go binding. 2011-04-03 11:14:10 +09:00
Hideyuki Tanaka
324f215316 haskell: version bump 2011-03-29 16:17:46 +09:00
Hideyuki Tanaka
ace4f1e7f0 fix encoding unicode strings, and Text support 2011-03-29 16:15:29 +09:00
Hideyuki Tanaka
5c5f16f148 haskell: version bump 2011-03-18 00:46:43 +09:00
Hideyuki Tanaka
f50855d5c0 fix for packing and unpacking Object 2011-03-18 00:44:15 +09:00
Muga Nishizawa
86917b0ba7 improved constructor in JavassistTemplateBuilder class. This improvement is based on https://github.com/msgpack/msgpack-rpc/issues#issue/13. 2011-03-11 12:24:09 +09:00
Hideyuki Tanaka
7201fcbe0f remove Iteratee dependency 2011-03-10 22:17:15 +09:00
Hideyuki Tanaka
83f1735fbb fix description 2011-03-09 18:06:57 +09:00
Hideyuki Tanaka
80fd8e70f0 update library version. 2011-03-09 17:02:01 +09:00
Hideyuki Tanaka
698c1c2b7a Merge git://github.com/xanxys/msgpack into pull-master 2011-03-09 16:19:19 +09:00
Yuto Hayamizu
5d3287f5aa gtest requires pthread 2011-03-03 06:42:14 +09:00
Yuto Hayamizu
6990fe6f51 remove duplicated code 2011-03-03 06:38:09 +09:00
Yuto Hayamizu
0b81068368 /cpp/preprocess: fix string comp. operator 2011-03-03 06:27:31 +09:00
FURUHASHI Sadayuki
5b1851ae22 cpp: version 0.5.5 2011-02-24 00:35:00 +09:00
FURUHASHI Sadayuki
0d5708a01d cpp: fixes problem that InterlockedIncrement/Decrement are not found on _WIN32 platform 2011-02-24 00:21:54 +09:00
FURUHASHI Sadayuki
67ab510b5d cpp: fixes some implicit cast warnings 2011-02-23 23:48:26 +09:00
FURUHASHI Sadayuki
d1264a1289 cpp: fixes msgpack_vc.postbuild.bat 2011-02-23 23:47:33 +09:00
FURUHASHI Sadayuki
3b973021a1 sysdep.h: eliminated #include <winsock2.h> 2011-02-23 23:46:39 +09:00
INADA Naoki
182624895f python: Remove UnpackIterator. Unpacker is iterator of itself. 2011-01-30 10:45:39 +09:00
INADA Naoki
548de3739c python: Disable gc while deserializing. 2011-01-29 23:23:56 +09:00
INADA Naoki
718a3efd64 python: Fix segmentation fault when default returns it's argument. 2011-01-29 23:22:41 +09:00
INADA Naoki
76b8c3250b Merge branch 'master' of github.com:msgpack/msgpack 2011-01-29 07:31:59 +09:00
INADA Naoki
dafaa8bd8c python: 0.1.9 2011-01-29 07:31:06 +09:00
INADA Naoki
9c9b2c25ea python: refactoring. 2011-01-29 07:27:10 +09:00
INADA Naoki
e89cd81022 Add use_list option to unpack and unpackb 2011-01-28 18:59:05 +09:00
advect
5debbd2be8 php: added unpack of class object converter 2011-01-16 17:35:10 +09:00
INADA Naoki
fe26df5355 python: Add memory error check. 2011-01-10 20:47:23 +09:00
INADA Naoki
85778494e4 python: Check if (m|re)alloc's return value is NULL. (Thanks to Mateusz) 2011-01-10 05:07:07 +09:00
INADA Naoki
a94ce3c715 python: Fix typo in docstring. (thanks to Mateusz.) 2011-01-10 05:05:14 +09:00
INADA Naoki
a440ff1117 python: Change URL in setup.py from sf.net to msgpack.org 2011-01-10 00:10:29 +09:00
INADA Naoki
8195137bc5 python: msgpack-python-0.1.8 2011-01-09 23:58:26 +09:00
INADA Naoki
3e2bd25e4e python: Fix another segv. 2011-01-09 23:54:06 +09:00
INADA Naoki
ffd0c2f624 python: Fix segv on unpacking from stream. 2011-01-09 23:40:09 +09:00
INADA Naoki
23333c98d7 python: Add test for issue29. 2011-01-09 23:29:18 +09:00
INADA Naoki
5a12ab98c4 python: Make aliases for API compatibility to pickle.
``dumps`` is alias of ``packb`` and ``loads`` is alias of ``unpacks``.
2011-01-09 23:17:20 +09:00
INADA Naoki
0b327a63fc python: Don't use `from __future__ import unicode_literals`.
Python 2.5 or older doesn't support it.
2011-01-09 23:13:35 +09:00
INADA Naoki
15b28a245c python: Update ChangeLog. 2011-01-09 23:06:56 +09:00
INADA Naoki
6ef5684797 Merge branch 'master' of github.com:msgpack/msgpack 2011-01-08 17:45:13 +09:00
xanxys
d439b1495b haskell: add ObjectFloat to send floats, and Assoc to make map (un)packing explicit 2010-12-28 19:22:37 +09:00
advect
9e096a3f0e php: version 0.3.4: supported Windows building 2010-12-28 16:09:13 +09:00
advect
0acf6ec150 php: version 0.3.3 2010-12-27 11:09:14 +09:00
Muga Nishizawa
4b36340474 java: refactor JavassistTemplateBuilder.java 2010-12-23 15:51:04 +09:00
FURUHASHI Sadayuki
910e642a8b java: version 0.5.1 2010-12-14 18:21:53 +09:00
FURUHASHI Sadayuki
9f571146fb java: fixes cast error on GenericArrayType 2010-12-14 17:47:45 +09:00
FURUHASHI Sadayuki
339725f73d java: throws MessagePackException if target==null on *ArrayTemplate 2010-12-13 18:52:25 +09:00
Muga Nishizawa
aff964c58b java: fixed a bug within CollectionTemplate.java 2010-12-12 00:48:31 +09:00
Muga Nishizawa
0c07e745f8 java: change spec. of pack methods in ListTemplate and MapTemplate as follow: If user passes null object to the pack method, MessageTypeException is thrown. 2010-12-12 00:47:20 +09:00
Muga Nishizawa
419d2e9564 java: change spec. of pack methods in several template classes as follow: If user passes null object to the pack method, MessageTypeException is thrown. 2010-12-12 00:46:05 +09:00
Muga Nishizawa
f936a307c6 java: add test methods for CollectionTemplate and change spec. of several test methods 2010-12-12 00:38:13 +09:00
Muga Nishizawa
4e4678edfa java: add packByteBuffer method in Packer.java because I needed non-nullcheck pack(ByteBuffer) for refining ByteBufferTemplate.java 2010-12-12 00:35:43 +09:00
FURUHASHI Sadayuki
cb7a4b3116 java: version 0.5.0 2010-12-09 23:36:27 +09:00
FURUHASHI Sadayuki
5ca4c42a74 Merge branch 'master' of github.com:msgpack/msgpack 2010-12-09 23:28:23 +09:00
FURUHASHI Sadayuki
1238a7ca07 java: adds AUTHORS file 2010-12-09 23:28:16 +09:00
Muga Nishizawa
a9db60a73d java: replace reflective method calls with base-level method calls in JavassistTemplateBuilder.java 2010-12-09 23:25:11 +09:00
FURUHASHI Sadayuki
bd32ac19d4 java: removes old benchmark codes 2010-12-09 23:01:04 +09:00
FURUHASHI Sadayuki
eaf9944e43 java: added ElementType.PARAMETER to the target of @Ignore, @Index, @Nulable, @Optional and @Required annotations for RPC 2010-12-09 17:31:29 +09:00
FURUHASHI Sadayuki
703fdbc01d java: array type support 2010-12-08 19:38:12 +09:00
FURUHASHI Sadayuki
2daa08b0e7 java: disabled ObjectArrayTempalte - it doesn't work 2010-12-06 00:13:05 +09:00
FURUHASHI Sadayuki
05d9d22d9e java: fixes native zero-copy unpacking routines of ByteBuffer 2010-12-03 22:56:04 +09:00
FURUHASHI Sadayuki
8b7894f9bd java: fixes comments in TemplateBuffer.java 2010-12-03 22:54:20 +09:00
Muga Nishizawa
a71439607f java: performance improvement for ByteBufferTemplate 2010-12-03 21:53:29 +09:00
Muga Nishizawa
aca0d7f969 java: refactor ByteBufferTemplate.java 2010-12-02 01:11:55 +09:00
Muga Nishizawa
310a8e4342 Merge branch 'master' of git@github.com:msgpack/msgpack
Conflicts:
	java/src/main/java/org/msgpack/MessagePack.java
2010-12-02 00:54:28 +09:00
FURUHASHI Sadayuki
24fbe1ef5b java: uses ReflectionTemplateBuilder instead of JavassistTempalteBuilder where System.getProperty("java.vm.name") == "Dalvik" 2010-12-01 23:27:36 +09:00
FURUHASHI Sadayuki
33d8faa35d java: JavassistTemplateBuilder: fixes comments 2010-12-01 23:15:55 +09:00
FURUHASHI Sadayuki
44be714f65 java: adds JavassistTemplateBuilder.addClassLoader method 2010-12-01 22:59:33 +09:00
FURUHASHI Sadayuki
0df3da6b10 java: adds TemplateRegistry.setTemplateBuilder method 2010-12-01 22:59:20 +09:00
FURUHASHI Sadayuki
79197b6ec7 java: more test cases of TemplateBuilder 2010-12-01 22:44:38 +09:00
FURUHASHI Sadayuki
353b6b51cb java: adds TemplateBuildException 2010-12-01 22:44:24 +09:00
FURUHASHI Sadayuki
bd9a2c0d3a java: migrates from util.codegen to TemplateBuilder 2010-12-01 22:42:55 +09:00
Muga Nishizawa
53b0ee6536 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-12-01 21:20:10 +09:00
FURUHASHI Sadayuki
78daac0f1b java: adds type.RawTemplate 2010-12-01 20:49:41 +09:00
FURUHASHI Sadayuki
b970b9b9a8 java: adds JavassistTemplateBuilder 2010-12-01 20:39:11 +09:00
FURUHASHI Sadayuki
0339db57f1 java: adds TemplateBuilder and ReflectionTemplateBUilder 2010-12-01 20:38:58 +09:00
FURUHASHI Sadayuki
461b147897 java: uses TemplateRepostry as default 2010-12-01 20:37:32 +09:00
FURUHASHI Sadayuki
a3cd13b399 java: adds actual generic templates 2010-12-01 20:36:52 +09:00
FURUHASHI Sadayuki
eb5d326a1e java: adds GenericTemplates 2010-12-01 20:34:33 +09:00
FURUHASHI Sadayuki
cce6eb94e2 java: adds DefaultTemplate 2010-12-01 20:34:23 +09:00
FURUHASHI Sadayuki
8311c72c69 java: adds BultInTemplateLoader 2010-12-01 20:33:38 +09:00
FURUHASHI Sadayuki
9a059285d9 java: registers buit-in templates to TemplateRegistry 2010-12-01 20:32:22 +09:00
FURUHASHI Sadayuki
469ac7891d java adds TemplateRegistry that replaces CustomMessage 2010-12-01 20:25:06 +09:00
FURUHASHI Sadayuki
16264a5693 java: adds array templates 2010-12-01 20:24:36 +09:00
FURUHASHI Sadayuki
6eedb50f56 java: adds TemplateBuilder and ReflectionTemplateBuilder 2010-11-30 21:59:07 +09:00
FURUHASHI Sadayuki
5f07215662 java: adds @Requred, @Ignore and @Index annotations 2010-11-30 21:58:24 +09:00
FURUHASHI Sadayuki
d3a02fb2ca java: @MessagePackMessage(default field option) 2010-11-30 21:57:12 +09:00
FURUHASHI Sadayuki
2c823f1aaa java: uses bit shift operations instead of ByteBuffer.putXxx 2010-11-30 21:55:45 +09:00
FURUHASHI Sadayuki
706293aadc java: adds type.Raw 2010-11-30 15:34:32 +09:00
FURUHASHI Sadayuki
dfdceb4258 java: updates VectoredByteBuffer 2010-11-29 18:37:47 +09:00
FURUHASHI Sadayuki
0014b7fdb9 java: adds VectoredByteBuffer 2010-11-29 18:01:39 +09:00
FURUHASHI Sadayuki
3b28f1f8af ruby: buffer size limit (disabled at present) 2010-11-28 23:13:53 +09:00
FURUHASHI Sadayuki
c689d476ca Merge remote branch 'egtra/master' 2010-11-24 18:05:50 +09:00
FURUHASHI Sadayuki
cc534fd21f ruby: adds Unpacker#feed_each 2010-11-24 17:24:55 +09:00
egtra
124efcf247 improve msvc support 2010-11-23 23:32:55 +09:00
Muga Nishizawa
dd452b05e3 java: rollback MessagePack.java 2010-11-19 02:57:42 +09:00
Muga Nishizawa
b5617f7df9 java: refactor register method in MessagePack.java for TemplateProvider 2010-11-19 01:58:30 +09:00
Muga Nishizawa
b73ca1ba3a java: edit MessagePack.java for TemplateProvider 2010-11-19 01:46:31 +09:00
Muga Nishizawa
39ad071c4f java: fixed a bug that javassist cannot find class files that were loaded by custom class loader 2010-11-18 22:26:58 +09:00
Muga Nishizawa
fa0b576a45 java: Fixed a bug that ClassTemplate cannot pack a ByteBuffer object but, it is a temporary impl. 2010-11-11 13:38:15 +09:00
frsyuki
c2c7591987 java: version 0.4.3-devel 2010-11-10 00:54:49 +09:00
frsyuki
3e939e3775 java: fixes MessagePackObject.convert(Template, T) 2010-11-10 00:53:15 +09:00
frsyuki
f6384e10bc java: adds test for DynamicOrdinalEnumTemplate 2010-11-10 00:32:25 +09:00
frsyuki
c283842563 java: MessagePackOptional -> Optional, MessagePackNullable -> Nullable 2010-11-10 00:16:23 +09:00
frsyuki
1135976225 java: adds MessagePack.unpack(Class<?>, FieldList) 2010-11-09 23:51:58 +09:00
frsyuki
76679d33df java: changes Template interface: unpack(Unpacker, Object to = null), convert(MessagePackObject from, Object to = null) 2010-11-09 23:43:16 +09:00
frsyuki
e9d44b90bc java: adds FieldList class 2010-11-09 22:11:47 +09:00
Muga Nishizawa
8a7a391166 java: delete ByteBufferTemplate.java in org.msgpack.util.codegen package 2010-11-09 10:13:55 +09:00
Muga Nishizawa
d6c5a9eece delete a dead code within DynamicCodeGen.java 2010-11-09 09:57:23 +09:00
Muga Nishizawa
56ad6915d0 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-11-09 09:28:38 +09:00
frsyuki
466c260782 java: version 0.4.2-devel 2010-11-09 03:16:00 +09:00
frsyuki
d8e2d1725a java: MessagePack.unpack(InputStream) throws IOException 2010-11-09 02:57:49 +09:00
frsyuki
33b43d03ac java: adds MessagePackNullable annotation 2010-11-09 02:46:23 +09:00
frsyuki
517509db6e java: adds NullableTemplate 2 2010-11-09 02:07:53 +09:00
frsyuki
95f01a5976 java: adds MessagePackObject.unpack(Class<T> klass) 2010-11-09 02:07:50 +09:00
frsyuki
d08d3bf56d java: adds NullableTemplate 2010-11-09 01:07:25 +09:00
frsyuki
587fd669e8 java: adds ByteBufferTemplate 2010-11-08 23:20:27 +09:00
Muga Nishizawa
e3553b87fe java: move ByteBufferTemplate.java to org.msgpack.util.codegen package 2010-11-06 11:31:40 +09:00
Muga Nishizawa
a078d2360c java: add temporal implementation of ByteBufferTemplate.java 2010-11-06 00:59:32 +09:00
frsyuki
2d3abf8e6e java: version 0.4.1-devel 2010-11-05 19:21:27 +09:00
Muga Nishizawa
cacae0fb7d java: refactor DynamicCodeGen.java and Constants.java. Thanks frsyuki for fixing a bug in DynamicCodeGen.java 2010-11-04 02:00:34 +09:00
INADA Naoki
d7fc215c16 python: 0.1.7 2010-11-03 03:43:49 +09:00
INADA Naoki
bb69aa18f2 python: Add ws2_32 library if platform is win32. 2010-11-03 03:35:52 +09:00
INADA Naoki
e4f515166a python: Add ChangeLog.rst 2010-11-03 03:26:33 +09:00
INADA Naoki
f325acb0ea Merge branch 'master' of github.com:msgpack/msgpack 2010-11-03 03:19:28 +09:00
INADA Naoki
d1b6e65dd8 python: Port some tests from 2 to 3. 2010-11-03 03:15:12 +09:00
INADA Naoki
4688252bd4 python: Support old buffer protocol when unpack. (experimental) 2010-11-03 03:11:00 +09:00
INADA Naoki
b1df5d3ad7 python: Add test for unpacking buffer object. 2010-11-02 14:09:50 +09:00
INADA Naoki
09bad2938e python: Add msgpack/_msgpack.c to .gitignore 2010-11-02 14:02:10 +09:00
advect
bad69fd397 php: fiexed unpacker 2010-10-30 16:06:50 +09:00
Fuji, Goro
b4ae6bf82c perl: disable warnings 2010-10-30 13:04:30 +09:00
Fuji, Goro
eac0f83864 perl: check data strictly; which is slow, but required 2010-10-30 12:38:32 +09:00
Fuji, Goro
3f16f080ac perl: add failing tests for PP 2010-10-30 01:09:12 +09:00
Fuji, Goro
5de2b974fb perl: ord(substr(...)) *is* faster than unpack() 2010-10-30 00:42:00 +09:00
Fuji, Goro
6a9cb51828 perl: modify internal names for the next refactoring 2010-10-30 00:31:41 +09:00
Fuji, Goro
f1c294ca50 perl: make error messages compatible with XS 2010-10-30 00:28:53 +09:00
Fuji, Goro
c320e44a23 perl: update Unpacker.pod 2010-10-28 17:26:04 +09:00
Fuji, Goro
ea36ef3107 perl: tests 2010-10-28 17:05:41 +09:00
Fuji, Goro
fedc37d079 Revert "perl: cleanup"
This reverts commit bc8d8ab65a.
2010-10-28 16:31:19 +09:00
Fuji, Goro
86ccfcc03c perl: changelogging 2010-10-28 16:25:19 +09:00
Fuji, Goro
bc8d8ab65a Revert "Revert "perl: cleanup""
This reverts commit a7a23d3bc8.
2010-10-28 16:17:53 +09:00
Fuji, Goro
a7a23d3bc8 Revert "perl: cleanup"
This reverts commit 82d33944e6.
2010-10-28 16:16:12 +09:00
Fuji, Goro
82d33944e6 perl: cleanup 2010-10-28 16:08:20 +09:00
Fuji, Goro
8a629ad6fb Fix streaming unpacking for splitted packed data 2010-10-28 15:49:22 +09:00
INADA Naoki
e1711ffcf2 Add list_hook option to unpacker. 2010-10-26 02:09:52 +09:00
INADA Naoki
063d51c662 Add check for recursion limit and default hook result. 2010-10-26 01:49:00 +09:00
INADA Naoki
d8e3575a46 Remove unnecessary refcount manipulation. 2010-10-26 01:32:08 +09:00
INADA Naoki
6fa609be3f Add test for Python3. 2010-10-26 01:31:27 +09:00
INADA Naoki
70982e204c Add object_hook option to unpack and default option to pack.
(see simplejson for how to use).
2010-10-26 01:26:06 +09:00
frsyuki
2af7df5865 java: fixes MessagePack.unpack method 2010-10-25 14:49:14 +09:00
frsyuki
59610e81de java: DynamicCodeGen::insertCodeOfUnpackMethodBody unpacks last optional field of classes correctly 2010-10-25 14:18:41 +09:00
Muga Nishizawa
cdfac703ef java: merge CustomMessage.java and DynamicCodeGenBase.java that can be not merged automatically 2010-10-24 23:24:27 +09:00
Muga Nishizawa
ad5ebd007e java: refactor org.msgpack.util.codegen.*.java 2010-10-24 23:10:07 +09:00
frsyuki
1bd347d997 java: fixes CustomMessage class 2010-10-24 21:17:19 +09:00
frsyuki
147056073d java: improves test case of the MessagePack class 2010-10-24 21:04:31 +09:00
frsyuki
1b3231e617 java: improves test case of the MessagePack class 2010-10-24 20:59:19 +09:00
frsyuki
7ac4ad3e38 java: adds MessagePack.register methods 2010-10-24 20:46:22 +09:00
frsyuki
0a345cb12b java: fixes CollectionTemplate 2010-10-24 20:16:37 +09:00
frsyuki
19ff0dd17f java: fixes ListTemplate and MapTemplate 2010-10-24 20:11:39 +09:00
frsyuki
e3bf8a404b java: adds MessagePack class 2010-10-24 19:32:45 +09:00
frsyuki
dbb28d9a8f java: Template extends MessagePacker 2010-10-24 18:46:48 +09:00
frsyuki
19fd4e755c java: removes ReflectionPacker and ReflectionTemplate (replaced by DynamicCodeGen) 2010-10-24 18:45:58 +09:00
Muga Nishizawa
77698cd924 java: change modifiers specified by several methods 2010-10-24 00:59:14 +09:00
Muga Nishizawa
945d279f28 java: fix a bug within a code of DynamicCodeGenBase.java 2010-10-24 00:40:58 +09:00
Muga Nishizawa
645d296841 java: add test programs for org.msgpack.util.codegen.FieldOption.java 2010-10-23 23:13:54 +09:00
Muga Nishizawa
57446de875 java: refactor org.msgpack.util.codegen.*.java 2010-10-23 23:13:17 +09:00
Muga Nishizawa
3473800ab6 java: not use a putIfAbsent method in ConcurrentHashMap class 2010-10-23 23:11:52 +09:00
Muga Nishizawa
7e5c5153a8 java: edit copyright notions in org.msgpack.annotation.*.java and org.msgpack.util.codegen.*.java 2010-10-23 14:50:32 +09:00
Muga Nishizawa
1b8979f285 java: refactor org.msgpack.util.codegen.*.java 2010-10-23 14:39:01 +09:00
Muga Nishizawa
2aac51dd20 java: append getter methods for element templates in org.msgpack.template.ListTemplate.java, MapTemplate.java and OptionalTemplate.java 2010-10-23 14:37:24 +09:00
Muga Nishizawa
69e32d264c java: write test programs for OptionalTemplate.java 2010-10-22 23:23:53 +09:00
frsyuki
71ae75a5bf java: adds OptionalPacker 2010-10-22 16:18:07 +09:00
frsyuki
86043fd87e java: adds OptionalTemplate 2010-10-22 08:31:03 +09:00
Fuji, Goro
d8aaef4f04 perl: tests 2010-10-21 23:35:07 +09:00
Fuji, Goro
7fc34b6369 perl: tweaks 2010-10-21 23:27:26 +09:00
Fuji, Goro
92b346efa7 perl: clean up 2010-10-21 23:26:03 +09:00
Muga Nishizawa
c790735b9f java: add test programs for org.msgpack.util.codegen.*.java 2010-10-21 02:02:23 +09:00
Muga Nishizawa
64711e615e java: write test programs for org.msgpack.util.codegen.*.java 2010-10-20 21:04:37 +09:00
frsyuki
2065affd45 java: adds CollectionTemplate 2010-10-20 16:40:25 +09:00
frsyuki
4067c56b5d java: supports Collection<T> to pack 2010-10-20 16:32:01 +09:00
tokuhirom
65515638aa perl: oops! added settings for shipit 2010-10-19 13:45:44 +09:00
tokuhirom
371ba3ffe3 Checking in changes prior to tagging of version 0.34.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 50177f4..486f1c3 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,6 @@
+0.34
+
+    - do not use the corrupt my_snprintf(%ll[du]) on win32(kazuho)

 0.33
2010-10-18 19:30:08 +09:00
Kazuho Oku
5395b62f2f shorter code, fix comment 2010-10-18 19:26:24 +09:00
Kazuho Oku
3e164eab26 do not use the corrupt my_snprintf(%ll[du]) on win32 2010-10-18 19:22:28 +09:00
Muga Nishizawa
ad85533975 java: add a log4j.properties file for unit testing 2010-10-17 19:23:42 +09:00
Muga Nishizawa
d6c2a97931 java: write test programs for org.msgpack.packer.*.java 2010-10-17 18:57:00 +09:00
Muga Nishizawa
17def94ba4 java: describe test programs for org.msgpack.template.*.java 2010-10-17 18:24:08 +09:00
Muga Nishizawa
cf254ea240 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-10-17 14:37:35 +09:00
Muga Nishizawa
2d05110239 java: refactor DynamicCodeGenBase.java 2010-10-17 14:37:13 +09:00
Fuji, Goro
0017f4fce8 Checking in changes prior to tagging of version 0.33.
Changelog diff is:
2010-10-13 12:46:41 +09:00
Fuji, Goro
02f3dd947a perl: optimize PP 2010-10-13 12:46:11 +09:00
Fuji, Goro
ef0874feba perl: tweaks for PreferInteger 2010-10-13 11:02:57 +09:00
Fuji, Goro
14aa1420f0 perl: comments 2010-10-13 10:54:37 +09:00
Fuji, Goro
c506cd97e0 perl: tests 2010-10-13 10:43:56 +09:00
Fuji, Goro
3761aacb1d perl: cleanup PP 2010-10-13 10:14:31 +09:00
Fuji, Goro
233f13aac5 perl: add tests for unpacking 'float' 2010-10-13 10:03:56 +09:00
Fuji, Goro
0ced3ec2d2 perl: fix tests 2010-10-13 09:38:40 +09:00
Fuji, Goro
5b786f65a4 Checking in changes prior to tagging of version 0.32.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 6e07966..4657079 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,4 +1,8 @@

+0.32
+
+    - add tests to detect Alpha problems reported via CPAN testers (gfx)
+
 0.31

     - update Module::Install::XSUtil for ccache support (gfx)
2010-10-12 23:12:34 +09:00
Fuji, Goro
770542c8c7 perl: add tests 2010-10-12 23:10:59 +09:00
Fuji, Goro
4f1207a38c perl: add a strong assertion 2010-10-12 23:05:58 +09:00
Fuji, Goro
2b65f81e23 Add tests 2010-10-12 22:58:53 +09:00
Muga Nishizawa
c10eb2c17b java: add the code for checking a null pointer to DynamicCodeGen.java 2010-10-11 01:30:42 +09:00
Muga Nishizawa
3f5ac54bf5 java: refactor the programs in a org.msgpack.util.codegen package 2010-10-09 21:53:49 +09:00
Muga Nishizawa
790f9409b1 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-10-07 23:53:22 +09:00
Muga Nishizawa
a3d831b723 java: refactor DynamicCodeGen.java 2010-10-07 23:53:01 +09:00
Fuji, Goro
b9483deea3 Checking in changes prior to tagging of version 0.31.
Changelog diff is:
2010-10-07 17:06:45 +09:00
Fuji, Goro
c211d2ac45 Merge commit 'perl-0.30' 2010-10-07 17:05:37 +09:00
Fuji, Goro
119a03dd5f perl: changelogging 2010-10-07 16:56:36 +09:00
Fuji, Goro
f3fbb7e1f6 perl: Update Makefile.PL using M::I::XSUtil 0.36 (support for ccache) 2010-10-07 16:54:49 +09:00
Fuji, Goro
2be98e8467 perl: changelogging 2010-10-07 16:18:47 +09:00
Fuji, Goro
91b1806e9d perl: add XS_VERSION_BOOTCHECK for safety 2010-10-07 16:16:59 +09:00
Fuji, Goro
8548b3645a perl: cleanup 2010-10-07 16:13:56 +09:00
Muga Nishizawa
4bbfb3f9a3 java: refactor DynamicCodeGen.java 2010-10-07 15:27:11 +09:00
Muga Nishizawa
98eec72522 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-10-07 13:01:33 +09:00
Muga Nishizawa
562d50df4d java: refactor several programs in a org.msgpack.util.codegen package 2010-10-07 13:01:06 +09:00
frsyuki
f3ee5ab372 cpp: fixes ./bootstrap to surely run ./preprocess 2010-10-07 06:28:12 +09:00
INADA Naoki
aa2a3e5b07 Add unicode testcase for Python2. 2010-10-07 03:07:52 +09:00
INADA Naoki
8467307239 Fix testcase for unicode. 2010-10-07 03:04:00 +09:00
INADA Naoki
90da951a6f Use PyUnicode_AsUTF8String() instead of o.encode('utf-8'). 2010-10-07 03:02:02 +09:00
tokuhirom
59f81b331c Checking in changes prior to tagging of version 0.30.
Changelog diff is:
2010-10-06 18:00:00 +09:00
Fuji, Goro
77a7d3d26a perl: Fix utf8 mode not to be reseted by $unpacker->reset method 2010-10-06 17:52:32 +09:00
tokuhirom
4321b80999 Checking in changes prior to tagging of version 0.29.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index b506234..333a824 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.29
+
+    - add $unpacker->utf8 mode, decoding strings as UTF-8.
+
 0.28

     - added more tests(gfx)
2010-10-06 12:29:31 +09:00
tokuhirom
4b93b06323 perl: regenerated README file 2010-10-06 12:27:41 +09:00
tokuhirom
96fb2e4b7c Merge branch 'perl-utf8-mode' of github.com:msgpack/msgpack 2010-10-06 12:24:36 +09:00
Muga Nishizawa
3dc1048dfb Merge branch 'master' of git@github.com:msgpack/msgpack 2010-10-05 20:47:41 +09:00
Muga Nishizawa
28f4bd5a67 java: edit test programs for org.msgpack.util.codegen.* 2010-10-05 20:47:03 +09:00
Muga Nishizawa
b01c270889 java: refactor the programs in a org.msgpack.util.codegen package 2010-10-05 20:45:51 +09:00
Fuji, Goro
7c92f8a90b perl: improve docs 2010-10-05 17:47:27 +09:00
Fuji, Goro
a4a04872a3 perl: add $unpacker->utf8 mode, decoding strings as UTF-8. 2010-10-05 17:10:10 +09:00
Fuji, Goro
f2d13cd647 perl: make test code more simple 2010-10-05 15:58:49 +09:00
Fuji, Goro
9346908485 perl: remove tricky hacks 2010-10-05 15:55:38 +09:00
Fuji, Goro
b3a7ba14f7 Merge branch 'master' of github.com:msgpack/msgpack 2010-10-05 15:53:57 +09:00
frsyuki
524ef9553c Merge branch 'master' of http://github.com/advect/msgpack into advect-master 2010-10-03 16:55:59 +09:00
Muga Nishizawa
a85f6e72fe java: edit DynamicCodeGen.java 2010-10-03 02:09:01 +09:00
Muga Nishizawa
1ae6a41336 java: edit BasicConstants.java in org.msgpack.util.codegen 2010-10-02 23:37:08 +09:00
Muga Nishizawa
3ec55791c6 java: refactor DynamicCodeGen.java 2010-10-02 22:12:40 +09:00
Muga Nishizawa
a3accd28ea java: insert logging codes into CustomConverter.java, CustomPacker.java, CustomUnpacker.java and util.codegen programs 2010-10-02 21:28:21 +09:00
Muga Nishizawa
fc5bc84207 java: add a log4j.properties file in src/main/java/resources 2010-10-02 21:25:30 +09:00
Muga Nishizawa
d8b4051d6d java: edit pom.xml to enable to using slf4j logger 2010-10-02 21:24:22 +09:00
Muga Nishizawa
804a1cc22d Merge branch 'master' of git@github.com:msgpack/msgpack 2010-10-02 17:44:00 +09:00
Muga Nishizawa
cdd60e5f9c add a packer and unpacker for Enum types 2010-10-02 17:43:31 +09:00
frsyuki
7c76f07384 java: adds standard packer classes 2010-10-01 13:12:31 +09:00
frsyuki
a3b1ef9527 java: Packer: supports Set 2010-10-01 12:51:09 +09:00
Muga Nishizawa
0bd4150a80 java: changes several methods declared in a DynamicCodeGen class 2010-09-30 01:17:44 +09:00
Muga Nishizawa
7f7f5253f2 java: adds a test program of the DynamicCodeGen class for packing and unpacking an object that has a field anntated by @MessagePackMessage 2010-09-30 00:55:56 +09:00
advect
2a0a847634 php: update 0.3.0 2010-09-29 08:47:06 +09:00
Muga Nishizawa
92ddb37ed3 java: add test programs for DynamicCodeGenPacker, Unpacker, Converter classes 2010-09-28 22:51:38 +09:00
Fuji, Goro
01f944e6bd perl: tiny tweaks 2010-09-28 20:35:05 +09:00
Muga Nishizawa
732c8d7350 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-09-28 19:12:17 +09:00
Muga Nishizawa
21678aeef5 java: moves a TestDynamicCodeGenPackerTemplate.java file to org.msgpack.util.codegen 2010-09-28 19:11:54 +09:00
tokuhirom
cda1ca35a4 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-28 16:02:29 +09:00
Muga Nishizawa
923580d2cd write a simple test program for a DynamicCodeGenPacker class 2010-09-28 15:31:55 +09:00
Muga Nishizawa
190af1d32b delete old programs: org.msgpack.util.codegen.MessagePackOptional, MessagePackRequired, MessagePackUnpackable, and PackUnpackUtil classes 2010-09-28 15:24:47 +09:00
Muga Nishizawa
bffe0443f9 edit DynamicCodeGenPacker and DynamicCodeGenUnpacker class 2010-09-28 12:17:32 +09:00
Muga Nishizawa
29e99e229b Merge branch 'master' of git@github.com:msgpack/msgpack 2010-09-27 17:56:19 +09:00
Muga Nishizawa
2736b88dd5 edit Packer and Unpacker classes, and move org.msgpack.util.annotation.*.java to org.msgpack.util.codegen.*.java 2010-09-27 17:55:48 +09:00
frsyuki
e739c60e9f java: pom.xml: v0.4 2010-09-27 17:42:22 +09:00
frsyuki
1c0afbc5c5 java: loads template classes when Unpacker, MessagePackObject or ClassTemplate is loaded 2010-09-27 17:42:00 +09:00
Muga Nishizawa
ee1ba5c0f2 java: fixed a bug within a Packer class 2010-09-27 10:16:32 +09:00
Muga Nishizawa
02342ba540 java: refactor a Packer class 2010-09-27 10:10:10 +09:00
Muga Nishizawa
12a130e9bc Merge branch 'master' of git@github.com:msgpack/msgpack 2010-09-27 10:02:03 +09:00
Muga Nishizawa
dfb97e7961 java: adds several annotations in an org.msgpack.annotation package and edits Packer.java and its test program 2010-09-27 10:00:47 +09:00
tokuhirom
54e03a62bd Checking in changes prior to tagging of version 0.28.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 82174fe..b506234 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.28
+
+    - added more tests(gfx)
+    - refactor the PP code(gfx)
+
 0.27

     - * 6d9a629 perl: modified trivial codes in PP::Unpacker(makamaka)
2010-09-27 08:35:26 +09:00
tokuhirom
ec9659ff25 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-27 08:32:10 +09:00
frsyuki
0a41b253f3 java: adds templates for primitive types 2010-09-27 04:27:44 +09:00
frsyuki
002b86198c java: adds ReflectionPacker and ReflectionTemplate 2010-09-27 04:17:20 +09:00
frsyuki
7161a235f1 java: uses CustomMessage class on Packer, Unpacker and ClassTemplate 2010-09-27 03:33:21 +09:00
frsyuki
391034a785 java: adds type-conversion mechanisms 2010-09-27 03:06:06 +09:00
frsyuki
446a7fbd67 java: adds CustomMessage class (currently not implemented on Packer, Unpacker and ClassTemplate) 2010-09-27 03:05:32 +09:00
advect
2ccb09434f Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-26 12:44:05 +09:00
frsyuki
7974060a40 cpp: zone: adds msgpack_zone_swap and msgpack::zone::swap 2010-09-26 11:37:37 +09:00
frsyuki
e8abcc1765 cpp: sbuffer: check initial buffer size != 0 2010-09-26 11:36:57 +09:00
frsyuki
1be1927a1f Merge branch 'master' of github.com:msgpack/msgpack 2010-09-24 16:10:07 +09:00
tanakh
894ff71664 haskell: fix for empty constructor 2010-09-24 03:49:31 +09:00
tanakh
93bed9c5df haskell: finish template-haskell deriving implement 2010-09-24 01:24:13 +09:00
Muga Nishizawa
34c008adce java: refactor annotation-utilities 2010-09-23 20:40:50 +09:00
Muga Nishizawa
22ddd91b1f java: add several API to annotation-utilities 2010-09-23 20:38:54 +09:00
Muga Nishizawa
e121f34407 java: refactor annotation-utilities and edit those test programs 2010-09-23 17:26:31 +09:00
Muga Nishizawa
df8a3e870a java: refactor annotation-utilities 2010-09-23 16:18:23 +09:00
Muga Nishizawa
13b6708a09 java: append a code for generating a messageConvert method to annotation-utilities 2010-09-23 15:24:12 +09:00
tanakh
6aa196cf55 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-09-23 00:06:26 +09:00
tanakh
142493076a haskell: TH support and refactoring 2010-09-23 00:04:34 +09:00
gfx
3d905a7a4f perl: add tests for 'extra bytes' exceptions 2010-09-22 16:14:55 +09:00
gfx
0a8a6ed168 perl: cleanup PP 2010-09-22 15:59:21 +09:00
gfx
68b6fa46e6 perl: add tests for boolean values 2010-09-22 15:28:14 +09:00
gfx
80f7c54e4d perl: make scopes 2010-09-22 15:25:08 +09:00
tokuhirom
c0e2041006 Checking in changes prior to tagging of version 0.27.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index b717a82..82174fe 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.27
+
+    - * 6d9a629 perl: modified trivial codes in PP::Unpacker(makamaka)
+    - * ead8edc modified be unpack_(u)int64 in PP(makamaka)
+
 0.26

     - fixed a serious code typo in PP(makamaka)
2010-09-22 15:12:51 +09:00
tokuhirom
f6d2cd7704 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-22 15:09:03 +09:00
makamaka
6d9a629b15 perl: modified trivial codes in PP::Unpacker 2010-09-22 14:19:09 +09:00
makamaka
ead8edc7cd modified be unpack_(u)int64 in PP 2010-09-22 14:12:19 +09:00
tokuhirom
664eefdddb Checking in changes prior to tagging of version 0.26.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 3d455cb..b717a82 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.26
+
+    - fixed a serious code typo in PP(makamaka)
+
 0.25

     (NO FEATURE CHANGES)
2010-09-20 23:40:12 +09:00
tokuhirom
220d76c974 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-20 23:36:50 +09:00
makamaka
d973192b5e perl: modified a serious code typo in PP 2010-09-20 11:49:52 +09:00
tokuhirom
978bb5059f Checking in changes prior to tagging of version 0.25.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index d338cf8..3d455cb 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.25
+
+    (NO FEATURE CHANGES)
+    - oops. I failed releng.

 0.24
     - Fixed a lot of streaming unpacking issues (tokuhirom, gfx)
2010-09-20 09:54:25 +09:00
tokuhirom
f59178bc33 Checking in changes prior to tagging of version 0.24.
Changelog diff is:
2010-09-20 09:30:26 +09:00
gfx
53899cc492 perl: tweaks for Makefile.PL 2010-09-19 22:12:28 +09:00
gfx
6379d0fe0f perl: more tests for nil/true/false entities 2010-09-19 15:53:54 +09:00
gfx
a1c4d8696a Merge branch 'master' of github.com:msgpack/msgpack 2010-09-19 15:49:32 +09:00
gfx
7f42ed86f2 More tests 2010-09-19 15:47:32 +09:00
frsyuki
6bb8b4c994 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-19 15:41:46 +09:00
gfx
afefbe4e56 perl: update .gitignore and MANIFEST.SKIP 2010-09-19 15:21:25 +09:00
gfx
5cd37e5505 perl: always unpacking 64 bit ints as a string on 32 bit perls 2010-09-19 15:20:03 +09:00
gfx
d6a825981d perl: fix unpacking int64_t in PP (based on makamaka's patch) 2010-09-19 15:16:08 +09:00
gfx
a1c01c6722 perl: regen README 2010-09-19 15:15:31 +09:00
gfx
8d182f1d79 perl: Changelogging 2010-09-18 16:30:07 +09:00
gfx
29707bd2ea perl: fix bootstrap 2010-09-18 16:19:16 +09:00
gfx
c2bf2a8174 perl: make pp benchmarks available 2010-09-18 16:16:51 +09:00
gfx
b402849557 perl: docs 2010-09-18 15:54:22 +09:00
gfx
cb85dcfcb8 perl: tweaks for benchmarks 2010-09-18 15:49:25 +09:00
gfx
49379140c7 perl: PERL_ONLY=1 disables XS 2010-09-18 15:14:29 +09:00
gfx
63f6c86b46 perl: add a note about 64 bit integers 2010-09-18 15:05:22 +09:00
gfx
1865898cd4 perl: Fix Makefile.PL 2010-09-18 14:58:32 +09:00
gfx
8935ecfdb8 perl: requires the latest version of Math::BigInt for PP 2010-09-18 14:56:33 +09:00
gfx
4902bed409 perl: more kind testing messages 2010-09-18 14:51:17 +09:00
gfx
e6f6aba207 perl: add portability stuff 2010-09-18 14:50:52 +09:00
gfx
bab622de25 perl: fix max depth checks in PP 2010-09-18 14:46:10 +09:00
gfx
a86c1624a7 perl: More kind error messages in PP 2010-09-18 14:38:35 +09:00
gfx
c707392a5a perl: fix int64_t unpacking in both XS and PP 2010-09-18 14:30:08 +09:00
gfx
1f07721ec4 perl: Scalar::Util is no longer used 2010-09-18 13:33:27 +09:00
gfx
4767e45035 perl: fix a test name 2010-09-18 13:18:25 +09:00
Muga Nishizawa
f2a64ed685 Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-18 10:02:46 +09:00
tokuhirom
2c9966a0a3 perl: fixed stream deserializer in pp. 2010-09-18 09:44:32 +09:00
tokuhirom
953aa95c64 perl: added failing test case for streaming unpacker with PP. 2010-09-18 06:16:26 +09:00
tokuhirom
446266776e perl: regenerate README file 2010-09-18 06:16:17 +09:00
tokuhirom
845af014dc perl: gfx is a author. 2010-09-18 06:15:51 +09:00
gfx
7c8f8703a1 Add TODOs 2010-09-17 18:26:16 +09:00
gfx
a0c18e4380 Docs 2010-09-17 18:16:33 +09:00
gfx
e8d8099563 Fix a macro redefinition 2010-09-17 18:08:34 +09:00
gfx
2c9d90d463 perl: regen README 2010-09-17 18:08:15 +09:00
tokuhirom
130d2064d5 perl: updated benchmark result! gfx++ # performance tuning 2010-09-17 15:28:24 +09:00
gfx
a10eb2a0d7 Changelogging 2010-09-17 14:02:12 +09:00
gfx
b71cc5d7ee chmod -x 2010-09-17 13:59:52 +09:00
gfx
8512f9eda1 Add .gitignore 2010-09-17 13:49:55 +09:00
gfx
80058083b8 Tweaks 2010-09-17 13:49:08 +09:00
gfx
d5a17a3c25 Fix stddata.t 2010-09-17 13:43:42 +09:00
gfx
eab7c87781 Tidy PP 2010-09-17 13:37:17 +09:00
gfx
d2962d8676 Split the boolean class into an outer module 2010-09-17 13:25:23 +09:00
gfx
5e602fb575 Fix tests 2010-09-17 13:10:54 +09:00
gfx
599964ea5f Comments 2010-09-16 21:45:06 +09:00
gfx
562de7926b More tests; some fails now :( 2010-09-16 21:38:17 +09:00
gfx
8eaed95e02 Fix an use of execute() 2010-09-16 20:44:51 +09:00
gfx
3cffd46008 Fix a comment 2010-09-16 20:41:52 +09:00
gfx
e239bfda8a Make leaktrace.t as a regular test 2010-09-16 20:36:07 +09:00
gfx
bd887b660d Preallocate hv keys 2010-09-16 20:31:34 +09:00
gfx
7c1e0ea95d Add binmode() for stream unpacking 2010-09-16 20:27:25 +09:00
gfx
afbddbfcda Fix the stream unpacker 2010-09-16 20:24:01 +09:00
Muga Nishizawa
9eeb702ca5 change an annotation-utility in Java. it allows users to pack and unpack a List object. 2010-09-15 22:28:46 +09:00
gfx
4cb6d6995f Make the code clearer 2010-09-15 15:27:26 +09:00
gfx
fe7e7a8d07 Add leaktrace tests 2010-09-15 15:26:02 +09:00
gfx
f8ee79ab72 Add failing tests 2010-09-15 15:25:48 +09:00
gfx
a11165830b More useful error messages 2010-09-15 15:06:03 +09:00
gfx
11cde61eab No debug output 2010-09-15 14:38:26 +09:00
gfx
cd862409cc Clean up 2010-09-15 14:25:50 +09:00
gfx
7644555d6b Use sv_mortalcopy() 2010-09-15 14:21:44 +09:00
gfx
07e68aa694 Fix an usage message 2010-09-15 14:20:32 +09:00
gfx
0ae206b1bb Revert "The object root can be NULL"
This reverts commit 5bdac96375.
2010-09-15 14:19:22 +09:00
gfx
5bdac96375 The object root can be NULL 2010-09-15 14:18:38 +09:00
gfx
f0e044ecd8 Cleanup 2010-09-15 14:09:03 +09:00
gfx
f32234291e Remove an useless local variable 2010-09-15 14:07:33 +09:00
gfx
83acd6529f Remove an unused user data: source (sv) 2010-09-15 14:06:10 +09:00
gfx
6a60cb4dc0 Add const 2010-09-15 13:54:18 +09:00
gfx
1de03fbe18 Tweaks for unpacker 2010-09-15 13:41:10 +09:00
gfx
0e0a2aa981 Add various integers to benchmarks 2010-09-15 13:34:18 +09:00
gfx
af73b9d11b Shortcut av_push() 2010-09-15 13:22:39 +09:00
gfx
859969241a Tweaks 2010-09-15 13:20:20 +09:00
gfx
6852a8ca9d Remove an unused function: xs_unpack_limit 2010-09-15 13:16:55 +09:00
gfx
c694f1a4a9 Tweaks 2010-09-15 13:16:13 +09:00
gfx
d36543b204 Micro optimizations 2010-09-15 13:12:17 +09:00
gfx
6981234736 Fix a possible mis-unpack on int64 2010-09-15 13:09:14 +09:00
gfx
10bf3ee9de Avoid compiler's warnings 2010-09-15 13:07:44 +09:00
gfx
9953218de1 Tidy 2010-09-15 13:03:47 +09:00
gfx
50c74103aa Avoid compiler's warnings 2010-09-15 12:56:13 +09:00
gfx
c5e15123fd Add an assertion 2010-09-15 12:52:07 +09:00
gfx
4adcdb5ba8 Remove a duplicated depth check 2010-09-15 12:51:33 +09:00
gfx
60b36ffaa3 Micro optimizations 2010-09-15 12:50:11 +09:00
gfx
d86104ed5d Tweaks 2010-09-15 12:48:23 +09:00
gfx
0f02ef20a9 Improve benchmarks 2010-09-15 12:46:11 +09:00
gfx
0768cf17b6 Taking NULL is a bug 2010-09-15 12:36:43 +09:00
gfx
197205853f Use newSV(). NEWSV() is deprecated. 2010-09-15 12:35:10 +09:00
gfx
bebcc24ab8 Depends on XSUtil 0.32 2010-09-15 12:32:01 +09:00
gfx
987248ccbb Use xshelper.h in all the C files 2010-09-15 12:31:01 +09:00
Muga Nishizawa
56ece4db0f fixed a bug the program for packing and unpacking byte[] in annotation-utility 2010-09-14 23:23:09 +09:00
Muga Nishizawa
c7f8b94ccd fixed several bugs of a verify error within annotation-utilities 2010-09-14 22:26:04 +09:00
Muga Nishizawa
95b820305a add a new test program for annotation-utilities 2010-09-14 13:34:11 +09:00
Muga Nishizawa
599b200ca5 change the version of javassist 3.12.1.GA 2010-09-12 23:04:23 +09:00
Muga Nishizawa
a9566b31be add annotation utilities for Java 2010-09-12 22:21:33 +09:00
Muga Nishizawa
f30837d726 Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-12 09:02:40 +09:00
tokuhirom
1242ffa4c6 Checking in changes prior to tagging of version 0.23.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index dd47b98..4120376 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,10 +1,15 @@
+0.23
+
+    (NO FEATURE CHANGES)
+    - fixed english docs(hanekomu++)
+
 0.22

     - fixed issue on ithreads(broken from 0.21)

 0.21

-    - doc enhancment
+    - doc enhancments
     - micro performance tuning.

 0.20
2010-09-12 05:38:15 +09:00
Muga Nishizawa
37c0347c47 Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-12 00:50:26 +09:00
tokuhirom
65befb84a0 Checking in changes prior to tagging of version 0.22.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 5d5a5e2..dd47b98 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.22
+
+    - fixed issue on ithreads(broken from 0.21)
+
 0.21

     - doc enhancment
2010-09-12 00:11:31 +09:00
tokuhirom
a41f7ce3bd oops. 0.21 breakes ithreads support! 2010-09-12 00:09:44 +09:00
Muga Nishizawa
81ced6bf2a Merge branch 'master' of git@github.com:muga/msgpack 2010-09-11 12:13:24 +09:00
Muga Nishizawa
fa8033f998 Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-11 12:12:16 +09:00
Muga Nishizawa
19e3178d0c Merge branch 'master' of http://github.com/msgpack/msgpack 2010-09-10 22:17:06 +09:00
tokuhirom
1e6262f24f Checking in changes prior to tagging of version 0.21.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index dc3dd5c..5d5a5e2 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.21
+
+    - doc enhancment
+    - micro performance tuning.
+
 0.20

     - first production ready release with PP driver.
2010-09-10 21:27:38 +09:00
tokuhirom
beb2284440 perl: added docs for circular reference and blessed object. 2010-09-10 21:25:46 +09:00
tokuhirom
0c4f0de13d perl: inlining the small functions 2010-09-10 21:18:45 +09:00
tokuhirom
0cd31a4b96 perl: inlining utility functions 2010-09-10 21:00:27 +09:00
tokuhirom
ef0a86e7cc perl: more inline 2010-09-10 20:45:17 +09:00
tokuhirom
b79c1345b9 use gfx's standard header. 2010-09-10 20:42:40 +09:00
tokuhirom
5bb8b6f16c perl: ugpraded benchmarking script. and added result to docs. 2010-09-10 20:38:37 +09:00
tokuhirom
f6f675d1e1 updated benchmark script 2010-09-10 20:27:11 +09:00
tokuhirom
9f684e7670 Checking in changes prior to tagging of version 0.20.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 7910882..dc3dd5c 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.20
+
+    - first production ready release with PP driver.
+
 0.16_04

     - no feature changes
2010-09-10 09:35:39 +09:00
tanakh
a998706452 haskell: update cabal file 2010-09-08 13:36:45 +09:00
tanakh
5e19bc6f84 haskell: Object is Eq, Ord, Typeable. 2010-09-07 17:35:24 +09:00
tanakh
169f287970 haskell: Now, Object is an instance of NFData. 2010-09-07 16:14:29 +09:00
tanakh
c56926428c haskell: add packToHandle' 2010-09-07 16:14:00 +09:00
tanakh
43eab5c4e5 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-09-06 23:29:10 +09:00
tanakh
c6424c2ce7 haskell: nonblocking enumerator 2010-09-06 23:27:50 +09:00
tanakh
dfe19d308c haskell: add overlapping instances 2010-09-06 18:14:47 +09:00
tanakh
b75db110dc haskell: add Iteratee interface 2010-09-06 17:00:22 +09:00
tanakh
9e50ba6ec6 haskell: instance tupples and String and lazy ByteString 2010-09-06 16:33:36 +09:00
tanakh
aca2ba13c2 haskell: refactoring 2010-09-06 15:37:55 +09:00
tokuhirom
c5afe7a573 Checking in changes prior to tagging of version 0.16_04.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index a4a3e36..7910882 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,4 +1,4 @@
-0.16_03
+0.16_04

     - no feature changes
2010-09-06 14:35:41 +09:00
tokuhirom
8b90968cb1 Checking in changes prior to tagging of version 0.16_03.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 68b58ba..a4a3e36 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.16_03
+
+    - no feature changes
+
 0.16_02

     - document enhancement(tokuhirom)
2010-09-06 14:34:48 +09:00
tokuhirom
9281dba896 Checking in changes prior to tagging of version 0.16_02.
Changelog diff is:

diff --git a/perl/Changes b/perl/Changes
index 9b061cf..68b58ba 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.16_02
+
+    - document enhancement(tokuhirom)
+    - M::I::XSUtil 0.26 is broken. use 0.27.
+
 0.16_01

     - added PP version (used in cases PERL_DATA_MESSAGEPACK=pp or fail to load XS).
2010-09-06 14:34:04 +09:00
tokuhirom
c7555f1c3c Perl: added link to git repository. 2010-09-06 14:31:53 +09:00
tokuhirom
e781831032 upgraded docs 2010-09-06 14:20:54 +09:00
tokuhirom
8025895168 Checking in changes prior to tagging of version 0.16_01.
Changelog diff is:
2010-09-06 14:20:54 +09:00
tanakh
799935e44c haskel: incr version and update infos. 2010-09-06 14:03:47 +09:00
tanakh
209d8d058c forgot to remove file 2010-09-06 13:57:47 +09:00
tanakh
0368a70dd7 forgot to add file 2010-09-06 13:55:34 +09:00
Hideyuki Tanaka
c3603426de Merge branch 'master' of github.com:msgpack/msgpack 2010-09-06 01:51:18 +09:00
Hideyuki Tanaka
80db9971b5 pure haskell implementation. 2010-09-06 01:50:22 +09:00
tokuhirom
e3e771708e Merge branch 'master' of git://github.com/makamaka/msgpack
Conflicts:
	perl/Changes
2010-09-05 16:18:57 +09:00
tokuhirom
b9bca2a19f bump to 0.16 2010-09-05 16:17:19 +09:00
Muga Nishizawa
ffae70a99a Merge branch 'master' of git@github.com:muga/msgpack 2010-09-05 15:49:42 +09:00
makamaka
10ec1e48b0 modified begin process about byte order 2010-09-05 01:54:44 +09:00
makamaka
84123f5445 fallback PP configuration with c99 unspport compiler 2010-09-04 20:02:46 +09:00
makamaka
25531d8393 modified t/05_preferred_int.t for Win32 2010-09-04 19:54:12 +09:00
makamaka
adfadc542a enable PP to pack/unpack int64 in less than Perl 5.10 2010-09-04 14:35:24 +09:00
makamaka
7682e1cb57 Merge branch 'master' of git://github.com/msgpack/msgpack
Conflicts:
	perl/t/05_preferred_int.t
2010-09-03 15:09:49 +09:00
tokuhirom
1fe4109a42 fixed tests on 64bit machines with -Duselongdouble #60625 2010-09-03 14:50:01 +09:00
makamaka
b97baf4d47 added some comments in Data::MessagePack::PP 2010-09-03 12:53:56 +09:00
makamaka
f91728561f ouch, modified pod 2010-09-02 23:58:40 +09:00
makamaka
2b75d54ce1 modified pod 2010-09-02 23:56:55 +09:00
makamaka
cdc09a7d30 Changes 2010-09-02 23:52:36 +09:00
makamaka
4cc6c3e535 modified t/05_preferred_int.t for Win32 2010-09-02 23:48:57 +09:00
makamaka
8f43e033a4 removed dependency on Data::Float 2010-09-02 23:45:05 +09:00
makamaka
918dbd1926 made Makefile.PL XS/PP configurable 2010-09-02 14:37:22 +09:00
makamaka
8fc86ce7fa removed commented out codes 2010-09-02 14:33:59 +09:00
INADA Naoki
bf0cb40586 python: Add python3 category. 2010-09-02 10:13:49 +09:00
INADA Naoki
a62aefe74b python: Release 0.1.6 - Fix wrong version string. 2010-09-02 10:10:34 +09:00
INADA Naoki
138d232149 python: vesion 0.1.5 2010-09-02 09:58:50 +09:00
INADA Naoki
8fa64e3ab2 Add msgpack.version as version tuple. 2010-09-02 09:54:38 +09:00
INADA Naoki
8d0d2bd3fc python: Add test for python3 and fix found problems. 2010-09-02 02:16:28 +09:00
INADA Naoki
2146f5f623 python: Fix Unpacker.feed doesn't accept bytes on Python3. 2010-09-02 02:02:47 +09:00
INADA Naoki
623df23570 Merge branch 'master' of github.com:msgpack/msgpack 2010-09-02 01:30:32 +09:00
INADA Naoki
4a15d8b6d2 python: Support Python3. 2010-09-02 01:29:57 +09:00
makamaka
af83a62474 modified some codes for test warnings 2010-09-01 16:04:25 +09:00
makamaka
a0705a6c67 added PP backend switch into Data::MessagePack 2010-09-01 11:59:01 +09:00
makamaka
712b8eec3d added pp version 2010-09-01 11:22:43 +09:00
tokuhirom
558e9c21ed Perl: 0.15 2010-09-01 08:19:05 +09:00
tokuhirom
23a7137e6a Perl: better argument validation(patch from dankogai) 2010-08-31 23:42:32 +09:00
frsyuki
71a1cb0184 fixes compatibility with Rubinius 2010-08-31 09:29:01 +09:00
frsyuki
09b47cc536 ruby: fixes compatibility with ruby-1.8.5 2010-08-31 07:00:19 +09:00
frsyuki
b5c78de2dd ruby: converts encodings into UTF-8 on Ruby 1.9 2010-08-31 06:30:16 +09:00
frsyuki
a1bd14e516 template: casts integer types explicitly 2010-08-31 06:27:15 +09:00
frsyuki
9684c8664f cpp: version 0.5.4 2010-08-29 18:27:10 +09:00
frsyuki
3c75361e5a cpp: updates README.md 2010-08-29 18:24:32 +09:00
frsyuki
c44c9ab74d cpp: adds msgpack_vc2008.vcproj file in source package 2010-08-29 18:23:16 +09:00
frsyuki
8cc9c871b7 Merge branch 'master' of github.com:msgpack/msgpack 2010-08-28 11:40:45 +09:00
UENISHI Kota
31d211cded Merge branch 'master' of ssh://github.com/msgpack/msgpack 2010-08-28 00:36:54 +09:00
UENISHI Kota
c42cba1d54 erlang: fixed bug around error case when serializing atom. 2010-08-27 23:02:16 +09:00
frsyuki
c87f7cb9ac cpp: fixes fix_int; updates test/fixint.cc 2010-08-27 20:52:40 +09:00
frsyuki
421bee3871 cpp: version 0.5.3 2010-08-27 17:53:19 +09:00
frsyuki
2c7573a032 cpp: updates msgpack_vc8.postbuild.bat 2010-08-27 17:53:02 +09:00
frsyuki
fe2a0f5089 cpp: adds fixed length serialization for integers 2010-08-27 17:42:05 +09:00
frsyuki
59ba8dec4e cpp: fixes include paths 2010-08-27 16:45:48 +09:00
Muga Nishizawa
ff0e1bbbc0 change the part for creating a new constructor within DynamicCodeGenerator 2010-08-26 17:53:29 +09:00
Muga Nishizawa
18c712cd99 object serialization with reflection and with dynamic code generation 2010-08-25 21:35:52 +09:00
tokuhirom
8de1f764fd Perl: bump up version to 0.14 2010-08-21 16:09:30 +09:00
tokuhirom
a91c1ec6d9 fixed segv on cyclic reference(patch by dankogai) 2010-08-21 16:02:23 +09:00
frsyuki
c8e351b31e java: adds TestMessageUnpackable test 2010-08-21 03:36:44 +09:00
frsyuki
b4c98584db java: adds Unpacker.unpackBigInteger() 2010-08-19 01:19:34 +09:00
frsyuki
1d17836b7d java: NilType::create() returns NilType's one and only instance 2010-08-19 00:54:23 +09:00
frsyuki
193a739749 java: updates TestDirectConversion 2010-08-19 00:05:48 +09:00
frsyuki
48da2b8353 java: adds Packer.pack(<primitive types>) 2010-08-18 23:47:31 +09:00
frsyuki
40dc9de6c9 java: supports packing/unpacking of BigInteger less than 0xffffffffffffffff 2010-08-18 23:37:47 +09:00
frsyuki
d7469e4694 java: fixes cross-language test case 2010-08-18 22:55:50 +09:00
frsyuki
fdfabc9f88 java: adds cross-language test case 2010-08-18 22:51:23 +09:00
frsyuki
5658ca5b90 java: adds ObjectEquals test 2010-08-18 22:24:51 +09:00
frsyuki
8b79e6d3c7 java: uses MessagePackObject instead of Object for type of deserialized objects 2010-08-18 18:10:30 +09:00
frsyuki
8c67087a15 java: adds MessagePackObject.bigIntegerValue(), asBigInteger() and equals() 2010-08-18 16:32:42 +09:00
frsyuki
057f73a73e java: implements MessagePackObject::hashCode() 2010-08-10 14:11:44 +09:00
frsyuki
d3bb37d113 java: fixes MapSchema 2010-08-10 14:11:25 +09:00
frsyuki
6c91b862c9 java: MessagePackObject implements Cloneable and MessagePackable interfaces 2010-07-28 01:17:20 +09:00
frsyuki
cba47b635a java: changed deploy path to ./target/website/maven2 directory. 2010-07-27 09:50:57 +09:00
Kazuki Ohta
cd83388f8b java: fixed repository location. msgpack.sourceforge.net => msgpack.org 2010-07-27 08:59:09 +09:00
frsyuki
02ae247536 java: adds MessagePackObject class 2 2010-07-24 18:20:00 +09:00
frsyuki
1621a68191 Merge branch 'master' of github.com:msgpack/msgpack 2010-07-24 18:08:19 +09:00
frsyuki
2aef495d62 java: adds MessagePackObject class 2010-07-24 18:08:00 +09:00
frsyuki
227c168b65 java: fixes fatal offset calculation bugs on BufferedUnpackerIMPL.unpackInt() 2010-07-24 18:07:22 +09:00
UENISHI Kota
dcbcf5842f erlang: msgpack:unpack_all/1 doc. 2010-07-18 23:55:07 +09:00
UENISHI Kota
8a3ac6d9bd erlang: omake menus added. 2010-07-18 23:50:29 +09:00
UENISHI Kota
6cabad19d5 erlang: unpack_all/1 improve, error handling added. 2010-07-18 23:48:20 +09:00
UENISHI Kota
dad7a03d19 erlang: stopped support for dict() type. 2010-07-18 23:42:23 +09:00
UENISHI Kota
7b152640d9 erlang: 'edoc' document generation 2010-07-18 23:40:25 +09:00
UENISHI Kota
78fddff34e erlang: merged vincent's contribution 2010-07-18 23:01:43 +09:00
advect
78f542f6c0 Update PHP Extension 2010-07-17 18:46:28 +09:00
frsyuki
f8a016edb5 Merge branch 'master' of github.com:msgpack/msgpack 2010-07-14 17:09:34 +09:00
frsyuki
f5453d38ec cpp: version 0.5.2 2010-07-14 17:06:16 +09:00
frsyuki
331bf0af21 cpp: type::raw_ref::str(), operator==, operator!=, operator< and operator> are now const 2010-07-14 17:04:41 +09:00
tokuhirom
9ac69337e8 perl: bump up version to 0.13! 2010-07-14 09:58:41 +09:00
tokuhirom
ca0c844f32 clearly specified this distribution requires requires C99. 2010-07-14 09:58:05 +09:00
Vincent de Phily
e629e8784f erlang: Improve documentation
The doc is in edoc format, generated from the source as an html file.
The makefile's default action now also generates the documentation.

I ignored unpack_all/1 and pack(dict()) for now because their future is still uncertain.
2010-07-12 14:08:22 +02:00
Vincent de Phily
e944c1ee93 erlang: Only handle throw() in pack/1 and unpack/1
Rationale: We only use throw/1 for error handling, never erlang:error/1.
           Caller bugs will get a nice {error,...} return while library bugs will
           bubble up in all their uglyness; that's the proper way to do things
           in erlang.
2010-07-09 20:37:06 +02:00
Vincent de Phily
02c882bda3 erlang: Make pack_map/1 api private 2010-07-09 20:34:38 +02:00
Vincent de Phily
2c29377abf erlang: s/short/incomplete/ and s/badarg/{badarg,Term}/
Nicer error returns.
2010-07-09 20:30:17 +02:00
Vincent de Phily
21992f1b9e erlang: fix receiving from port_command in unit tests
Ports can send data bit by bit; make sure we read all the port has to offer in one go.
This should fix the "broken pipe" error we sometime got during testing.
We did not previously check the return of compare_all/2, which is why the bug was not noticed.
Incidentally, this change fixes dialyzer warnings too.
2010-07-09 18:53:24 +02:00
Vincent de Phily
8a3f090684 erlang: Fix some existing specs and add a few other.
dialyzer still complains about dict() and ?assert(false), but I don't think they're real issues.
2010-07-09 17:36:36 +02:00
UENISHI Kota
a4258505a9 erlang: modified wrong testcase. 2010-07-09 23:23:00 +09:00
Vincent de Phily
ba4a971bfa erlang: Remove unecessary 'throw(short)' clause for unpack_{array,map}_/1
Unecessary because unpack_/1 will throw it anyway.
This does mean that we go a tiny bit deeper to find that we don't have enough data,
but that should be a rare code path. Keep the main code path fast and the code clean.

While at it, rename vars to match its sibling function and to avoid thinking that
RestLen is a byte count (it's an item count).
2010-07-09 13:44:02 +02:00
Vincent de Phily
6abc120279 erlang: Fix incomplete/invalid cases of unpack_/1
* fix list of invalid bytes was missing 3 possibilities (see type chart section of msgpack format spec)
* fix matching of invalid bytes to look at 1 byte instead of 2
* simplify 'incomplete' case : anything that's not complete or invalid is by definition incomplete
2010-07-09 13:29:47 +02:00
Vincent de Phily
64c36b7a8f Remove a couple of superfluous 'when' clauses.
The when clause for unpack_/1 has been moved to unpack/1 so that it is performed only once.
2010-07-09 13:06:57 +02:00
Vincent de Phily
64b9f0762c Merge branch 'master' of git://github.com/msgpack/msgpack
Reseting msgpack.erl to upstream version.
2010-07-09 12:35:22 +02:00
UENISHI Kota
e799082e5c erlang: better test cases, except 'Broken pipe' 2010-07-09 01:21:35 +09:00
UENISHI Kota
eab66a022e erlang: added try-catch clause for easy error handling 2010-07-09 01:04:09 +09:00
UENISHI Kota
485915c27a erlang: added simple performance test description. 2010-07-08 23:39:47 +09:00
UENISHI Kota
45fb482ab4 erlang: added simple performance test. 2010-07-08 23:36:18 +09:00
frsyuki
167e2475d8 cpp: generate version.h using AC_OUTPUT macro in ./configure 2010-07-06 23:30:15 +09:00
frsyuki
fe77251242 cpp: fixes missing dependency to generate version.h 2010-07-06 19:16:49 +09:00
frsyuki
0c331d2887 cpp: updates vcproj 2010-07-06 18:18:28 +09:00
frsyuki
39facd5dc6 cpp: version 0.5.1 2010-07-06 17:59:07 +09:00
frsyuki
a2bd5ae638 cpp: ./configure supports --disable-cxx option not to build/install C++ API 2010-07-06 17:45:15 +09:00
frsyuki
c57f616141 cpp: adds MSGPACK_VERSION{,_MAJOR,_MINOR} macros and msgpack{,_major,_minor} functions 2010-07-06 17:10:25 +09:00
frsyuki
3af10a1d00 cpp: adds MSGPACK_VERSION{,_MAJOR,_MINOR} macros and msgpack{,_major,_minor} functions 2010-07-06 17:00:58 +09:00
frsyuki
b3987e2402 Merge branch 'master' of github.com:msgpack/msgpack 2010-07-06 12:26:30 +09:00
frsyuki
71dd44f430 cpp: adds operator<<(std::ostream&, const tuple<Type...>&) (experimental) 2010-07-06 12:26:21 +09:00
UENISHI Kota
584462f9b9 erlang: improved spec. 2010-07-01 01:16:25 +09:00
UENISHI Kota
ff5d5d7cbc erlang: updated the comments 2010-07-01 01:14:38 +09:00
UENISHI Kota
370e92b1a6 erlang: just a golf. 2010-07-01 01:14:20 +09:00
UENISHI Kota
2469768a85 erlang: reducing unnecessary binary matching in unpack_/2
* more efficient unpack_/1 by Vincent de Phille's code. thanks.
2010-07-01 01:07:56 +09:00
UENISHI Kota
acb8fa613e erlang: adding shorthand fix for {more, undefined} problem 2010-07-01 01:02:19 +09:00
UENISHI Kota
83b4b7d83d erlang: more suitable variable name and removing unnecessary guards. 2010-07-01 00:58:48 +09:00
Vincent de Phily
33a7d56042 * Return {more,undefined} instead of {more,integer()}, as we can only know the "minimum bytes needed to continue" instead of the actually usefull "total packet size".
* Merge all {more,...} clauses of unpack_/1 into one.
* Reformat unpack_/1 for readability.
* Fix some specs, error values, and documentation.
2010-06-29 11:59:56 +02:00
frsyuki
20de730541 ruby: 0.4.3 2010-06-29 15:39:47 +09:00
frsyuki
134c27c900 Merge branch 'master' of github.com:msgpack/msgpack 2010-06-29 15:13:21 +09:00
frsyuki
123ae024c6 ruby: MessagePack::VERSION constant 2010-06-29 15:12:52 +09:00
frsyuki
34a29cd0a5 ruby: fixes SEGV problem caused by GC bug at MessagePack_Unpacker_mark. 2010-06-29 14:56:23 +09:00
frsyuki
9fffa9800a ruby: fixes RDoc of Unpacker#execute and Unpacker#execute_impl 2010-06-29 14:54:09 +09:00
Vincent de Phily
8f7f23a0e5 Rewrite unpack_/1 using pattern matching to get a 30-40% speedup.
Simplify pack_* and unpack_{array,map} function clauses to get more readability and a minor speedup.
2010-06-28 18:11:52 +02:00
UENISHI Kota
358457f49d erlang: bad wrong export.. 2010-06-29 00:25:58 +09:00
UENISHI Kota
90e305d789 erlang: explicit API for serializing proplists,
so as not to make wrong call of pack({proplists()}).
2010-06-29 00:23:49 +09:00
UENISHI Kota
b471e52e28 erlang: explicit API for serializing proplists,
so as not to make wrong call of pack({proplists()}).
2010-06-29 00:21:47 +09:00
UENISHI Kota
9b5fc37399 Merge branch 'master' of http://github.com/vincentdephily/msgpack 2010-06-29 00:10:10 +09:00
Vincent de Phily
537322e3b5 Big speedup (around 40%) of maps and arrays encoding by using proper tail recursion. 2010-06-28 14:17:44 +02:00
Vincent de Phily
279121f87f erlang: Use a simple proplist instead of a dict.
A dict is overkill (code, cpu, memory) in most cases, and proplist<->dict conversion can easily be done by the libray user if desired.
        This is in line with other erlang libraries I've seen for various encoding schemes.
        The map encoder had a bug until I looked at it (see previous commit), so I guess it wasn't used much yet and a change is ok at this stage.
        The chosen representation for maps is a tuple containing the proplist as the only element.
2010-06-28 11:56:12 +02:00
UENISHI Kota
a1b2b41cdc erlang: bugfix(serialization of -234 goes <<208,22>> while it should go int16 <<0xD1, ...>>) 2010-06-26 08:40:36 +09:00
Vincent de Phily
0cca90c21d Fix encoding of fixmap type.
The tag value was wrong, and a missing /binary flag caused an error.
2010-06-25 17:32:11 +02:00
UENISHI Kota
ad052cb510 updated readme 2010-06-25 01:26:57 +09:00
UENISHI Kota
57f0598373 erlang: code refined and tests added 2010-06-25 00:44:14 +09:00
UENISHI Kota
92d192277e erlang: unpack_map's silly bug fixed. use dict:store/3.... 2010-06-25 00:22:53 +09:00
UENISHI Kota
2cdfbd8970 erlang: testing pack_map/unpack_map with a silly bug 2010-06-24 07:26:34 +09:00
UENISHI Kota
bc0c5f0cdc erlang: (un)pack_map improved, incremental unpacking 2010-06-23 09:02:53 +09:00
UENISHI Kota
230ee3a03b erlang: too short binary to decode causes error {more, Int}. 2010-06-23 01:26:10 +09:00
UENISHI Kota
ab0bf37d30 Merge branch 'master' of ssh://github.com/msgpack/msgpack 2010-06-22 11:44:25 +09:00
UENISHI Kota
b1e66256ce erlang: external APIs' type/specs. 2010-06-22 11:28:36 +09:00
UENISHI Kota
fd80693420 erlang: tests improved and code refined. 2010-06-22 11:15:18 +09:00
Naoki INADA
f222f5ed9b Python: 0.1.4 2010-06-15 18:06:58 +09:00
INADA Naoki
59603b902a Python: add "load(s)/dump(s)" alias for compatibility to simplejson/marshal/pickle. 2010-06-15 17:51:24 +09:00
frsyuki
82a5dd6cf9 java: update 2010-06-10 14:02:58 -07:00
frsyuki
a97f9081a3 Merge branch 'master' of github.com:msgpack/msgpack 2010-06-03 22:04:36 +09:00
frsyuki
b3e0ad1303 ruby: 0.4.2 2010-06-03 22:00:15 +09:00
frsyuki
251090406a ruby: adds a test case for buffering 2010-06-03 21:52:01 +09:00
frsyuki
9c3ed173b1 ruby: fixes buffering routine 2010-06-03 21:51:40 +09:00
UENISHI Kota
7cd41aeb72 erlang: tracing crosslang.rb moving to ../test 2010-06-03 00:17:17 +09:00
UENISHI Kota
8ecaf7ad4c Merge branch 'master' of ssh://github.com/msgpack/msgpack 2010-06-03 00:14:19 +09:00
frsyuki
d4049fe593 ruby: add test/test_cases.rb 2010-06-01 16:35:21 +09:00
frsyuki
989b14b519 update test/README.md 2010-06-01 15:58:44 +09:00
frsyuki
fb3e11408c add test/cases.json 2010-06-01 15:56:29 +09:00
frsyuki
3d3af3284e cpp: adds Doxyfile 2010-06-01 08:43:30 +09:00
frsyuki
eabcf15790 cpp: update tests 2010-06-01 07:16:25 +09:00
frsyuki
684bca203a cpp: adds msgpack_unpacker_next and msgpack_unpack_next 2010-06-01 07:15:58 +09:00
frsyuki
d42ecccf6f cpp: msgpack::unpack returns void 2010-06-01 07:13:47 +09:00
frsyuki
5a92c861e3 cpp: adds msgpack_vrefbuffer_new and msgpack_vrefbuffer_free 2010-06-01 07:11:01 +09:00
frsyuki
103b14ea3c cpp: adds msgpack_zbuffer_new and msgpack_zbuffer_free 2010-06-01 07:10:39 +09:00
frsyuki
e49f091b4e cpp: adds msgpack_sbuffer_new and msgpack_sbuffer_free 2010-06-01 07:10:17 +09:00
frsyuki
6056f93910 cpp: add cases.mpac test 2010-06-01 05:15:36 +09:00
frsyuki
18fa2d1af4 Merge branch 'master' of github.com:msgpack/msgpack 2010-06-01 04:47:37 +09:00
frsyuki
062ed8a4c4 add test/cases.mpac and test/cases_compact.mpac 2010-06-01 04:47:28 +09:00
UENISHI Kota
49f3872d04 erlang: temporary documentation and .gitignore 2010-06-01 00:31:12 +09:00
UENISHI Kota
d9b467098a erlang: added more cross-language tests. better type specification. 2010-05-31 23:56:06 +09:00
UENISHI Kota
7d1e51437e erlang: added usage of cross-language test. 2010-05-31 23:13:32 +09:00
frsyuki
f5a7d444e2 Merge branch 'master' of github.com:msgpack/msgpack 2010-05-31 17:32:51 +09:00
frsyuki
a0071c2f9f add crosslang.rb 2010-05-31 17:27:51 +09:00
frsyuki
98a5e43883 add crosslang.cc 2010-05-31 17:16:40 +09:00
UENISHI Kota
f40ebe5b43 Merge branch 'master' of ssh://github.com/msgpack/msgpack 2010-05-31 00:26:49 +09:00
UENISHI Kota
d7d78d9a2b added more tests,
and OMake continuous building.
2010-05-31 00:25:53 +09:00
Hideyuki Tanaka
5a12d36a0a incr version 2010-05-30 19:45:00 +09:00
Hideyuki Tanaka
e61dc76ae1 fix peek object 2010-05-30 19:11:04 +09:00
Hideyuki Tanaka
0da22193bd fix typo 2010-05-30 17:20:49 +09:00
Hideyuki Tanaka
d43921823e fix initialize pointer 2010-05-30 17:19:43 +09:00
UENISHI Kota
6b5b76b0c9 initial import from http://bitbucket.org/kuenishi/messagepack-for-erlang 2010-05-30 15:01:10 +09:00
frsyuki
602971408b cpp: move source files into src/ directory 2010-05-30 03:02:40 +09:00
frsyuki
2f5d83f07d cpp: type::tuple& operator>>: fix conversion type 2010-05-30 01:45:07 +09:00
frsyuki
81b0c316cd java: Unpacker: rewind internal buffer on filled <= offset 2010-05-30 01:39:48 +09:00
frsyuki
6df86384ca java: update javadoc 2010-05-29 07:54:49 +09:00
frsyuki
3fbcde4bd7 ruby: don't use rb_enc_set/get on ruby 1.8 2010-05-26 18:11:09 +09:00
frsyuki
293293c23c ruby: set mp->user.source = Qnil before tempalte_execute_do on Unpacker#each 2010-05-26 18:01:27 +09:00
frsyuki
47185d757e ruby: version 0.4.0 2010-05-26 07:55:02 +09:00
frsyuki
94c3998507 ruby: update gemspec 2010-05-26 07:43:05 +09:00
frsyuki
5fa589691c ruby: use malloc/realloc for stream buffer 2010-05-26 07:01:28 +09:00
frsyuki
26bc835c7e ruby: buffer rewinding 2010-05-26 04:30:49 +09:00
frsyuki
fc7da17fa2 cpp: add sbuffer::clear() and vrefbuffer::clear() 2010-05-25 02:57:37 +09:00
frsyuki
dbebe9771b ruby: update rdoc 2010-05-25 02:55:58 +09:00
frsyuki
d0af8aa9f1 ruby: rdoc 2010-05-23 21:10:49 +09:00
Kazuki Ohta
f8173e93f5 java: version 0.3 (added CHANGES.txt and LICENSE.txt) 2010-05-23 01:48:20 +09:00
frsyuki
fa6ea6848f java: fixed problem that empty array and empty map don't check Schema 2010-05-23 01:38:01 +09:00
frsyuki
5982970e21 java: fixed problem that empty array and empty map don't check Schema 2010-05-23 01:34:45 +09:00
Kazuki Ohta
c43e5e0c95 java: added testcases for empty array and empty map 2010-05-23 01:31:15 +09:00
frsyuki
b4fc79c38e java: fixes compile error 2010-05-22 17:05:17 +09:00
frsyuki
b9cb270b8f java: add Unpacker.unpack(MessageUnpackable) and Unpacker.tryUnpackNil() 2010-05-22 03:34:43 +09:00
frsyuki
1fe35d7efe java: fix Packer.packByte 2010-05-22 03:34:17 +09:00
frsyuki
ec8c19b1f0 java: javadoc 2010-05-20 17:32:15 +09:00
frsyuki
c2525bcc05 java: add Unpacker.wrap method 2010-05-20 06:19:26 +09:00
frsyuki
985c31b378 java: add Unpacker.wrap method 2010-05-20 06:18:32 +09:00
frsyuki
135a9f5586 java: fix direct conversion API 2010-05-20 05:44:44 +09:00
frsyuki
979ff80982 java: redesign 2010-05-20 03:49:26 +09:00
frsyuki
6cde9f3a9d Merge branch 'master' of github.com:msgpack/msgpack 2010-05-19 16:31:16 +09:00
frsyuki
5cad81bf4c cpp: fix return type mismatch in zone.c 2010-05-18 14:48:36 +09:00
frsyuki
18967162cf cpp: fix return type mismatch in unpack.c 2010-05-18 14:48:23 +09:00
tokuhirom
6ea75f3a9f Perl: do not use done_testing 2010-05-17 05:52:32 +09:00
tokuhirom
f51123d009 oops 2010-05-17 05:49:39 +09:00
tokuhirom
be6376ee2d Perl: build_requires and requires are duped. 2010-05-08 12:02:31 +09:00
tokuhirom
120a85a3e5 Perl: releng for 0.12 2010-05-05 17:28:38 +09:00
tokuhirom
262fe96c29 Perl: PERL_NO_GET_CONTEXT makes horrible dTHXs. remove it. 2010-05-05 17:25:45 +09:00
tokuhirom
1864df5ed0 Perl: cleanup Makefile.PL 2010-05-05 17:25:25 +09:00
tokuhirom
09bae0a9e8 Perl: Test::Requires is not needed for this test. 2010-05-05 17:25:08 +09:00
tokuhirom
ebe41a24f1 perl: releng for data-messagepack 0.11 2010-05-05 16:59:31 +09:00
tokuhirom
f0f574a15b Perl: releng for 0.10 2010-05-05 16:55:06 +09:00
tokuhirom
9420436c09 Perl: added test case 2010-05-05 16:22:40 +09:00
tokuhirom
2b8f853b96 Perl: fixed some issues. thanks to gfx++
http://gist.github.com/387743
2010-05-05 16:17:57 +09:00
tokuhirom
2c2bf60d0c Perl: added README file. 2010-05-05 15:50:07 +09:00
Hideyuki Tanaka
62b82448d5 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-05-05 04:33:11 +09:00
Hideyuki Tanaka
2f12e6c3d0 remove compiler warnings 2010-05-05 04:28:04 +09:00
Kazuki Ohta
8ce23f8e3e java: fixed pom.xml to work "mvn deploy" command 2010-05-04 18:33:29 +09:00
Hideyuki Tanaka
dbe760d6e2 make () to OBJECT instance (Nil) 2010-05-04 16:24:45 +09:00
Hideyuki Tanaka
674c26d9c7 fix feed function from Handle 2010-05-04 16:22:04 +09:00
tokuhirom
7b68b04efd Perl: change for release Data-MessagePack-0.09_01 2010-05-03 01:36:48 +09:00
tokuhirom
e0b65bf196 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-05-03 01:20:00 +09:00
tokuhirom
77f5cb1f1f Perl: updated docs. 2010-05-03 01:09:21 +09:00
tokuhirom
2a222737f8 Merge branch 'master' of git@github.com:msgpack/msgpack 2010-05-03 01:04:50 +09:00
tokuhirom
77d48f9cee Perl: fixed memory leak issue 2010-05-03 00:46:15 +09:00
tokuhirom
c77eac325e Perl: added failing test case for memory leaks 2010-05-03 00:22:16 +09:00
tokuhirom
517ced2a54 Perl: added more test case for streaming unpacker 2010-05-03 00:08:02 +09:00
tokuhirom
70d2c47367 perl: added more test case for streaming deserializer. 2010-05-02 22:09:18 +09:00
frsyuki
e57084f6df cpp: update ChangeLog 2010-04-29 23:45:48 +09:00
frsyuki
8783cf8ec3 cpp: fixes unpacker::next 2010-04-29 22:32:43 +09:00
frsyuki
2af7a7c6ac Merge branch 'master' of github.com:msgpack/msgpack 2010-04-29 22:15:17 +09:00
frsyuki
91a1f8d9e1 cpp: new streaming deserialier API. 2010-04-29 22:15:03 +09:00
Kazuki Ohta
fc5e8ddca1 java: add Unpacker.feed() function for java.nio.ByteBuffer 2010-04-29 21:27:41 +09:00
frsyuki
6352472c5f python: sourceforge.jp -> sourceforge.net 2010-04-29 09:06:46 +09:00
Naoki INADA
833ee6484c Release msgpack-python 0.1.3 2010-04-29 07:52:32 +09:00
Naoki INADA
dda3d24bca Add download url. 2010-04-29 07:08:41 +09:00
Naoki INADA
f77d76a320 Add COPYING file to python package. 2010-04-29 07:01:16 +09:00
frsyuki
c51fabf6ed msgpack/pack_template.h: don't evaluate undefined macro 2010-04-29 02:39:53 +09:00
frsyuki
b10cb658ca pack_template.h: template_unsigned_long:
wrong size checking on !defined(SIZEOF_SHORT) && !defined(SHRT_MAX)"
2010-04-29 00:39:45 +09:00
frsyuki
68f60568ac cpp: build libmsgpackc.so for backward compatibility. 2010-04-26 21:52:19 +09:00
frsyuki
9fbca83ac0 cpp: add test/{zone,pack_unpack,streaming,object,convert,buffer}.cc 2010-04-25 18:08:14 +09:00
frsyuki
d19bfaa2cb cpp: fixes msgpack_vc8.vcproj 2010-04-25 09:09:06 +09:00
frsyuki
53d5ddb345 cpp: fixes operator<<(packer<Stream>&, const object&) 2010-04-25 08:26:42 +09:00
frsyuki
0a5c2e7ab9 c,cpp: MSGPACK_OBJECT_NIL = 0x00 2010-04-25 08:16:12 +09:00
frsyuki
35802ba949 cpp: msgpack_object_equal 2010-04-25 08:00:04 +09:00
frsyuki
72160aac9a cpp: combines libmsgpackc and libmsgpack into libmsgpack 2010-04-25 07:56:19 +09:00
frsyuki
9df6916029 cpp: object::object(const T& v, zone* z) 2 2010-04-25 06:39:12 +09:00
frsyuki
9bfa2354ff cpp: fixes serialization of object::type == DOUBLE 2010-04-25 02:37:04 +09:00
frsyuki
7d945d3c8e cpp: explicit object(const T& v) 2010-04-25 02:30:53 +09:00
frsyuki
05e28752f1 cpp: MSGPACK_DEFINE defines T::msgpack_object(object*, zone*) 2010-04-25 01:57:05 +09:00
frsyuki
01b6673528 cpp: bool operator==(object& x, const T& y) 2010-04-25 01:24:24 +09:00
frsyuki
4e85ebbf98 cpp: object::object(const T& v, zone* z) 2010-04-25 01:12:25 +09:00
frsyuki
120e8bffd7 cpp: object::object(const T& v) and object::operator=(const T& v) 2010-04-25 00:03:09 +09:00
frsyuki
8335823748 ruby-0.3.9 2010-04-23 20:24:36 +09:00
frsyuki
c9fcf4020f ruby: streaming deserializer test 2010-04-23 20:18:48 +09:00
frsyuki
b10a736744 ruby: fixese backward compatibility of streaming deserializer 2010-04-23 18:13:36 +09:00
frsyuki
60fbaf7612 ruby: 0.3.8 2010-04-22 14:56:25 +09:00
frsyuki
d24193630e reverts variable-length stack: avoids memory leak 2010-04-22 14:46:54 +09:00
frsyuki
354af69f62 ruby: fixes SEGV on MessagePack_Unpacker_each 2010-04-22 14:38:10 +09:00
Taro L. Saito
bccac610a4 changed the src/test folder 2010-04-20 00:05:26 +09:00
Taro L. Saito
5aa6209664 add README 2010-04-19 23:52:40 +09:00
Taro L. Saito
d693d92702 removed unnecessary settings 2010-04-19 23:34:18 +09:00
Taro L. Saito
f2622e54e3 moved src and test codes to src/{main,test}/java 2010-04-19 23:05:00 +09:00
Taro L. Saito
20fe9b6dde added pom.xml 2010-04-19 22:39:53 +09:00
Kazuki Ohta
11f7aa4212 cpp: fixed small typo in configure.in 2010-04-18 15:11:50 +09:00
Hideyuki Tanaka
f53c351fd2 haskell binding 2010-04-18 02:17:49 +09:00
Kazuki Ohta
fb96617377 java: add javadoc,javadoc-jar,pom,dist,mvn-install,mvn-deploy ANT tasks.
Now maven2 repository for msgpack is created at the following URL.
  - http://msgpack.sourceforge.net/maven2/
2010-04-18 01:18:40 +09:00
frsyuki
05b8c00ee7 cpp: fixes windows compatibility 2010-04-18 00:39:45 +09:00
frsyuki
58854fdae9 cpp: add cpp/README.md 2010-04-18 00:39:23 +09:00
frsyuki
fd31ff772f Merge branch 'master' of github.com:msgpack/msgpack 2010-04-18 00:08:17 +09:00
frsyuki
ab8e0c9e31 c,cpp: reforms source tree 2010-04-18 00:08:03 +09:00
Kazuki Ohta
abeed3be84 java: add tests for array and map 2010-04-17 23:25:42 +09:00
Kazuki Ohta
a65438c6fe java: skip building jar file for the faster testing 2010-04-17 22:53:56 +09:00
frsyuki
c3f43fb0cf template_execute: fixes embed stack 2010-04-17 22:43:11 +09:00
Kazuki Ohta
2807504a81 java: add tests for float, double, nil, boolean, string 2010-04-17 22:10:41 +09:00
Kazuki Ohta
08b716c96d java: add TestPackUnpack for int 2010-04-17 21:16:32 +09:00
Kazuki Ohta
b4b1f0a2c9 introduce JUnit framework for testing. 2010-04-17 20:17:43 +09:00
frsyuki
228f742b2f ruby: set encoding to 'ASCII-8BIT' before deserializing on ruby-1.9 2010-04-17 20:02:47 +09:00
frsyuki
a55affe4d5 ruby: add Symbol#to_msgpack 2010-04-17 16:16:56 +09:00
frsyuki
a6ec726ed7 malloc/realloc the stack when its length becomes > MSGPACK_EMBED_STACK_SIZE 2010-04-14 21:11:31 +09:00
frsyuki
87835a4e60 ruby: remove init_stack, adopt rb_gc_mark_maybe 2010-04-14 21:08:06 +09:00
Masahiro Nakagawa
1f18af4395 c: fixes comment in pack_template.h 2010-04-08 23:01:19 +09:00
frsyuki
e79747a600 cpp: msgpack/pack.hpp: fixes header 2010-04-07 20:02:00 +09:00
Masahiro Nakagawa
bd36ac2c0c cpp: fixes argument type of pack_int* methods 2010-04-07 19:54:14 +09:00
frsyuki
c6186f2c01 ruby: version 0.3.7 2010-04-06 17:59:34 +09:00
frsyuki
d639f57470 ruby: fixes Segmentation fault on MessagePack.unpack(nil) 2010-04-06 17:46:38 +09:00
Hideyuki TAKEI
99a2d28592 import MessagePack for PHP 2010-04-05 00:10:28 +09:00
frsyuki
254ee80c16 c: fixes msgpack_zbuffer_write: error checking 2010-04-04 22:11:16 +09:00
frsyuki
e43f57fe1a c: fixes msgpack_zbuffer_flush: error checking 2010-04-04 22:06:27 +09:00
Masahiro Nakagawa
f88c029a4c c: fixes msgpack_zbuffer_flush 2010-04-04 21:55:00 +09:00
frsyuki
93c3cbeaef ruby fixes gemspec: require_paths = ["lib"] 2010-04-04 21:45:56 +09:00
frsyuki
88c77b793f Merge branch 'master' of github.com:msgpack/msgpack 2010-04-04 21:40:19 +09:00
frsyuki
11286524a5 ruby: fixes 'File not found: lib' message on gem installation 2010-04-02 03:22:29 +09:00
frsyuki
7c863c341e ruby: use gem-compile gem instead of some scripts to create binary gems 2010-04-02 02:19:41 +09:00
moaikids
3416cf984e fix: org.msgpack.impl.UnpackerImpl.java CS_MAP_16 deserialize bug(line.388) 2010-04-01 23:15:36 +09:00
moaikids
1784746e7e fix: CS_MAP_16 deserialize bug(line.388) 2010-04-01 23:13:56 +09:00
Keiji Muraishi
6c6df1adaf should raise TypeError on find unsupported value 2010-03-31 17:29:07 +09:00
Keiji Muraishi
f91e1c17c0 fix typo in Makefile 2010-03-31 17:09:00 +09:00
frsyuki
58201b95f2 ruby: version 0.3.4 2010-03-31 13:46:28 +09:00
frsyuki
fcce8f6d51 ruby: use 'readpartial' instead of 'sysread' if !io.respond_to?(:sysread) 2010-03-31 12:00:26 +09:00
frsyuki
f7bdda8828 cpp: fixes pack_short(int) -> pack_short(short) 2010-03-29 21:18:01 +09:00
frsyuki
df5a60fd5b ruby: append_buffer calls "<<" method if the buffer object.class != String 2010-03-26 15:16:13 +09:00
frsyuki
5782ab7ccc c,cpp: add msgpack_zbuffer and msgpack::zbuffer 2010-03-26 14:33:49 +09:00
frsyuki
72e3f98213 cpp: alias pack(Stream* s, const T& v) -> pack(Stream& const T& v) 2010-03-26 14:30:50 +09:00
frsyuki
1b1433a664 ruby: copy the deserialized string if length <= RSTRING_EMBED_LEN_MAX 2010-03-26 14:29:49 +09:00
frsyuki
568704ed22 fixes Visual C++ compatibility 2010-03-19 13:34:53 +09:00
frsyuki
05a7e4eb64 ruby: add msgpack.mingw.{gemspec,sh} 2010-03-02 17:09:59 +09:00
frsyuki
7a0acf2838 Merge branch 'master' of frsyuki@git.sourceforge.jp:/gitroot/msgpack/msgpack 2010-03-01 18:00:16 +09:00
frsyuki
27787505e0 strict-aliasing rule 2 2010-02-27 02:37:01 +09:00
frsyuki
2c8048115d Merge branch 'master' of frsyuki@git.sourceforge.jp:/gitroot/msgpack/msgpack 2010-02-18 14:31:41 +09:00
frsyuki
7df1780853 ruby: makegem.sh 2010-02-06 21:31:16 +09:00
frsyuki
d5609f3207 ruby: makegem.sh 2010-02-06 21:28:27 +09:00
frsyuki
cd10fbc1fe removed symbolic links 2010-02-06 20:09:41 +09:00
firewood
ca0b085d15 add a blanc after Japanese comment 2010-02-05 22:50:05 +09:00
firewood
9a034234d8 add vc2005 project file. 2010-02-05 22:49:28 +09:00
firewood
66ef6c9e4c undef after including winsock2.h. 2010-02-05 22:49:00 +09:00
frsyuki
7df60b259b MSVC2005 compatibility (@hotpepsi++) 2010-02-02 10:52:42 +09:00
frsyuki
34b3bbc883 ruby: add Unpacker#each 2010-01-29 17:23:48 +09:00
Naoki INADA
e02d20dd74 replace setup by setup_dev. 2010-01-25 20:52:48 +09:00
Naoki INADA
1a11608f1f cythoning *.pyx when sdist. 2010-01-25 20:51:55 +09:00
Naoki INADA
9e2c9d7812 Tiny fix in README 2010-01-25 12:21:46 +09:00
Kazuki Ohta
404a393315 c, cpp: fix test problem
- using LDADD instead of LDFLAGS
- fix include path in test.cpp
2010-01-21 21:55:06 +09:00
frsyuki
c69092e110 configure.in: fix message 2010-01-21 17:25:32 +09:00
frsyuki
ebc0eeac79 c,cpp: 0.4.1 2010-01-20 15:17:33 +09:00
frsyuki
2b72f35c32 configure.in: show error message if __sync_* atomic operations are not supported 2010-01-20 14:49:51 +09:00
frsyuki
d8212ad620 strict-aliasing rule 2010-01-20 14:46:54 +09:00
Kazuki Ohta
1066bb38a8 add tests for multi[map, set] and tr1::unordered_[multi][map, set] 2010-01-16 02:03:11 +09:00
frsyuki
2bf3f1856f c,cpp: configure.in: version 0.4.0 2010-01-15 14:45:52 +09:00
frsyuki
f145129f6e c,cpp: optimize msgpack_vrefbuffer 2010-01-15 05:29:41 +09:00
frsyuki
8d365458d5 c,cpp: optimize msgpack_zone: variable-length array of chunk -> list of chunk 2010-01-15 05:27:44 +09:00
frsyuki
55cfbf378e cpp: add msgpack/type/tr1/unordered_{map,set}.hpp 2010-01-14 21:20:32 +09:00
frsyuki
d76093b148 import MessagePack for Java 2010-01-08 17:34:14 +09:00
tokuhirom
7873e41e00 Perl: change for release Data-MessagePack-0.09 2010-01-04 12:10:46 +09:00
tokuhirom
9817e9b18d Perl: support NVTYPE=="long double" or IVTYPE="long long" environment. 2010-01-04 11:59:52 +09:00
tokuhirom
519716bbe4 Merge branch 'master' of git://git.sourceforge.jp/gitroot/msgpack/msgpack 2010-01-04 11:23:40 +09:00
frsyuki
c2dd22ec10 c,cpp: add msgpack_vrefbuffer_migrate, msgpack::vrefbuffer::migrate 2009-12-19 22:09:29 +09:00
Naoki INADA
232aced926 Update gitignore. 2009-12-17 18:03:33 +09:00
Naoki INADA
63b9a876b0 Fix tests. 2009-12-17 17:58:41 +09:00
inada-n
5cf85a82d3 Add .gitignore for Python. 2009-12-17 15:20:20 +09:00
inada-n
b9f78821d4 Make tuple default. 2009-12-17 15:19:18 +09:00
Naoki INADA
f4c5b15cc6 Add use_tuple option that returns tuple for array object to Unpacker. 2009-12-17 11:13:47 +09:00
Naoki INADA
4d33bd456c Update new headers. 2009-12-17 10:43:22 +09:00
Naoki INADA
3a5f7f53ff Start 0.2.0 2009-12-17 10:43:01 +09:00
inada-n
1ed4236bcf Make new Python release. 2009-12-16 22:18:17 +09:00
inada-n
5ff2c6be74 Fix bug come from previous commit 2009-12-16 22:14:13 +09:00
inada-n
dd18402737 Fix stream unpacker broken. 2009-12-16 22:05:31 +09:00
frsyuki
686e8ca0f0 c,cpp: fix unpacker 2009-12-16 04:08:36 +09:00
frsyuki
5aa47d6677 cpp: zone::push_finalizer supports std::auto_ptr<T> 2009-12-16 03:52:14 +09:00
frsyuki
0d44348c7d ruby: version 0.3.2 2009-12-11 04:13:24 +09:00
frsyuki
35929b46ae add msgpack/sysdep.h 2009-12-10 07:22:39 +09:00
frsyuki
ba3ba0367c msgpack template: macros for compilers that doesn't not support Case Ranges 2009-12-10 06:40:29 +09:00
frsyuki
7ce866ad7c msgpack template: architecture specific endian conversion 2009-12-10 06:19:53 +09:00
frsyuki
0ae1965f6b ruby: fixes MessagePack_Unpacker_mark marks uninitialized map_key 2009-12-10 04:32:33 +09:00
frsyuki
eb9e892491 import MessagePack for Java implementation plan 3 2009-11-26 11:22:08 +09:00
frsyuki
e39e1d4f60 import MessagePack for Java implementation plan 2 2009-11-12 01:10:36 +09:00
Naoki INADA
93a95725fc Fix Makefile 2009-11-05 14:26:12 +09:00
Naoki INADA
4758d9f04b Fix to use MANIEFST.in. 2009-11-05 14:24:47 +09:00
frsyuki
d39c016e1d java: fix streaming de/serializer 2009-10-25 02:41:55 +09:00
frsyuki
5393a0df16 import MessagePack for Java implementation plan 1 2009-10-25 01:27:09 +09:00
Tokuhiro Matsuno
68176e10f5 added some pattern to MANIFEST.SKIP 2009-10-22 14:34:53 +09:00
Tokuhiro Matsuno
c6a2569af8 - generate README automatically
- added LICENSE term
2009-10-22 14:32:39 +09:00
frsyuki
3424dc916c cpp: add missing type::tuple::tuple(object o) 2009-10-09 17:49:30 +09:00
frsyuki
c8ad32a39e cpp: preprocess.sh: more verbose 2009-10-05 23:31:08 +09:00
Kazuki Ohta
d0b76814b0 cpp: add tests for stream unpacker api 2009-09-12 03:12:53 +09:00
frsyuki
bf3cb63d46 cpp: version 0.3.8 2009-09-10 13:53:12 +09:00
frsyuki
8da7b692f6 cpp: define, type::tuple: GENERATION_LIMIT = 31 2009-09-10 13:50:19 +09:00
Kazuki Ohta
320c79db49 c++: add vrefbuffer test 2009-09-04 16:20:29 +09:00
frsyuki
ebf64d9892 cpp: test.cpp: fixes EXPECT_EQ rule 2009-08-26 12:28:08 +09:00
frsyuki
c12d5b8461 c: test.cpp: add msgpack_sbuffer_destroy and msgpack_zone_destroy 2009-08-26 12:27:28 +09:00
Kazuki Ohta
7186edc45e C: more strict tests for float, double
C++: more strict tests for float, double & enum, union member
2009-08-26 11:52:12 +09:00
Kazuki Ohta
c94772104d C: add test for map
C++: add tests for primitive types, stl types, user-defined type
2009-08-26 11:28:54 +09:00
Kazuki Ohta
9374571056 C: add more tests (float, double, nil, true, false, array, raw) 2009-08-26 09:24:07 +09:00
Kazuki Ohta
c232e91f83 c: fix bugs in c/test.cpp and add more tests 2009-08-25 19:26:54 +09:00
Kazuki Ohta
5b8777026a c: add sometests for serialization 2009-08-25 19:04:21 +09:00
Kazuki Ohta
51e435d46c fix build 2009-08-25 18:40:06 +09:00
frsyuki
d3f9ab7dec add c/test.cpp cpp/test.cpp 2009-08-25 18:35:26 +09:00
frsyuki
1ba330c473 fix cpp/preprocess.sh 2009-08-25 18:25:58 +09:00
frsyuki
dba7f480ed cpp: add missing preprocess.sh file 2009-08-19 17:50:15 +09:00
frsyuki
3a39accb0b cpp: preprocess eruby templates on ./bootstrap; released package doesn't require erb 2009-08-19 17:47:22 +09:00
frsyuki
387eca6fbf cpp-0.3.7 2009-08-19 17:36:05 +09:00
frsyuki
b2381d0513 cpp: fix overflow check for minimum number of signed integer type 2009-08-19 15:10:10 +09:00
frsyuki
92952f6566 c++: fix object >> std::string 2009-08-10 22:16:44 +09:00
frsyuki
a62a5d6c69 c++: fix type.hpp 2009-08-10 18:33:35 +09:00
frsyuki
0627324da6 c++: rebuild type/*.hpp 2009-08-10 18:26:01 +09:00
frsyuki
394331cd4e c++: add std::pair and std::set serializer 2009-08-10 17:34:21 +09:00
frsyuki
0491768fb2 c++: fix Makefile.am 2009-08-10 15:58:43 +09:00
frsyuki
a5705183d6 0.3.5 2009-08-07 13:32:32 +09:00
frsyuki
95a6316cc7 cpp: fix msgpack::type::make_define() 2009-08-07 13:32:07 +09:00
frsyuki
be32e3b1fb cpp: add missing msgpack::type::make_tuple() 2009-08-07 13:31:42 +09:00
frsyuki
b4cb5e23c0 fix Makefile.am 2009-08-07 11:28:23 +09:00
frsyuki
1375732c80 add 2009-08-07 11:15:33 +09:00
frsyuki
7fbe845434 cpp: msgpack::define is obsolete 2009-08-06 13:59:48 +09:00
frsyuki
3afa9f265e cpp: add msgpack::type::define 2009-08-06 13:51:49 +09:00
frsyuki
ec8932d6a1 fix missing tuple<>::value_type 2009-08-06 13:28:41 +09:00
frsyuki
f7a9805f7b operator>> (object, std::vector<T>): return reference; don't copy 2009-08-06 13:26:34 +09:00
frsyuki
aaef612a05 Makefile.am: don't package perl and ruby files 2009-08-06 13:20:43 +09:00
Tokuhiro Matsuno
da9b75f553 Checking in changes prior to tagging of version 0.08. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 4e7f1d7..c6e370c 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.08
+
+    - fixed PVNV issue...
+
 0.07

     - do not use switch (SvTYPE(val)).
2009-07-30 16:52:13 +09:00
Tokuhiro Matsuno
d3906bd1ab Perl: use M::I::XSUtil 2009-07-30 16:38:03 +09:00
Tokuhiro Matsuno
4db90d23ac - fixed SVt_PVNV issue. 2009-07-30 16:22:00 +09:00
Tokuhiro Matsuno
bb455c1f71 perl: display module version 2009-07-30 13:29:24 +09:00
Tokuhiro Matsuno
3275eee281 Perl: display original data 2009-07-30 13:24:38 +09:00
Tokuhiro Matsuno
0fe79a7752 Perl: added benchmark script for memroy-usage 2009-07-30 13:19:49 +09:00
Tokuhiro Matsuno
794adf9469 Checking in changes prior to tagging of version 0.07. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 1a51ddf..4e7f1d7 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.07
+
+    - do not use switch (SvTYPE(val)).
+
 0.06

     - use SvNOK.
2009-07-22 16:42:12 +09:00
Tokuhiro Matsuno
718227bc2c Perl: do not use switch (SvTYPE) 2009-07-22 16:40:15 +09:00
Tokuhiro Matsuno
390c5ad8a0 added test case. 2009-07-22 13:41:31 +09:00
Tokuhiro Matsuno
2da4b17d0b Merge branch 'master' of tokuhirom@git.sourceforge.jp:/gitroot/msgpack/msgpack 2009-07-22 13:28:27 +09:00
inada-n
d19c488929 version: python-0.1.1 2009-07-13 15:52:25 +09:00
inada-n
0db5e0439d Fix: Unpacker.unpack() may raise StopIteration before unpacking large object when deserializing from file. 2009-07-13 15:49:38 +09:00
inada-n
6083bad5ff Fix wrong MANIFEST. 2009-07-13 14:46:53 +09:00
inada-n
63a507a123 merge python binding from bzr. 2009-07-13 14:40:02 +09:00
Naoki INADA
294e3fe7ab Add setup script for distribution. 2009-07-13 14:27:57 +09:00
Naoki INADA
e5c49dae13 Release 0.1.0 2009-07-12 20:02:21 +09:00
Naoki INADA
900785e1aa Clean up 2009-07-12 09:29:11 +09:00
Naoki INADA
979efbb950 Support MinGW. 2009-07-09 13:41:04 +09:00
Tokuhiro Matsuno
7da1a9b3cf Checking in changes prior to tagging of version 0.06. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 15603ea..1a51ddf 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.06
+
+    - use SvNOK.
+
 0.05

     - change type detection for old perl
2009-07-03 18:19:29 +09:00
Tokuhiro Matsuno
661f273481 Perl: use SvNOK. 2009-07-03 18:18:40 +09:00
Tokuhiro Matsuno
cb5c878b77 Checking in changes prior to tagging of version 0.05. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 33fb36c..15603ea 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,7 @@
+0.05
+
+    - change type detection for old perl
+
 0.04

     - check SvROK first(reported by yappo++)
2009-07-03 18:15:45 +09:00
Tokuhiro Matsuno
34ed3bc9e3 Perl: check IV by SvIOK 2009-07-03 18:09:38 +09:00
Tokuhiro Matsuno
ad7cf12128 perl: added test case for "the flag is working?" 2009-07-03 17:27:44 +09:00
Tokuhiro Matsuno
6fb6283463 Checking in changes prior to tagging of version 0.04. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 0c170a3..33fb36c 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,11 @@
+0.04
+
+    - check SvROK first(reported by yappo++)
+    - PreferInteger: faster string to integer conversion; support negative value
+      (frsyuki++)
+    - make PreferInteger variable magical and remove get_sv from _msgpack_pack_sv
+      (frsyuki++)
+
 0.03

     - performance tuning for too long string
2009-07-03 15:23:50 +09:00
Tokuhiro Matsuno
b45dc8db61 check SvROK first 2009-07-03 15:14:31 +09:00
Tokuhiro Matsuno
3397d261d8 Merge branch 'master' of tokuhirom@git.sourceforge.jp:/gitroot/msgpack/msgpack
Conflicts:
	perl/lib/Data/MessagePack.pm
2009-07-03 11:39:34 +09:00
frsyuki
eaa8be8ddd perl: PreferInteger: faster string to integer conversion; support negative value 2009-07-03 02:08:22 +09:00
frsyuki
0f9dcb8610 perl: make PreferInteger variable magical and remove get_sv from _msgpack_pack_sv 2009-07-03 01:49:37 +09:00
Tokuhiro Matsuno
3446c475d7 Checking in changes prior to tagging of version 0.03. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index fb31a69..0c170a3 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.03
+
+    - performance tuning for too long string
+    - fixed memory leaks in stream unpacker
+
 0.02

     - added $Data::MessagePack::PreferInteger
2009-07-02 17:43:58 +09:00
Tokuhiro Matsuno
ffef0a0b6f oops. fixed memory leaks in stream unpacker. 2009-07-02 17:42:28 +09:00
Tokuhiro Matsuno
580fbe77e9 do not check the string longer than 10. 2009-07-02 16:40:41 +09:00
Tokuhiro Matsuno
e92e99c4d1 Perl: I don't need CCFLAGS 2009-07-02 14:43:22 +09:00
Tokuhiro Matsuno
c3f793aa09 Checking in changes prior to tagging of version 0.02. Changelog diff is:
diff --git a/perl/Changes b/perl/Changes
index 18041d4..fb31a69 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,8 @@
+0.02
+
+    - added $Data::MessagePack::PreferInteger
+      (requested by yappo++)
+
 0.01

     - initial release to CPAN
2009-07-02 14:37:54 +09:00
Tokuhiro Matsuno
3d9908c8e5 Merge branch 'master' of git://git.sourceforge.jp/gitroot/msgpack/msgpack
Conflicts:
	perl/pack.c
2009-07-02 14:31:52 +09:00
Tokuhiro Matsuno
7b198d5966 s/Preferred/Prefer/g suggested by kazuho++ 2009-07-02 14:29:49 +09:00
Tokuhiro Matsuno
601209c83c support $Data::MessagePack::PreferredInteger for Data::Model 2009-07-02 14:25:48 +09:00
Naoki INADA
78db826a75 Fix memory leak. Remove stream packing feature. Add errorcheck in packing. 2009-07-01 20:55:24 +09:00
Tokuhiro Matsuno
c2a63b2c54 Checking in changes prior to tagging of version 0.01. Changelog diff is: 2009-07-01 18:40:14 +09:00
Tokuhiro Matsuno
7c27624161 added .shipit file 2009-07-01 18:34:27 +09:00
Tokuhiro Matsuno
d86b90e663 added Changes file 2009-07-01 18:34:11 +09:00
Tokuhiro Matsuno
d72bef9f9a added MANIFEST.SKIP files 2009-07-01 18:33:56 +09:00
Tokuhiro Matsuno
37972dfe3e copy files into this dir. 2009-07-01 18:20:14 +09:00
Tokuhiro Matsuno
c6496ddf13 added .gitignore file 2009-07-01 18:08:39 +09:00
Tokuhiro Matsuno
a95e8c790c this module requires perl 5.8 2009-07-01 17:45:18 +09:00
Naoki INADA
03942a1b90 Major speedup on packing. 2009-07-01 00:57:46 +09:00
Naoki INADA
d4317fdc85 Some optimization on packing. 2009-06-30 23:03:33 +09:00
Naoki INADA
b5010c71a9 Fix tests. 2009-06-29 11:21:28 +09:00
Naoki INADA
9015bd4ecf Fix error on packing unsigned long long. 2009-06-29 10:09:04 +09:00
Naoki INADA
fe2421275d Add some test cases. 2009-06-29 09:31:43 +09:00
Naoki INADA
257270c1eb Refactor packing code. 2009-06-29 08:23:49 +09:00
Naoki INADA
0b33a634a6 Update test_format. 2009-06-29 08:23:27 +09:00
Naoki INADA
3e396ef146 Don't use C++. 2009-06-28 21:24:16 +09:00
Naoki INADA
1b07b61c04 Ues more suitable type when packing. 2009-06-28 21:24:02 +09:00
Naoki INADA
fa2efcdb5b Rename test files. 2009-06-27 12:04:11 +09:00
Naoki INADA
a345131aaa Add: README 2009-06-27 12:03:00 +09:00
Naoki INADA
ffc16736ba merge to git master 2009-06-27 10:35:07 +09:00
Naoki INADA
3c3df3133c Implement streaming deserializer. 2009-06-26 14:10:20 +09:00
Naoki INADA
16a208243b merge 2009-06-26 14:09:15 +09:00
frsyuki
dd407410d2 version 0.3.3 2009-06-24 16:01:13 +09:00
frsyuki
8f52ed26c7 version 0.3.3 2009-06-24 16:01:13 +09:00
Naoki INADA
479263989b Stop unnecessary caching. 2009-06-24 14:58:02 +09:00
Tokuhiro Matsuno
87e1adcb40 works correctly under Perl5.8.x. Perl5.8.x makes "a" as PVIV in {"a", 0}. 2009-06-24 14:46:28 +09:00
Tokuhiro Matsuno
8e166de1d1 works correctly under Perl5.8.x. Perl5.8.x makes "a" as PVIV in {"a", 0}. 2009-06-24 14:46:28 +09:00
Tokuhiro Matsuno
3aef3edbad works correctly under Perl5.8.x.
Perl5.8.x makes "a" as PVIV in {"a", 0}.
2009-06-24 14:36:37 +09:00
Tokuhiro Matsuno
b2fdaac99e update ppport.h 2009-06-24 14:11:06 +09:00
Tokuhiro Matsuno
9a342ab7f8 update ppport.h 2009-06-24 14:11:06 +09:00
frsyuki
a961f646e5 perl package 2009-06-24 13:53:12 +09:00
frsyuki
8596d36d02 perl package 2009-06-24 13:53:12 +09:00
Naoki INADA
423e5132a1 merge 2009-06-24 08:49:48 +09:00
Naoki INADA
1581acfd14 Make setup.py executable. 2009-06-24 14:33:36 +09:00
Naoki INADA
5d4189306a Check return value of c-api. 2009-06-24 04:25:05 +09:00
Naoki INADA
f61b282886 Reduce memory footprint. 2009-06-24 01:54:47 +09:00
Naoki INADA
3fd28d0792 Remove duplicated values. 2009-06-24 01:38:48 +09:00
Naoki INADA
dd53b141ef Remove unneccessary value. 2009-06-24 01:13:39 +09:00
Naoki INADA
99d0a41ec6 Fix setup script bug. 2009-06-24 01:13:22 +09:00
Naoki INADA
b8e5b918a3 Update manifest. 2009-06-22 22:50:05 +09:00
Naoki INADA
71af62c1df merge to master. 2009-06-22 20:08:17 +09:00
Naoki INADA
7d5f04917e Update manifest. 2009-06-22 19:55:46 +09:00
Naoki INADA
46d7c65621 Fix compile error. 2009-06-22 19:49:02 +09:00
Naoki INADA
87f5df1503 Use std::stack. 2009-06-22 15:59:02 +09:00
Naoki INADA
9a77ab57f6 merge document fix. 2009-06-22 14:55:46 +09:00
Naoki INADA
20a7ff0be8 Make msgpack package instead of module. and using Cython in setup script. 2009-06-22 14:38:36 +09:00
Naoki INADA
075081a521 Fix manifest. 2009-06-22 14:28:04 +09:00
Naoki INADA
f4387e9746 merge changing include path 2009-06-22 13:26:41 +09:00
Naoki INADA
0d14239c21 Optimize to parsing data that has a number of same short raw field. 2009-06-22 09:51:24 +09:00
Naoki INADA
2475187c7d Fix refcount leak and optimize list initialization. 2009-06-17 13:45:08 +09:00
Naoki INADA
4d6e9ffaa2 Fix can't pack float values. 2009-06-16 01:58:07 +09:00
Naoki INADA
6184e17a42 Increase stack size. 2009-06-16 01:56:04 +09:00
Naoki INADA
e814986b4e Fix document miss. 2009-06-10 13:33:42 +09:00
Naoki INADA
3a9f74e79c Make msgpack package instead of module. 2009-06-10 10:58:09 +09:00
Naoki INADA
a1fb1507d4 Refactor include path. 2009-06-10 10:45:07 +09:00
Naoki INADA
85ca594118 free buffer when packer deleted. 2009-06-09 13:12:29 +09:00
Naoki INADA
9c9393bff9 Fix setup script doesn't work. 2009-06-08 13:21:38 +09:00
Naoki INADA
560bd901f8 Fix double INCREF-ing when unpacking. 2009-06-08 12:46:02 +09:00
Naoki INADA
114ef92d42 Merge branch 'master' of git://git.sourceforge.jp/gitroot/msgpack/msgpack 2009-06-08 04:43:25 +09:00
Naoki INADA
1840ef70ae merge to trunk 2009-06-08 04:38:20 +09:00
Naoki INADA
935db853f0 add test. 2009-06-08 04:33:58 +09:00
Naoki INADA
17d2ca2d63 Fix unpacking True, False and True. 2009-06-08 04:33:47 +09:00
Naoki INADA
c930f5367b add cythoned source and setup script. 2009-06-08 01:43:50 +09:00
Naoki INADA
d8a3bc920c refactoring 2009-06-08 01:30:43 +09:00
Naoki INADA
711e4817a5 support packing long and tuple. add missing files. 2009-06-08 00:23:38 +09:00
frsyuki
8ed1d61529 add msgpack_vrefbuffer, msgpack::vrefbuffer 2009-06-07 14:59:50 +09:00
frsyuki
7cd359c1fd add msgpack_vrefbuffer, msgpack::vrefbuffer 2009-06-07 14:59:50 +09:00
frsyuki
f6cc274bbc Merge branch 'master' of frsyuki@git.sourceforge.jp:/gitroot/msgpack/msgpack 2009-06-07 13:33:22 +09:00
frsyuki
2598d98922 Merge branch 'master' of frsyuki@git.sourceforge.jp:/gitroot/msgpack/msgpack 2009-06-07 13:33:22 +09:00
frsyuki
b3846a411f cpp: fix map<K, V> converter 2009-06-03 22:01:27 +09:00
frsyuki
8617213149 cpp: fix map<K, V> converter 2009-06-03 22:01:27 +09:00
Naoki INADA
3628ea22d4 add pyx 2009-05-22 14:31:20 +09:00
frsyuki
8903e2dea9 cpp: const 2009-05-13 17:53:27 +09:00
frsyuki
6a0729ea91 cpp: const 2009-05-13 17:53:27 +09:00
Tokuhiro Matsuno
62231983d7 perl: oops. this doens't needed. 2009-04-15 23:14:56 +09:00
Tokuhiro Matsuno
b0062a7f6f perl: oops. this doens't needed. 2009-04-15 23:14:56 +09:00
Tokuhiro Matsuno
0b3db48976 perl: added argument check 2009-04-15 23:11:26 +09:00
Tokuhiro Matsuno
b140b27b9a perl: added argument check 2009-04-15 23:11:26 +09:00
Tokuhiro Matsuno
45321baa66 perl: added benchmark script for deserialization 2009-04-15 23:06:47 +09:00
Tokuhiro Matsuno
e0bd2a2911 perl: added benchmark script for deserialization 2009-04-15 23:06:47 +09:00
Tokuhiro Matsuno
0b083030b1 perl: renamed benchmark script 2009-04-15 23:02:27 +09:00
Tokuhiro Matsuno
ea41db4cc7 perl: renamed benchmark script 2009-04-15 23:02:27 +09:00
Tokuhiro Matsuno
e53799d779 perl: use more efficent strategy for memory allocation.this code taken from JSON::XS. thanks to mlehmann++ 2009-04-15 22:43:59 +09:00
Tokuhiro Matsuno
5a201be844 perl: use more efficent strategy for memory allocation.this code taken from JSON::XS. thanks to mlehmann++ 2009-04-15 22:43:59 +09:00
Tokuhiro Matsuno
2aeeef3368 oops. remove debugging code. 2009-04-15 22:43:16 +09:00
Tokuhiro Matsuno
28e113fd00 oops. remove debugging code. 2009-04-15 22:43:16 +09:00
Tokuhiro Matsuno
c7b6bb7303 perl: enhancement portability 2009-04-15 13:09:05 +09:00
Tokuhiro Matsuno
5710b87b06 perl: enhancement portability 2009-04-15 13:09:05 +09:00
Tokuhiro Matsuno
d449b1d20d added perl support 2009-04-15 12:55:41 +09:00
Tokuhiro Matsuno
8c62d93bca added perl support 2009-04-15 12:55:41 +09:00
frsyuki
5bd53f018f version 0.3.1 2009-03-04 01:54:07 +09:00
frsyuki
b8cc8b72bd version 0.3.1 2009-03-04 01:54:07 +09:00
frsyuki
840388720e more test caces 2009-03-04 01:36:56 +09:00
frsyuki
cc7379d532 more test caces 2009-03-04 01:36:56 +09:00
frsyuki
c612a177cc fix serialization bug on BigEndian environment 3 2009-03-04 01:15:22 +09:00
frsyuki
163fc6f589 fix serialization bug on BigEndian environment 3 2009-03-04 01:15:22 +09:00
frsyuki
44cdc5f976 fix serialization bug on BigEndian environment 2009-03-04 01:04:43 +09:00
frsyuki
c7f193e441 fix serialization bug on BigEndian environment 2009-03-04 01:04:43 +09:00
frsyuki
09978e500a update ruby/msgpack.gemspec 2009-03-01 18:32:50 +09:00
frsyuki
2fad10ca3f zone::base 2009-03-01 16:40:02 +09:00
frsyuki
e707b7a600 zone::push_finalizer reverts memory allocation on exception 2009-03-01 15:49:24 +09:00
frsyuki
e7403013e5 msgpack_zone: sizeof(int) bytes alignment 2009-03-01 14:59:13 +09:00
frsyuki
c3f9696268 fix packaging problem 2009-03-01 13:46:20 +09:00
frsyuki
cb24a0c24f fix msgpack_unpacker_expand_buffer 2009-03-01 03:39:34 +09:00
frsyuki
0efb8160b9 msgpack_zone_clear, msgpack::zone::clear 2009-03-01 02:55:45 +09:00
frsyuki
bf13ba72b5 fix unpacker 2009-03-01 02:27:04 +09:00
frsyuki
6fc38d1669 msgpack::pack is not obsolete 2009-03-01 01:31:12 +09:00
frsyuki
879c70f93a fix msgpack_sbuffer_release 2009-03-01 01:13:31 +09:00
frsyuki
6fda01111e msgpack::sbuffer::data() const 2009-03-01 01:06:16 +09:00
frsyuki
4f4fa39cd5 c: msgpack_sbuffer; cpp: msgpack::sbuffer 2009-03-01 00:59:15 +09:00
frsyuki (none)
c60b6be548 add NOTICE file 2009-02-26 18:37:13 +09:00
frsyuki (none)
9b4b49a6a8 example: limit message size 2009-02-26 01:33:34 +09:00
frsyuki (none)
c0baf9b873 add msgpack_unpacker_message_size 2009-02-26 01:27:00 +09:00
frsyuki (none)
65ef9cab66 remove msgpack_unpacker_buffered_size, add msgpack_unpacker_parsed_size 2009-02-26 01:15:14 +09:00
frsyuki (none)
6ffee9e54a c: msgpack_unpacker_buffered_size; c++: unpacker::buffered_size 2009-02-25 23:31:53 +09:00
frsyuki (none)
43360e3786 fix msgpack::unpack_return 2009-02-25 18:55:56 +09:00
frsyuki (none)
4d708aa4da c: msgpack_pack_object 2009-02-24 16:37:47 +09:00
frsyuki (none)
5d51129e65 add example/simple.c 2009-02-24 16:37:01 +09:00
frsyuki (none)
a0b82e39e1 AC_CONFIG_AUX_DIR(ac) 2009-02-22 15:47:06 +09:00
frsyuki (none)
9642368835 type conversion operator msgpack_object <-> msgpack::object 2009-02-22 15:36:02 +09:00
frsyuki (none)
cbf7afc1cc c and c++: rewritten and integrated 2009-02-22 15:14:21 +09:00
227 changed files with 48752 additions and 6782 deletions

51
.gitignore vendored Normal file
View File

@@ -0,0 +1,51 @@
# Files generated by the bootstrap script.
/INSTALL
/AUTHORS
/ChangeLog
/NEWS
/README
/ac/
/aclocal.m4
/autom4te.cache/
/config.h.in
/configure
/msgpack_vc2008.sln
/msgpack_vc2008.vcproj
Makefile.in
# Files generated by the configure script.
/config.h
/config.log
/config.status
/libtool
/msgpack.pc
/src/msgpack/version.h
/src/msgpack/version.hpp
/stamp-h1
Makefile
.deps
.libs
# Files generated by make.
*.o
*.so
*.lo
*.la
# Files generated by make check.
# TODO: Replace these with something like /test/*_test
/test/buffer
/test/cases
/test/convert
/test/fixint
/test/fixint_c
/test/msgpack_test
/test/msgpackc_test
/test/object
/test/pack_unpack
/test/pack_unpack_c
/test/streaming
/test/streaming_c
/test/version
/test/zone

34
.travis.yml Normal file
View File

@@ -0,0 +1,34 @@
language: cpp
cache:
- apt
compiler:
- clang
- gcc
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo add-apt-repository -y ppa:h-rayflood/llvm
- sudo apt-get update -qq
- sudo apt-get update
- sudo apt-get install valgrind
install:
- sudo apt-get install -qq gcc-4.8-multilib g++-4.8-multilib
- sudo apt-get install --allow-unauthenticated -qq clang-3.4
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
- sudo apt-get install -y lib32gcc1
- sudo apt-get install -y libc6-i386
- sudo apt-get install -y lib32z1-dev
- sudo apt-get install -y lib32stdc++6
- wget https://googletest.googlecode.com/files/gtest-1.7.0.zip
- unzip gtest-1.7.0.zip && cd gtest-1.7.0 && sudo cp -r include/gtest /usr/local/include && g++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && g++ -m32 src/gtest-all.cc -I. -Iinclude -c && g++ -m32 src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mkdir /usr/local/lib32 && sudo mv *.a /usr/local/lib32 && cd ..
env:
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib"
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32"
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib"
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32"
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib"
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32"
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib"
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32"
script:
- git clean -xdf && CMAKE_LIBRARY_PATH=${LIBPATH} ${ACTION} ${VERSION} ${ARCH}

View File

@@ -1 +0,0 @@
FURUHASHI Sadayuki <frsyuki _at_ users.sourceforge.jp>

72
CHANGELOG.md Normal file
View File

@@ -0,0 +1,72 @@
2014-07-02 version 0.5.9:
* Support std::tr1 unordered containers by default (#51, #63, #68, #69)
* Remove some warnings (#56)
* Fix segmentation fault after malloc failures (#58, #59)
* Fix alloc/dealloc mismatch (#52, #61)
* Fix sample codes (#60, #64)
* Support implicit conversion from integer to float/double (#54)
* Improve documents (#45, #75, #82, #83)
* Support CMake (#20, #87)
* Remove Ruby dependencies in bootstrap (#86, #87)
* Add FILE* buffer (#40)
* Other bug fixes and refactoring: #39, #73, #77, #79, #80, #81, #84, #90
2013-12-23 version 0.5.8:
* Move to the new github repository msgpack/msgpack-c
* Support the new deserialization specification
* fixes the problem of unpack helpers for array and map with 32bit compilers (#37, #38)
* Other bug fixes and refactoring: #46, #41, #36, #35, #33, #32, #30, #29, #28, #27, #26, #25, #8, #3
* Update of documents: #23, #18, #17
2011-08-08 version 0.5.7:
* fixes compile error problem with llvm-gcc and Mac OS X Lion
2011-04-24 version 0.5.6:
* #42 fixes double-free problem on msgpack_unpacker_release_zone
2011-02-24 version 0.5.5:
* eliminates dependency of winsock2.h header
* fixes msgpack_vc.postbuild.bat file
* fixes some implicit cast warnings
2010-08-29 version 0.5.4:
* includes msgpack_vc2008.vcproj file in source package
* fixes type::fix_int types
2010-08-27 version 0.5.3:
* adds type::fix_{u,}int{8,16,32,64} types
* adds msgpack_pack_fix_{u,}int{8,16,32,64} functions
* adds packer<Stream>::pack_fix_{u,}int{8,16,32,64} functions
* fixes include paths
2010-07-14 version 0.5.2:
* type::raw::str(), operator==, operator!=, operator< and operator> are now const
* generates version.h using AC_OUTPUT macro in ./configure
2010-07-06 version 0.5.1:
* Add msgpack_vrefbuffer_new and msgpack_vrefbuffer_free
* Add msgpack_sbuffer_new and msgpack_sbuffer_free
* Add msgpack_unpacker_next and msgpack_unpack_next
* msgpack::unpack returns void
* Add MSGPACK_VERSION{,_MAJOR,_MINOR} macros to check header version
* Add msgpack_version{,_major,_minor} functions to check library version
* ./configure supports --disable-cxx option not to build C++ API
2010-04-29 version 0.5.0:
* msgpack_object_type is changed. MSGPACK_OBJECT_NIL is now 0x00.
* New safe streaming deserializer API.
* Add object::object(const T&) and object::operator=(const T&)
* Add operator==(object, const T&)
* MSGPACK_DEFINE macro defines msgpack_object(object* obj, zone* z)
* C++ programs doesn't need to link "msgpackc" library.

265
CMakeLists.txt Normal file
View File

@@ -0,0 +1,265 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.6)
PROJECT (msgpack)
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/version_master.h contents)
STRING (REGEX MATCH "#define MSGPACK_VERSION_MAJOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents})
SET (VERSION_MAJOR ${CMAKE_MATCH_1})
STRING (REGEX MATCH "#define MSGPACK_VERSION_MINOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents})
SET (VERSION_MINOR ${CMAKE_MATCH_1})
STRING (REGEX MATCH "#define MSGPACK_VERSION_REVISION *([0-9a-zA-Z_]*)" NULL_OUT ${contents})
SET (VERSION_REVISION ${CMAKE_MATCH_1})
SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
SET (prefix ${CMAKE_INSTALL_PREFIX})
SET (exec_prefix "\${prefix}")
SET (libdir "\${exec_prefix}/lib")
SET (includedir "\${prefix}/include")
OPTION (MSGPACK_CXX11 "Using c++11 compiler" OFF)
OPTION (MSGPACK_32BIT "32bit compile" OFF)
IF (MSGPACK_CXX11)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++11 yet.")
ENDIF ()
ENDIF ()
IF (MSGPACK_32BIT)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}")
SET (CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
SET (CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET (CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}")
SET (CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
SET (CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}")
ENDIF ()
ENDIF ()
FIND_PACKAGE (GTest)
FIND_PACKAGE (ZLIB)
FIND_PACKAGE (Threads)
IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND)
OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." ON)
ENDIF ()
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES ("
#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
int main(int argc, char * argv[])
{
atomic_sub(1);
atomic_add(1);
}
" MSGPACK_ENABLE_GCC_CXX_ATOMIC)
IF (MSGPACK_ENABLE_GCC_CXX_ATOMIC)
LIST (APPEND msgpack_SOURCES
src/gcc_atomic.cpp
)
ENDIF ()
LIST (APPEND msgpack_SOURCES
src/unpack.c
src/objectc.c
src/version.c
src/vrefbuffer.c
src/zone.c
)
LIST (APPEND msgpack_HEADERS
include/msgpack/pack_define.h
include/msgpack/pack_template.h
include/msgpack/unpack_define.h
include/msgpack/unpack_template.h
include/msgpack/util.h
include/msgpack/sysdep.h
include/msgpack/gcc_atomic.h
include/msgpack/sbuffer.h
include/msgpack/version.h
include/msgpack/vrefbuffer.h
include/msgpack/zbuffer.h
include/msgpack/fbuffer.h
include/msgpack/pack.h
include/msgpack/unpack.h
include/msgpack/object.h
include/msgpack/zone.h
)
IF (MSGPACK_ENABLE_CXX)
LIST (APPEND msgpack_HEADERS
include/msgpack.hpp
include/msgpack_fwd.hpp
include/msgpack/adaptor/bool.hpp
include/msgpack/adaptor/bool_fwd.hpp
include/msgpack/adaptor/char_ptr.hpp
include/msgpack/adaptor/char_ptr_fwd.hpp
include/msgpack/adaptor/check_container_size.hpp
include/msgpack/adaptor/cpp11/array.hpp
include/msgpack/adaptor/cpp11/array_fwd.hpp
include/msgpack/adaptor/cpp11/array_char.hpp
include/msgpack/adaptor/cpp11/array_char_fwd.hpp
include/msgpack/adaptor/cpp11/forward_list.hpp
include/msgpack/adaptor/cpp11/forward_list_fwd.hpp
include/msgpack/adaptor/cpp11/tuple.hpp
include/msgpack/adaptor/cpp11/tuple_fwd.hpp
include/msgpack/adaptor/cpp11/unordered_map.hpp
include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp
include/msgpack/adaptor/cpp11/unordered_set.hpp
include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp
include/msgpack/adaptor/define.hpp
include/msgpack/adaptor/deque.hpp
include/msgpack/adaptor/deque_fwd.hpp
include/msgpack/adaptor/detail/cpp03_define.hpp
include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp
include/msgpack/adaptor/detail/cpp03_msgpack_tuple_fwd.hpp
include/msgpack/adaptor/detail/cpp11_define.hpp
include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp
include/msgpack/adaptor/detail/cpp11_msgpack_tuple_fwd.hpp
include/msgpack/adaptor/fixint.hpp
include/msgpack/adaptor/fixint_fwd.hpp
include/msgpack/adaptor/float.hpp
include/msgpack/adaptor/float_fwd.hpp
include/msgpack/adaptor/int.hpp
include/msgpack/adaptor/int_fwd.hpp
include/msgpack/adaptor/list.hpp
include/msgpack/adaptor/list_fwd.hpp
include/msgpack/adaptor/map.hpp
include/msgpack/adaptor/map_fwd.hpp
include/msgpack/adaptor/msgpack_tuple.hpp
include/msgpack/adaptor/msgpack_tuple_fwd.hpp
include/msgpack/adaptor/nil.hpp
include/msgpack/adaptor/nil_fwd.hpp
include/msgpack/adaptor/pair.hpp
include/msgpack/adaptor/pair_fwd.hpp
include/msgpack/adaptor/raw.hpp
include/msgpack/adaptor/raw_fwd.hpp
include/msgpack/adaptor/set.hpp
include/msgpack/adaptor/set_fwd.hpp
include/msgpack/adaptor/string.hpp
include/msgpack/adaptor/string_fwd.hpp
include/msgpack/adaptor/tr1/unordered_map.hpp
include/msgpack/adaptor/tr1/unordered_map_fwd.hpp
include/msgpack/adaptor/tr1/unordered_set.hpp
include/msgpack/adaptor/tr1/unordered_set_fwd.hpp
include/msgpack/adaptor/vector.hpp
include/msgpack/adaptor/vector_fwd.hpp
include/msgpack/adaptor/vector_bool.hpp
include/msgpack/adaptor/vector_bool_fwd.hpp
include/msgpack/adaptor/vector_char.hpp
include/msgpack/adaptor/vector_char_fwd.hpp
include/msgpack/cpp_config.hpp
include/msgpack/detail/cpp03_zone.hpp
include/msgpack/detail/cpp11_zone.hpp
include/msgpack/fbuffer.hpp
include/msgpack/object.hpp
include/msgpack/object_fwd.hpp
include/msgpack/pack.hpp
include/msgpack/sbuffer.hpp
include/msgpack/type.hpp
include/msgpack/unpack.hpp
include/msgpack/version.hpp
include/msgpack/versioning.hpp
include/msgpack/vrefbuffer.hpp
include/msgpack/zbuffer.hpp
include/msgpack/zone.hpp
)
ENDIF ()
EXECUTE_PROCESS (
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/src/msgpack
)
CONFIGURE_FILE (
msgpack.pc.in
msgpack.pc
@ONLY
)
INCLUDE_DIRECTORIES (
./
include/
${CMAKE_CURRENT_BINARY_DIR}/include/
)
ADD_LIBRARY (msgpack SHARED
${msgpack_SOURCES}
${msgpack_HEADERS}
)
ADD_LIBRARY (msgpack-static STATIC
${msgpack_SOURCES}
${msgpack_HEADERS}
)
SET_TARGET_PROPERTIES (msgpack-static PROPERTIES OUTPUT_NAME "msgpack")
SET_TARGET_PROPERTIES (msgpack PROPERTIES IMPORT_SUFFIX "_import.lib")
SET_TARGET_PROPERTIES (msgpack PROPERTIES SOVERSION 3 VERSION 4.0.0)
IF (MSGPACK_BUILD_TESTS)
ENABLE_TESTING ()
SET(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind")
INCLUDE(Dart)
SET(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --error-exitcode=1")
ADD_SUBDIRECTORY (test)
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET msgpack APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -g -O3 -DPIC")
SET_PROPERTY (TARGET msgpack-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -g -O3" )
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10")
SET_SOURCE_FILES_PROPERTIES(${msgpack_SOURCES} PROPERTIES LANGUAGE CXX)
ENDIF()
IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR lib)
ENDIF ()
INSTALL (TARGETS msgpack msgpack-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Doxygen
FIND_PACKAGE (Doxygen)
IF (DOXYGEN_FOUND)
ADD_CUSTOM_TARGET (
doxygen_c
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.h" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_c" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
VERBATIM
)
ADD_CUSTOM_TARGET (
doxygen_cpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.hpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C++\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
VERBATIM
)
ADD_CUSTOM_TARGET (
doxygen
DEPENDS doxygen_c doxygen_cpp
)
ENDIF ()

View File

@@ -1,4 +1,4 @@
Copyright (C) 2008-2009 FURUHASHI Sadayuki
Copyright (C) 2008-2010 FURUHASHI Sadayuki
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

38
CROSSLANG.md Normal file
View File

@@ -0,0 +1,38 @@
MessagePack cross-language test cases
=====================================
## cases
Valid serialized data are stored in "cases.mpac" and "cases_compact.mpac".
These files describe same objects. And "cases.json" describes an array of the described objects.
Thus you can verify your implementations as comparing the objects.
## crosslang
The *crosslang* tool reads serialized data from stdin and writes re-serialize data to stdout.
There are C++ and Ruby implementation of crosslang tool. You can verify your implementation
as comparing that implementations.
### C++ version
$ cd ../cpp && ./configure && make && make install
or
$ port install msgpack # MacPorts
$ g++ -Wall crosslang.cc -lmsgpack -o crosslang
$ ./crosslang
Usage: ./crosslang [in-file] [out-file]
### Ruby version
$ gem install msgpack
or
$ port install rb_msgpack # MacPorts
$ ruby crosslang.rb
Usage: crosslang.rb [in-file] [out-file]

View File

1552
Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,21 @@
if ENABLE_CXX
export ERB
SUBDIRS = c cpp
else
SUBDIRS = c
endif
SUBDIRS = src test
nobase_include_HEADERS = \
msgpack/pack_define.h \
msgpack/pack_template.h \
msgpack/unpack_define.h \
msgpack/unpack_template.h
DOC_FILES = \
README.md \
LICENSE \
NOTICE \
msgpack_vc8.vcproj \
msgpack_vc8.sln \
msgpack_vc.postbuild.bat
EXTRA_DIST = \
ruby/bench.rb \
ruby/extconf.rb \
ruby/gem/README \
ruby/gem/Rakefile \
ruby/gem/test/test_helper.rb \
ruby/gengem.sh \
ruby/msgpack.gemspec \
ruby/pack.c \
ruby/pack.h \
ruby/rbinit.c \
ruby/test_case.rb \
ruby/test_format.rb \
ruby/test_pack.rb \
ruby/unpack.c \
ruby/unpack.h
$(DOC_FILES) CMakeLists.txt test/CMakeLists.txt
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = msgpack.pc
doxygen:
./preprocess clean
cd src && $(MAKE) doxygen
./preprocess

0
NEWS
View File

4
NOTICE
View File

@@ -1,4 +0,0 @@
MessagePack is developed by FURUHASHI Sadayuki, licensed under Apache License,
Version 2.0. The original software and related information is available at
http://msgpack.sourceforge.jp/.

194
QUICKSTART-C.md Normal file
View File

@@ -0,0 +1,194 @@
# Implementation Status
The serialization library is production-ready.
Currently, no RPC implementation is not available.
# Install
## Mac OS X with MacPorts
On Mac OS X, you can install MessagePack for C using MacPorts.
```
$ sudo port install msgpack
```
You might need to run `sudo port selfupdate` before installing to update the package repository.
You can also install via Homebrew.
```
$ sudo brew install msgpack
```
## FreeBSD with Ports Collection
On FreeBSD, you can use Ports Collection. Install [net/msgpack|http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/msgpack/] package.
## Gentoo Linux with Portage
On Gentoo Linux, you can use emerge. Install [dev-libs/msgpack|http://gentoo-portage.com/dev-libs/msgpack] package.
## Other UNIX-like platform with ./configure
On the other UNIX-like platforms, download source package from [Releases|http://msgpack.org/releases/cpp/] and run `./configure && make && make install`.
```
$ wget http://msgpack.org/releases/cpp/msgpack-0.5.5.tar.gz
$ tar zxvf msgpack-0.5.5.tar.gz
$ cd msgpack-0.5.5
$ ./configure
$ make
$ sudo make install
```
## Windows
On Windows, download source package from [here|https://sourceforge.net/projects/msgpack/files/] and extract it.
Then open `msgpack_vc8.vcproj` file and build it using batch build. It builds libraries on `lib/` folder and header files on `include/` folder.
You can build using command line as follows:
```
> vcbuild msgpack_vc2008.vcproj
> dir lib % DLL files are here
> dir include % header files are here
```
## Install from git repository
You need to install gcc (4.1.0 or higher), autotools.
```
$ git clone git@github.com:msgpack/msgpack.git
$ cd msgpack/cpp
$ ./bootstrap
$ ./configure
$ make
$ sudo make install
```
# Serialization QuickStart for C
## First program
Include `msgpack.h` header and link `msgpack` library to use MessagePack on your program.
```c
#include <msgpack.h>
#include <stdio.h>
int main(void) {
/* creates buffer and serializer instance. */
msgpack_sbuffer* buffer = msgpack_sbuffer_new();
msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
/* serializes ["Hello", "MessagePack"]. */
msgpack_pack_array(pk, 2);
msgpack_pack_raw(pk, 5);
msgpack_pack_raw_body(pk, "Hello", 5);
msgpack_pack_raw(pk, 11);
msgpack_pack_raw_body(pk, "MessagePack", 11);
/* deserializes it. */
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);
bool success = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
/* prints the deserialized object. */
msgpack_object obj = msg.data;
msgpack_object_print(stdout, obj); /*=> ["Hello", "MessagePack"] */
/* cleaning */
msgpack_sbuffer_free(buffer);
msgpack_packer_free(pk);
}
```
## Simple program with a loop
```c
#include <msgpack.h>
#include <stdio.h>
int main(void) {
/* creates buffer and serializer instance. */
msgpack_sbuffer* buffer = msgpack_sbuffer_new();
msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
int j;
for(j = 0; j<23; j++) {
/* NB: the buffer needs to be cleared on each iteration */
msgpack_sbuffer_clear(buffer);
/* serializes ["Hello", "MessagePack"]. */
msgpack_pack_array(pk, 3);
msgpack_pack_raw(pk, 5);
msgpack_pack_raw_body(pk, "Hello", 5);
msgpack_pack_raw(pk, 11);
msgpack_pack_raw_body(pk, "MessagePack", 11);
msgpack_pack_int(pk, j);
/* deserializes it. */
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);
bool success = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
/* prints the deserialized object. */
msgpack_object obj = msg.data;
msgpack_object_print(stdout, obj); /*=> ["Hello", "MessagePack"] */
puts("");
}
/* cleaning */
msgpack_sbuffer_free(buffer);
msgpack_packer_free(pk);
}
```
## Streaming feature
```c
#include <msgpack.h>
#include <stdio.h>
int main(void) {
/* serializes multiple objects using msgpack_packer. */
msgpack_sbuffer* buffer = msgpack_sbuffer_new();
msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
msgpack_pack_int(pk, 1);
msgpack_pack_int(pk, 2);
msgpack_pack_int(pk, 3);
/* deserializes these objects using msgpack_unpacker. */
msgpack_unpacker pac;
msgpack_unpacker_init(&pac, MSGPACK_UNPACKER_INIT_BUFFER_SIZE);
/* feeds the buffer. */
msgpack_unpacker_reserve_buffer(&pac, buffer->size);
memcpy(msgpack_unpacker_buffer(&pac), buffer->data, buffer->size);
msgpack_unpacker_buffer_consumed(&pac, buffer->size);
/* now starts streaming deserialization. */
msgpack_unpacked result;
msgpack_unpacked_init(&result);
while(msgpack_unpacker_next(&pac, &result)) {
msgpack_object_print(stdout, result.data);
puts("");
}
/* results:
* $ gcc stream.cc -lmsgpack -o stream
* $ ./stream
* 1
* 2
* 3
*/
}
```

159
QUICKSTART-CPP.md Normal file
View File

@@ -0,0 +1,159 @@
# Implementation Status
The serialization library is production-ready.
Currently, RPC implementation is testing phase. Requires newer kernel, not running on RHEL5/CentOS5.
# Install
Same as QuickStart for C Language.
# Serialization QuickStart for C+\+
## First program
Include `msgpack.hpp` header and link `msgpack` library to use MessagePack on your program.
```cpp
#include <msgpack.hpp>
#include <vector>
#include <string>
#include <iostream>
int main(void) {
// serializes this object.
std::vector<std::string> vec;
vec.push_back("Hello");
vec.push_back("MessagePack");
// serialize it into simple buffer.
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, vec);
// deserialize it.
msgpack::unpacked msg;
msgpack::unpack(&msg, sbuf.data(), sbuf.size());
// print the deserialized object.
msgpack::object obj = msg.get();
std::cout << obj << std::endl; //=> ["Hello", "MessagePack"]
// convert it into statically typed object.
std::vector<std::string> rvec;
obj.convert(&rvec);
}
```
Compile it as follows:
```
$ g++ hello.cc -lmsgpack -o hello
$ ./hello
["Hello", "MessagePack"]
```
## Streaming feature
```cpp
#include <msgpack.hpp>
#include <iostream>
#include <string>
int main(void) {
// serializes multiple objects using msgpack::packer.
msgpack::sbuffer buffer;
msgpack::packer<msgpack::sbuffer> pk(&buffer);
pk.pack(std::string("Log message ... 1"));
pk.pack(std::string("Log message ... 2"));
pk.pack(std::string("Log message ... 3"));
// deserializes these objects using msgpack::unpacker.
msgpack::unpacker pac;
// feeds the buffer.
pac.reserve_buffer(buffer.size());
memcpy(pac.buffer(), buffer.data(), buffer.size());
pac.buffer_consumed(buffer.size());
// now starts streaming deserialization.
msgpack::unpacked result;
while(pac.next(&result)) {
std::cout << result.get() << std::endl;
}
// results:
// $ g++ stream.cc -lmsgpack -o stream
// $ ./stream
// "Log message ... 1"
// "Log message ... 2"
// "Log message ... 3"
}
```
### Streaming into an array or map
```cpp
#include <msgpack.hpp>
#include <iostream>
#include <string>
int main(void) {
// serializes multiple objects into one message containing an array using msgpack::packer.
msgpack::sbuffer buffer;
msgpack::packer<msgpack::sbuffer> pk(&buffer);
pk.pack_array(3);
pk.pack(std::string("Log message ... 1"));
pk.pack(std::string("Log message ... 2"));
pk.pack(std::string("Log message ... 3"));
// serializes multiple objects into one message containing a map using msgpack::packer.
msgpack::sbuffer buffer2;
msgpack::packer<msgpack::sbuffer> pk2(&buffer2);
pk2.pack_map(2);
pk2.pack(std::string("x"));
pk2.pack(3);
pk2.pack(std::string("y"));
pk2.pack(3.4321);
}
```
## User-defined classes
You can use serialize/deserializes user-defined classes using `MSGPACK_DEFINE` macro.
```cpp
#include <msgpack.hpp>
#include <vector>
#include <string>
class myclass {
private:
std::string m_str;
std::vector<int> m_vec;
public:
MSGPACK_DEFINE(m_str, m_vec);
};
int main(void) {
std::vector<myclass> vec;
// add some elements into vec...
// you can serialize myclass directly
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, vec);
msgpack::unpacked msg;
msgpack::unpack(&msg, sbuf.data(), sbuf.size());
msgpack::object obj = msg.get();
// you can convert object to myclass directly
std::vector<myclass> rvec;
obj.convert(&rvec);
}
```

72
README
View File

@@ -1,72 +0,0 @@
MessagePack
-----------
Binary-based efficient data interchange format.
*Requirements
MessagePack is only tested on Linux and Mac OS X, but it may run on other
UNIX-like platforms.
Following programs is required to build:
- gcc >= 4.1 with C++ support
- ruby >= 1.8 (ruby is used as a preprocessor)
*Installation
Simply run ./configure && make && make install to install C and C++ binding.
$ ./configure
$ make
$ sudo make install
To install Ruby binding, run ./gengem.sh script on ruby/ directory and install
generated gem package.
$ cd ruby
$ ./gengem.sh
$ gem install gem/pkg/msgpack-*.gem
*Usage
C++:
include msgpack.hpp header and link libmsgpack library.
see example/simple.cc for example.
g++ simple.cc -lmsgpack
g++ stream.cc -lmsgpack -lpthread
C:
include msgpack.h header and link libmsgpackc library.
see example/simple.c for example.
gcc simple.c -lmsgpackc
Ruby:
require msgpack library.
see example/simple.rb for example.
ruby -rubygems simple.rb
API Document is available at http://msgpack.sourceforge.jp/.
Copyright (C) 2008-2009 FURUHASHI Sadayuki
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

219
README.md Normal file
View File

@@ -0,0 +1,219 @@
`msgpack` for C/C++
===================
Version 1.0.0 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c)
It's like JSON but small and fast.
Overview
--------
[MessagePack](http://msgpack.org/) is an efficient binary serialization
format, which lets you exchange data among multiple languages like JSON,
except that it's faster and smaller. Small integers are encoded into a
single byte while typical short strings require only one extra byte in
addition to the strings themselves.
Example
-------
In C:
```c
#include <msgpack.h>
#include <stdio.h>
int main(void)
{
/* msgpack::sbuffer is a simple buffer implementation. */
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
msgpack_packer pk;
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone mempool;
msgpack_zone_init(&mempool, 2048);
msgpack_object deserialized;
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
/* print the deserialized object. */
msgpack_object_print(stdout, deserialized);
puts("");
msgpack_zone_destroy(&mempool);
msgpack_sbuffer_destroy(&sbuf);
return 0;
}
```
See [`QUICKSTART-C.md`](./QUICKSTART-C.md) for more details.
In C++:
```c++
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
int main(void)
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);
// send the buffer ...
buffer.seekg(0);
// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());
msgpack::unpacked result;
msgpack::unpack(result, str.data(), str.size());
// deserialized object is valid during the msgpack::unpacked instance alive.
msgpack::object deserialized = result.get();
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(&dst);
return 0;
}
```
See [`QUICKSTART-CPP.md`](./QUICKSTART-CPP.md) for more details.
Usage
-----
### C++ Header Only Library
When you use msgpack on C++03 and C++11, you can just add
msgpack-c/include to your include path:
g++ -I msgpack-c/include your_source_file.cpp
If you want to use C version of msgpack, you need to build it. You can
also install the C and C++ versions of msgpack.
### Building and Installing
#### Install from git repository
##### Using autotools
You will need:
- `gcc >= 4.1.0` or `clang >= 3.3.0`
- `autoconf >= 2.60`
- `automake >= 1.10`
- `libtool >= 2.2.4`
The build steps below are for C and C++03. If compiling for C++11,
add `-std=c++11` to the environmental variable `CXXFLAGS` with
`export CXXFLAGS="$CXXFLAGS -std=c++11"` prior to following the
directions below.
```bash
$ git clone https://github.com/msgpack/msgpack-c
$ cd msgpack-c
$ ./bootstrap
$ ./configure
$ make
```
You can install the resulting library like this:
```bash
$ sudo make install
```
##### Using cmake
###### Using the Terminal (CLI)
You will need:
- `gcc >= 4.1.0`
- `cmake >= 2.8.0`
C and C++03:
$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake .
$ make
$ sudo make install
If you want to setup C++11 version of msgpack instead,
execute the following commands:
$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake -DMSGPACK_CXX11=ON .
$ sudo make install
##### GUI on Windows
Clone msgpack-c git repository.
$ git clone https://github.com/msgpack/msgpack-c.git
or using GUI git client.
e.g.) tortoise git https://code.google.com/p/tortoisegit/
1. Launch [cmake GUI client](http://www.cmake.org/cmake/resources/software.html).
2. Set 'Where is the source code:' text box and 'Where to build
the binaries:' text box.
3. Click 'Configure' button.
4. Choose your Visual Studio version.
5. Click 'Generate' button.
6. Open the created msgpack.sln on Visual Studio.
7. Build all.
### Documentation
You can get addtional information on the
[wiki](https://github.com/msgpack/msgpack-c/wiki/cpp_overview).
Contributing
------------
`msgpack-c` is developed on GitHub at [msgpack/msgpack-c](https://github.com/msgpack/msgpack-c).
To report an issue or send a pull request, use the
[issue tracker](https://github.com/msgpack/msgpack-c/issues).
Here's the list of [great contributors](https://github.com/msgpack/msgpack-c/graphs/contributors).
License
-------
`msgpack-c` is licensed under the Apache License Version 2.0. See
the [`LICENSE`](./LICENSE) file for details.

View File

@@ -31,12 +31,13 @@ if test x"$1" = x"--help"; then
fi
#if [ -z "$NO_NEST" ];then
# cd c && ./bootstrap $@; cd ..
# cd cpp && ./bootstrap $@; cd ..
#fi
mkdir -p ac
test -f AUTHORS || touch AUTHORS
test -f COPYING || touch COPYING
test -f ChangeLog || touch ChangeLog
test -f NEWS || touch NEWS
test -f NOTICE || touch NOTICE
test -f README || cp -f README.md README
ACLOCAL="aclocal"
ACLOCAL_FILES="aclocal.m4"

View File

@@ -1,18 +0,0 @@
lib_LTLIBRARIES = libmsgpackc.la
libmsgpackc_la_SOURCES = \
unpack.c \
object.c \
zone.c
nobase_include_HEADERS = \
msgpack.h \
msgpack/sbuffer.h \
msgpack/pack.h \
msgpack/unpack.h \
msgpack/object.h \
msgpack/zone.h
# -version-info CURRENT:REVISION:AGE
libmsgpackc_la_LDFLAGS = -version-info 1:0:0

323
c/bench.c
View File

@@ -1,323 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <msgpack/pack.h>
#include <msgpack/unpack.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_gen.h>
static struct timeval g_timer;
void reset_timer()
{
gettimeofday(&g_timer, NULL);
}
void show_timer(size_t bufsz)
{
struct timeval endtime;
gettimeofday(&endtime, NULL);
double sec = (endtime.tv_sec - g_timer.tv_sec)
+ (double)(endtime.tv_usec - g_timer.tv_usec) / 1000 / 1000;
printf("%f sec\n", sec);
printf("%f MB\n", ((double)bufsz)/1024/1024);
printf("%f Mbps\n", ((double)bufsz)*8/sec/1000/1000);
}
static int reformat_null(void * ctx) { return 1; }
static int reformat_boolean(void * ctx, int boolean) { return 1; }
static int reformat_number(void * ctx, const char * s, unsigned int l) { return 1; }
static int reformat_string(void * ctx, const unsigned char * stringVal, unsigned int stringLen) { return 1; }
static int reformat_map_key(void * ctx, const unsigned char * stringVal, unsigned int stringLen) { return 1; }
static int reformat_start_map(void * ctx) { return 1; }
static int reformat_end_map(void * ctx) { return 1; }
static int reformat_start_array(void * ctx) { return 1; }
static int reformat_end_array(void * ctx) { return 1; }
static void* unpack_uint8(void* data, uint8_t d) { return NULL; }
static void* unpack_uint16(void* data, uint16_t d) { return NULL; }
static void* unpack_uint32(void* data, uint32_t d) { return NULL; }
static void* unpack_uint64(void* data, uint64_t d) { return NULL; }
static void* unpack_int8(void* data, int8_t d) { return NULL; }
static void* unpack_int16(void* data, int16_t d) { return NULL; }
static void* unpack_int32(void* data, int32_t d) { return NULL; }
static void* unpack_int64(void* data, int64_t d) { return NULL; }
static void* unpack_float(void* data, float d) { return NULL; }
static void* unpack_double(void* data, double d) { return NULL; }
static void* unpack_nil(void* data) { return NULL; }
static void* unpack_true(void* data) { return NULL; }
static void* unpack_false(void* data) { return NULL; }
static void* unpack_array(void* data, unsigned int n) { return NULL; }
static void unpack_array_item(void* data, void* c, void* o) { }
static void* unpack_map(void* data, unsigned int n) { return NULL; }
static void unpack_map_item(void* data, void* c, void* k, void* v) { }
static void* unpack_raw(void* data, const char* b, const char* p, unsigned int l) { /*printf("unpack raw %p %lu\n",p,l);*/ return NULL; }
typedef struct {
size_t allocated;
size_t length;
char* buffer;
} pack_buffer;
static const size_t PACK_INITIAL_BUFFER_SIZE = 32*1024;
static void pack_buffer_init(pack_buffer* data)
{
data->buffer = malloc(PACK_INITIAL_BUFFER_SIZE);
data->length = 0;
data->allocated = PACK_INITIAL_BUFFER_SIZE;
}
static void pack_buffer_reset(pack_buffer* data)
{
data->buffer = realloc(data->buffer, PACK_INITIAL_BUFFER_SIZE);
data->allocated = PACK_INITIAL_BUFFER_SIZE;
data->length = 0;
}
static void pack_buffer_free(pack_buffer* data)
{
free(data->buffer);
}
static void pack_append_buffer(void* user, const char* b, unsigned int l)
{
pack_buffer* data = (pack_buffer*)user;
if(data->allocated - data->length < l) {
data->buffer = realloc(data->buffer, data->allocated*2);
data->allocated *= 2;
}
memcpy(data->buffer + data->length, b, l);
data->length += l;
}
static const unsigned int TASK_INT_NUM = 1<<24;
static const unsigned int TASK_STR_LEN = 1<<15;
//static const unsigned int TASK_INT_NUM = 1<<20;
//static const unsigned int TASK_STR_LEN = 1<<12;
static const char* TASK_STR_PTR;
void bench_json(void)
{
puts("== JSON ==");
yajl_gen_config gcfg = {0, NULL};
yajl_gen g = yajl_gen_alloc(&gcfg);
yajl_parser_config hcfg = { 0, 0 };
yajl_callbacks callbacks = {
reformat_null,
reformat_boolean,
NULL,
NULL,
reformat_number,
reformat_string,
reformat_start_map,
reformat_map_key,
reformat_end_map,
reformat_start_array,
reformat_end_array
};
yajl_handle h = yajl_alloc(&callbacks, &hcfg, NULL);
const unsigned char * buf;
unsigned int len;
puts("generate integer");
reset_timer();
{
unsigned int i;
yajl_gen_array_open(g);
for(i=0; i < TASK_INT_NUM; ++i) {
yajl_gen_integer(g, i);
}
yajl_gen_array_close(g);
}
show_timer(len);
yajl_gen_get_buf(g, &buf, &len);
puts("----");
puts("parse integer");
reset_timer();
{
yajl_status stat = yajl_parse(h, buf, len);
if (stat != yajl_status_ok && stat != yajl_status_insufficient_data) {
unsigned char * str = yajl_get_error(h, 1, buf, len);
fprintf(stderr, (const char *) str);
}
}
show_timer(len);
//yajl_gen_clear(g);
yajl_gen_free(g);
g = yajl_gen_alloc(&gcfg);
yajl_free(h);
h = yajl_alloc(&callbacks, &hcfg, NULL);
puts("----");
puts("generate string");
reset_timer();
{
unsigned int i;
yajl_gen_array_open(g);
for(i=0; i < TASK_STR_LEN; ++i) {
yajl_gen_string(g, (const unsigned char*)TASK_STR_PTR, i);
}
yajl_gen_array_close(g);
}
show_timer(len);
yajl_gen_get_buf(g, &buf, &len);
puts("----");
puts("parse string");
reset_timer();
{
yajl_status stat = yajl_parse(h, buf, len);
if (stat != yajl_status_ok && stat != yajl_status_insufficient_data) {
unsigned char * str = yajl_get_error(h, 1, buf, len);
fprintf(stderr, (const char *) str);
}
}
show_timer(len);
yajl_gen_free(g);
yajl_free(h);
}
void bench_msgpack(void)
{
puts("== MessagePack ==");
pack_buffer mpkbuf;
pack_buffer_init(&mpkbuf);
msgpack_pack_t* mpk = msgpack_pack_new(
&mpkbuf, pack_append_buffer);
msgpack_unpack_callback cb = {
unpack_uint8,
unpack_uint16,
unpack_uint32,
unpack_uint64,
unpack_int8,
unpack_int16,
unpack_int32,
unpack_int64,
unpack_float,
unpack_double,
unpack_nil,
unpack_true,
unpack_false,
unpack_array,
unpack_array_item,
unpack_map,
unpack_map_item,
unpack_raw,
};
msgpack_unpack_t* mupk = msgpack_unpack_new(NULL, &cb);
size_t len;
const char* buf;
puts("pack integer");
reset_timer();
{
unsigned int i;
msgpack_pack_array(mpk, TASK_INT_NUM);
for(i=0; i < TASK_INT_NUM; ++i) {
msgpack_pack_unsigned_int(mpk, i);
}
}
show_timer(mpkbuf.length);
len = mpkbuf.length;
buf = mpkbuf.buffer;
puts("----");
puts("unpack integer");
reset_timer();
{
size_t off = 0;
int ret = msgpack_unpack_execute(mupk, buf, len, &off);
if(ret < 0) {
fprintf(stderr, "Parse error.\n");
} else if(ret == 0) {
fprintf(stderr, "Not finished.\n");
}
}
show_timer(mpkbuf.length);
pack_buffer_reset(&mpkbuf);
msgpack_unpack_reset(mupk);
puts("----");
puts("pack string");
reset_timer();
{
unsigned int i;
msgpack_pack_array(mpk, TASK_STR_LEN);
for(i=0; i < TASK_STR_LEN; ++i) {
msgpack_pack_raw(mpk, i);
msgpack_pack_raw_body(mpk, TASK_STR_PTR, i);
}
}
show_timer(mpkbuf.length);
len = mpkbuf.length;
buf = mpkbuf.buffer;
puts("----");
puts("unpack string");
reset_timer();
{
size_t off = 0;
int ret = msgpack_unpack_execute(mupk, buf, len, &off);
if(ret < 0) {
fprintf(stderr, "Parse error.\n");
} else if(ret == 0) {
fprintf(stderr, "Not finished.\n");
}
}
show_timer(mpkbuf.length);
msgpack_unpack_free(mupk);
msgpack_pack_free(mpk);
pack_buffer_free(&mpkbuf);
}
int main(int argc, char* argv[])
{
char* str = malloc(TASK_STR_LEN);
memset(str, 'a', TASK_STR_LEN);
TASK_STR_PTR = str;
bench_msgpack();
bench_json();
return 0;
}

View File

@@ -1,9 +0,0 @@
CFLAGS += -Wall -g -I. -I.. -O4
LDFLAGS += -lyajl
all: bench
bench: bench.o pack.o unpack.o pack.h unpack.h
$(CC) bench.o pack.o unpack.o $(CFLAGS) $(LDFLAGS) -o $@

View File

@@ -1 +0,0 @@
.

View File

@@ -1,161 +0,0 @@
/*
* MessagePack for C dynamic typing routine
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "msgpack/object.h"
#include "msgpack/pack.h"
#include <stdio.h>
#include <inttypes.h>
int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
{
switch(d.type) {
case MSGPACK_OBJECT_NIL:
return msgpack_pack_nil(pk);
case MSGPACK_OBJECT_BOOLEAN:
if(d.via.boolean) {
return msgpack_pack_true(pk);
} else {
return msgpack_pack_false(pk);
}
case MSGPACK_OBJECT_POSITIVE_INTEGER:
return msgpack_pack_uint64(pk, d.via.u64);
case MSGPACK_OBJECT_NEGATIVE_INTEGER:
return msgpack_pack_int64(pk, d.via.i64);
case MSGPACK_OBJECT_DOUBLE:
return msgpack_pack_double(pk, d.via.dec);
case MSGPACK_OBJECT_RAW:
{
int ret = msgpack_pack_raw(pk, d.via.raw.size);
if(ret < 0) { return ret; }
return msgpack_pack_raw_body(pk, d.via.raw.ptr, d.via.raw.size);
}
case MSGPACK_OBJECT_ARRAY:
{
int ret = msgpack_pack_array(pk, d.via.array.size);
if(ret < 0) { return ret; }
msgpack_object* o = d.via.array.ptr;
msgpack_object* const oend = d.via.array.ptr + d.via.array.size;
for(; o != oend; ++o) {
ret = msgpack_pack_object(pk, *o);
if(ret < 0) { return ret; }
}
return 0;
}
case MSGPACK_OBJECT_MAP:
{
int ret = msgpack_pack_map(pk, d.via.map.size);
if(ret < 0) { return ret; }
msgpack_object_kv* kv = d.via.map.ptr;
msgpack_object_kv* const kvend = d.via.map.ptr + d.via.map.size;
for(; kv != kvend; ++kv) {
ret = msgpack_pack_object(pk, kv->key);
if(ret < 0) { return ret; }
ret = msgpack_pack_object(pk, kv->val);
if(ret < 0) { return ret; }
}
return 0;
}
default:
return -1;
}
}
void msgpack_object_print(FILE* out, msgpack_object o)
{
switch(o.type) {
case MSGPACK_OBJECT_NIL:
fprintf(out, "nil");
break;
case MSGPACK_OBJECT_BOOLEAN:
fprintf(out, (o.via.boolean ? "true" : "false"));
break;
case MSGPACK_OBJECT_POSITIVE_INTEGER:
fprintf(out, "%"PRIu64, o.via.u64);
break;
case MSGPACK_OBJECT_NEGATIVE_INTEGER:
fprintf(out, "%"PRIi64, o.via.i64);
break;
case MSGPACK_OBJECT_DOUBLE:
fprintf(out, "%f", o.via.dec);
break;
case MSGPACK_OBJECT_RAW:
fprintf(out, "\"");
fwrite(o.via.raw.ptr, o.via.raw.size, 1, out);
fprintf(out, "\"");
break;
case MSGPACK_OBJECT_ARRAY:
fprintf(out, "[");
if(o.via.array.size != 0) {
msgpack_object* p = o.via.array.ptr;
msgpack_object_print(out, *p);
++p;
msgpack_object* const pend = o.via.array.ptr + o.via.array.size;
for(; p < pend; ++p) {
fprintf(out, ", ");
msgpack_object_print(out, *p);
}
}
fprintf(out, "]");
break;
// FIXME loop optimiziation
case MSGPACK_OBJECT_MAP:
fprintf(out, "{");
if(o.via.map.size != 0) {
msgpack_object_kv* p = o.via.map.ptr;
msgpack_object_print(out, p->key);
fprintf(out, "=>");
msgpack_object_print(out, p->val);
++p;
msgpack_object_kv* const pend = o.via.map.ptr + o.via.map.size;
for(; p < pend; ++p) {
fprintf(out, ", ");
msgpack_object_print(out, p->key);
fprintf(out, "=>");
msgpack_object_print(out, p->val);
}
}
fprintf(out, "}");
break;
// FIXME loop optimiziation
default:
// FIXME
fprintf(out, "#<UNKNOWN %hu %"PRIu64">", o.type, o.via.u64);
}
}

View File

@@ -1,91 +0,0 @@
/*
* MessagePack for C dynamic typing routine
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MSGPACK_OBJECT_H__
#define MSGPACK_OBJECT_H__
#include "msgpack/zone.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
MSGPACK_OBJECT_NIL = 0x01,
MSGPACK_OBJECT_BOOLEAN = 0x02,
MSGPACK_OBJECT_POSITIVE_INTEGER = 0x03,
MSGPACK_OBJECT_NEGATIVE_INTEGER = 0x04,
MSGPACK_OBJECT_DOUBLE = 0x05,
MSGPACK_OBJECT_RAW = 0x06,
MSGPACK_OBJECT_ARRAY = 0x07,
MSGPACK_OBJECT_MAP = 0x08,
} msgpack_object_type;
struct msgpack_object;
struct msgpack_object_kv;
typedef struct {
uint32_t size;
struct msgpack_object* ptr;
} msgpack_object_array;
typedef struct {
uint32_t size;
struct msgpack_object_kv* ptr;
} msgpack_object_map;
typedef struct {
uint32_t size;
const char* ptr;
} msgpack_object_raw;
typedef union {
bool boolean;
uint64_t u64;
int64_t i64;
double dec;
msgpack_object_array array;
msgpack_object_map map;
msgpack_object_raw raw;
} msgpack_object_union;
typedef struct msgpack_object {
msgpack_object_type type;
msgpack_object_union via;
} msgpack_object;
typedef struct msgpack_object_kv {
msgpack_object key;
msgpack_object val;
} msgpack_object_kv;
void msgpack_object_print(FILE* out, msgpack_object o);
#ifdef __cplusplus
}
#endif
#endif /* msgpack/object.h */

View File

@@ -1,85 +0,0 @@
/*
* MessagePack for C simple buffer implementation
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MSGPACK_SBUFFER_H__
#define MSGPACK_SBUFFER_H__
#include <stdlib.h>
#include <string.h>
#ifndef MSGPACK_SBUFFER_INIT_SIZE
#define MSGPACK_SBUFFER_INIT_SIZE 2048
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct msgpack_sbuffer {
size_t size;
char* data;
size_t alloc;
} msgpack_sbuffer;
static inline void msgpack_sbuffer_init(msgpack_sbuffer* sbuf)
{
memset(sbuf, 0, sizeof(msgpack_sbuffer));
}
static inline void msgpack_sbuffer_destroy(msgpack_sbuffer* sbuf)
{
free(sbuf->data);
}
static inline int msgpack_sbuffer_write(void* data, const char* buf, unsigned int len)
{
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
if(sbuf->alloc - sbuf->size < len) {
size_t nsize = (sbuf->alloc) ?
sbuf->alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE;
while(nsize < sbuf->size + len) { nsize *= 2; }
void* tmp = realloc(sbuf->data, nsize);
if(!tmp) { return -1; }
sbuf->data = (char*)tmp;
sbuf->alloc = nsize;
}
memcpy(sbuf->data + sbuf->size, buf, len);
sbuf->size += len;
return 0;
}
static inline char* msgpack_sbuffer_release(msgpack_sbuffer* sbuf)
{
char* tmp = sbuf->data;
sbuf->size = 0;
sbuf->data = NULL;
sbuf->alloc = 0;
return tmp;
}
#ifdef __cplusplus
}
#endif
#endif /* msgpack/sbuffer.h */

View File

@@ -1,399 +0,0 @@
/*
* MessagePack for C unpacking routine
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "msgpack/unpack.h"
#include "msgpack/unpack_define.h"
#include <stdlib.h>
typedef struct {
msgpack_zone* z;
bool referenced;
} unpack_user;
#define msgpack_unpack_struct(name) \
struct template ## name
#define msgpack_unpack_func(ret, name) \
ret template ## name
#define msgpack_unpack_callback(name) \
template_callback ## name
#define msgpack_unpack_object msgpack_object
#define msgpack_unpack_user unpack_user
struct template_context;
typedef struct template_context template_context;
static void template_init(template_context* ctx);
static msgpack_object template_data(template_context* ctx);
static int template_execute(template_context* ctx,
const char* data, size_t len, size_t* off);
static inline msgpack_object template_callback_root(unpack_user* u)
{ msgpack_object o; return o; }
static inline int template_callback_uint8(unpack_user* u, uint8_t d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
static inline int template_callback_uint16(unpack_user* u, uint16_t d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
static inline int template_callback_uint32(unpack_user* u, uint32_t d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
static inline int template_callback_uint64(unpack_user* u, uint64_t d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
static inline int template_callback_int8(unpack_user* u, int8_t d, msgpack_object* o)
{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } }
static inline int template_callback_int16(unpack_user* u, int16_t d, msgpack_object* o)
{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } }
static inline int template_callback_int32(unpack_user* u, int32_t d, msgpack_object* o)
{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } }
static inline int template_callback_int64(unpack_user* u, int64_t d, msgpack_object* o)
{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; }
else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } }
static inline int template_callback_float(unpack_user* u, float d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_DOUBLE; o->via.dec = d; return 0; }
static inline int template_callback_double(unpack_user* u, double d, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_DOUBLE; o->via.dec = d; return 0; }
static inline int template_callback_nil(unpack_user* u, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_NIL; return 0; }
static inline int template_callback_true(unpack_user* u, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_BOOLEAN; o->via.boolean = true; return 0; }
static inline int template_callback_false(unpack_user* u, msgpack_object* o)
{ o->type = MSGPACK_OBJECT_BOOLEAN; o->via.boolean = false; return 0; }
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o)
{
o->type = MSGPACK_OBJECT_ARRAY;
o->via.array.size = 0;
o->via.array.ptr = msgpack_zone_malloc(u->z, n*sizeof(msgpack_object));
if(o->via.array.ptr == NULL) { return -1; }
return 0;
}
static inline int template_callback_array_item(unpack_user* u, msgpack_object* c, msgpack_object o)
{ c->via.array.ptr[c->via.array.size++] = o; return 0; }
static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_object* o)
{
o->type = MSGPACK_OBJECT_MAP;
o->via.map.size = 0;
o->via.map.ptr = (msgpack_object_kv*)msgpack_zone_malloc(u->z, n*sizeof(msgpack_object_kv));
if(o->via.map.ptr == NULL) { return -1; }
return 0;
}
static inline int template_callback_map_item(unpack_user* u, msgpack_object* c, msgpack_object k, msgpack_object 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 0;
}
static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_object* o)
{
o->type = MSGPACK_OBJECT_RAW;
o->via.raw.ptr = p;
o->via.raw.size = l;
u->referenced = true;
return 0;
}
#include "msgpack/unpack_template.h"
#define CTX_CAST(m) ((template_context*)(m))
#define CTX_REFERENCED(mpac) CTX_CAST((mpac)->ctx)->user.referenced
static const size_t COUNTER_SIZE = sizeof(unsigned int);
static inline void init_count(void* buffer)
{
*(volatile unsigned int*)buffer = 1;
}
static inline void decl_count(void* buffer)
{
//if(--*(unsigned int*)buffer == 0) {
if(__sync_sub_and_fetch((unsigned int*)buffer, 1) == 0) {
free(buffer);
}
}
static inline void incr_count(void* buffer)
{
//++*(unsigned int*)buffer;
__sync_add_and_fetch((unsigned int*)buffer, 1);
}
static inline unsigned int get_count(void* buffer)
{
return *(volatile unsigned int*)buffer;
}
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size)
{
if(initial_buffer_size < COUNTER_SIZE) {
initial_buffer_size = COUNTER_SIZE;
}
char* buffer = (char*)malloc(initial_buffer_size);
if(buffer == NULL) {
return false;
}
void* ctx = malloc(sizeof(template_context));
if(ctx == NULL) {
free(buffer);
return false;
}
msgpack_zone* z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
if(z == NULL) {
free(ctx);
free(buffer);
return false;
}
mpac->buffer = buffer;
mpac->used = COUNTER_SIZE;
mpac->free = initial_buffer_size - mpac->used;
mpac->off = COUNTER_SIZE;
mpac->parsed = 0;
mpac->initial_buffer_size = initial_buffer_size;
mpac->z = z;
mpac->ctx = ctx;
init_count(mpac->buffer);
template_init(CTX_CAST(mpac->ctx));
CTX_CAST(mpac->ctx)->user.z = mpac->z;
CTX_CAST(mpac->ctx)->user.referenced = false;
return true;
}
void msgpack_unpacker_destroy(msgpack_unpacker* mpac)
{
msgpack_zone_free(mpac->z);
free(mpac->ctx);
decl_count(mpac->buffer);
}
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size)
{
msgpack_unpacker* mpac = (msgpack_unpacker*)malloc(sizeof(msgpack_unpacker));
if(mpac == NULL) {
return NULL;
}
if(!msgpack_unpacker_init(mpac, initial_buffer_size)) {
free(mpac);
return NULL;
}
return mpac;
}
void msgpack_unpacker_free(msgpack_unpacker* mpac)
{
msgpack_unpacker_destroy(mpac);
free(mpac);
}
bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
{
if(mpac->used == mpac->off && get_count(mpac->buffer) == 1
&& !CTX_REFERENCED(mpac)) {
// rewind buffer
mpac->free += mpac->used - COUNTER_SIZE;
mpac->used = COUNTER_SIZE;
mpac->off = COUNTER_SIZE;
if(mpac->free >= size) {
return true;
}
}
if(mpac->off == COUNTER_SIZE) {
size_t next_size = (mpac->used + mpac->free) * 2; // include COUNTER_SIZE
while(next_size < size + mpac->used) {
next_size *= 2;
}
char* tmp = (char*)realloc(mpac->buffer, next_size);
if(tmp == NULL) {
return false;
}
mpac->buffer = tmp;
mpac->free = next_size - mpac->used;
} else {
size_t next_size = mpac->initial_buffer_size; // include COUNTER_SIZE
size_t not_parsed = mpac->used - mpac->off;
while(next_size < size + not_parsed + COUNTER_SIZE) {
next_size *= 2;
}
char* tmp = (char*)malloc(next_size);
if(tmp == NULL) {
return false;
}
init_count(tmp);
memcpy(tmp+COUNTER_SIZE, mpac->buffer+mpac->off, not_parsed);
if(CTX_REFERENCED(mpac)) {
if(!msgpack_zone_push_finalizer(mpac->z, decl_count, mpac->buffer)) {
free(tmp);
return false;
}
CTX_REFERENCED(mpac) = false;
} else {
decl_count(mpac->buffer);
}
mpac->buffer = tmp;
mpac->used = not_parsed + COUNTER_SIZE;
mpac->free = next_size - mpac->used;
mpac->off = COUNTER_SIZE;
}
return true;
}
int msgpack_unpacker_execute(msgpack_unpacker* mpac)
{
size_t off = mpac->off;
int ret = template_execute(CTX_CAST(mpac->ctx),
mpac->buffer, mpac->used, &mpac->off);
if(mpac->off > off) {
mpac->parsed += mpac->off - off;
}
return ret;
}
msgpack_object msgpack_unpacker_data(msgpack_unpacker* mpac)
{
return template_data(CTX_CAST(mpac->ctx));
}
msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac)
{
if(!msgpack_unpacker_flush_zone(mpac)) {
return false;
}
msgpack_zone* r = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
if(r == NULL) {
return NULL;
}
msgpack_zone* old = mpac->z;
mpac->z = r;
return old;
}
void msgpack_unpacker_reset_zone(msgpack_unpacker* mpac)
{
msgpack_zone_clear(mpac->z);
}
bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac)
{
if(CTX_REFERENCED(mpac)) {
if(!msgpack_zone_push_finalizer(mpac->z, decl_count, mpac->buffer)) {
return false;
}
CTX_REFERENCED(mpac) = false;
incr_count(mpac->buffer);
}
return true;
}
void msgpack_unpacker_reset(msgpack_unpacker* mpac)
{
template_init(CTX_CAST(mpac->ctx));
// don't reset referenced flag
mpac->parsed = 0;
}
msgpack_unpack_return
msgpack_unpack(const char* data, size_t len, size_t* off,
msgpack_zone* z, msgpack_object* result)
{
template_context ctx;
template_init(&ctx);
ctx.user.z = z;
ctx.user.referenced = false;
size_t noff = 0;
if(off != NULL) { noff = *off; }
int ret = template_execute(&ctx, data, len, &noff);
if(ret < 0) {
return MSGPACK_UNPACK_PARSE_ERROR;
}
if(off != NULL) { *off = noff; }
if(ret == 0) {
return MSGPACK_UNPACK_CONTINUE;
}
*result = template_data(&ctx);
if(noff < len) {
return MSGPACK_UNPACK_EXTRA_BYTES;
}
return MSGPACK_UNPACK_SUCCESS;
}

View File

@@ -1,125 +0,0 @@
/*
* MessagePack for C unpacking routine
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef msgpack_unpacker_H__
#define msgpack_unpacker_H__
#include "msgpack/zone.h"
#include "msgpack/object.h"
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct msgpack_unpacker {
char* buffer;
size_t used;
size_t free;
size_t off;
size_t parsed;
msgpack_zone* z;
size_t initial_buffer_size;
void* ctx;
} msgpack_unpacker;
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size);
void msgpack_unpacker_destroy(msgpack_unpacker* mpac);
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size);
void msgpack_unpacker_free(msgpack_unpacker* mpac);
static inline bool msgpack_unpacker_reserve_buffer(msgpack_unpacker* mpac, size_t size);
static inline char* msgpack_unpacker_buffer(msgpack_unpacker* mpac);
static inline size_t msgpack_unpacker_buffer_capacity(const msgpack_unpacker* mpac);
static inline void msgpack_unpacker_buffer_consumed(msgpack_unpacker* mpac, size_t size);
int msgpack_unpacker_execute(msgpack_unpacker* mpac);
msgpack_object msgpack_unpacker_data(msgpack_unpacker* mpac);
msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac);
void msgpack_unpacker_reset_zone(msgpack_unpacker* mpac);
void msgpack_unpacker_reset(msgpack_unpacker* mpac);
static inline size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac);
typedef enum {
MSGPACK_UNPACK_SUCCESS = 2,
MSGPACK_UNPACK_EXTRA_BYTES = 1,
MSGPACK_UNPACK_CONTINUE = 0,
MSGPACK_UNPACK_PARSE_ERROR = -1,
} msgpack_unpack_return;
msgpack_unpack_return
msgpack_unpack(const char* data, size_t len, size_t* off,
msgpack_zone* z, msgpack_object* result);
static inline size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac);
bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac);
bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size);
bool msgpack_unpacker_reserve_buffer(msgpack_unpacker* mpac, size_t size)
{
if(mpac->free >= size) { return true; }
return msgpack_unpacker_expand_buffer(mpac, size);
}
char* msgpack_unpacker_buffer(msgpack_unpacker* mpac)
{
return mpac->buffer + mpac->used;
}
size_t msgpack_unpacker_buffer_capacity(const msgpack_unpacker* mpac)
{
return mpac->free;
}
void msgpack_unpacker_buffer_consumed(msgpack_unpacker* mpac, size_t size)
{
mpac->used += size;
mpac->free -= size;
}
size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac)
{
return mpac->parsed - mpac->off + mpac->used;
}
size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac)
{
return mpac->parsed;
}
#ifdef __cplusplus
}
#endif
#endif /* msgpack/unpack.h */

241
c/zone.c
View File

@@ -1,241 +0,0 @@
/*
* MessagePack for C memory pool implementation
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "msgpack/zone.h"
#include <stdlib.h>
#include <string.h>
static inline bool init_chunk_array(msgpack_zone_chunk_array* ca, size_t chunk_size)
{
// glibcは72バイト以下のmallocが高速
const size_t nfirst = (sizeof(msgpack_zone_chunk) < 72/2) ?
72 / sizeof(msgpack_zone_chunk) : 8;
msgpack_zone_chunk* array = (msgpack_zone_chunk*)malloc(
sizeof(msgpack_zone_chunk) * nfirst);
if(!array) {
return false;
}
const size_t sz = chunk_size;
char* ptr = (char*)malloc(sz);
if(ptr == NULL) {
free(array);
return NULL;
}
ca->tail = array;
ca->end = array + nfirst;
ca->array = array;
array[0].free = sz;
array[0].ptr = ptr;
array[0].alloc = ptr;
return true;
}
static inline void destroy_chunk_array(msgpack_zone_chunk_array* ca)
{
msgpack_zone_chunk* chunk = ca->array;
for(; chunk != ca->tail+1; ++chunk) {
free(chunk->alloc);
}
free(ca->array);
}
static inline void clear_chunk_array(msgpack_zone_chunk_array* ca)
{
msgpack_zone_chunk* chunk = ca->array + 1;
for(; chunk != ca->tail+1; ++chunk) {
free(chunk->alloc);
}
ca->tail = ca->array;
ca->array[0].free += ca->array[0].ptr - (char*)ca->array[0].alloc;
ca->array[0].ptr = (char*)ca->array[0].alloc;
}
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
{
msgpack_zone_chunk_array* const ca = &zone->chunk_array;
msgpack_zone_chunk* chunk = ++ca->tail;
if(chunk == ca->end) {
// ca->arrayに空きがない
// ca->arrayを拡張する
const size_t nused = ca->end - ca->array;
const size_t nnext = (ca->end - ca->array) * 2;
chunk = (msgpack_zone_chunk*)realloc(ca->array,
sizeof(msgpack_zone_chunk) * nnext);
if(chunk == NULL) {
return NULL;
}
ca->array = chunk;
ca->end = chunk + nnext;
chunk = ca->tail = chunk + nused;
}
size_t sz = zone->chunk_size;
while(sz < size) {
sz *= 2;
}
char* ptr = (char*)malloc(sz);
if(ptr == NULL) {
return NULL;
}
chunk->free = sz - size;
chunk->ptr = ptr + size;
chunk->alloc = ptr;
return ptr;
}
static inline void init_finalizer_array(msgpack_zone_finalizer_array* fa)
{
fa->tail = NULL;
fa->end = NULL;
fa->array = NULL;
}
static inline void call_finalizer_array(msgpack_zone_finalizer_array* fa)
{
// 逆順に呼び出し
msgpack_zone_finalizer* fin = fa->tail;
for(; fin != fa->array; --fin) {
(*(fin-1)->func)((fin-1)->data);
}
}
static inline void destroy_finalizer_array(msgpack_zone_finalizer_array* fa)
{
call_finalizer_array(fa);
free(fa->array);
}
static inline void clear_finalizer_array(msgpack_zone_finalizer_array* fa)
{
call_finalizer_array(fa);
fa->tail = fa->array;
}
bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
void (*func)(void* data), void* data)
{
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
const size_t nused = fa->end - fa->array;
size_t nnext;
if(nused == 0) {
// 初回の呼び出しfa->tail == fa->end == fa->array == NULL
// glibcは72バイト以下のmallocが高速
nnext = (sizeof(msgpack_zone_finalizer) < 72/2) ?
72 / sizeof(msgpack_zone_finalizer) : 8;
} else {
nnext = nused * 2;
}
msgpack_zone_finalizer* tmp =
(msgpack_zone_finalizer*)realloc(fa->array,
sizeof(msgpack_zone_finalizer) * nnext);
if(tmp == NULL) {
return false;
}
fa->array = tmp;
fa->end = tmp + nnext;
fa->tail = tmp + nused;
fa->tail->func = func;
fa->tail->data = data;
++fa->tail;
return true;
}
bool msgpack_zone_is_empty(msgpack_zone* zone)
{
msgpack_zone_chunk_array* const ca = &zone->chunk_array;
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
return ca->array[0].ptr == ca->array[0].alloc &&
ca->tail == ca->array &&
fa->tail == fa->array;
}
bool msgpack_zone_init(msgpack_zone* zone, size_t chunk_size)
{
zone->chunk_size = chunk_size;
if(!init_chunk_array(&zone->chunk_array, chunk_size)) {
return false;
}
init_finalizer_array(&zone->finalizer_array);
return true;
}
void msgpack_zone_destroy(msgpack_zone* zone)
{
destroy_finalizer_array(&zone->finalizer_array);
destroy_chunk_array(&zone->chunk_array);
}
void msgpack_zone_clear(msgpack_zone* zone)
{
clear_finalizer_array(&zone->finalizer_array);
clear_chunk_array(&zone->chunk_array);
}
msgpack_zone* msgpack_zone_new(size_t chunk_size)
{
msgpack_zone* zone = (msgpack_zone*)malloc(sizeof(msgpack_zone));
if(zone == NULL) {
return NULL;
}
if(!msgpack_zone_init(zone, chunk_size)) {
free(zone);
return NULL;
}
return zone;
}
void msgpack_zone_free(msgpack_zone* zone)
{
msgpack_zone_destroy(zone);
free(zone);
}

130
c/zone.h
View File

@@ -1,130 +0,0 @@
/*
* MessagePack for C memory pool implementation
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MSGPACK_ZONE_H__
#define MSGPACK_ZONE_H__
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct msgpack_zone_chunk {
size_t free;
char* ptr;
void* alloc;
} msgpack_zone_chunk;
typedef struct msgpack_zone_finalizer {
void (*func)(void* data);
void* data;
} msgpack_zone_finalizer;
typedef struct msgpack_zone_chunk_array {
msgpack_zone_chunk* tail;
msgpack_zone_chunk* end;
msgpack_zone_chunk* array;
} msgpack_zone_chunk_array;
typedef struct msgpack_zone_finalizer_array {
msgpack_zone_finalizer* tail;
msgpack_zone_finalizer* end;
msgpack_zone_finalizer* array;
} msgpack_zone_finalizer_array;
typedef struct msgpack_zone {
msgpack_zone_chunk_array chunk_array;
msgpack_zone_finalizer_array finalizer_array;
size_t chunk_size;
} msgpack_zone;
#ifndef MSGPACK_ZONE_CHUNK_SIZE
#define MSGPACK_ZONE_CHUNK_SIZE 2048
#endif
bool msgpack_zone_init(msgpack_zone* zone, size_t chunk_size);
void msgpack_zone_destroy(msgpack_zone* zone);
msgpack_zone* msgpack_zone_new(size_t chunk_size);
void msgpack_zone_free(msgpack_zone* zone);
static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size);
static inline bool msgpack_zone_push_finalizer(msgpack_zone* zone,
void (*func)(void* data), void* data);
bool msgpack_zone_is_empty(msgpack_zone* zone);
void msgpack_zone_clear(msgpack_zone* zone);
#ifndef MSGPACK_ZONE_ALIGN
#define MSGPACK_ZONE_ALIGN sizeof(int)
#endif
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size);
void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
{
size = ((size)+((MSGPACK_ZONE_ALIGN)-1)) & ~((MSGPACK_ZONE_ALIGN)-1);
msgpack_zone_chunk* chunk = zone->chunk_array.tail;
if(chunk->free < size) {
return msgpack_zone_malloc_expand(zone, size);
}
char* ptr = chunk->ptr;
chunk->ptr += size;
chunk->free -= size;
return ptr;
}
bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
void (*func)(void* data), void* data);
bool msgpack_zone_push_finalizer(msgpack_zone* zone,
void (*func)(void* data), void* data)
{
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
msgpack_zone_finalizer* fin = fa->tail;
if(fin == fa->end) {
return msgpack_zone_push_finalizer_expand(zone, func, data);
}
fin->func = func;
fin->data = data;
++fa->tail;
return true;
}
#ifdef __cplusplus
}
#endif
#endif /* msgpack/zone.h */

1
cases.json Normal file
View File

@@ -0,0 +1 @@
[false,true,null,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,127,127,255,65535,4294967295,-32,-32,-128,-32768,-2147483648,0.0,-0.0,1.0,-1.0,"a","a","a","","","",[0],[0],[0],[],[],[],{},{},{},{"a":97},{"a":97},{"a":97},[[]],[["a"]]]

99
cases_gen.rb Normal file
View File

@@ -0,0 +1,99 @@
#
# MessagePack format test case
#
begin
require 'rubygems'
rescue LoadError
end
require 'msgpack'
require 'json'
source = <<EOF
c2 # false
c3 # true
c0 # nil
00 # 0 Positive FixNum
cc 00 # 0 uint8
cd 00 00 # 0 uint16
ce 00 00 00 00 # 0 uint32
cf 00 00 00 00 00 00 00 00 # 0 uint64
d0 00 # 0 int8
d1 00 00 # 0 int16
d2 00 00 00 00 # 0 int32
d3 00 00 00 00 00 00 00 00 # 0 int64
ff # -1 Negative FixNum
d0 ff # -1 int8
d1 ff ff # -1 int16
d2 ff ff ff ff # -1 int32
d3 ff ff ff ff ff ff ff ff # -1 int64
7f # 127 Positive FixNum
cc 7f # 127 uint8
cd 00 ff # 255 uint16
ce 00 00 ff ff # 65535 uint32
cf 00 00 00 00 ff ff ff ff # 4294967295 uint64
e0 # -32 Negative FixNum
d0 e0 # -32 int8
d1 ff 80 # -128 int16
d2 ff ff 80 00 # -32768 int32
d3 ff ff ff ff 80 00 00 00 # -2147483648 int64
#ca 00 00 00 00 # 0.0 float
cb 00 00 00 00 00 00 00 00 # 0.0 double
#ca 80 00 00 00 # -0.0 float
cb 80 00 00 00 00 00 00 00 # -0.0 double
cb 3f f0 00 00 00 00 00 00 # 1.0 double
cb bf f0 00 00 00 00 00 00 # -1.0 double
a1 61 # "a" FixRaw
da 00 01 61 # "a" raw 16
db 00 00 00 01 61 # "a" raw 32
a0 # "" FixRaw
da 00 00 # "" raw 16
db 00 00 00 00 # "" raw 32
91 00 # [0] FixArray
dc 00 01 00 # [0] array 16
dd 00 00 00 01 00 # [0] array 32
90 # [] FixArray
dc 00 00 # [] array 16
dd 00 00 00 00 # [] array 32
80 # {} FixMap
de 00 00 # {} map 16
df 00 00 00 00 # {} map 32
81 a1 61 61 # {"a"=>97} FixMap
de 00 01 a1 61 61 # {"a"=>97} map 16
df 00 00 00 01 a1 61 61 # {"a"=>97} map 32
91 90 # [[]]
91 91 a1 61 # [["a"]]
EOF
source.gsub!(/\#.+$/,'')
bytes = source.strip.split(/\s+/).map {|x| x.to_i(16) }.pack('C*')
objs = []
compact_bytes = ""
pac = MessagePack::Unpacker.new
pac.feed(bytes)
pac.each {|obj|
p obj
objs << obj
compact_bytes << obj.to_msgpack
}
json = objs.to_json
# self check
cpac = MessagePack::Unpacker.new
cpac.feed(compact_bytes)
cpac.each {|cobj|
obj = objs.shift
if obj != cobj
puts "** SELF CHECK FAILED **"
puts "expected: #{obj.inspect}"
puts "actual: #{cobj.inspect}"
exit 1
end
}
File.open("cases.mpac","w") {|f| f.write(bytes) }
File.open("cases_compact.mpac","w") {|f| f.write(compact_bytes) }
File.open("cases.json","w") {|f| f.write(json) }

57
ci/build_autotools.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/sh
./bootstrap
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
if [ $1 = "cpp11" ]
then
if [ $2 = "32" ]
then
./configure CFLAGS="-m32" CXXFLAGS="-std=c++11 -m32"
else
./configure CXXFLAGS="-std=c++11"
fi
else
if [ $2 = "32" ]
then
./configure CFLAGS="-m32" CXXFLAGS="-m32"
else
./configure
fi
fi
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make check
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make install DESTDIR=`pwd`/install
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
exit 0

83
ci/build_cmake.sh Executable file
View File

@@ -0,0 +1,83 @@
#!/bin/bash
mkdir build
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
cd build
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
if [ $1 = "cpp11" ]
then
if [ $2 = "32" ]
then
cmake -DMSGPACK_CXX11=ON -DMSGPACK_32BIT=ON ..
else
cmake -DMSGPACK_CXX11=ON ..
fi
else
if [ $2 = "32" ]
then
cmake -DMSGPACK_32BIT=ON ..
else
cmake ..
fi
fi
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make test
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
make install DESTDIR=`pwd`/install
ret=$?
if [ $ret -ne 0 ]
then
exit $ret
fi
if [ $2 != "32" ]
then
ctest -T memcheck | tee memcheck.log
ret=${PIPESTATUS[0]}
if [ $ret -ne 0 ]
then
exit $ret
fi
cat memcheck.log | grep "Memory Leak" > /dev/null
ret=$?
if [ $ret -eq 0 ]
then
exit 1
fi
fi
exit 0

View File

@@ -1,44 +1,98 @@
AC_INIT(msgpack/unpack_template.h)
AC_INIT(msgpack, m4_esyscmd([cat include/msgpack/version_master.h | tr -d "\n" | sed -e 's/#define MSGPACK_VERSION_MAJOR[[:space:]]*\([[:alnum:]]*\)/\1./g' -e 's/#define MSGPACK_VERSION_MINOR[[:space:]]*\([[:alnum:]]*\)/\1./g' -e 's/#define MSGPACK_VERSION_REVISION[[:space:]]*\([[:alnum:]]*\)/\1/g' | tr -d "\n"]))
AC_CONFIG_AUX_DIR(ac)
AM_INIT_AUTOMAKE(msgpack, 0.3.0)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER(config.h)
AC_SUBST(CFLAGS)
if test "" = "$CFLAGS"; then
CFLAGS="-g -O4"
fi
CFLAGS="-O3 -Wall $CFLAGS"
AC_SUBST(CXXFLAGS)
CXXFLAGS="-O3 -Wall $CXXFLAGS"
AC_PROG_CC
CFLAGS="-O4 -Wall $CFLAGS -I.."
AC_MSG_CHECKING([if c++ api is enabled])
AC_MSG_CHECKING([if C++ API is enabled])
AC_ARG_ENABLE(cxx,
AS_HELP_STRING([--disable-cxx],
[don't build c++ api.]) )
AC_MSG_RESULT($enable_cxx)
[don't build C++ API]) ) #'
AC_MSG_RESULT([$enable_cxx])
if test "$enable_cxx" != "no"; then
AC_SUBST(CXXFLAGS)
if test "" = "$CXXFLAGS"; then
CXXFLAGS="-g -O4"
AC_PROG_CXX
AM_PROG_CC_C_O
fi
AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no")
AC_PROG_LIBTOOL
AM_PROG_AS
AC_MSG_CHECKING([if debug option is enabled])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--disable-debug],
[disable assert macros and omit -g option]) )
AC_MSG_RESULT([$enable_debug])
if test "$enable_debug" != "no"; then
CXXFLAGS="$CXXFLAGS -g"
CFLAGS="$CFLAGS -g"
else
CXXFLAGS="$CXXFLAGS -DNDEBUG"
CFLAGS="$CFLAGS -DNDEBUG"
fi
AC_CACHE_CHECK([for __sync_* atomic operations], msgpack_cv_atomic_ops, [
AC_TRY_LINK([
int atomic_sub(int i) { return __sync_sub_and_fetch(&i, 1); }
int atomic_add(int i) { return __sync_add_and_fetch(&i, 1); }
], [atomic_sub(1); atomic_add(1);], msgpack_cv_atomic_ops="yes")
])
if test "$msgpack_cv_atomic_ops" != "yes"; then
if test "$enable_cxx" = "no"; then
AC_MSG_ERROR([__sync_* atomic operations are not found. Try to enable C++ support.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
])
fi
AC_CHECK_PROG(ERB, erb, erb)
if test "x$ERB" = x; then
AC_MSG_ERROR([cannot find erb. Ruby is needed to build.])
AC_LANG_PUSH([C++])
AC_CACHE_CHECK([for __gnu_cxx::__exchange_and_add], msgpack_cv_gcc_cxx_atomic_ops, [
AC_TRY_LINK([
#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
], [atomic_sub(1); atomic_add(1);], msgpack_cv_gcc_cxx_atomic_ops="yes")
])
AC_LANG_POP([C++])
if test "$msgpack_cv_gcc_cxx_atomic_ops" != "yes"; then
AC_MSG_ERROR([__sync_* atomic operations nor __gnu_cxx::__exchange_and_add are not found.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
])
else
enable_gcc_cxx_atomic=yes
fi
fi
# FIXME
AC_PROG_CXX
AM_CONDITIONAL(ENABLE_GCC_CXX_ATOMIC, test "$enable_gcc_cxx_atomic" = "yes")
CXXFLAGS="-O4 -Wall $CXXFLAGS -I.. -I../c"
major=`echo $VERSION | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
minor=`echo $VERSION | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
revision=`echo $VERSION | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
AC_SUBST(VERSION_MAJOR, $major)
AC_SUBST(VERSION_MINOR, $minor)
AC_SUBST(VERSION_REVISION, $revision)
AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no")
AC_PROG_LIBTOOL
AC_OUTPUT([Makefile c/Makefile cpp/Makefile])
AC_OUTPUT([Makefile
msgpack.pc
src/Makefile
test/Makefile])

View File

@@ -1,46 +0,0 @@
lib_LTLIBRARIES = libmsgpack.la
libmsgpack_la_SOURCES = \
object.cpp
nobase_include_HEADERS = \
msgpack.hpp \
msgpack/sbuffer.hpp \
msgpack/pack.hpp \
msgpack/unpack.hpp \
msgpack/object.hpp \
msgpack/zone.hpp \
msgpack/type.hpp \
msgpack/type/array.hpp \
msgpack/type/boolean.hpp \
msgpack/type/float.hpp \
msgpack/type/integer.hpp \
msgpack/type/map.hpp \
msgpack/type/nil.hpp \
msgpack/type/raw.hpp \
msgpack/type/tuple.hpp
# FIXME
object.lo: msgpack/type/tuple.hpp msgpack/zone.hpp
msgpack/type/tuple.hpp: msgpack/type/tuple.hpp.erb
$(ERB) $< > $@.tmp
mv $@.tmp $@
msgpack/zone.hpp: msgpack/zone.hpp.erb
$(ERB) $< > $@.tmp
mv $@.tmp $@
MOSTLYCLEANFILES = \
msgpack/type/tuple.hpp \
msgpack/zone.hpp
EXTRA_DIST = \
msgpack/type/tuple.hpp.erb \
msgpack/zone.hpp.erb
libmsgpack_la_LIBADD = -L../c -lmsgpackc
# -version-info CURRENT:REVISION:AGE
libmsgpack_la_LDFLAGS = -version-info 1:0:0

View File

@@ -1,188 +0,0 @@
#include <msgpack/unpack.hpp>
#include <msgpack/pack.hpp>
#include <string.h>
#include <sys/time.h>
#include <iostream>
#include <stdexcept>
#include <string>
static const unsigned int TASK_INT_NUM = 1<<24;
static const unsigned int TASK_STR_LEN = 1<<15;
//static const unsigned int TASK_INT_NUM = 1<<22;
//static const unsigned int TASK_STR_LEN = 1<<13;
static const char* TASK_STR_PTR;
class simple_timer {
public:
void reset() { gettimeofday(&m_timeval, NULL); }
void show_stat(size_t bufsz)
{
struct timeval endtime;
gettimeofday(&endtime, NULL);
double sec = (endtime.tv_sec - m_timeval.tv_sec)
+ (double)(endtime.tv_usec - m_timeval.tv_usec) / 1000 / 1000;
std::cout << sec << " sec" << std::endl;
std::cout << (double(bufsz)/1024/1024) << " MB" << std::endl;
std::cout << (bufsz/sec/1000/1000*8) << " Mbps" << std::endl;
}
private:
timeval m_timeval;
};
class simple_buffer {
public:
static const size_t DEFAULT_INITIAL_SIZE = 32*1024;//512*1024*1024*2;
simple_buffer(size_t initial_size = DEFAULT_INITIAL_SIZE) :
m_storage((char*)malloc(initial_size)),
m_allocated(initial_size),
m_used(0)
{
if(!m_storage) { throw std::bad_alloc(); }
}
~simple_buffer()
{
free(m_storage);
}
public:
inline void write(const char* buf, size_t len)
{
if(m_allocated - m_used < len) {
expand_buffer(len);
}
memcpy(m_storage + m_used, buf, len);
m_used += len;
}
void clear()
{
m_used = 0;
}
private:
void expand_buffer(size_t req)
{
size_t nsize = m_allocated * 2;
size_t at_least = m_used + req;
while(nsize < at_least) { nsize *= 2; }
char* tmp = (char*)realloc(m_storage, nsize);
if(!tmp) { throw std::bad_alloc(); }
m_storage = tmp;
m_allocated = nsize;
}
public:
size_t size() const { return m_used; }
const char* data() const { return m_storage; }
private:
char* m_storage;
size_t m_allocated;
size_t m_used;
};
void bench_msgpack_int()
{
simple_buffer buf;
simple_timer timer;
std::cout << "----" << std::endl;
std::cout << "pack integer" << std::endl;
timer.reset();
{
msgpack::packer<simple_buffer> pk(buf);
pk.pack_array(TASK_INT_NUM);
for(unsigned int i=0; i < TASK_INT_NUM; ++i) {
pk.pack_unsigned_int(i);
}
}
timer.show_stat(buf.size());
std::cout << "----" << std::endl;
std::cout << "unpack integer" << std::endl;
msgpack::zone z;
msgpack::object obj;
timer.reset();
{
obj = msgpack::unpack(buf.data(), buf.size(), z);
}
timer.show_stat(buf.size());
/*
std::cout << "----" << std::endl;
std::cout << "dynamic pack integer" << std::endl;
buf.clear();
timer.reset();
msgpack::pack(buf, obj);
timer.show_stat(buf.size());
*/
}
void bench_msgpack_str()
{
simple_buffer buf;
simple_timer timer;
std::cout << "----" << std::endl;
std::cout << "pack string" << std::endl;
timer.reset();
{
msgpack::packer<simple_buffer> pk(buf);
pk.pack_array(TASK_STR_LEN);
for(unsigned int i=0; i < TASK_STR_LEN; ++i) {
pk.pack_raw(i);
pk.pack_raw_body(TASK_STR_PTR, i);
}
}
timer.show_stat(buf.size());
std::cout << "----" << std::endl;
std::cout << "unpack string" << std::endl;
msgpack::zone z;
msgpack::object obj;
timer.reset();
{
obj = msgpack::unpack(buf.data(), buf.size(), z);
}
timer.show_stat(buf.size());
/*
std::cout << "----" << std::endl;
std::cout << "dynamic pack string" << std::endl;
buf.clear();
timer.reset();
msgpack::pack(buf, obj);
timer.show_stat(buf.size());
*/
}
int main(void)
{
char* str = (char*)malloc(TASK_STR_LEN);
memset(str, 'a', TASK_STR_LEN);
TASK_STR_PTR = str;
bench_msgpack_int();
bench_msgpack_str();
return 0;
}

View File

@@ -1,9 +0,0 @@
CXXFLAGS += -Wall -g -I. -I.. -O4
LDFLAGS +=
all: bench
bench: bench.o unpack.o zone.o object.o pack.hpp unpack.hpp zone.hpp object.hpp
$(CXX) bench.o unpack.o zone.o object.o $(CXXFLAGS) $(LDFLAGS) -o $@

View File

@@ -1 +0,0 @@
.

View File

@@ -1,139 +0,0 @@
//
// MessagePack for C++ dynamic typed objects
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "msgpack/object.hpp"
#include <string.h>
namespace msgpack {
std::ostream& operator<< (std::ostream& s, const object o)
{
switch(o.type) {
case type::NIL:
s << "nil";
break;
case type::BOOLEAN:
s << (o.via.boolean ? "true" : "false");
break;
case type::POSITIVE_INTEGER:
s << o.via.u64;
break;
case type::NEGATIVE_INTEGER:
s << o.via.i64;
break;
case type::DOUBLE:
s << o.via.dec;
break;
case type::RAW:
(s << '"').write(o.via.raw.ptr, o.via.raw.size) << '"';
break;
case type::ARRAY:
s << "[";
if(o.via.array.size != 0) {
object* p(o.via.array.ptr);
s << *p;
++p;
for(object* const pend(o.via.array.ptr + o.via.array.size);
p < pend; ++p) {
s << ", " << *p;
}
}
s << "]";
break;
// FIXME loop optimiziation
case type::MAP:
s << "{";
if(o.via.map.size != 0) {
object_kv* p(o.via.map.ptr);
s << p->key << "=>" << p->val;
++p;
for(object_kv* const pend(o.via.map.ptr + o.via.map.size);
p < pend; ++p) {
s << ", " << p->key << "=>" << p->val;
}
}
s << "}";
break;
// FIXME loop optimiziation
default:
// FIXME
s << "#<UNKNOWN " << (uint16_t)o.type << ">";
}
return s;
}
bool operator==(const object x, const object y)
{
if(x.type != y.type) { return false; }
switch(x.type) {
case type::NIL:
return true;
case type::BOOLEAN:
return x.via.boolean == y.via.boolean;
case type::POSITIVE_INTEGER:
return x.via.u64 == y.via.u64;
case type::NEGATIVE_INTEGER:
return x.via.i64 == y.via.i64;
case type::RAW:
return x.via.raw.size == y.via.raw.size &&
memcmp(x.via.raw.ptr, y.via.raw.ptr, x.via.raw.size) == 0;
case type::ARRAY:
if(x.via.array.size != y.via.array.size) { return false; }
for(object* px(x.via.array.ptr),
* const pxend(x.via.array.ptr + x.via.array.size),
* py(y.via.array.ptr);
px < pxend; ++px, ++py) {
if(*px != *py) { return false; }
}
return true;
// FIXME loop optimiziation
case type::MAP:
if(x.via.map.size != y.via.map.size) { return false; }
for(object_kv* px(x.via.map.ptr),
* const pxend(x.via.map.ptr + x.via.map.size),
* py(y.via.map.ptr);
px < pxend; ++px, ++py) {
if(px->key != py->key || px->val != py->val) { return false; }
}
return true;
default:
return false;
}
}
} // namespace msgpack

View File

@@ -1,329 +0,0 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_OBJECT_HPP__
#define MSGPACK_OBJECT_HPP__
#include "msgpack/object.h"
#include "msgpack/pack.hpp"
#include <stdint.h>
#include <string.h>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <ostream>
namespace msgpack {
class type_error : public std::bad_cast { };
namespace type {
enum object_type {
NIL = 0x01,
BOOLEAN = 0x02,
POSITIVE_INTEGER = 0x03,
NEGATIVE_INTEGER = 0x04,
DOUBLE = 0x05,
RAW = 0x06,
ARRAY = 0x07,
MAP = 0x08,
};
}
struct object;
struct object_kv;
struct object_array {
uint32_t size;
object* ptr;
};
struct object_map {
uint32_t size;
object_kv* ptr;
};
struct object_raw {
uint32_t size;
const char* ptr;
};
struct object {
union union_type {
bool boolean;
uint64_t u64;
int64_t i64;
double dec;
object_array array;
object_map map;
object_raw raw;
object_raw ref; // obsolete
};
type::object_type type;
union_type via;
bool is_nil() { return type == type::NIL; }
template <typename T>
T as();
template <typename T>
void convert(T* v);
object();
object(msgpack_object obj);
operator msgpack_object();
private:
struct implicit_type;
public:
implicit_type convert();
};
struct object_kv {
object key;
object val;
};
bool operator==(const object x, const object y);
bool operator!=(const object x, const object y);
std::ostream& operator<< (std::ostream& s, const object o);
template <typename Stream, typename T>
packer<Stream>& operator<< (packer<Stream>& o, const T& v);
template <typename T>
T& operator>> (object o, T& v);
struct object::implicit_type {
implicit_type(object o) : obj(o) { }
~implicit_type() { }
template <typename T>
operator T() { return obj.as<T>(); }
private:
object obj;
};
template <typename Type>
class define : public Type {
public:
typedef Type msgpack_type;
typedef define<Type> define_type;
define() {}
define(const msgpack_type& v) : msgpack_type(v) {}
template <typename Packer>
void msgpack_pack(Packer& o) const
{
o << static_cast<const msgpack_type&>(*this);
}
void msgpack_unpack(object o)
{
o >> static_cast<msgpack_type&>(*this);
}
};
template <typename Stream>
template <typename T>
inline packer<Stream>& packer<Stream>::pack(const T& v)
{
*this << v;
return *this;
}
inline object& operator>> (object o, object& v)
{
v = o;
return v;
}
template <typename T>
inline T& operator>> (object o, T& v)
{
v.msgpack_unpack(o.convert());
return v;
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
{
v.msgpack_pack(o);
return o;
}
inline bool operator!=(const object x, const object y)
{ return !(x == y); }
inline object::object() { }
inline object::object(msgpack_object obj)
{
// FIXME beter way?
::memcpy(this, &obj, sizeof(obj));
}
inline object::operator msgpack_object()
{
// FIXME beter way?
msgpack_object obj;
::memcpy(&obj, this, sizeof(obj));
return obj;
}
inline object::implicit_type object::convert()
{
return implicit_type(*this);
}
template <typename T>
inline T object::as()
{
T v;
convert(&v);
return v;
}
template <typename T>
inline void object::convert(T* v)
{
*this >> *v;
}
// obsolete
template <typename T>
inline void convert(T& v, object o)
{
o.convert(&v);
}
// obsolete
template <typename Stream, typename T>
inline void pack(packer<Stream>& o, const T& v)
{
o.pack(v);
}
// obsolete
template <typename Stream, typename T>
inline void pack_copy(packer<Stream>& o, T v)
{
pack(o, v);
}
template <typename Stream>
packer<Stream>& operator<< (packer<Stream>& o, const object& v)
{
switch(v.type) {
case type::NIL:
o.pack_nil();
return o;
case type::BOOLEAN:
if(v.via.boolean) {
o.pack_true();
} else {
o.pack_false();
}
return o;
case type::POSITIVE_INTEGER:
if(v.via.u64 <= (uint64_t)std::numeric_limits<uint16_t>::max()) {
if(v.via.u64 <= (uint16_t)std::numeric_limits<uint8_t>::max()) {
o.pack_uint8(v.via.u64);
} else {
o.pack_uint16(v.via.u64);
}
} else {
if(v.via.u64 <= (uint64_t)std::numeric_limits<uint32_t>::max()) {
o.pack_uint32(v.via.u64);
} else {
o.pack_uint64(v.via.u64);
}
}
return o;
case type::NEGATIVE_INTEGER:
if(v.via.i64 >= (int64_t)std::numeric_limits<int16_t>::min()) {
if(v.via.i64 >= (int64_t)std::numeric_limits<int8_t>::min()) {
o.pack_int8(v.via.i64);
} else {
o.pack_int16(v.via.i64);
}
} else {
if(v.via.i64 >= (int64_t)std::numeric_limits<int32_t>::min()) {
o.pack_int64(v.via.i64);
} else {
o.pack_int64(v.via.i64);
}
}
return o;
case type::RAW:
o.pack_raw(v.via.raw.size);
o.pack_raw_body(v.via.raw.ptr, v.via.raw.size);
return o;
case type::ARRAY:
o.pack_array(v.via.array.size);
for(object* p(v.via.array.ptr),
* const pend(v.via.array.ptr + v.via.array.size);
p < pend; ++p) {
o << *p;
}
return o;
case type::MAP:
o.pack_map(v.via.map.size);
for(object_kv* p(v.via.map.ptr),
* const pend(v.via.map.ptr + v.via.map.size);
p < pend; ++p) {
o << p->key;
o << p->val;
}
return o;
default:
throw type_error();
}
}
} // namespace msgpack
#include "msgpack/type.hpp"
#endif /* msgpack/object.hpp */

View File

@@ -1,253 +0,0 @@
//
// MessagePack for C++ serializing routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_PACK_HPP__
#define MSGPACK_PACK_HPP__
#include <arpa/inet.h> // __BYTE_ORDER
#include <stdexcept>
#include <limits.h>
#include "msgpack/pack_define.h"
namespace msgpack {
template <typename Stream>
class packer {
public:
packer(Stream& s);
~packer();
public:
template <typename T>
packer<Stream>& pack(const T& v);
packer<Stream>& pack_uint8(uint8_t d);
packer<Stream>& pack_uint16(uint16_t d);
packer<Stream>& pack_uint32(uint32_t d);
packer<Stream>& pack_uint64(uint64_t d);
packer<Stream>& pack_int8(uint8_t d);
packer<Stream>& pack_int16(uint16_t d);
packer<Stream>& pack_int32(uint32_t d);
packer<Stream>& pack_int64(uint64_t d);
packer<Stream>& pack_short(int d);
packer<Stream>& pack_int(int d);
packer<Stream>& pack_long(long d);
packer<Stream>& pack_long_long(long long d);
packer<Stream>& pack_unsigned_short(unsigned short d);
packer<Stream>& pack_unsigned_int(unsigned int d);
packer<Stream>& pack_unsigned_long(unsigned long d);
packer<Stream>& pack_unsigned_long_long(unsigned long long d);
packer<Stream>& pack_float(float d);
packer<Stream>& pack_double(double d);
packer<Stream>& pack_nil();
packer<Stream>& pack_true();
packer<Stream>& pack_false();
packer<Stream>& pack_array(unsigned int n);
packer<Stream>& pack_map(unsigned int n);
packer<Stream>& pack_raw(size_t l);
packer<Stream>& pack_raw_body(const char* b, size_t l);
private:
static void _pack_uint8(Stream& x, uint8_t d);
static void _pack_uint16(Stream& x, uint16_t d);
static void _pack_uint32(Stream& x, uint32_t d);
static void _pack_uint64(Stream& x, uint64_t d);
static void _pack_int8(Stream& x, int8_t d);
static void _pack_int16(Stream& x, int16_t d);
static void _pack_int32(Stream& x, int32_t d);
static void _pack_int64(Stream& x, int64_t d);
static void _pack_short(Stream& x, short d);
static void _pack_int(Stream& x, int d);
static void _pack_long(Stream& x, long d);
static void _pack_long_long(Stream& x, long long d);
static void _pack_unsigned_short(Stream& x, unsigned short d);
static void _pack_unsigned_int(Stream& x, unsigned int d);
static void _pack_unsigned_long(Stream& x, unsigned long d);
static void _pack_unsigned_long_long(Stream& x, unsigned long long d);
static void _pack_float(Stream& x, float d);
static void _pack_double(Stream& x, double d);
static void _pack_nil(Stream& x);
static void _pack_true(Stream& x);
static void _pack_false(Stream& x);
static void _pack_array(Stream& x, unsigned int n);
static void _pack_map(Stream& x, unsigned int n);
static void _pack_raw(Stream& x, size_t l);
static void _pack_raw_body(Stream& x, const void* b, size_t l);
static void append_buffer(Stream& x, const unsigned char* buf, unsigned int len)
{ x.write((const char*)buf, len); }
private:
Stream& m_stream;
private:
packer();
};
template <typename Stream, typename T>
inline void pack(Stream& s, const T& v)
{
packer<Stream>(s).pack(v);
}
#define msgpack_pack_inline_func(name) \
template <typename Stream> \
inline void packer<Stream>::_pack ## name
#define msgpack_pack_inline_func_cint(name) \
template <typename Stream> \
inline void packer<Stream>::_pack ## name
#define msgpack_pack_user Stream&
#define msgpack_pack_append_buffer append_buffer
#include "msgpack/pack_template.h"
template <typename Stream>
packer<Stream>::packer(Stream& s) : m_stream(s) { }
template <typename Stream>
packer<Stream>::~packer() { }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_uint8(uint8_t d)
{ _pack_uint8(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_uint16(uint16_t d)
{ _pack_uint16(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_uint32(uint32_t d)
{ _pack_uint32(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_uint64(uint64_t d)
{ _pack_uint64(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_int8(uint8_t d)
{ _pack_int8(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_int16(uint16_t d)
{ _pack_int16(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_int32(uint32_t d)
{ _pack_int32(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_int64(uint64_t d)
{ _pack_int64(m_stream, d); return *this;}
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_short(int d)
{ _pack_short(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_int(int d)
{ _pack_int(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_long(long d)
{ _pack_long(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_long_long(long long d)
{ _pack_long_long(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_unsigned_short(unsigned short d)
{ _pack_unsigned_short(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_unsigned_int(unsigned int d)
{ _pack_unsigned_int(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_unsigned_long(unsigned long d)
{ _pack_unsigned_long(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_unsigned_long_long(unsigned long long d)
{ _pack_unsigned_long_long(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_float(float d)
{ _pack_float(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_double(double d)
{ _pack_double(m_stream, d); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_nil()
{ _pack_nil(m_stream); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_true()
{ _pack_true(m_stream); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_false()
{ _pack_false(m_stream); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_array(unsigned int n)
{ _pack_array(m_stream, n); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_map(unsigned int n)
{ _pack_map(m_stream, n); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_raw(size_t l)
{ _pack_raw(m_stream, l); return *this; }
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_raw_body(const char* b, size_t l)
{ _pack_raw_body(m_stream, b, l); return *this; }
} // namespace msgpack
#endif /* msgpack/pack.hpp */

View File

@@ -1,103 +0,0 @@
//
// MessagePack for C++ simple buffer implementation
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_SBUFFER_HPP__
#define MSGPACK_SBUFFER_HPP__
#include "msgpack/sbuffer.h"
#include <stdexcept>
namespace msgpack {
class sbuffer : public msgpack_sbuffer {
public:
sbuffer(size_t initsz = MSGPACK_SBUFFER_INIT_SIZE)
{
base::data = (char*)::malloc(initsz);
if(!base::data) {
throw std::bad_alloc();
}
base::size = 0;
base::alloc = initsz;
}
~sbuffer()
{
::free(base::data);
}
public:
void write(const char* buf, unsigned int len)
{
if(base::alloc - base::size < len) {
expand_buffer(len);
}
memcpy(base::data + base::size, buf, len);
base::size += len;
}
char* data()
{
return base::data;
}
const char* data() const
{
return base::data;
}
size_t size() const
{
return base::size;
}
char* release()
{
return msgpack_sbuffer_release(this);
}
private:
void expand_buffer(size_t len)
{
size_t nsize = (base::alloc) ?
base::alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE;
while(nsize < base::size + len) { nsize *= 2; }
void* tmp = realloc(base::data, nsize);
if(!tmp) {
throw std::bad_alloc();
}
base::data = (char*)tmp;
base::alloc = nsize;
}
private:
typedef msgpack_sbuffer base;
private:
sbuffer(const sbuffer&);
};
} // namespace msgpack
#endif /* msgpack/sbuffer.hpp */

View File

@@ -1,201 +0,0 @@
#include <iostream>
#include <string>
#include <msgpack.hpp>
#include <sstream>
#include <memory>
using namespace msgpack;
class checker {
public:
template <typename T>
void check(const char* d, size_t len, T should) {
try {
std::cout << "----" << std::endl;
object o;
try {
o = unpack(d, len, m_zone);
} catch (std::runtime_error& e) {
std::cout << o << std::endl;
std::cout << "**" << e.what() << "**" << std::endl;
return;
}
std::cout << o << std::endl;
try {
std::stringstream s;
pack(s, should);
std::string str(s.str());
object ro = unpack(str.data(), str.size(), m_zone);
std::cout << ro << std::endl;
if(ro != o) { throw std::runtime_error("NOT MATCH"); }
} catch (std::runtime_error& e) {
std::cout << "** REUNPACK FAILED **" << std::endl;
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "** REUNPACK FAILED **" << std::endl;
std::cout << "unknown error" << std::endl;
}
} catch (...) { m_zone.clear(); throw; }
m_zone.clear();
}
private:
zone m_zone;
};
int main(void)
{
checker c;
#if 0
{ // SimpleValue
const char d[] = {
0x93, 0xc0, 0xc2, 0xc3,
};
c.check(d, sizeof(d),
type::make_tuple(
type::nil(), false, true
)
);
}
{ // Fixnum
const char d[] = {
0x92,
0x93, 0x00, 0x40, 0x7f,
0x93, 0xe0, 0xf0, 0xff,
};
c.check(d, sizeof(d),
type::make_tuple(
type::make_tuple(
0, 64, 127
),
type::make_tuple(
-32, -16, -1
)
)
);
}
{ // FixArray
const char d[] = {
0x92,
0x90,
0x91,
0x91, 0xc0,
};
std::vector<int> empty;
c.check(d, sizeof(d),
type::make_tuple(
empty,
type::make_tuple(
type::make_tuple(
type::nil()
)
)
)
);
}
{ // FixRaw
const char d[] = {
0x94,
0xa0,
0xa1, 'a',
0xa2, 'b', 'c',
0xa3, 'd', 'e', 'f',
};
c.check(d, sizeof(d),
type::make_tuple(
std::string(""),
std::string("a"),
std::string("bc"),
type::raw_ref("def", 3)
)
);
}
#endif
static const unsigned TASK_ARRAY = 1000;
static const unsigned TASK_REPEAT = 10;
std::vector<std::string> task;
// create task
{
static char traw[64];
memset(traw, 'a', sizeof(traw));
task.resize(TASK_ARRAY);
for(unsigned i=0; i < TASK_ARRAY; ++i) {
task[i] = std::string(traw, sizeof(traw));
}
}
std::stringstream stream;
// send message
{
for(unsigned i=0; i < TASK_REPEAT; ++i) {
pack(stream, task);
}
std::cout << "send " << stream.str().size() << " bytes" << std::endl;
}
ssize_t total_bytes = stream.str().size();
stream.seekg(0);
// reserive message
{
unsigned num_msg = 0;
static const size_t RESERVE_SIZE = 32;//*1024;
unpacker pac;
while(stream.good() && total_bytes > 0) {
// 1. reserve buffer
pac.reserve_buffer(RESERVE_SIZE);
// 2. read data to buffer() up to buffer_capacity() bytes
size_t sz = stream.readsome(
pac.buffer(),
pac.buffer_capacity());
total_bytes -= sz;
std::cout << "read " << sz << " bytes to capacity "
<< pac.buffer_capacity() << " bytes"
<< std::endl;
// 3. specify the number of bytes actually copied
pac.buffer_consumed(sz);
// 4. repeat execute() until it returns false
while( pac.execute() ) {
// 5.1. take out the parsed object
object o = pac.data();
// 5.2 release the zone
std::auto_ptr<zone> olife( pac.release_zone() );
// 5.3 re-initialize the unpacker */
pac.reset();
// do some with the o and olife
std::cout << "message parsed: " << o << std::endl;
++num_msg;
}
}
std::cout << "stream finished" << std::endl;
std::cout << num_msg << " messages reached" << std::endl;
}
return 0;
}

View File

@@ -1,9 +0,0 @@
CXXFLAGS += -Wall -g -I. -I.. -O4
LDFLAGS +=
all: test
test: test.o unpack.o zone.o object.o pack.hpp unpack.hpp zone.hpp object.hpp
$(CXX) test.o unpack.o zone.o object.o $(CXXFLAGS) $(LDFLAGS) -o $@

View File

@@ -1,9 +0,0 @@
#include "msgpack/type/array.hpp"
#include "msgpack/type/boolean.hpp"
#include "msgpack/type/float.hpp"
#include "msgpack/type/integer.hpp"
#include "msgpack/type/map.hpp"
#include "msgpack/type/nil.hpp"
#include "msgpack/type/raw.hpp"
#include "msgpack/type/tuple.hpp"

View File

@@ -1,147 +0,0 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_INTEGER_HPP__
#define MSGPACK_TYPE_INTEGER_HPP__
#include "msgpack/object.hpp"
#include <limits>
namespace msgpack {
namespace type {
namespace detail {
template <typename T, bool Signed>
struct convert_integer_sign;
template <typename T>
struct convert_integer_sign<T, true> {
static inline T convert(object o) {
if(o.type == type::POSITIVE_INTEGER) {
if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max())
{ throw type_error(); }
return o.via.u64;
} else if(o.type == type::NEGATIVE_INTEGER) {
if(o.via.i64 < (int64_t)-std::numeric_limits<T>::max())
{ throw type_error(); }
return o.via.i64;
}
throw type_error();
}
};
template <typename T>
struct convert_integer_sign<T, false> {
static inline T convert(object o) {
if(o.type == type::POSITIVE_INTEGER) {
if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max())
{ throw type_error(); }
return o.via.u64;
}
throw type_error();
}
};
template <typename T>
static inline T convert_integer(object o)
{
return detail::convert_integer_sign<T, std::numeric_limits<T>::is_signed>::convert(o);
}
} // namespace detail
} // namespace type
inline signed char& operator>> (object o, signed char& v)
{ v = type::detail::convert_integer<signed char>(o); return v; }
inline signed short& operator>> (object o, signed short& v)
{ v = type::detail::convert_integer<signed short>(o); return v; }
inline signed int& operator>> (object o, signed int& v)
{ v = type::detail::convert_integer<signed int>(o); return v; }
inline signed long& operator>> (object o, signed long& v)
{ v = type::detail::convert_integer<signed long>(o); return v; }
inline signed long long& operator>> (object o, signed long long& v)
{ v = type::detail::convert_integer<signed long long>(o); return v; }
inline unsigned char& operator>> (object o, unsigned char& v)
{ v = type::detail::convert_integer<unsigned char>(o); return v; }
inline unsigned short& operator>> (object o, unsigned short& v)
{ v = type::detail::convert_integer<unsigned short>(o); return v; }
inline unsigned int& operator>> (object o, unsigned int& v)
{ v = type::detail::convert_integer<unsigned int>(o); return v; }
inline unsigned long& operator>> (object o, unsigned long& v)
{ v = type::detail::convert_integer<unsigned long>(o); return v; }
inline unsigned long long& operator>> (object o, unsigned long long& v)
{ v = type::detail::convert_integer<unsigned long long>(o); return v; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const signed char& v)
{ o.pack_int8(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const signed short& v)
{ o.pack_short(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const signed int& v)
{ o.pack_int(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const signed long& v)
{ o.pack_long(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const signed long long& v)
{ o.pack_long_long(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned char& v)
{ o.pack_uint8(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned short& v)
{ o.pack_unsigned_short(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned int& v)
{ o.pack_unsigned_int(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned long& v)
{ o.pack_unsigned_long(v); return o; }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned long long& v)
{ o.pack_unsigned_long_long(v); return o; }
} // namespace msgpack
#endif /* msgpack/type/integer.hpp */

View File

@@ -1,139 +0,0 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_MAP_HPP__
#define MSGPACK_TYPE_MAP_HPP__
#include "msgpack/object.hpp"
#include <map>
#include <vector>
#include <algorithm>
namespace msgpack {
namespace type {
template <typename K, typename V>
class assoc_vector : public std::vector< std::pair<K, V> > {};
namespace detail {
template <typename K, typename V>
struct pair_first_less {
bool operator() (const std::pair<K, V>& x, const std::pair<K, V>& y) const
{ return x.first < y.first; }
};
}
} //namespace type
template <typename K, typename V>
inline type::assoc_vector<K,V>& operator>> (object o, type::assoc_vector<K,V>& v)
{
if(o.type != type::MAP) { throw type_error(); }
v.resize(o.via.map.size);
object_kv* p = o.via.map.ptr;
object_kv* const pend = o.via.map.ptr + o.via.map.size;
std::pair<K, V>* it(&v.front());
for(; p < pend; ++p, ++it) {
p->key.convert(&it->first);
p->val.convert(&it->second);
}
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K,V>());
return v;
}
template <typename Stream, typename K, typename V>
inline packer<Stream>& operator<< (packer<Stream>& o, const type::assoc_vector<K,V>& v)
{
o.pack_map(v.size());
for(typename type::assoc_vector<K,V>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(it->first);
o.pack(it->second);
}
return o;
}
template <typename K, typename V>
inline std::map<K, V> operator>> (object o, std::map<K, V>& v)
{
if(o.type != type::MAP) { throw type_error(); }
object_kv* p(o.via.map.ptr);
object_kv* const pend(o.via.map.ptr + o.via.map.size);
for(; p != pend; ++p) {
K key;
p->key.convert(&key);
typename std::map<K,V>::iterator it(v.find(key));
if(it != v.end()) {
V val;
p->val.convert(&val);
it->insert( std::pair<K,V>(key, val) );
} else {
p->val.convert(&it->second);
}
}
return v;
}
template <typename Stream, typename K, typename V>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::map<K,V>& v)
{
o.pack_map(v.size());
for(typename std::map<K,V>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(it->first);
o.pack(it->second);
}
return o;
}
template <typename K, typename V>
inline std::multimap<K, V> operator>> (object o, std::multimap<K, V>& v)
{
if(o.type != type::MAP) { throw type_error(); }
object_kv* p(o.via.map.ptr);
object_kv* const pend(o.via.map.ptr + o.via.map.size);
for(; p != pend; ++p) {
std::pair<K, V> value;
p->key.convert(&value.first);
p->val.convert(&value.second);
v.insert(value);
}
return v;
}
template <typename Stream, typename K, typename V>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::multimap<K,V>& v)
{
o.pack_map(v.size());
for(typename std::multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(it->first);
o.pack(it->second);
}
return o;
}
} // namespace msgpack
#endif /* msgpack/type/map.hpp */

View File

@@ -1,103 +0,0 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_RAW_HPP__
#define MSGPACK_TYPE_RAW_HPP__
#include "msgpack/object.hpp"
#include <string.h>
#include <string>
namespace msgpack {
namespace type {
struct raw_ref {
raw_ref() : size(0), ptr(NULL) {}
raw_ref(const char* p, uint32_t s) : size(s), ptr(p) {}
uint32_t size;
const char* ptr;
std::string str() { return std::string(ptr, size); }
bool operator== (const raw_ref& x)
{
return size == x.size && memcmp(ptr, x.ptr, size) == 0;
}
bool operator!= (const raw_ref& x)
{
return !(*this != x);
}
bool operator< (const raw_ref& x)
{
if(size == x.size) { return memcmp(ptr, x.ptr, size) < 0; }
else { return size < x.size; }
}
bool operator> (const raw_ref& x)
{
if(size == x.size) { return memcmp(ptr, x.ptr, size) > 0; }
else { return size > x.size; }
}
};
} // namespace type
inline type::raw_ref& operator>> (object o, type::raw_ref& v)
{
if(o.type != type::RAW) { throw type_error(); }
v.ptr = o.via.raw.ptr;
v.size = o.via.raw.size;
return v;
}
inline std::string& operator>> (object o, std::string& v)
{
type::raw_ref r;
o >> r;
v.assign(r.ptr, r.size);
return v;
}
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v)
{
o.pack_raw(v.size);
o.pack_raw_body(v.ptr, v.size);
return o;
}
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::string& v)
{
o.pack_raw(v.size());
o.pack_raw_body(v.data(), v.size());
return o;
}
} // namespace msgpack
#endif /* msgpack/type/raw.hpp */

View File

@@ -1,170 +0,0 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_TUPLE_HPP__
#define MSGPACK_TYPE_TUPLE_HPP__
#include "msgpack/object.hpp"
namespace msgpack {
namespace type {
// FIXME operator==
// FIXME operator!=
<% GENERATION_LIMIT = 15 %>
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
struct tuple;
template <typename Tuple, int N>
struct tuple_element;
template <typename Tuple, int N>
struct const_tuple_element;
template <typename T>
struct tuple_type {
typedef T type;
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef const T& transparent_reference;
};
template <typename T>
struct tuple_type<T&> {
typedef T type;
typedef T& value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T& transparent_reference;
};
template <typename T>
struct tuple_type<const T&> {
typedef T type;
typedef T& value_type;
typedef T& reference;
typedef const T& const_reference;
typedef const T& transparent_reference;
};
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>> : tuple_type<A<%=j%>> {
tuple_element(tuple<A0<%1.upto(i) {|k|%>, A<%=k%> <%}%>>& x) : _x(x.a<%=j%>) {}
typename tuple_type<A<%=j%>>::reference get() { return _x; }
typename tuple_type<A<%=j%>>::const_reference get() const { return _x; }
private:
typename tuple_type<A<%=j%>>::reference _x;
};
<%}%>
<%}%>
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct const_tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>> : tuple_type<A<%=j%>> {
const_tuple_element(const tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>& x) : _x(x.a<%=j%>) {}
typename tuple_type<A<%=j%>>::const_reference get() const { return _x; }
private:
typename tuple_type<A<%=j%>>::const_reference _x;
};
<%}%>
<%}%>
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
{
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
}
<%}%>
template <>
struct tuple<> {
};
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
typedef tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> value_type;
tuple() {}
tuple(typename tuple_type<A0>::transparent_reference _a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference _a<%=j%><%}%>) :
a0(_a0)<%1.upto(i) {|j|%>, a<%=j%>(_a<%=j%>)<%}%> {}
tuple(object o) { o.convert(this); }
template <int N> typename tuple_element<value_type, N>::reference get()
{ return tuple_element<value_type, N>(*this).get(); }
template <int N> typename const_tuple_element<value_type, N>::const_reference get() const
{ return const_tuple_element<value_type, N>(*this).get(); }
<%0.upto(i) {|j|%>
A<%=j%> a<%=j%>;<%}%>
};
<%}%>
} // namespace type
inline type::tuple<>& operator>> (
object o,
type::tuple<>& v) {
if(o.type != type::ARRAY) { throw type_error(); }
return v;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& operator>> (
object o,
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
if(o.type != type::ARRAY) { throw type_error(); }
if(o.via.array.size < <%=i+1%>) { throw type_error(); }
<%0.upto(i) {|j|%>
o.via.array.ptr[<%=j%>].convert<A<%=j%>>(&v.template get<<%=j%>>());<%}%>
return v;
}
<%}%>
template <typename Stream>
const packer<Stream>& operator<< (
packer<Stream>& o,
const type::tuple<>& v) {
o.pack_array(0);
return o;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
const packer<Stream>& operator<< (
packer<Stream>& o,
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
o.pack_array(<%=i+1%>);
<%0.upto(i) {|j|%>
o.pack(v.template get<<%=j%>>());<%}%>
return o;
}
<%}%>
} // namespace msgpack
#endif /* msgpack/type/tuple.hpp */

View File

@@ -1,301 +0,0 @@
//
// MessagePack for C++ deserializing routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_UNPACK_HPP__
#define MSGPACK_UNPACK_HPP__
#include "msgpack/unpack.h"
#include "msgpack/object.hpp"
#include "msgpack/zone.hpp"
#include <memory>
#include <stdexcept>
#ifndef MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE
#define MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE (32*1024)
#endif
namespace msgpack {
struct unpack_error : public std::runtime_error {
unpack_error(const std::string& msg) :
std::runtime_error(msg) { }
};
class unpacker : public msgpack_unpacker {
public:
unpacker(size_t init_buffer_size = MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE);
~unpacker();
public:
/*! 1. reserve buffer. at least `size' bytes of capacity will be ready */
void reserve_buffer(size_t size);
/*! 2. read data to the buffer() up to buffer_capacity() bytes */
char* buffer();
size_t buffer_capacity() const;
/*! 3. specify the number of bytes actually copied */
void buffer_consumed(size_t size);
/*! 4. repeat execute() until it retunrs false */
bool execute();
/*! 5.1. if execute() returns true, take out the parsed object */
object data();
/*! 5.2. the object is valid until the zone is deleted */
// Note that once release_zone() from unpacker, you must delete it
// otherwise the memrory will leak.
zone* release_zone();
/*! 5.2. this method is equivalence to `delete release_zone()` */
void reset_zone();
/*! 5.3. after release_zone(), re-initialize unpacker */
void reset();
/*! 6. check if the size of message doesn't exceed assumption. */
size_t message_size() const;
// Basic usage of the unpacker is as following:
//
// msgpack::unpacker pac;
//
// while( /* readable */ ) {
//
// // 1.
// pac.reserve(1024);
//
// // 2.
// ssize_t bytes =
// read(the_source, pac.buffer(), pac.buffer_capacity());
//
// // error handling ...
//
// // 3.
// pac.buffer_consumed(bytes);
//
// // 4.
// while(pac.execute()) {
// // 5.1
// object o = pac.data();
//
// // 5.2
// std::auto_ptr<msgpack::zone> olife( pac.release_zone() );
//
// // boost::shared_ptr is also usable:
// // boost::shared_ptr<msgpack::zone> olife( pac.release_zone() );
//
// // 5.3
// pac.reset();
//
// // do some with the object with the old zone.
// do_something(o, olife);
// }
// }
//
public:
// These functions are usable when non-MessagePack message follows after
// MessagePack message.
size_t parsed_size() const;
/*! get address of the buffer that is not parsed */
char* nonparsed_buffer();
size_t nonparsed_size() const;
/*! skip specified size of non-parsed buffer, leaving the buffer */
// Note that the `size' argument must be smaller than nonparsed_size()
void skip_nonparsed_buffer(size_t size);
/*! remove unparsed buffer from unpacker */
// Note that reset() leaves non-parsed buffer.
void remove_nonparsed_buffer();
private:
typedef msgpack_unpacker base;
private:
unpacker(const unpacker&);
};
typedef enum {
UNPACK_SUCCESS = 2,
UNPACK_EXTRA_BYTES = 1,
UNPACK_CONTINUE = 0,
UNPACK_PARSE_ERROR = -1,
} unpack_return;
static unpack_return unpack(const char* data, size_t len, size_t* off,
zone* z, object* result);
// obsolete
static object unpack(const char* data, size_t len, zone& z, size_t* off = NULL);
inline unpacker::unpacker(size_t initial_buffer_size)
{
if(!msgpack_unpacker_init(this, initial_buffer_size)) {
throw std::bad_alloc();
}
}
inline unpacker::~unpacker()
{
msgpack_unpacker_destroy(this);
}
inline void unpacker::reserve_buffer(size_t size)
{
if(!msgpack_unpacker_reserve_buffer(this, size)) {
throw std::bad_alloc();
}
}
inline char* unpacker::buffer()
{
return msgpack_unpacker_buffer(this);
}
inline size_t unpacker::buffer_capacity() const
{
return msgpack_unpacker_buffer_capacity(this);
}
inline void unpacker::buffer_consumed(size_t size)
{
return msgpack_unpacker_buffer_consumed(this, size);
}
inline bool unpacker::execute()
{
int ret = msgpack_unpacker_execute(this);
if(ret < 0) {
throw unpack_error("parse error");
} else if(ret == 0) {
return false;
} else {
return true;
}
}
inline object unpacker::data()
{
return msgpack_unpacker_data(this);
}
inline zone* unpacker::release_zone()
{
if(!msgpack_unpacker_flush_zone(this)) {
throw std::bad_alloc();
}
zone* r = new zone();
msgpack_zone old = *base::z;
*base::z = *r;
*static_cast<msgpack_zone*>(r) = old;
return r;
}
inline void unpacker::reset_zone()
{
msgpack_unpacker_reset_zone(this);
}
inline void unpacker::reset()
{
msgpack_unpacker_reset(this);
}
inline size_t unpacker::message_size() const
{
return msgpack_unpacker_message_size(this);
}
inline size_t unpacker::parsed_size() const
{
return msgpack_unpacker_parsed_size(this);
}
inline char* unpacker::nonparsed_buffer()
{
return base::buffer + base::off;
}
inline size_t unpacker::nonparsed_size() const
{
return base::used - base::off;
}
inline void unpacker::skip_nonparsed_buffer(size_t size)
{
base::off += size;
}
inline void unpacker::remove_nonparsed_buffer()
{
base::used = base::off;
}
inline unpack_return unpack(const char* data, size_t len, size_t* off,
zone* z, object* result)
{
return (unpack_return)msgpack_unpack(data, len, off,
z, reinterpret_cast<msgpack_object*>(result));
}
// obsolete
inline object unpack(const char* data, size_t len, zone& z, size_t* off)
{
object result;
switch( msgpack::unpack(data, len, off, &z, &result) ) {
case UNPACK_SUCCESS:
return result;
case UNPACK_EXTRA_BYTES:
if(off) {
return result;
} else {
throw unpack_error("extra bytes");
}
case UNPACK_CONTINUE:
throw unpack_error("insufficient bytes");
case UNPACK_PARSE_ERROR:
default:
throw unpack_error("parse error");
}
}
} // namespace msgpack
#endif /* msgpack/unpack.hpp */

View File

@@ -1,127 +0,0 @@
//
// MessagePack for C++ memory pool
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_ZONE_HPP__
#define MSGPACK_ZONE_HPP__
#include "msgpack/object.hpp"
#include "msgpack/zone.h"
#include <cstdlib>
#include <vector>
<% GENERATION_LIMIT = 15 %>
namespace msgpack {
class zone : public msgpack_zone {
public:
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE);
~zone();
public:
void* malloc(size_t size);
void push_finalizer(void (*func)(void*), void* data);
void clear();
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
<%}%>
private:
void undo_malloc(size_t size);
template <typename T>
static void object_destructor(void* obj);
typedef msgpack_zone base;
private:
zone(const zone&);
};
inline zone::zone(size_t chunk_size)
{
msgpack_zone_init(this, chunk_size);
}
inline zone::~zone()
{
msgpack_zone_destroy(this);
}
inline void* zone::malloc(size_t size)
{
void* ptr = msgpack_zone_malloc(this, size);
if(!ptr) {
throw std::bad_alloc();
}
return ptr;
}
inline void zone::push_finalizer(void (*func)(void*), void* data)
{
if(!msgpack_zone_push_finalizer(this, func, data)) {
throw std::bad_alloc();
}
}
inline void zone::clear()
{
msgpack_zone_clear(this);
}
template <typename T>
void zone::object_destructor(void* obj)
{
reinterpret_cast<T*>(obj)->~T();
}
inline void zone::undo_malloc(size_t size)
{
msgpack_zone_chunk* chunk = base::chunk_array.tail;
chunk->ptr -= size;
chunk->free += size;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
{
void* x = malloc(sizeof(T));
if(!msgpack_zone_push_finalizer(this, &zone::object_destructor<T>, x)) {
undo_malloc(sizeof(T));
throw std::bad_alloc();
}
try {
return new (x) T(<%=(1..i).map{|j|"a#{j}"}.join(', ')%>);
} catch (...) {
--base::finalizer_array.tail;
undo_malloc(sizeof(T));
throw;
}
}
<%}%>
} // namespace msgpack
#endif /* msgpack/zone.hpp */

133
crosslang.cc Normal file
View File

@@ -0,0 +1,133 @@
//
// MessagePack cross-language test tool
//
// $ cd ../cpp && ./configure && make && make install
// or
// $ port install msgpack # MacPorts
//
// $ g++ -Wall crosslang.cc -lmsgpack
//
#include <msgpack.hpp>
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
static int run(int infd, int outfd)
try {
msgpack::unpacker pac;
while(true) {
pac.reserve_buffer(32*1024);
ssize_t count =
read(infd, pac.buffer(), pac.buffer_capacity());
if(count <= 0) {
if(count == 0) {
return 0;
}
if(errno == EAGAIN || errno == EINTR) {
continue;
}
return 1;
}
pac.buffer_consumed(count);
msgpack::unpacked result;
while(pac.next(&result)) {
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, result.get());
const char* p = sbuf.data();
const char* const pend = p + sbuf.size();
while(p < pend) {
ssize_t bytes = write(outfd, p, pend-p);
if(bytes <= 0) {
if(count == 0) {
return 0;
}
if(errno == EAGAIN || errno == EINTR) {
continue;
}
return 1;
}
p += bytes;
}
}
}
return 0;
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
}
static void usage(const char* prog)
{
printf(
"Usage: %s [in-file] [out-file]\n"
"\n"
"This tool is for testing of MessagePack implementation.\n"
"This does following behavior:\n"
"\n"
" 1. Reads objects serialized by MessagePack from <in-file> (default: stdin)\n"
" 2. Re-serializes the objects using C++ implementation of MessagePack (Note that C++ implementation is considered valid)\n"
" 3. Writes the re-serialized objects into <out-file> (default: stdout)\n"
"\n"
, prog);
exit(1);
}
int main(int argc, char* argv[])
{
int infd = 0;
int outfd = 1;
if(argc < 1 || argc > 3) {
usage(argv[0]);
}
for(int i=1; i < argc; ++i) {
if(strlen(argv[i]) > 1 && argv[i][0] == '-') {
usage(argv[0]);
}
}
if(argc >= 2) {
const char* fname = argv[1];
if(strcmp(fname, "-") != 0) {
infd = open(fname, O_RDONLY);
if(infd < 0) {
perror("can't open input file");
exit(1);
}
}
}
if(argc >= 3) {
const char* fname = argv[2];
if(strcmp(fname, "-") != 0) {
outfd = open(fname, O_WRONLY | O_CREAT| O_TRUNC, 0666);
if(outfd < 0) {
perror("can't open output file");
exit(1);
}
}
}
int code = run(infd, outfd);
close(infd);
close(outfd);
return code;
}

88
crosslang.rb Normal file
View File

@@ -0,0 +1,88 @@
#
# MessagePack cross-language test tool
#
# $ gem install msgpack
# or
# $ port install rb_msgpack # MacPorts
#
begin
require 'rubygems'
rescue LoadError
end
require 'msgpack'
def run(inio, outio)
pac = MessagePack::Unpacker.new(inio)
begin
pac.each {|obj|
outio.write MessagePack.pack(obj)
outio.flush
}
rescue EOFError
return 0
rescue
$stderr.puts $!
return 1
end
return 0
end
def usage
puts <<EOF
Usage: #{$0} [in-file] [out-file]
This tool is for testing of MessagePack implementation.
This does following behavior:
1. Reads objects serialized by MessagePack from <in-file> (default: stdin)
2. Re-serializes the objects using Ruby implementation of MessagePack (Note that Ruby implementation is considered valid)
3. Writes the re-serialized objects into <out-file> (default: stdout)
EOF
exit 1
end
inio = $stdin
outio = $stdout
if ARGV.length > 2
usage
end
ARGV.each {|str|
if str.size > 1 && str[0] == ?-
usage
end
}
if fname = ARGV[0]
unless fname == "-"
begin
inio = File.open(fname)
rescue
puts "can't open output file: #{$!}"
exit 1
end
end
end
if fname = ARGV[1]
unless fname == "-"
begin
outio = File.open(fname, "w")
rescue
puts "can't open output file: #{$!}"
exit 1
end
end
end
code = run(inio, outio)
inio.close
outio.close
exit code

158
erb/cpp03_define.hpp.erb Normal file
View File

@@ -0,0 +1,158 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP03_DEFINE_HPP
#define MSGPACK_CPP03_DEFINE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
#include "msgpack/adaptor/int_fwd.hpp"
#include "msgpack/object_fwd.hpp"
#define MSGPACK_DEFINE(...) \
template <typename Packer> \
void msgpack_pack(Packer& pk) const \
{ \
msgpack::type::make_define(__VA_ARGS__).msgpack_pack(pk); \
} \
void msgpack_unpack(msgpack::object const& o) \
{ \
msgpack::type::make_define(__VA_ARGS__).msgpack_unpack(o); \
}\
template <typename MSGPACK_OBJECT> \
void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \
{ \
msgpack::type::make_define(__VA_ARGS__).msgpack_object(o, z); \
}
// MSGPACK_ADD_ENUM must be used in the global namespace.
#define MSGPACK_ADD_ENUM(enum) \
namespace msgpack { \
MSGPACK_API_VERSION_NAMESPACE(v1) { \
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
{ \
int tmp; \
o >> tmp; \
v = static_cast<enum>(tmp); \
return o; \
} \
inline void operator<< (msgpack::object& o, const enum& v) \
{ \
o << static_cast<int>(v); \
} \
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
{ \
o << static_cast<int>(v); \
} \
namespace detail { \
template <typename Stream> \
struct packer_serializer<Stream, enum> { \
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
return o << static_cast<int>(v); \
} \
}; \
} \
} \
}
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
<% GENERATION_LIMIT = 31 %>
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
struct define;
template <>
struct define<> {
typedef define<> value_type;
typedef tuple<> tuple_type;
template <typename Packer>
void msgpack_pack(Packer& pk) const
{
pk.pack_array(0);
}
void msgpack_unpack(msgpack::object const& o)
{
if(o.type != msgpack::type::ARRAY) { throw type_error(); }
}
void msgpack_object(msgpack::object* o, msgpack::zone&) const
{
o->type = msgpack::type::ARRAY;
o->via.array.ptr = nullptr;
o->via.array.size = 0;
}
};
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
typedef define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> value_type;
typedef tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> tuple_type;
define(A0& _a0<%1.upto(i) {|j|%>, A<%=j%>& _a<%=j%><%}%>) :
a0(_a0)<%1.upto(i) {|j|%>, a<%=j%>(_a<%=j%>)<%}%> {}
template <typename Packer>
void msgpack_pack(Packer& pk) const
{
pk.pack_array(<%=i+1%>);
<%0.upto(i) {|j|%>
pk.pack(a<%=j%>);<%}%>
}
void msgpack_unpack(msgpack::object const& o)
{
if(o.type != msgpack::type::ARRAY) { throw type_error(); }
const size_t size = o.via.array.size;
if(size > 0) {
msgpack::object *ptr = o.via.array.ptr;
switch(size) {
default:<%(i).downto(0) {|j|%>
case <%=j+1%>: ptr[<%=j%>].convert(a<%=j%>);<%}%>
}
}
}
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
{
o->type = msgpack::type::ARRAY;
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
o->via.array.size = <%=i+1%>;
<%0.upto(i) {|j|%>
o->via.array.ptr[<%=j%>] = msgpack::object(a<%=j%>, z);<%}%>
}
<%0.upto(i) {|j|%>
A<%=j%>& a<%=j%>;<%}%>
};
<%}%>
inline define<> make_define()
{
return define<>();
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>, A<%=j%>& a<%=j%><%}%>)
{
return define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
}
<%}%>
} // namespace type
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP03_DEFINE_HPP

View File

@@ -0,0 +1,216 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#define MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
// FIXME operator==
// FIXME operator!=
<% GENERATION_LIMIT = 31 %>
template <typename A0<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%><%}%>>
struct tuple;
template <typename Tuple, int N>
struct tuple_element;
template <typename Tuple, int N>
struct const_tuple_element;
template <typename T>
struct tuple_type {
typedef T type;
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef const T& transparent_reference;
};
template <typename T>
struct tuple_type<T&> {
typedef T type;
typedef T& value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T& transparent_reference;
};
template <typename T>
struct tuple_type<const T&> {
typedef T type;
typedef T& value_type;
typedef T& reference;
typedef const T& const_reference;
typedef const T& transparent_reference;
};
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>> : tuple_type<A<%=j%>> {
tuple_element(tuple<A0<%1.upto(i) {|k|%>, A<%=k%> <%}%>>& x) : m_x(x.a<%=j%>) {}
typename tuple_type<A<%=j%>>::reference get() { return m_x; }
typename tuple_type<A<%=j%>>::const_reference get() const { return m_x; }
private:
typename tuple_type<A<%=j%>>::reference m_x;
};
<%}%>
<%}%>
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct const_tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>> : tuple_type<A<%=j%>> {
const_tuple_element(const tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>& x) : m_x(x.a<%=j%>) {}
typename tuple_type<A<%=j%>>::const_reference get() const { return m_x; }
private:
typename tuple_type<A<%=j%>>::const_reference m_x;
};
<%}%>
<%}%>
template <>
struct tuple<> {
tuple() {}
tuple(msgpack::object const& o) { o.convert(*this); }
typedef tuple<> value_type;
};
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
typedef tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> value_type;
tuple() {}
tuple(typename tuple_type<A0>::transparent_reference _a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference _a<%=j%><%}%>) :
a0(_a0)<%1.upto(i) {|j|%>, a<%=j%>(_a<%=j%>)<%}%> {}
tuple(msgpack::object const& o) { o.convert(*this); }
template <int N> typename tuple_element<value_type, N>::reference get()
{ return tuple_element<value_type, N>(*this).get(); }
template <int N> typename const_tuple_element<value_type, N>::const_reference get() const
{ return const_tuple_element<value_type, N>(*this).get(); }
<%0.upto(i) {|j|%>
A<%=j%> a<%=j%>;<%}%>
};
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline typename type::tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& t)
{ return t.template get<N>(); }
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline typename type::const_tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::const_reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> const& t)
{ return t.template get<N>(); }
<%}%>
inline tuple<> make_tuple()
{
return tuple<>();
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
{
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
}
<%}%>
} // namespace type
inline msgpack::object const& operator>> (
msgpack::object const& o,
type::tuple<>&) {
if(o.type != msgpack::type::ARRAY) { throw type_error(); }
return o;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline msgpack::object const& operator>> (
msgpack::object const& o,
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
if(o.type != msgpack::type::ARRAY) { throw type_error(); }
if(o.via.array.size < <%=i+1%>) { throw type_error(); }
<%0.upto(i) {|j|%>
o.via.array.ptr[<%=j%>].convert<typename type::tuple_type<A<%=j%>>::type>(v.template get<<%=j%>>());<%}%>
return o;
}
<%}%>
template <typename Stream>
inline const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const type::tuple<>&) {
o.pack_array(0);
return o;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
o.pack_array(<%=i+1%>);
<%0.upto(i) {|j|%>
o.pack(v.template get<<%=j%>>());<%}%>
return o;
}
<%}%>
inline void operator<< (
msgpack::object::with_zone& o,
const type::tuple<>&) {
o.type = msgpack::type::ARRAY;
o.via.array.ptr = nullptr;
o.via.array.size = 0;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
inline void operator<< (
msgpack::object::with_zone& o,
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
o.type = msgpack::type::ARRAY;
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
o.via.array.size = <%=i+1%>;
<%0.upto(i) {|j|%>
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
}
<%}%>
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
//inline std::ostream& operator<< (std::ostream& o, const msgpack::type::tuple<>& v) {
// return o << "[]";
//}
//<%0.upto(GENERATION_LIMIT) {|i|%>
//template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
//inline std::ostream& operator<< (std::ostream& o,
// const msgpack::type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
// return o << "["
// <%0.upto(i) {|j|%>
// <<<%if j != 0 then%> ", " <<<%end%> v.template get<<%=j%>>()<%}%>
// << "]";
//}
//<%}%>
#endif // MSGPACK_CPP03_MSGPACK_TUPLE_HPP

View File

@@ -0,0 +1,125 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP
#define MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
// FIXME operator==
// FIXME operator!=
<% GENERATION_LIMIT = 31 %>
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
struct tuple;
template <typename Tuple, int N>
struct tuple_element;
template <typename Tuple, int N>
struct const_tuple_element;
template <typename T>
struct tuple_type;
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>>;
<%}%>
<%}%>
<%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
struct const_tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>>;
<%}%>
<%}%>
template <>
struct tuple<>;
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>;
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
typename type::tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& t);
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
typename type::const_tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::const_reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> const& t);
<%}%>
tuple<> make_tuple();
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>);
<%}%>
} // namespace type
msgpack::object const& operator>> (
msgpack::object const& o,
type::tuple<>&);
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
msgpack::object const& operator>> (
msgpack::object const& o,
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
<%}%>
template <typename Stream>
const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const type::tuple<>&);
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
<%}%>
void operator<< (
msgpack::object::with_zone& o,
const type::tuple<>&);
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
void operator<< (
msgpack::object::with_zone& o,
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
<%}%>
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
//std::ostream& operator<< (std::ostream& o, const msgpack::type::tuple<>& v);
//<%0.upto(GENERATION_LIMIT) {|i|%>
//template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
//std::ostream& operator<< (std::ostream& o,
// const msgpack::type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
//<%}%>
#endif // MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP

332
erb/cpp03_zone.hpp.erb Normal file
View File

@@ -0,0 +1,332 @@
//
// MessagePack for C++ memory pool
//
// Copyright (C) 2008-2010 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP03_ZONE_HPP
#define MSGPACK_CPP03_ZONE_HPP
#include <cstdlib>
#include <memory>
#include <vector>
#include "msgpack/versioning.hpp"
#ifndef MSGPACK_ZONE_CHUNK_SIZE
#define MSGPACK_ZONE_CHUNK_SIZE 8192
#endif
#ifndef MSGPACK_ZONE_ALIGN
#define MSGPACK_ZONE_ALIGN sizeof(void*)
#endif
<% GENERATION_LIMIT = 15 %>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class zone {
struct finalizer {
finalizer(void (*func)(void*), void* data):m_func(func), m_data(data) {}
void operator()() { m_func(m_data); }
void (*m_func)(void*);
void* m_data;
};
struct finalizer_array {
finalizer_array():m_tail(nullptr), m_end(nullptr), m_array(nullptr) {}
void call() {
finalizer* fin = m_tail;
for(; fin != m_array; --fin) (*(fin-1))();
}
~finalizer_array() {
call();
::free(m_array);
}
void clear() {
call();
m_tail = m_array;
}
void push(void (*func)(void* data), void* data)
{
finalizer* fin = m_tail;
if(fin == m_end) {
push_expand(func, data);
return;
}
fin->m_func = func;
fin->m_data = data;
++m_tail;
}
void push_expand(void (*func)(void*), void* data) {
const size_t nused = m_end - m_array;
size_t nnext;
if(nused == 0) {
nnext = (sizeof(finalizer) < 72/2) ?
72 / sizeof(finalizer) : 8;
} else {
nnext = nused * 2;
}
finalizer* tmp =
static_cast<finalizer*>(::realloc(m_array, sizeof(finalizer) * nnext));
if(!tmp) {
throw std::bad_alloc();
}
m_array = tmp;
m_end = tmp + nnext;
m_tail = tmp + nused;
new (m_tail) finalizer(func, data);
++m_tail;
}
finalizer* m_tail;
finalizer* m_end;
finalizer* m_array;
};
struct chunk {
chunk* m_next;
};
struct chunk_list {
chunk_list(size_t chunk_size)
{
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + chunk_size));
if(!c) {
throw std::bad_alloc();
}
m_head = c;
m_free = chunk_size;
m_ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
c->m_next = nullptr;
}
~chunk_list()
{
chunk* c = m_head;
while(c) {
chunk* n = c->m_next;
::free(c);
c = n;
}
}
void clear(size_t chunk_size)
{
chunk* c = m_head;
while(true) {
chunk* n = c->m_next;
if(n) {
::free(c);
c = n;
} else {
break;
}
}
m_head->m_next = nullptr;
m_free = chunk_size;
m_ptr = reinterpret_cast<char*>(m_head) + sizeof(chunk);
}
size_t m_free;
char* m_ptr;
chunk* m_head;
};
size_t m_chunk_size;
chunk_list m_chunk_list;
finalizer_array m_finalizer_array;
public:
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE) /* throw() */;
public:
void* allocate_align(size_t size, size_t align = MSGPACK_ZONE_ALIGN);
void* allocate_no_align(size_t size);
void push_finalizer(void (*func)(void*), void* data);
template <typename T>
void push_finalizer(msgpack::unique_ptr<T> obj);
void clear();
void swap(zone& o);
static void* operator new(std::size_t size)
{
void* p = ::malloc(size);
if (!p) throw std::bad_alloc();
return p;
}
static void operator delete(void *p) /* throw() */
{
::free(p);
}
static void* operator new(std::size_t size, void* place) /* throw() */
{
return ::operator new(size, place);
}
static void operator delete(void* p, void* place) /* throw() */
{
::operator delete(p, place);
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
<%}%>
private:
void undo_allocate(size_t size);
template <typename T>
static void object_destruct(void* obj);
template <typename T>
static void object_delete(void* obj);
void* allocate_expand(size_t size);
private:
zone(const zone&);
zone& operator=(const zone&);
};
inline zone::zone(size_t chunk_size) /* throw() */ :m_chunk_size(chunk_size), m_chunk_list(m_chunk_size)
{
}
inline void* zone::allocate_align(size_t size, size_t align)
{
char* aligned =
reinterpret_cast<char*>(
reinterpret_cast<size_t>(
(m_chunk_list.m_ptr + (align - 1))) / align * align);
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
if(m_chunk_list.m_free >= adjusted_size) {
m_chunk_list.m_free -= adjusted_size;
m_chunk_list.m_ptr += adjusted_size;
return aligned;
}
return reinterpret_cast<char*>(
reinterpret_cast<size_t>(
allocate_expand(size + (align - 1))) / align * align);
}
inline void* zone::allocate_no_align(size_t size)
{
if(m_chunk_list.m_free < size) {
return allocate_expand(size);
}
char* ptr = m_chunk_list.m_ptr;
m_chunk_list.m_free -= size;
m_chunk_list.m_ptr += size;
return ptr;
}
inline void* zone::allocate_expand(size_t size)
{
chunk_list* const cl = &m_chunk_list;
size_t sz = m_chunk_size;
while(sz < size) {
size_t tmp_sz = sz * 2;
if (tmp_sz <= sz) {
sz = size;
break;
}
sz = tmp_sz;
}
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
if (!c) throw std::bad_alloc();
char* ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
c->m_next = cl->m_head;
cl->m_head = c;
cl->m_free = sz - size;
cl->m_ptr = ptr + size;
return ptr;
}
inline void zone::push_finalizer(void (*func)(void*), void* data)
{
m_finalizer_array.push(func, data);
}
template <typename T>
inline void zone::push_finalizer(msgpack::unique_ptr<T> obj)
{
m_finalizer_array.push(&zone::object_delete<T>, obj.release());
}
inline void zone::clear()
{
m_finalizer_array.clear();
m_chunk_list.clear(m_chunk_size);
}
inline void zone::swap(zone& o)
{
using std::swap;
swap(m_chunk_size, o.m_chunk_size);
swap(m_chunk_list, o.m_chunk_list);
swap(m_finalizer_array, o.m_finalizer_array);
}
template <typename T>
void zone::object_destruct(void* obj)
{
static_cast<T*>(obj)->~T();
}
template <typename T>
void zone::object_delete(void* obj)
{
delete static_cast<T*>(obj);
}
inline void zone::undo_allocate(size_t size)
{
m_chunk_list.m_ptr -= size;
m_chunk_list.m_free += size;
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
{
void* x = allocate_align(sizeof(T));
try {
m_finalizer_array.push(&zone::object_destruct<T>, x);
} catch (...) {
undo_allocate(sizeof(T));
throw;
}
try {
return new (x) T(<%=(1..i).map{|j|"a#{j}"}.join(', ')%>);
} catch (...) {
--m_finalizer_array.m_tail;
undo_allocate(sizeof(T));
throw;
}
}
<%}%>
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP03_ZONE_HPP

View File

@@ -0,0 +1,119 @@
#include <msgpack.h>
#include <stdio.h>
#include <assert.h>
typedef struct receiver {
msgpack_sbuffer sbuf;
size_t rest;
} receiver;
receiver r;
void receiver_init(receiver *r) {
msgpack_packer pk;
msgpack_sbuffer_init(&r->sbuf);
msgpack_packer_init(&pk, &r->sbuf, msgpack_sbuffer_write);
/* 1st object */
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* 2nd object */
msgpack_pack_str(&pk, 6);
msgpack_pack_str_body(&pk, "second", 6);
/* 3rd object */
msgpack_pack_array(&pk, 2);
msgpack_pack_int(&pk, 42);
msgpack_pack_false(&pk);
r->rest = r->sbuf.size;
}
size_t receiver_recv(receiver *r, char* buf, size_t try_size) {
size_t off = r->sbuf.size - r->rest;
size_t actual_size = try_size;
if (actual_size > r->rest) actual_size = r->rest;
memcpy(buf, r->sbuf.data + off, actual_size);
r->rest -= actual_size;
return actual_size;
}
#define EACH_RECV_SIZE 4
void unpack(receiver* r) {
/* buf is allocated by unpacker. */
msgpack_unpacker* unp = msgpack_unpacker_new(100);
msgpack_unpacked result;
msgpack_unpack_return ret;
char* buf;
size_t recv_len;
msgpack_unpacked_init(&result);
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
bool expanded = msgpack_unpacker_reserve_buffer(unp, 100);
assert(expanded);
}
buf = msgpack_unpacker_buffer(unp);
recv_len = receiver_recv(r, buf, EACH_RECV_SIZE);
msgpack_unpacker_buffer_consumed(unp, recv_len);
int recv_count = 0;
while (recv_len > 0) {
int i = 0;
printf("receive count: %d %zd bytes received.:\n", recv_count++, recv_len);
ret = msgpack_unpacker_next(unp, &result);
while (ret == MSGPACK_UNPACK_SUCCESS) {
msgpack_object obj = result.data;
/* Use obj. */
printf("Object no %d:\n", i++);
msgpack_object_print(stdout, obj);
printf("\n");
/* If you want to allocate something on the zone, you can use zone. */
/* msgpack_zone* zone = result.zone; */
/* The lifetime of the obj and the zone, */
ret = msgpack_unpacker_next(unp, &result);
}
if (ret == MSGPACK_UNPACK_PARSE_ERROR) {
printf("The data in the buf is invalid format.\n");
msgpack_unpacked_destroy(&result);
return;
}
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
bool expanded = msgpack_unpacker_reserve_buffer(unp, 100);
assert(expanded);
}
buf = msgpack_unpacker_buffer(unp);
recv_len = receiver_recv(r, buf, 4);
msgpack_unpacker_buffer_consumed(unp, recv_len);
}
msgpack_unpacked_destroy(&result);
}
int main(void) {
receiver r;
receiver_init(&r);
unpack(&r);
return 0;
}
/* Output */
/*
Object no 1:
[1, true, "example"]
Object no 2:
"second"
Object no 3:
[42, false]
*/

37
example/c/simple.c Normal file
View File

@@ -0,0 +1,37 @@
#include <msgpack.h>
#include <stdio.h>
int main(void)
{
/* msgpack::sbuffer is a simple buffer implementation. */
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
msgpack_packer pk;
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone mempool;
msgpack_zone_init(&mempool, 2048);
msgpack_object deserialized;
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
/* print the deserialized object. */
msgpack_object_print(stdout, deserialized);
puts("");
msgpack_zone_destroy(&mempool);
msgpack_sbuffer_destroy(&sbuf);
return 0;
}

View File

@@ -0,0 +1,36 @@
#include <msgpack.h>
#include <assert.h>
void test()
{
size_t size = 10000000;
msgpack_sbuffer buf;
msgpack_sbuffer_init(&buf);
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
msgpack_pack_array(pk, size);
{
int idx = 0;
for (; idx < size; ++idx)
msgpack_pack_uint32(pk, 1);
}
msgpack_packer_free(pk);
size_t upk_pos = 0;
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
}
msgpack_sbuffer_destroy(&buf);
}
int main(int argc, char **argv)
{
int i = 0;
for (; i < 10; ++i) test();
return 0;
}

View File

@@ -0,0 +1,37 @@
#include <msgpack.h>
#include <assert.h>
void test()
{
uint64_t test_u64 = 0xFFF0000000000001LL;
size_t size = 10000000;
msgpack_sbuffer buf;
msgpack_sbuffer_init(&buf);
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
msgpack_pack_array(pk, size);
{
int idx = 0;
for (; idx < size; ++idx)
msgpack_pack_uint64(pk, test_u64);
}
msgpack_packer_free(pk);
size_t upk_pos = 0;
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
}
msgpack_sbuffer_destroy(&buf);
}
int main(int argc, char **argv)
{
int i = 0;
for (; i < 10; ++i) test();
return 0;
}

View File

@@ -0,0 +1,75 @@
#include <msgpack.h>
#include <stdio.h>
#include <assert.h>
void prepare(msgpack_sbuffer* sbuf) {
msgpack_packer pk;
msgpack_packer_init(&pk, sbuf, msgpack_sbuffer_write);
/* 1st object */
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* 2nd object */
msgpack_pack_str(&pk, 6);
msgpack_pack_str_body(&pk, "second", 6);
/* 3rd object */
msgpack_pack_array(&pk, 2);
msgpack_pack_int(&pk, 42);
msgpack_pack_false(&pk);
}
void unpack(char const* buf, size_t len) {
/* buf is allocated by client. */
msgpack_unpacked result;
size_t off = 0;
msgpack_unpack_return ret;
int i = 0;
msgpack_unpacked_init(&result);
ret = msgpack_unpack_next(&result, buf, len, &off);
while (ret == MSGPACK_UNPACK_SUCCESS) {
msgpack_object obj = result.data;
/* Use obj. */
printf("Object no %d:\n", i++);
msgpack_object_print(stdout, obj);
printf("\n");
/* If you want to allocate something on the zone, you can use zone. */
/* msgpack_zone* zone = result.zone; */
/* The lifetime of the obj and the zone, */
ret = msgpack_unpack_next(&result, buf, len, &off);
}
msgpack_unpacked_destroy(&result);
if (ret == MSGPACK_UNPACK_CONTINUE) {
printf("All msgpack_object in the buffer is consumed.\n");
}
else if (ret == MSGPACK_UNPACK_PARSE_ERROR) {
printf("The data in the buf is invalid format.\n");
}
}
int main(void) {
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
prepare(&sbuf);
unpack(sbuf.data, sbuf.size);
msgpack_sbuffer_destroy(&sbuf);
return 0;
}
/* Output */
/*
Object no 1:
[1, true, "example"]
Object no 2:
"second"
Object no 3:
[42, false]
*/

View File

@@ -0,0 +1,83 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cassert>
// msgpack.hpp is also ok
#include <msgpack_fwd.hpp>
class my_class {
public:
my_class() {} // When you want to convert from msgpack::object to my_class,
// my_class should be default constractible.
my_class(std::string const& name, int age):name_(name), age_(age) {}
friend bool operator==(my_class const& lhs, my_class const& rhs) {
return lhs.name_ == rhs.name_ && lhs.age_ == rhs.age_;
}
private:
std::string name_;
int age_;
public:
MSGPACK_DEFINE(name_, age_);
};
void print(std::string const& buf) {
for (std::string::const_iterator it = buf.begin(), end = buf.end();
it != end;
++it) {
std::cout
<< std::setw(2)
<< std::hex
<< std::setfill('0')
<< (static_cast<int>(*it) & 0xff)
<< ' ';
}
std::cout << std::dec << std::endl;
}
#include <msgpack.hpp>
int main() {
{ // pack, unpack
my_class my("John Smith", 42);
std::stringstream ss;
msgpack::pack(ss, my);
print(ss.str());
msgpack::unpacked unp;
msgpack::unpack(unp, ss.str().data(), ss.str().size());
msgpack::object obj = unp.get();
std::cout << obj << std::endl;
assert(obj.as<my_class>() == my);
}
{ // create object with zone
my_class my("John Smith", 42);
msgpack::zone z;
msgpack::object obj(my, z);
std::cout << obj << std::endl;
assert(obj.as<my_class>() == my);
}
}

View File

@@ -0,0 +1,139 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cassert>
// msgpack.hpp should be included at after user declarations
#include <msgpack_fwd.hpp>
// declarations
class my_class;
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
object const& operator>> (msgpack::object const& o, my_class& v);
template <typename Stream>
packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v);
void operator<< (msgpack::object::with_zone& o, my_class const& v);
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
} // namespace msgpack
#include <msgpack.hpp>
class my_class {
public:
my_class() {} // When you want to convert from msgpack::object to my_class,
// my_class should be default constractible.
my_class(std::string const& name, int age):name_(name), age_(age) {}
// my_class should provide getters for the data members you want to pack.
std::string const& get_name() const { return name_; }
int get_age() const { return age_; }
friend bool operator==(my_class const& lhs, my_class const& rhs) {
return lhs.name_ == rhs.name_ && lhs.age_ == rhs.age_;
}
private:
std::string name_;
int age_;
};
// definitions
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
inline object const& operator>> (msgpack::object const& o, my_class& v) {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
if (o.via.array.size != 2) throw msgpack::type_error();
v = my_class(
o.via.array.ptr[0].as<std::string>(),
o.via.array.ptr[1].as<int>());
return o;
}
template <typename Stream>
inline packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v) {
// packing member variables as an array.
o.pack_array(2);
o.pack(v.get_name());
o.pack(v.get_age());
return o;
}
inline void operator<< (msgpack::object::with_zone& o, my_class const& v) {
o.type = type::ARRAY;
o.via.array.size = 2;
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * o.via.array.size));
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
}
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
} // namespace msgpack
void print(std::string const& buf) {
for (std::string::const_iterator it = buf.begin(), end = buf.end();
it != end;
++it) {
std::cout
<< std::setw(2)
<< std::hex
<< std::setfill('0')
<< (static_cast<int>(*it) & 0xff)
<< ' ';
}
std::cout << std::dec << std::endl;
}
int main() {
{ // pack, unpack
my_class my("John Smith", 42);
std::stringstream ss;
msgpack::pack(ss, my);
print(ss.str());
msgpack::unpacked unp;
msgpack::unpack(unp, ss.str().data(), ss.str().size());
msgpack::object obj = unp.get();
std::cout << obj << std::endl;
assert(obj.as<my_class>() == my);
}
{ // create object with zone
my_class my("John Smith", 42);
msgpack::zone z;
msgpack::object obj(my, z);
std::cout << obj << std::endl;
assert(obj.as<my_class>() == my);
}
}

75
example/cpp03/custom.cpp Normal file
View File

@@ -0,0 +1,75 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <msgpack.hpp>
#include <sstream>
#include <string>
#include <iostream>
class old_class {
public:
old_class() : value("default") { }
std::string value;
MSGPACK_DEFINE(value);
};
class new_class {
public:
new_class() : value("default"), flag(-1) { }
std::string value;
int flag;
MSGPACK_DEFINE(value, flag);
};
int main(void)
{
{
old_class oc;
new_class nc;
std::stringstream sbuf;
msgpack::pack(sbuf, oc);
msgpack::unpacked result;
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
msgpack::object obj = result.get();
obj.convert(&nc);
std::cout << obj << " value=" << nc.value << " flag=" << nc.flag << std::endl;
}
{
new_class nc;
old_class oc;
std::stringstream sbuf;
msgpack::pack(sbuf, nc);
msgpack::unpacked result;
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
msgpack::object obj = result.get();
obj.convert(&oc);
std::cout << obj << " value=" << oc.value << std::endl;
}
}

68
example/cpp03/enum.cpp Normal file
View File

@@ -0,0 +1,68 @@
// MessagePack for C++ example
//
// Copyright (C) 2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <msgpack_fwd.hpp>
#include <sstream>
#include <iostream>
#include <cassert>
enum my_enum {
elem1,
elem2,
elem3
};
MSGPACK_ADD_ENUM(my_enum);
#include <msgpack.hpp>
int main(void)
{
{ // pack, unpack
std::stringstream sbuf;
msgpack::pack(sbuf, elem1);
msgpack::pack(sbuf, elem2);
my_enum e3 = elem3;
msgpack::pack(sbuf, e3);
msgpack::unpacked result;
std::size_t off = 0;
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
std::cout << result.get().as<my_enum>() << std::endl;
assert(result.get().as<my_enum>() == elem1);
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
std::cout << result.get().as<my_enum>() << std::endl;
assert(result.get().as<my_enum>() == elem2);
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
std::cout << result.get().as<my_enum>() << std::endl;
assert(result.get().as<my_enum>() == elem3);
}
{ // create object without zone
msgpack::object obj(elem2);
std::cout << obj.as<my_enum>() << std::endl;
assert(obj.as<my_enum>() == elem2);
}
{ // create object with zone
msgpack::zone z;
msgpack::object objz(elem3, z);
std::cout << objz.as<my_enum>() << std::endl;
assert(objz.as<my_enum>() == elem3);
}
}

103
example/cpp03/protocol.cpp Normal file
View File

@@ -0,0 +1,103 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
namespace myprotocol {
using namespace msgpack::type;
using msgpack::define;
struct Get : define< tuple<uint32_t, std::string> > {
Get() { }
Get(uint32_t f, const std::string& k) :
define_type(msgpack_type(f, k)) { }
uint32_t& flags() { return msgpack::type::get<0>(*this); }
std::string& key() { return msgpack::type::get<1>(*this); }
};
struct Put : define< tuple<uint32_t, std::string, raw_ref> > {
Put() { }
Put(uint32_t f, const std::string& k, const char* valref, uint32_t vallen) :
define_type(msgpack_type( f, k, raw_ref(valref,vallen) )) { }
uint32_t& flags() { return msgpack::type::get<0>(*this); }
std::string& key() { return msgpack::type::get<1>(*this); }
raw_ref& value() { return msgpack::type::get<2>(*this); }
};
struct MultiGet : define< std::vector<Get> > {
};
}
int main(void)
{
// send Get request
std::stringstream stream;
{
myprotocol::Get req;
req.flags() = 0;
req.key() = "key0";
msgpack::pack(stream, req);
}
stream.seekg(0);
// receive Get request
{
std::string buffer(stream.str());
msgpack::unpacked result;
msgpack::unpack(result, buffer.data(), buffer.size());
msgpack::object o = result.get();
myprotocol::Get req;
o.convert(req);
std::cout << "received: " << o << std::endl;
}
stream.str("");
// send MultiGet request
{
myprotocol::MultiGet req;
req.push_back( myprotocol::Get(1, "key1") );
req.push_back( myprotocol::Get(2, "key2") );
req.push_back( myprotocol::Get(3, "key3") );
msgpack::pack(stream, req);
}
stream.seekg(0);
// receive MultiGet request
{
std::string buffer(stream.str());
msgpack::unpacked result;
msgpack::unpack(result, buffer.data(), buffer.size());
msgpack::object o = result.get();
myprotocol::MultiGet req;
o.convert(req);
std::cout << "received: " << o << std::endl;
}
}

View File

@@ -0,0 +1,47 @@
// MessagePack for C++ example
//
// Copyright (C) 2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <iostream>
#include <sstream>
#include <cassert>
#include <string>
#include <vector>
#include <msgpack.hpp>
int main() {
std::vector<int> v;
v.push_back(1);
v.push_back(42);
std::string s("ABC");
std::stringstream ss;
msgpack::pack(ss, v);
msgpack::pack(ss, s);
msgpack::zone z;
std::size_t offset = 0;
// msgpack array is constructed on z.
msgpack::object obj = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset);
assert(obj.as<std::vector<int> >() == v);
// msgpack str is constructed on z.
assert(msgpack::unpack(z, ss.str().data(), ss.str().size(), offset).as<std::string>() == s);
}

54
example/cpp03/simple.cpp Normal file
View File

@@ -0,0 +1,54 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
int main(void)
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);
// send the buffer ...
buffer.seekg(0);
// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());
msgpack::unpacked result;
msgpack::unpack(result, str.data(), str.size());
// deserialized object is valid during the msgpack::unpacked instance alive.
msgpack::object deserialized = result.get();
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(&dst);
return 0;
}

View File

@@ -0,0 +1,71 @@
// MessagePack for C++ example
//
// Copyright (C) 2013-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// g++ -std=c++11 -O3 -g -Ipath_to_msgpack_src -Ipath_to_boost speed_test.cc -Lpath_to_boost_lib -lboost_timer -lboost_system
// export LD_LIBRARY_PATH=path_to_boost_lib
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <boost/timer/timer.hpp>
void test_map_pack_unpack() {
std::cout << "[TEST][map_pack_unpack]" << std::endl;
// setup
std::cout << "Setting up map data..." << std::endl;
std::map<int, int> m1;
int const num = 30000000L;
for (int i = 0; i < num; ++i) m1[i] = i;
std::cout << "Start packing..." << std::endl;
std::stringstream buffer;
{
boost::timer::cpu_timer timer;
msgpack::pack(buffer, m1);
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Pack finished..." << std::endl;
buffer.seekg(0);
std::string str(buffer.str());
msgpack::unpacked unpacked;
std::cout << "Start unpacking...by void unpack(unpacked& result, const char* data, size_t len)" << std::endl;
{
boost::timer::cpu_timer timer;
msgpack::unpack(unpacked, str.data(), str.size());
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Unpack finished..." << std::endl;
std::map<int, int> m2;
std::cout << "Start converting..." << std::endl;
{
boost::timer::cpu_timer timer;
unpacked.get().convert(&m2);
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Convert finished..." << std::endl;
}
int main(void)
{
test_map_pack_unpack();
}

View File

@@ -0,0 +1,94 @@
// MessagePack for C++ example
//
// Copyright (C) 2013-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// g++ -std=c++11 -O3 -g -Ipath_to_msgpack_src -Ipath_to_boost speed_test.cc -Lpath_to_boost_lib -lboost_timer -lboost_system
// export LD_LIBRARY_PATH=path_to_boost_lib
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <boost/timer/timer.hpp>
template <typename T, std::size_t level>
struct vecvec {
typedef std::vector<typename vecvec<T, level - 1>::type> type;
static void fill(type& v, std::size_t num_of_elems, T const& val) {
for (int elem = 0; elem < num_of_elems; ++elem) {
typename vecvec<T, level - 1>::type child;
vecvec<T, level - 1>::fill(child, num_of_elems, val);
v.push_back(child);
}
}
};
template <typename T>
struct vecvec<T, 0> {
typedef std::vector<T> type;
static void fill(type& v, std::size_t num_of_elems, T const& val) {
for (int elem = 0; elem < num_of_elems; ++elem) {
v.push_back(val);
}
}
};
void test_array_of_array() {
std::cout << "[TEST][array_of_array]" << std::endl;
// setup
int const depth = 16;
std::cout << "Setting up array data..." << std::endl;
typename vecvec<int, depth>::type v1;
vecvec<int, depth>::fill(v1, 3, 42);
std::cout << "Start packing..." << std::endl;
std::stringstream buffer;
{
boost::timer::cpu_timer timer;
msgpack::pack(buffer, v1);
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Pack finished..." << std::endl;
buffer.seekg(0);
std::string str(buffer.str());
msgpack::unpacked unpacked;
std::cout << "Start unpacking...by void unpack(unpacked& result, const char* data, size_t len)" << std::endl;
{
boost::timer::cpu_timer timer;
msgpack::unpack(unpacked, str.data(), str.size());
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Unpack finished..." << std::endl;
typename vecvec<int, depth>::type v2;
std::cout << "Start converting..." << std::endl;
{
boost::timer::cpu_timer timer;
unpacked.get().convert(&v2);
std::string result = timer.format();
std::cout << result << std::endl;
}
std::cout << "Convert finished..." << std::endl;
}
int main(void)
{
test_array_of_array();
}

150
example/cpp03/stream.cpp Normal file
View File

@@ -0,0 +1,150 @@
// MessagePack for C++ example
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <msgpack.hpp>
#include <iostream>
#include <stdexcept>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
class Server {
public:
Server(int sock) : m_sock(sock) { }
~Server() { }
typedef msgpack::unique_ptr<msgpack::zone> unique_zone;
void socket_readable()
{
m_pac.reserve_buffer(1024);
ssize_t count =
read(m_sock, m_pac.buffer(), m_pac.buffer_capacity());
if(count <= 0) {
if(count == 0) {
throw std::runtime_error("connection closed");
}
if(errno == EAGAIN || errno == EINTR) {
return;
}
throw std::runtime_error(strerror(errno));
}
m_pac.buffer_consumed(count);
msgpack::unpacked result;
while (m_pac.next(&result)) {
msgpack::object msg = result.get();
unique_zone& life = result.zone();
process_message(msg, life);
}
if(m_pac.message_size() > 10*1024*1024) {
throw std::runtime_error("message is too large");
}
}
private:
void process_message(msgpack::object msg, unique_zone&)
{
std::cout << "message reached: " << msg << std::endl;
}
private:
int m_sock;
msgpack::unpacker m_pac;
};
static void* run_server(void* arg)
{
try {
Server* srv = reinterpret_cast<Server*>(arg);
while(true) {
srv->socket_readable();
}
return NULL;
} catch (std::exception& e) {
std::cerr << "error while processing client packet: "
<< e.what() << std::endl;
return NULL;
} catch (...) {
std::cerr << "error while processing client packet: "
<< "unknown error" << std::endl;
return NULL;
}
}
struct fwriter {
fwriter(int fd) : m_fp( fdopen(fd, "w") ) { }
void write(const char* buf, size_t buflen)
{
size_t count = fwrite(buf, buflen, 1, m_fp);
if(count < 1) {
std::cout << buflen << std::endl;
std::cout << count << std::endl;
throw std::runtime_error(strerror(errno));
}
}
void flush() { fflush(m_fp); }
void close() { fclose(m_fp); }
private:
FILE* m_fp;
};
int main(void)
{
int pair[2];
pipe(pair);
// run server thread
Server srv(pair[0]);
pthread_t thread;
pthread_create(&thread, NULL,
run_server, reinterpret_cast<void*>(&srv));
// client thread:
fwriter writer(pair[1]);
msgpack::packer<fwriter> pk(writer);
typedef msgpack::type::tuple<std::string, std::string, std::string> put_t;
typedef msgpack::type::tuple<std::string, std::string> get_t;
put_t req1("put", "apple", "red");
put_t req2("put", "lemon", "yellow");
get_t req3("get", "apple");
pk.pack(req1);
pk.pack(req2);
pk.pack(req3);
writer.flush();
writer.close();
pthread_join(thread, NULL);
}

108
example/cpp11/container.cpp Normal file
View File

@@ -0,0 +1,108 @@
// MessagePack for C++ example
//
// Copyright (C) 2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <iostream>
#include <sstream>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <forward_list>
#include <string>
#include <msgpack.hpp>
void array() {
std::array<int, 5> a { 1, 2, 3, 4, 5 };
std::stringstream ss;
msgpack::pack(ss, a);
msgpack::unpacked und = msgpack::unpack(ss.str().data(), ss.str().size());
msgpack::object obj = und.get();
std::array<int, 5> const& new_a = obj.as<std::array<int, 5>>();
assert(new_a == a);
}
void tuple() {
std::tuple<bool, std::string, int> t(true, "ABC", 42);
std::stringstream ss;
msgpack::pack(ss, t);
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
auto obj = und.get();
assert(obj.as<decltype(t)>() == t);
}
void unordered_map() {
std::unordered_map<std::string, int> m { {"ABC", 1}, {"DEF", 3} };
std::stringstream ss;
msgpack::pack(ss, m);
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
assert(und.get().as<decltype(m)>() == m);
}
void unordered_set() {
std::unordered_set<std::string> s { "ABC", "DEF" };
std::stringstream ss;
msgpack::pack(ss, s);
assert(msgpack::unpack(ss.str().data(), ss.str().size()).get().as<decltype(s)>() == s);
}
void forward_list() {
using type = std::forward_list<std::string>;
type f { "ABC", "DEF" };
std::stringstream ss;
msgpack::pack(ss, f);
assert(msgpack::unpack(ss.str().data(), ss.str().size()).get().as<type>() == f);
}
void combi() {
std::array<int, 5> a { 1, 2, 3, 4, 5 };
std::tuple<bool, std::string, int> t {true, "ABC", 42};
std::unordered_map<std::string, int> m { {"ABC", 1}, {"DEF", 3} };
std::unordered_set<std::string> s { "ABC", "DEF" };
std::forward_list<std::string> f { "ABC", "DEF" };
std::stringstream ss;
msgpack::pack(ss, a);
msgpack::pack(ss, t);
msgpack::pack(ss, m);
msgpack::pack(ss, s);
msgpack::pack(ss, f);
std::size_t offset = 0;
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(a)>() == a);
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(t)>() == t);
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(m)>() == m);
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(s)>() == s);
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(f)>() == f);
}
int main() {
array();
tuple();
unordered_map();
unordered_set();
forward_list();
combi();
}

View File

@@ -1,86 +0,0 @@
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
namespace myprotocol {
using namespace msgpack::type;
using msgpack::define;
struct Get : define< tuple<uint32_t, std::string> > {
Get() { }
Get(uint32_t f, const std::string& k) :
define_type(msgpack_type(f, k)) { }
uint32_t& flags() { return get<0>(); }
std::string& key() { return get<1>(); }
};
struct Put : define< tuple<uint32_t, std::string, raw_ref> > {
Put() { }
Put(uint32_t f, const std::string& k, const char* valref, size_t vallen) :
define_type(msgpack_type( f, k, raw_ref(valref,vallen) )) { }
uint32_t& flags() { return get<0>(); }
std::string& key() { return get<1>(); }
raw_ref& value() { return get<2>(); }
};
struct MultiGet : define< std::vector<Get> > {
};
}
int main(void)
{
// send Get request
std::stringstream stream;
{
myprotocol::Get req;
req.flags() = 0;
req.key() = "key0";
msgpack::pack(stream, req);
}
stream.seekg(0);
// receive Get request
{
std::string buffer(stream.str());
msgpack::zone mempool;
msgpack::object o =
msgpack::unpack(buffer.data(), buffer.size(), mempool);
myprotocol::Get req;
msgpack::convert(req, o);
std::cout << "received: " << o << std::endl;
}
stream.str("");
// send MultiGet request
{
myprotocol::MultiGet req;
req.push_back( myprotocol::Get(1, "key1") );
req.push_back( myprotocol::Get(2, "key2") );
req.push_back( myprotocol::Get(3, "key3") );
msgpack::pack(stream, req);
}
stream.seekg(0);
// receive MultiGet request
{
std::string buffer(stream.str());
msgpack::zone mempool;
msgpack::object o =
msgpack::unpack(buffer.data(), buffer.size(), mempool);
myprotocol::MultiGet req;
msgpack::convert(req, o);
std::cout << "received: " << o << std::endl;
}
}

View File

@@ -1,37 +0,0 @@
#include <msgpack.h>
#include <stdio.h>
int main(void)
{
/* msgpack::sbuffer is a simple buffer implementation. */
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
msgpack_packer pk;
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_raw(&pk, 7);
msgpack_pack_raw_body(&pk, "example", 7);
/* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone mempool;
msgpack_zone_init(&mempool, 2048);
msgpack_object deserialized;
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
/* print the deserialized object. */
msgpack_object_print(stdout, deserialized);
puts("");
msgpack_zone_destroy(&mempool);
msgpack_sbuffer_destroy(&sbuf);
return 0;
}

View File

@@ -1,37 +0,0 @@
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
int main(void)
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);
// send the buffer ...
buffer.seekg(0);
// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());
// deserialized object is valid during the msgpack::zone instance alive.
msgpack::zone mempool;
msgpack::object deserialized;
msgpack::unpack(str.data(), str.size(), NULL, &mempool, &deserialized);
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(&dst);
return 0;
}

View File

@@ -1,5 +0,0 @@
require 'msgpack'
serialized = [1, -1, true, false, nil, {"key" => "value"}].to_msgpack
p MessagePack.unpack(serialized)

View File

@@ -1,136 +0,0 @@
#include <msgpack.hpp>
#include <iostream>
#include <stdexcept>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
class Server {
public:
Server(int sock) : m_sock(sock) { }
~Server() { }
typedef std::auto_ptr<msgpack::zone> auto_zone;
void socket_readable()
{
m_pac.reserve_buffer(1024);
ssize_t count =
read(m_sock, m_pac.buffer(), m_pac.buffer_capacity());
if(count < 0) {
if(errno == EAGAIN || errno == EINTR) {
return;
} else {
throw std::runtime_error(strerror(errno));
}
} else if(count == 0) {
throw std::runtime_error("connection closed");
}
m_pac.buffer_consumed(count);
while(m_pac.execute()) {
msgpack::object msg = m_pac.data();
auto_zone life( m_pac.release_zone() );
m_pac.reset();
process_message(msg, life);
}
if(m_pac.message_size() > 10*1024*1024) {
throw std::runtime_error("message is too large");
}
}
private:
void process_message(msgpack::object msg, auto_zone& life)
{
std::cout << "message reached: " << msg << std::endl;
}
private:
int m_sock;
msgpack::unpacker m_pac;
};
static void* run_server(void* arg)
try {
Server* srv = reinterpret_cast<Server*>(arg);
while(true) {
srv->socket_readable();
}
return NULL;
} catch (std::exception& e) {
std::cerr << "error while processing client packet: "
<< e.what() << std::endl;
return NULL;
} catch (...) {
std::cerr << "error while processing client packet: "
<< "unknown error" << std::endl;
return NULL;
}
struct fwriter {
fwriter(int fd) : m_fp( fdopen(fd, "w") ) { }
void write(const char* buf, size_t buflen)
{
size_t count = fwrite(buf, buflen, 1, m_fp);
if(count < 1) {
std::cout << buflen << std::endl;
std::cout << count << std::endl;
throw std::runtime_error(strerror(errno));
}
}
void flush() { fflush(m_fp); }
void close() { fclose(m_fp); }
private:
FILE* m_fp;
};
int main(void)
{
int pair[2];
pipe(pair);
// run server thread
Server srv(pair[0]);
pthread_t thread;
pthread_create(&thread, NULL,
run_server, reinterpret_cast<void*>(&srv));
// client thread:
fwriter writer(pair[1]);
msgpack::packer<fwriter> pk(writer);
typedef msgpack::type::tuple<std::string, std::string, std::string> put_t;
typedef msgpack::type::tuple<std::string, std::string> get_t;
put_t req1("put", "apple", "red");
put_t req2("put", "lemon", "yellow");
get_t req3("get", "apple");
pk.pack(req1);
pk.pack(req2);
pk.pack(req3);
writer.flush();
writer.close();
pthread_join(thread, NULL);
}

View File

@@ -1,72 +0,0 @@
require 'msgpack'
class Server
def initialize(sock)
@sock = sock
@pk = MessagePack::Unpacker.new
@buffer = ''
@nread = 0
end
def run
while true
begin
data = @sock.sysread(1024)
rescue
puts "connection closed (#{$!})"
return
end
receive_data(data)
end
end
private
def receive_data(data)
@buffer << data
while true
@nread = @pk.execute(@buffer, @nread)
if @pk.finished?
msg = @pk.data
process_message(msg)
@pk.reset
@buffer.slice!(0, @nread)
@nread = 0
next unless @buffer.empty?
end
break
end
if @buffer.length > 10*1024*1024
raise "message is too large"
end
rescue
puts "error while processing client packet: #{$!}"
end
def process_message(msg)
puts "message reached: #{msg.inspect}"
end
end
rpipe, wpipe = IO.pipe
# run server thread
thread = Thread.new(Server.new(rpipe)) {|srv|
srv.run
}
# client thread:
wpipe.write ["put", "apple", "red"].to_msgpack
wpipe.write ["put", "lemon", "yellow"].to_msgpack
wpipe.write ["get", "apple"].to_msgpack
wpipe.close
thread.join

View File

@@ -15,8 +15,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @defgroup msgpack MessagePack C
* @{
* @}
*/
#include "msgpack/util.h"
#include "msgpack/object.h"
#include "msgpack/zone.h"
#include "msgpack/pack.h"
#include "msgpack/unpack.h"
#include "msgpack/sbuffer.h"
#include "msgpack/vrefbuffer.h"
#include "msgpack/version.h"

View File

@@ -16,8 +16,10 @@
// limitations under the License.
//
#include "msgpack/object.hpp"
#include "msgpack/iterator.hpp"
#include "msgpack/zone.hpp"
#include "msgpack/pack.hpp"
#include "msgpack/unpack.hpp"
#include "msgpack/sbuffer.hpp"
#include "msgpack.h"
#include "msgpack/vrefbuffer.hpp"
#include "msgpack/version.hpp"

View File

@@ -0,0 +1,58 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_BOOL_HPP
#define MSGPACK_TYPE_BOOL_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <vector>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
inline msgpack::object const& operator>> (msgpack::object const& o, bool& v)
{
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
v = o.via.boolean;
return o;
}
template <typename Stream>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v)
{
if(v) { o.pack_true(); }
else { o.pack_false(); }
return o;
}
inline void operator<< (msgpack::object& o, bool v)
{
o.type = msgpack::type::BOOLEAN;
o.via.boolean = v;
}
inline void operator<< (msgpack::object::with_zone& o, bool v)
{ static_cast<msgpack::object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_BOOL_HPP

View File

@@ -15,35 +15,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_NIL_HPP__
#define MSGPACK_TYPE_NIL_HPP__
#ifndef MSGPACK_TYPE_BOOL_FWD_HPP
#define MSGPACK_TYPE_BOOL_FWD_HPP
#include "msgpack/object.hpp"
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
namespace msgpack {
namespace type {
struct nil { };
} // namespace type
inline type::nil& operator>> (object o, type::nil& v)
{
if(o.type != type::NIL) { throw type_error(); }
return v;
}
MSGPACK_API_VERSION_NAMESPACE(v1) {
msgpack::object const& operator>> (msgpack::object const& o, bool& v);
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const type::nil& v)
{
o.pack_nil();
return o;
}
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v);
void operator<< (msgpack::object& o, bool v);
void operator<< (msgpack::object::with_zone& o, bool v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/nil.hpp */
#endif // MSGPACK_TYPE_BOOL_FWD_HPP

View File

@@ -0,0 +1,78 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_CHAR_PTR_HPP
#define MSGPACK_TYPE_CHAR_PTR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <cstring>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename Stream>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v)
{
uint32_t size = checked_get_container_size(std::strlen(v));
o.pack_str(size);
o.pack_str_body(v, size);
return o;
}
inline void operator<< (msgpack::object::with_zone& o, const char* v)
{
uint32_t size = checked_get_container_size(std::strlen(v));
o.type = msgpack::type::STR;
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.str.ptr = ptr;
o.via.str.size = size;
std::memcpy(ptr, v, size);
}
inline void operator<< (msgpack::object& o, const char* v)
{
uint32_t size = checked_get_container_size(std::strlen(v));
o.type = msgpack::type::STR;
o.via.str.ptr = v;
o.via.str.size = size;
}
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, char* v)
{
return msgpack::operator<<(o, static_cast<const char*>(v));
}
inline void operator<< (object::with_zone& o, char* v)
{
msgpack::operator<<(o, static_cast<const char*>(v));
}
inline void operator<< (object& o, char* v)
{
msgpack::operator<<(o, static_cast<const char*>(v));
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_CHAR_PTR_HPP

View File

@@ -0,0 +1,43 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_CHAR_PTR_FWD_HPP
#define MSGPACK_TYPE_CHAR_PTR_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <cstring>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename Stream>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v);
void operator<< (msgpack::object::with_zone& o, const char* v);
void operator<< (msgpack::object& o, const char* v);
template <typename Stream>
packer<Stream>& operator<< (packer<Stream>& o, char* v);
void operator<< (object::with_zone& o, char* v);
void operator<< (object& o, char* v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_CHAR_PTR_FWD_HPP

View File

@@ -0,0 +1,61 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CHECK_CONTAINER_SIZE_HPP
#define MSGPACK_CHECK_CONTAINER_SIZE_HPP
#include "msgpack/versioning.hpp"
#include <stdexcept>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
struct container_size_overflow : public std::runtime_error {
explicit container_size_overflow(const std::string& msg)
:std::runtime_error(msg) {}
#if !defined(MSGPACK_USE_CPP03)
explicit container_size_overflow(const char* msg):
std::runtime_error(msg) {}
#endif // !defined(MSGPACK_USE_CPP03)
};
namespace detail {
template <std::size_t N>
inline void check_container_size(std::size_t size) {
if (size > 0xffffffff) throw container_size_overflow("container size overflow");
}
template <>
inline void check_container_size<4>(std::size_t size) {
}
} // namespace detail
template <typename T>
inline uint32_t checked_get_container_size(T size) {
detail::check_container_size<sizeof(T)>(size);
return static_cast<uint32_t>(size);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CHECK_CONTAINER_SIZE_HPP

View File

@@ -0,0 +1,76 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_ARRAY_HPP
#define MSGPACK_CPP11_ARRAY_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <array>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T, std::size_t N>
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v) {
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
if(o.via.array.size != N) { throw msgpack::type_error(); }
if(o.via.array.size > 0) {
msgpack::object* p = o.via.array.ptr;
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
T* it = &v[0];
do {
p->convert(*it);
++p;
++it;
} while(p < pend);
}
return o;
}
template <typename Stream, typename T, std::size_t N>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v) {
uint32_t size = checked_get_container_size(v.size());
o.pack_array(size);
for(auto const& e : v) o.pack(e);
return o;
}
template <typename T, std::size_t N>
inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v) {
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
o.via.array.size = size;
o.via.array.ptr = p;
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_ARRAY_HPP

View File

@@ -0,0 +1,84 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_ARRAY_CHAR_HPP
#define MSGPACK_TYPE_ARRAY_CHAR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <array>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <std::size_t N>
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v)
{
switch (o.type) {
case msgpack::type::BIN:
if(o.via.bin.size != N) { throw msgpack::type_error(); }
std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size);
break;
case msgpack::type::STR:
if(o.via.str.size != N) { throw msgpack::type_error(); }
std::memcpy(v.data(), o.via.str.ptr, N);
break;
default:
throw msgpack::type_error();
break;
}
return o;
}
template <typename Stream, std::size_t N>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_bin(size);
o.pack_bin_body(v.data(), size);
return o;
}
template <std::size_t N>
inline void operator<< (msgpack::object& o, const std::array<char, N>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
o.via.bin.ptr = v.data();
o.via.bin.size = size;
}
template <std::size_t N>
inline void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.bin.ptr = ptr;
o.via.bin.size = size;
std::memcpy(ptr, v.data(), size);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_ARRAY_CHAR_HPP

View File

@@ -0,0 +1,45 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP
#define MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <array>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <std::size_t N>
msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v);
template <typename Stream, std::size_t N>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v);
template <std::size_t N>
void operator<< (msgpack::object& o, const std::array<char, N>& v);
template <std::size_t N>
void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP

View File

@@ -0,0 +1,44 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_ARRAY_FWD_HPP
#define MSGPACK_CPP11_ARRAY_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <array>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T, std::size_t N>
msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v);
template <typename Stream, typename T, std::size_t N>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v);
template <typename T, std::size_t N>
void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_ARRAY_FWD_HPP

View File

@@ -0,0 +1,75 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO-2015 Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_FORWARD_LIST_HPP
#define MSGPACK_CPP11_FORWARD_LIST_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <forward_list>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v)
{
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
v.resize(o.via.array.size);
msgpack::object* p = o.via.array.ptr;
for (auto &e : v) {
p->convert(e);
++p;
}
return o;
}
template <typename Stream, typename T>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v)
{
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
o.pack_array(size);
for(auto const& e : v) o.pack(e);
return o;
}
template <typename T>
inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v)
{
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
o.via.array.size = size;
msgpack::object* p = static_cast<msgpack::object*>(
o.zone.allocate_align(sizeof(msgpack::object)*size));
o.via.array.ptr = p;
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_FORWARD_LIST_HPP

View File

@@ -0,0 +1,44 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_FORWARD_LIST_FWD_HPP
#define MSGPACK_CPP11_FORWARD_LIST_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <forward_list>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v);
template <typename Stream, typename T>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v);
template <typename T>
void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_FORWARD_LIST_FWD_HPP

View File

@@ -0,0 +1,152 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_TUPLE_HPP
#define MSGPACK_CPP11_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <tuple>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
// --- Pack from tuple to packer stream ---
template <typename Stream, typename Tuple, std::size_t N>
struct StdTuplePacker {
static void pack(
msgpack::packer<Stream>& o,
const Tuple& v) {
StdTuplePacker<Stream, Tuple, N-1>::pack(o, v);
o.pack(std::get<N-1>(v));
}
};
template <typename Stream, typename Tuple>
struct StdTuplePacker<Stream, Tuple, 1> {
static void pack (
msgpack::packer<Stream>& o,
const Tuple& v) {
o.pack(std::get<0>(v));
}
};
template <typename Stream, typename Tuple>
struct StdTuplePacker<Stream, Tuple, 0> {
static void pack (
msgpack::packer<Stream>&,
const Tuple&) {
}
};
template <typename Stream, typename... Args>
inline const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const std::tuple<Args...>& v) {
uint32_t size = checked_get_container_size(sizeof...(Args));
o.pack_array(size);
StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
return o;
}
// --- Convert from tuple to object ---
template <typename Tuple, std::size_t N>
struct StdTupleConverter {
static void convert(
msgpack::object const& o,
Tuple& v) {
StdTupleConverter<Tuple, N-1>::convert(o, v);
o.via.array.ptr[N-1].convert<typename std::remove_reference<decltype(std::get<N-1>(v))>::type>(std::get<N-1>(v));
}
};
template <typename Tuple>
struct StdTupleConverter<Tuple, 1> {
static void convert (
msgpack::object const& o,
Tuple& v) {
o.via.array.ptr[0].convert<typename std::remove_reference<decltype(std::get<0>(v))>::type>(std::get<0>(v));
}
};
template <typename Tuple>
struct StdTupleConverter<Tuple, 0> {
static void convert (
msgpack::object const&,
Tuple&) {
}
};
template <typename... Args>
inline msgpack::object const& operator>> (
msgpack::object const& o,
std::tuple<Args...>& v) {
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
StdTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
return o;
}
// --- Convert from tuple to object with zone ---
template <typename Tuple, std::size_t N>
struct StdTupleToObjectWithZone {
static void convert(
msgpack::object::with_zone& o,
const Tuple& v) {
StdTupleToObjectWithZone<Tuple, N-1>::convert(o, v);
o.via.array.ptr[N-1] = msgpack::object(std::get<N-1>(v), o.zone);
}
};
template <typename Tuple>
struct StdTupleToObjectWithZone<Tuple, 1> {
static void convert (
msgpack::object::with_zone& o,
const Tuple& v) {
o.via.array.ptr[0] = msgpack::object(std::get<0>(v), o.zone);
}
};
template <typename Tuple>
struct StdTupleToObjectWithZone<Tuple, 0> {
static void convert (
msgpack::object::with_zone&,
const Tuple&) {
}
};
template <typename... Args>
inline void operator<< (
msgpack::object::with_zone& o,
std::tuple<Args...> const& v) {
uint32_t size = checked_get_container_size(sizeof...(Args));
o.type = msgpack::type::ARRAY;
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
o.via.array.size = size;
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_TUPLE_HPP

View File

@@ -0,0 +1,62 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_CPP11_TUPLE_FWD_HPP
#define MSGPACK_CPP11_TUPLE_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <tuple>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
// --- Pack from tuple to packer stream ---
template <typename Stream, typename Tuple, std::size_t N>
struct StdTuplePacker;
template <typename Stream, typename... Args>
const msgpack::packer<Stream>& operator<< (
msgpack::packer<Stream>& o,
const std::tuple<Args...>& v);
// --- Convert from tuple to object ---
template <typename Tuple, std::size_t N>
struct StdTupleConverter;
template <typename... Args>
msgpack::object const& operator>> (
msgpack::object const& o,
std::tuple<Args...>& v);
// --- Convert from tuple to object with zone ---
template <typename Tuple, std::size_t N>
struct StdTupleToObjectWithZone;
template <typename... Args>
void operator<< (
msgpack::object::with_zone& o,
std::tuple<Args...> const& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_TUPLE_FWD_HPP

View File

@@ -0,0 +1,142 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_UNORDERED_MAP_HPP
#define MSGPACK_TYPE_UNORDERED_MAP_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <unordered_map>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename K, typename V>
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v)
{
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
msgpack::object_kv* p(o.via.map.ptr);
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
std::unordered_map<K, V> tmp;
for(; p != pend; ++p) {
K key;
p->key.convert(key);
p->val.convert(tmp[key]);
}
tmp.swap(v);
return o;
}
template <typename Stream, typename K, typename V>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_map(size);
for(typename std::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(it->first);
o.pack(it->second);
}
return o;
}
template <typename K, typename V>
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v)
{
o.type = msgpack::type::MAP;
if(v.empty()) {
o.via.map.ptr = nullptr;
o.via.map.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
msgpack::object_kv* const pend = p + size;
o.via.map.ptr = p;
o.via.map.size = size;
typename std::unordered_map<K,V>::const_iterator it(v.begin());
do {
p->key = msgpack::object(it->first, o.zone);
p->val = msgpack::object(it->second, o.zone);
++p;
++it;
} while(p < pend);
}
}
template <typename K, typename V>
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v)
{
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
msgpack::object_kv* p(o.via.map.ptr);
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
std::unordered_multimap<K, V> tmp;
for(; p != pend; ++p) {
std::pair<K, V> value;
p->key.convert(value.first);
p->val.convert(value.second);
tmp.insert(value);
}
tmp.swap(v);
return o;
}
template <typename Stream, typename K, typename V>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_map(size);
for(typename std::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(it->first);
o.pack(it->second);
}
return o;
}
template <typename K, typename V>
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v)
{
o.type = msgpack::type::MAP;
if(v.empty()) {
o.via.map.ptr = nullptr;
o.via.map.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
msgpack::object_kv* const pend = p + size;
o.via.map.ptr = p;
o.via.map.size = size;
typename std::unordered_multimap<K,V>::const_iterator it(v.begin());
do {
p->key = msgpack::object(it->first, o.zone);
p->val = msgpack::object(it->second, o.zone);
++p;
++it;
} while(p < pend);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_UNORDERED_MAP_HPP

View File

@@ -0,0 +1,53 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
#define MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <unordered_map>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename K, typename V>
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v);
template <typename Stream, typename K, typename V>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v);
template <typename K, typename V>
void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v);
template <typename K, typename V>
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v);
template <typename Stream, typename K, typename V>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v);
template <typename K, typename V>
void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP

View File

@@ -0,0 +1,134 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014-2015 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_UNORDERED_SET_HPP
#define MSGPACK_TYPE_UNORDERED_SET_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <unordered_set>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v)
{
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
msgpack::object* p = o.via.array.ptr + o.via.array.size;
msgpack::object* const pbegin = o.via.array.ptr;
std::unordered_set<T> tmp;
while(p > pbegin) {
--p;
tmp.insert(p->as<T>());
}
tmp.swap(v);
return o;
}
template <typename Stream, typename T>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_array(size);
for(typename std::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
template <typename T>
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v)
{
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
msgpack::object* const pend = p + size;
o.via.array.ptr = p;
o.via.array.size = size;
typename std::unordered_set<T>::const_iterator it(v.begin());
do {
*p = msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
template <typename T>
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v)
{
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
msgpack::object* p = o.via.array.ptr + o.via.array.size;
msgpack::object* const pbegin = o.via.array.ptr;
std::unordered_multiset<T> tmp;
while(p > pbegin) {
--p;
tmp.insert(p->as<T>());
}
tmp.swap(v);
return o;
}
template <typename Stream, typename T>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_array(size);
for(typename std::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
template <typename T>
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v)
{
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
msgpack::object* const pend = p + size;
o.via.array.ptr = p;
o.via.array.size = size;
typename std::unordered_multiset<T>::const_iterator it(v.begin());
do {
*p = msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_UNORDERED_SET_HPP

View File

@@ -0,0 +1,52 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2014 KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
#define MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <unordered_set>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v);
template <typename Stream, typename T>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v);
template <typename T>
void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v);
template <typename T>
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v);
template <typename Stream, typename T>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v);
template <typename T>
void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_UNORDERED_SET_FWD_HPP

View File

@@ -0,0 +1,29 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_DEFINE_HPP
#define MSGPACK_DEFINE_HPP
#include "msgpack/cpp_config.hpp"
#if defined(MSGPACK_USE_CPP03)
#include "detail/cpp03_define.hpp"
#else // MSGPACK_USE_CPP03
#include "detail/cpp11_define.hpp"
#endif // MSGPACK_USE_CPP03
#endif // MSGPACK_DEFINE_HPP

View File

@@ -0,0 +1,83 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_DEQUE_HPP
#define MSGPACK_TYPE_DEQUE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <deque>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v)
{
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
v.resize(o.via.array.size);
msgpack::object* p = o.via.array.ptr;
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
typename std::deque<T>::iterator it = v.begin();
for(; p < pend; ++p, ++it) {
p->convert(*it);
}
return o;
}
template <typename Stream, typename T>
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v)
{
uint32_t size = checked_get_container_size(v.size());
o.pack_array(size);
for(typename std::deque<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
template <typename T>
inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
{
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
msgpack::object* const pend = p + size;
o.via.array.ptr = p;
o.via.array.size = size;
typename std::deque<T>::const_iterator it(v.begin());
do {
*p = msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/deque.hpp */

View File

@@ -0,0 +1,40 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_DEQUE_FWD_HPP
#define MSGPACK_TYPE_DEQUE_FWD_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object_fwd.hpp"
#include <deque>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v);
template <typename Stream, typename T>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v);
template <typename T>
void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_DEQUE_FWD_HPP

Some files were not shown because too many files have changed in this diff Show More