mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 07:45:02 +02:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
568704ed22 | ||
![]() |
05a7e4eb64 | ||
![]() |
7a0acf2838 | ||
![]() |
27787505e0 | ||
![]() |
2c8048115d | ||
![]() |
7df1780853 | ||
![]() |
d5609f3207 | ||
![]() |
cd10fbc1fe | ||
![]() |
ca0b085d15 | ||
![]() |
9a034234d8 | ||
![]() |
66ef6c9e4c | ||
![]() |
7df60b259b | ||
![]() |
34b3bbc883 | ||
![]() |
e02d20dd74 | ||
![]() |
1a11608f1f | ||
![]() |
9e2c9d7812 | ||
![]() |
404a393315 | ||
![]() |
c69092e110 | ||
![]() |
ebc0eeac79 | ||
![]() |
2b72f35c32 | ||
![]() |
d8212ad620 | ||
![]() |
1066bb38a8 |
2
COPYING
2
COPYING
@@ -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.
|
||||
|
@@ -11,3 +11,8 @@ nobase_include_HEADERS = \
|
||||
msgpack/unpack_template.h \
|
||||
msgpack/sysdep.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
msgpack_vc8.vcproj \
|
||||
msgpack_vc8.sln \
|
||||
msgpack_vc8.postbuild.bat
|
||||
|
||||
|
8
README
8
README
@@ -19,12 +19,12 @@ Binary-based efficient data interchange format.
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
To install Ruby binding, run ./gengem.sh script on ruby/ directory and install
|
||||
To install Ruby binding, run ./makegem.sh script on ruby/ directory and install
|
||||
generated gem package.
|
||||
|
||||
$ cd ruby
|
||||
$ ./gengem.sh
|
||||
$ gem install gem/pkg/msgpack-*.gem
|
||||
$ ./makegem.sh
|
||||
$ gem install msgpack-*.gem
|
||||
|
||||
|
||||
*Usage
|
||||
@@ -54,7 +54,7 @@ Binary-based efficient data interchange format.
|
||||
API Document is available at http://msgpack.sourceforge.jp/.
|
||||
|
||||
|
||||
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.
|
||||
|
@@ -23,6 +23,6 @@ check_PROGRAMS = \
|
||||
|
||||
msgpackc_test_SOURCES = test.cpp
|
||||
msgpackc_test_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/c
|
||||
msgpackc_test_LDFLAGS = libmsgpackc.la -lgtest_main
|
||||
msgpackc_test_LDADD = libmsgpackc.la -lgtest_main
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#define MSGPACK_OBJECT_H__
|
||||
|
||||
#include "msgpack/zone.h"
|
||||
#include "msgpack/sysdep.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
@@ -18,8 +18,7 @@
|
||||
#ifndef MSGPACK_ZONE_H__
|
||||
#define MSGPACK_ZONE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "msgpack/sysdep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@@ -52,7 +52,7 @@ static int template_execute(template_context* ctx,
|
||||
|
||||
|
||||
static inline msgpack_object template_callback_root(unpack_user* u)
|
||||
{ msgpack_object o; return o; }
|
||||
{ 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; }
|
||||
|
@@ -30,7 +30,6 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
vbuf->chunk_size = chunk_size;
|
||||
vbuf->ref_size = ref_size;
|
||||
|
||||
// glibcは72バイト以下のmallocが高速
|
||||
size_t nfirst = (sizeof(struct iovec) < 72/2) ?
|
||||
72 / sizeof(struct iovec) : 8;
|
||||
|
||||
|
4
c/zone.c
4
c/zone.c
@@ -104,7 +104,6 @@ static inline void init_finalizer_array(msgpack_zone_finalizer_array* fa)
|
||||
|
||||
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);
|
||||
@@ -132,9 +131,6 @@ bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
||||
|
||||
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;
|
||||
|
||||
|
28
configure.in
28
configure.in
@@ -1,6 +1,6 @@
|
||||
AC_INIT(msgpack/unpack_template.h)
|
||||
AC_CONFIG_AUX_DIR(ac)
|
||||
AM_INIT_AUTOMAKE(msgpack, 0.4.0)
|
||||
AM_INIT_AUTOMAKE(msgpack, 0.4.3)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
@@ -12,7 +12,6 @@ AC_PROG_CC
|
||||
|
||||
CFLAGS="-O4 -Wall $CFLAGS -I.."
|
||||
|
||||
|
||||
AC_MSG_CHECKING([if c++ api is enabled])
|
||||
AC_ARG_ENABLE(cxx,
|
||||
AS_HELP_STRING([--disable-cxx],
|
||||
@@ -25,11 +24,34 @@ if test "$enable_cxx" != "no"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# FIXME
|
||||
# FIXME enable_cxx
|
||||
AC_PROG_CXX
|
||||
|
||||
CXXFLAGS="-O4 -Wall $CXXFLAGS -I.. -I../c"
|
||||
|
||||
# FIXME enable_cxx
|
||||
AC_LANG_PUSH([C++])
|
||||
AC_CHECK_HEADERS(tr1/unordered_map)
|
||||
AC_CHECK_HEADERS(tr1/unordered_set)
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
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); }
|
||||
], [], msgpack_cv_atomic_ops="yes")
|
||||
])
|
||||
if test "$msgpack_cv_atomic_ops" != "yes"; then
|
||||
AC_MSG_ERROR([__sync_* atomic operations are not supported.
|
||||
|
||||
Note that gcc < 4.1 is not supported.
|
||||
|
||||
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
|
||||
add CFLAGS="--march=i686" and CXXFLAGS="-march=i668" options to ./configure as follows:
|
||||
|
||||
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
|
||||
])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no")
|
||||
|
||||
|
@@ -39,6 +39,6 @@ check_PROGRAMS = \
|
||||
|
||||
msgpack_test_SOURCES = test.cpp
|
||||
msgpack_test_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/c -I$(top_srcdir)/cpp
|
||||
msgpack_test_LDFLAGS = libmsgpack.la -lgtest_main
|
||||
msgpack_test_LDADD = libmsgpack.la -lgtest_main
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
@@ -1 +0,0 @@
|
||||
.
|
@@ -29,11 +29,15 @@ inline std::vector<T>& operator>> (object o, std::vector<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
T* it = &v.front();
|
||||
for(; p < pend; ++p, ++it) {
|
||||
p->convert(it);
|
||||
if(o.via.array.size > 0) {
|
||||
object* p = o.via.array.ptr;
|
||||
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 v;
|
||||
}
|
190
cpp/test.cpp
190
cpp/test.cpp
@@ -10,6 +10,10 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int kLoop = 10000;
|
||||
@@ -227,6 +231,8 @@ TEST(MSGPACK, simple_buffer_false)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// STL
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_string)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
@@ -365,6 +371,190 @@ TEST(MSGPACK_STL, simple_buffer_pair)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_multimap)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
multimap<int, int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++) {
|
||||
int i1 = rand();
|
||||
val1.insert(make_pair(i1, rand()));
|
||||
val1.insert(make_pair(i1, rand()));
|
||||
}
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
multimap<int, int> val2;
|
||||
obj.convert(&val2);
|
||||
|
||||
vector<pair<int, int> > v1, v2;
|
||||
multimap<int, int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it)
|
||||
v1.push_back(make_pair(it->first, it->second));
|
||||
for (it = val2.begin(); it != val2.end(); ++it)
|
||||
v2.push_back(make_pair(it->first, it->second));
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_EQ(v1.size(), v2.size());
|
||||
sort(v1.begin(), v1.end());
|
||||
sort(v2.begin(), v2.end());
|
||||
EXPECT_TRUE(v1 == v2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_multiset)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
multiset<int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1.insert(rand());
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
multiset<int> val2;
|
||||
obj.convert(&val2);
|
||||
|
||||
vector<int> v1, v2;
|
||||
multiset<int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it)
|
||||
v1.push_back(*it);
|
||||
for (it = val2.begin(); it != val2.end(); ++it)
|
||||
v2.push_back(*it);
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_EQ(v1.size(), v2.size());
|
||||
sort(v1.begin(), v1.end());
|
||||
sort(v2.begin(), v2.end());
|
||||
EXPECT_TRUE(v1 == v2);
|
||||
}
|
||||
}
|
||||
|
||||
// TR1
|
||||
|
||||
#ifdef HAVE_TR1_UNORDERED_MAP
|
||||
#include <tr1/unordered_map>
|
||||
#include "cpp/msgpack/type/tr1/unordered_map.hpp"
|
||||
TEST(MSGPACK_TR1, simple_buffer_unordered_map)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
tr1::unordered_map<int, int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1[rand()] = rand();
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
tr1::unordered_map<int, int> val2;
|
||||
obj.convert(&val2);
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
tr1::unordered_map<int, int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it) {
|
||||
EXPECT_TRUE(val2.find(it->first) != val2.end());
|
||||
EXPECT_EQ(it->second, val2.find(it->first)->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_TR1, simple_buffer_unordered_multimap)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
tr1::unordered_multimap<int, int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++) {
|
||||
int i1 = rand();
|
||||
val1.insert(make_pair(i1, rand()));
|
||||
val1.insert(make_pair(i1, rand()));
|
||||
}
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
tr1::unordered_multimap<int, int> val2;
|
||||
obj.convert(&val2);
|
||||
|
||||
vector<pair<int, int> > v1, v2;
|
||||
tr1::unordered_multimap<int, int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it)
|
||||
v1.push_back(make_pair(it->first, it->second));
|
||||
for (it = val2.begin(); it != val2.end(); ++it)
|
||||
v2.push_back(make_pair(it->first, it->second));
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_EQ(v1.size(), v2.size());
|
||||
sort(v1.begin(), v1.end());
|
||||
sort(v2.begin(), v2.end());
|
||||
EXPECT_TRUE(v1 == v2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TR1_UNORDERED_SET
|
||||
#include <tr1/unordered_set>
|
||||
#include "cpp/msgpack/type/tr1/unordered_set.hpp"
|
||||
TEST(MSGPACK_TR1, simple_buffer_unordered_set)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
tr1::unordered_set<int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1.insert(rand());
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
tr1::unordered_set<int> val2;
|
||||
obj.convert(&val2);
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
tr1::unordered_set<int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it)
|
||||
EXPECT_TRUE(val2.find(*it) != val2.end());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_TR1, simple_buffer_unordered_multiset)
|
||||
{
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
tr1::unordered_multiset<int> val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1.insert(rand());
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, val1);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj;
|
||||
msgpack::unpack_return ret =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size(), NULL, &z, &obj);
|
||||
EXPECT_EQ(msgpack::UNPACK_SUCCESS, ret);
|
||||
tr1::unordered_multiset<int> val2;
|
||||
obj.convert(&val2);
|
||||
|
||||
vector<int> v1, v2;
|
||||
tr1::unordered_multiset<int>::const_iterator it;
|
||||
for (it = val1.begin(); it != val1.end(); ++it)
|
||||
v1.push_back(*it);
|
||||
for (it = val2.begin(); it != val2.end(); ++it)
|
||||
v2.push_back(*it);
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_EQ(v1.size(), v2.size());
|
||||
sort(v1.begin(), v1.end());
|
||||
sort(v2.begin(), v2.end());
|
||||
EXPECT_TRUE(v1 == v2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// User-Defined Structures
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MessagePack unpacking routine template
|
||||
*
|
||||
* 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.
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "msgpack/sysdep.h"
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#endif /* msgpack/pack_define.h */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MessagePack packing routine template
|
||||
*
|
||||
* 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.
|
||||
@@ -69,7 +69,7 @@ do { \
|
||||
} else { \
|
||||
/* unsigned 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} \
|
||||
} while(0)
|
||||
@@ -89,12 +89,12 @@ do { \
|
||||
if(d < (1<<16)) { \
|
||||
/* unsigned 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else { \
|
||||
/* unsigned 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} \
|
||||
} \
|
||||
@@ -115,17 +115,17 @@ do { \
|
||||
if(d < (1ULL<<16)) { \
|
||||
/* signed 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else if(d < (1ULL<<32)) { \
|
||||
/* signed 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} else { \
|
||||
/* signed 64 */ \
|
||||
unsigned char buf[9]; \
|
||||
buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
|
||||
buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 9); \
|
||||
} \
|
||||
} \
|
||||
@@ -149,7 +149,7 @@ do { \
|
||||
if(d < -(1<<7)) { \
|
||||
/* signed 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else { \
|
||||
/* signed 8 */ \
|
||||
@@ -167,7 +167,7 @@ do { \
|
||||
} else { \
|
||||
/* unsigned 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} \
|
||||
} \
|
||||
@@ -179,12 +179,12 @@ do { \
|
||||
if(d < -(1<<15)) { \
|
||||
/* signed 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xd2; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} else if(d < -(1<<7)) { \
|
||||
/* signed 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else { \
|
||||
/* signed 8 */ \
|
||||
@@ -202,12 +202,12 @@ do { \
|
||||
} else if(d < (1<<16)) { \
|
||||
/* unsigned 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else { \
|
||||
/* unsigned 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} \
|
||||
} \
|
||||
@@ -220,19 +220,19 @@ do { \
|
||||
if(d < -(1LL<<31)) { \
|
||||
/* signed 64 */ \
|
||||
unsigned char buf[9]; \
|
||||
buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
|
||||
buf[0] = 0xd3; _msgpack_store64(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 9); \
|
||||
} else { \
|
||||
/* signed 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xd2; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} \
|
||||
} else { \
|
||||
if(d < -(1<<7)) { \
|
||||
/* signed 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} else { \
|
||||
/* signed 8 */ \
|
||||
@@ -252,19 +252,19 @@ do { \
|
||||
} else { \
|
||||
/* unsigned 16 */ \
|
||||
unsigned char buf[3]; \
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 3); \
|
||||
} \
|
||||
} else { \
|
||||
if(d < (1LL<<32)) { \
|
||||
/* unsigned 32 */ \
|
||||
unsigned char buf[5]; \
|
||||
buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
|
||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 5); \
|
||||
} else { \
|
||||
/* unsigned 64 */ \
|
||||
unsigned char buf[9]; \
|
||||
buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
|
||||
buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
|
||||
msgpack_pack_append_buffer(x, buf, 9); \
|
||||
} \
|
||||
} \
|
||||
@@ -283,21 +283,21 @@ msgpack_pack_inline_func_fastint(_uint8)(msgpack_pack_user x, uint8_t d)
|
||||
msgpack_pack_inline_func_fastint(_uint16)(msgpack_pack_user x, uint16_t d)
|
||||
{
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d);
|
||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func_fastint(_uint32)(msgpack_pack_user x, uint32_t d)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d);
|
||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func_fastint(_uint64)(msgpack_pack_user x, uint64_t d)
|
||||
{
|
||||
unsigned char buf[9];
|
||||
buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d);
|
||||
buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 9);
|
||||
}
|
||||
|
||||
@@ -310,21 +310,21 @@ msgpack_pack_inline_func_fastint(_int8)(msgpack_pack_user x, int8_t d)
|
||||
msgpack_pack_inline_func_fastint(_int16)(msgpack_pack_user x, int16_t d)
|
||||
{
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d);
|
||||
buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func_fastint(_int32)(msgpack_pack_user x, int32_t d)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d);
|
||||
buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func_fastint(_int64)(msgpack_pack_user x, int64_t d)
|
||||
{
|
||||
unsigned char buf[9];
|
||||
buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d);
|
||||
buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
|
||||
msgpack_pack_append_buffer(x, buf, 9);
|
||||
}
|
||||
|
||||
@@ -554,19 +554,19 @@ if(sizeof(unsigned long long) == 2) {
|
||||
|
||||
msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
|
||||
{
|
||||
union { char buf[4]; uint32_t num; } f;
|
||||
*((float*)&f.buf) = d; // FIXME
|
||||
union { float f; uint32_t i; } mem;
|
||||
mem.f = d;
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xca; *(uint32_t*)&buf[1] = _msgpack_be32(f.num);
|
||||
buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
|
||||
{
|
||||
union { char buf[8]; uint64_t num; } f;
|
||||
*((double*)&f.buf) = d; // FIXME
|
||||
union { double f; uint64_t i; } mem;
|
||||
mem.f = d;
|
||||
unsigned char buf[9];
|
||||
buf[0] = 0xcb; *(uint64_t*)&buf[1] = _msgpack_be64(f.num);
|
||||
buf[0] = 0xcb; _msgpack_store64(&buf[1], mem.i);
|
||||
msgpack_pack_append_buffer(x, buf, 9);
|
||||
}
|
||||
|
||||
@@ -610,11 +610,11 @@ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
|
||||
msgpack_pack_append_buffer(x, &d, 1);
|
||||
} else if(n < 65536) {
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xdc; *(uint16_t*)&buf[1] = _msgpack_be16(n);
|
||||
buf[0] = 0xdc; _msgpack_store16(&buf[1], n);
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
} else {
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xdd; *(uint32_t*)&buf[1] = _msgpack_be32(n);
|
||||
buf[0] = 0xdd; _msgpack_store32(&buf[1], n);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
}
|
||||
@@ -631,11 +631,11 @@ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
|
||||
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
|
||||
} else if(n < 65536) {
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xde; *(uint16_t*)&buf[1] = _msgpack_be16(n);
|
||||
buf[0] = 0xde; _msgpack_store16(&buf[1], n);
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
} else {
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xdf; *(uint32_t*)&buf[1] = _msgpack_be32(n);
|
||||
buf[0] = 0xdf; _msgpack_store32(&buf[1], n);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
}
|
||||
@@ -652,11 +652,11 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
|
||||
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
|
||||
} else if(l < 65536) {
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xda; *(uint16_t*)&buf[1] = _msgpack_be16(l);
|
||||
buf[0] = 0xda; _msgpack_store16(&buf[1], l);
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
} else {
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xdb; *(uint32_t*)&buf[1] = _msgpack_be32(l);
|
||||
buf[0] = 0xdb; _msgpack_store32(&buf[1], l);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MessagePack system dependencies
|
||||
*
|
||||
* 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.
|
||||
@@ -48,6 +48,17 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* numeric_limits<T>::min,max */
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <arpa/inet.h> /* __BYTE_ORDER */
|
||||
#endif
|
||||
@@ -90,5 +101,18 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
#endif
|
||||
|
||||
|
||||
#define _msgpack_store16(to, num) \
|
||||
do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0);
|
||||
#define _msgpack_store32(to, num) \
|
||||
do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0);
|
||||
#define _msgpack_store64(to, num) \
|
||||
do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0);
|
||||
|
||||
|
||||
#define _msgpack_load16(cast, from) ((cast)_msgpack_be16(*(uint16_t*)from))
|
||||
#define _msgpack_load32(cast, from) ((cast)_msgpack_be32(*(uint32_t*)from))
|
||||
#define _msgpack_load64(cast, from) ((cast)_msgpack_be64(*(uint64_t*)from))
|
||||
|
||||
|
||||
#endif /* msgpack/sysdep.h */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MessagePack unpacking routine template
|
||||
*
|
||||
* 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.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MessagePack unpacking routine template
|
||||
*
|
||||
* 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.
|
||||
@@ -130,11 +130,6 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
#define NEXT_CS(p) \
|
||||
((unsigned int)*p & 0x1f)
|
||||
|
||||
#define PTR_CAST_8(ptr) (*(uint8_t*)ptr)
|
||||
#define PTR_CAST_16(ptr) _msgpack_be16(*(uint16_t*)ptr)
|
||||
#define PTR_CAST_32(ptr) _msgpack_be32(*(uint32_t*)ptr)
|
||||
#define PTR_CAST_64(ptr) _msgpack_be64(*(uint64_t*)ptr)
|
||||
|
||||
#ifdef USE_CASE_RANGE
|
||||
#define SWITCH_RANGE_BEGIN switch(*p) {
|
||||
#define SWITCH_RANGE(FROM, TO) case FROM ... TO:
|
||||
@@ -222,70 +217,70 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
//case CS_
|
||||
//case CS_
|
||||
case CS_FLOAT: {
|
||||
union { uint32_t num; char buf[4]; } f;
|
||||
f.num = PTR_CAST_32(n); // FIXME
|
||||
push_fixed_value(_float, *((float*)f.buf)); }
|
||||
union { uint32_t i; float f; } mem;
|
||||
mem.i = _msgpack_load32(uint32_t,n);
|
||||
push_fixed_value(_float, mem.f); }
|
||||
case CS_DOUBLE: {
|
||||
union { uint64_t num; char buf[8]; } f;
|
||||
f.num = PTR_CAST_64(n); // FIXME
|
||||
push_fixed_value(_double, *((double*)f.buf)); }
|
||||
union { uint64_t i; double f; } mem;
|
||||
mem.i = _msgpack_load64(uint64_t,n);
|
||||
push_fixed_value(_double, mem.f); }
|
||||
case CS_UINT_8:
|
||||
push_fixed_value(_uint8, (uint8_t)PTR_CAST_8(n));
|
||||
push_fixed_value(_uint8, *(uint8_t*)n);
|
||||
case CS_UINT_16:
|
||||
push_fixed_value(_uint16, (uint16_t)PTR_CAST_16(n));
|
||||
push_fixed_value(_uint16, _msgpack_load16(uint16_t,n));
|
||||
case CS_UINT_32:
|
||||
push_fixed_value(_uint32, (uint32_t)PTR_CAST_32(n));
|
||||
push_fixed_value(_uint32, _msgpack_load32(uint32_t,n));
|
||||
case CS_UINT_64:
|
||||
push_fixed_value(_uint64, (uint64_t)PTR_CAST_64(n));
|
||||
push_fixed_value(_uint64, _msgpack_load64(uint64_t,n));
|
||||
|
||||
case CS_INT_8:
|
||||
push_fixed_value(_int8, (int8_t)PTR_CAST_8(n));
|
||||
push_fixed_value(_int8, *(int8_t*)n);
|
||||
case CS_INT_16:
|
||||
push_fixed_value(_int16, (int16_t)PTR_CAST_16(n));
|
||||
push_fixed_value(_int16, _msgpack_load16(int16_t,n));
|
||||
case CS_INT_32:
|
||||
push_fixed_value(_int32, (int32_t)PTR_CAST_32(n));
|
||||
push_fixed_value(_int32, _msgpack_load32(int32_t,n));
|
||||
case CS_INT_64:
|
||||
push_fixed_value(_int64, (int64_t)PTR_CAST_64(n));
|
||||
push_fixed_value(_int64, _msgpack_load64(int64_t,n));
|
||||
|
||||
//case CS_
|
||||
//case CS_
|
||||
//case CS_BIG_INT_16:
|
||||
// again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, (uint16_t)PTR_CAST_16(n), _big_int_zero);
|
||||
// again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, _msgpack_load16(uint16_t,n), _big_int_zero);
|
||||
//case CS_BIG_INT_32:
|
||||
// again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, (uint32_t)PTR_CAST_32(n), _big_int_zero);
|
||||
// again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, _msgpack_load32(uint32_t,n), _big_int_zero);
|
||||
//case ACS_BIG_INT_VALUE:
|
||||
//_big_int_zero:
|
||||
// // FIXME
|
||||
// push_variable_value(_big_int, data, n, trail);
|
||||
|
||||
//case CS_BIG_FLOAT_16:
|
||||
// again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint16_t)PTR_CAST_16(n), _big_float_zero);
|
||||
// again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, _msgpack_load16(uint16_t,n), _big_float_zero);
|
||||
//case CS_BIG_FLOAT_32:
|
||||
// again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint32_t)PTR_CAST_32(n), _big_float_zero);
|
||||
// again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, _msgpack_load32(uint32_t,n), _big_float_zero);
|
||||
//case ACS_BIG_FLOAT_VALUE:
|
||||
//_big_float_zero:
|
||||
// // FIXME
|
||||
// push_variable_value(_big_float, data, n, trail);
|
||||
|
||||
case CS_RAW_16:
|
||||
again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint16_t)PTR_CAST_16(n), _raw_zero);
|
||||
again_fixed_trail_if_zero(ACS_RAW_VALUE, _msgpack_load16(uint16_t,n), _raw_zero);
|
||||
case CS_RAW_32:
|
||||
again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint32_t)PTR_CAST_32(n), _raw_zero);
|
||||
again_fixed_trail_if_zero(ACS_RAW_VALUE, _msgpack_load32(uint32_t,n), _raw_zero);
|
||||
case ACS_RAW_VALUE:
|
||||
_raw_zero:
|
||||
push_variable_value(_raw, data, n, trail);
|
||||
|
||||
case CS_ARRAY_16:
|
||||
start_container(_array, (uint16_t)PTR_CAST_16(n), CT_ARRAY_ITEM);
|
||||
start_container(_array, _msgpack_load16(uint16_t,n), CT_ARRAY_ITEM);
|
||||
case CS_ARRAY_32:
|
||||
/* FIXME security guard */
|
||||
start_container(_array, (uint32_t)PTR_CAST_32(n), CT_ARRAY_ITEM);
|
||||
start_container(_array, _msgpack_load32(uint32_t,n), CT_ARRAY_ITEM);
|
||||
|
||||
case CS_MAP_16:
|
||||
start_container(_map, (uint16_t)PTR_CAST_16(n), CT_MAP_KEY);
|
||||
start_container(_map, _msgpack_load16(uint16_t,n), CT_MAP_KEY);
|
||||
case CS_MAP_32:
|
||||
/* FIXME security guard */
|
||||
start_container(_map, (uint32_t)PTR_CAST_32(n), CT_MAP_KEY);
|
||||
start_container(_map, _msgpack_load32(uint32_t,n), CT_MAP_KEY);
|
||||
|
||||
default:
|
||||
goto _failed;
|
||||
@@ -371,8 +366,4 @@ _end:
|
||||
#undef start_container
|
||||
|
||||
#undef NEXT_CS
|
||||
#undef PTR_CAST_8
|
||||
#undef PTR_CAST_16
|
||||
#undef PTR_CAST_32
|
||||
#undef PTR_CAST_64
|
||||
|
||||
|
41
msgpack_vc8.postbuild.bat
Normal file
41
msgpack_vc8.postbuild.bat
Normal file
@@ -0,0 +1,41 @@
|
||||
IF NOT EXIST include MKDIR include
|
||||
IF NOT EXIST include\msgpack MKDIR include\msgpack
|
||||
IF NOT EXIST include\msgpack\type MKDIR include\msgpack\type
|
||||
IF NOT EXIST include\msgpack\type\tr1 MKDIR include\msgpack\type\tr1
|
||||
copy msgpack\pack_define.h include\msgpack\
|
||||
copy msgpack\pack_template.h include\msgpack\
|
||||
copy msgpack\unpack_define.h include\msgpack\
|
||||
copy msgpack\unpack_template.h include\msgpack\
|
||||
copy msgpack\sysdep.h include\msgpack\
|
||||
copy c\msgpack.h include\
|
||||
copy c\msgpack\sbuffer.h include\msgpack\
|
||||
copy c\msgpack\vrefbuffer.h include\msgpack\
|
||||
copy c\msgpack\pack.h include\msgpack\
|
||||
copy c\msgpack\unpack.h include\msgpack\
|
||||
copy c\msgpack\object.h include\msgpack\
|
||||
copy c\msgpack\zone.h include\msgpack\
|
||||
copy cpp\msgpack.hpp include\
|
||||
copy cpp\msgpack\sbuffer.hpp include\msgpack\
|
||||
copy cpp\msgpack\vrefbuffer.hpp include\msgpack\
|
||||
copy cpp\msgpack\pack.hpp include\msgpack\
|
||||
copy cpp\msgpack\unpack.hpp include\msgpack\
|
||||
copy cpp\msgpack\object.hpp include\msgpack\
|
||||
copy cpp\msgpack\zone.hpp include\msgpack\
|
||||
copy cpp\msgpack\type.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\bool.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\float.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\int.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\list.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\deque.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\map.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\nil.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\pair.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\raw.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\set.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\string.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\vector.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\tuple.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\define.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\tr1\unordered_map.hpp include\msgpack\type\
|
||||
copy cpp\msgpack\type\tr1\unordered_set.hpp include\msgpack\type\
|
||||
|
20
msgpack_vc8.sln
Normal file
20
msgpack_vc8.sln
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MessagePack", "msgpack_vc8.vcproj", "{122A2EA4-B283-4241-9655-786DE78283B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{122A2EA4-B283-4241-9655-786DE78283B2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{122A2EA4-B283-4241-9655-786DE78283B2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{122A2EA4-B283-4241-9655-786DE78283B2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{122A2EA4-B283-4241-9655-786DE78283B2}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
283
msgpack_vc8.vcproj
Executable file
283
msgpack_vc8.vcproj
Executable file
@@ -0,0 +1,283 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="MessagePack"
|
||||
ProjectGUID="{122A2EA4-B283-4241-9655-786DE78283B2}"
|
||||
RootNamespace="MessagePack"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Gathering header files"
|
||||
CommandLine="msgpack_vc8.postbuild.bat"
|
||||
Outputs="include"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="cpp;c;."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="1"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="lib\$(ProjectName)d.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Gathering header files"
|
||||
CommandLine="msgpack_vc8.postbuild.bat"
|
||||
Outputs="include"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="cpp;c;."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="lib\$(ProjectName).lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\c\object.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpp\object.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\c\unpack.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\c\vrefbuffer.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\c\zone.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\msgpack\pack_define.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msgpack\pack_template.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msgpack\sysdep.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msgpack\unpack_define.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msgpack\unpack_template.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@@ -2,7 +2,7 @@
|
||||
MessagePack Python Binding
|
||||
===========================
|
||||
|
||||
:author: Naoki INADA
|
||||
:author: INADA Naoki
|
||||
:version: 0.1.0
|
||||
:date: 2009-07-12
|
||||
|
||||
@@ -32,7 +32,11 @@ MinGW GCC.
|
||||
|
||||
TEST
|
||||
----
|
||||
MessagePack uses nosetest for testing.
|
||||
MessagePack uses `nosetest` for testing.
|
||||
Run test with following command:
|
||||
|
||||
$ nosetests test
|
||||
|
||||
|
||||
..
|
||||
vim: filetype=rst
|
||||
|
@@ -1,16 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
#from Cython.Distutils import build_ext
|
||||
import os
|
||||
from glob import glob
|
||||
from distutils.core import setup, Extension
|
||||
from distutils.command.sdist import sdist
|
||||
|
||||
try:
|
||||
from Cython.Distutils import build_ext
|
||||
import Cython.Compiler.Main as cython_compiler
|
||||
have_cython = True
|
||||
except ImportError:
|
||||
from distutils.command.build_ext import build_ext
|
||||
have_cython = False
|
||||
|
||||
version = '0.2.0dev'
|
||||
|
||||
# take care of extension modules.
|
||||
if have_cython:
|
||||
sources = ['msgpack/_msgpack.pyx']
|
||||
|
||||
class Sdist(sdist):
|
||||
def __init__(self, *args, **kwargs):
|
||||
for src in glob('msgpack/*.pyx'):
|
||||
cython_compiler.compile(glob('msgpack/*.pyx'),
|
||||
cython_compiler.default_options)
|
||||
sdist.__init__(self, *args, **kwargs)
|
||||
else:
|
||||
sources = ['msgpack/_msgpack.c']
|
||||
|
||||
Sdist = sdist
|
||||
|
||||
msgpack_mod = Extension('msgpack._msgpack',
|
||||
#sources=['msgpack/_msgpack.pyx']
|
||||
sources=['msgpack/_msgpack.c']
|
||||
sources=sources,
|
||||
)
|
||||
del sources
|
||||
|
||||
|
||||
desc = 'MessagePack (de)serializer.'
|
||||
long_desc = desc + """
|
||||
@@ -26,14 +51,15 @@ What's MessagePack? (from http://msgpack.sourceforge.jp/)
|
||||
"""
|
||||
|
||||
setup(name='msgpack',
|
||||
author='Naoki INADA',
|
||||
author='INADA Naoki',
|
||||
author_email='songofacandy@gmail.com',
|
||||
version=version,
|
||||
#cmdclass={'build_ext': build_ext},
|
||||
cmdclass={'build_ext': build_ext, 'sdist': Sdist},
|
||||
ext_modules=[msgpack_mod],
|
||||
packages=['msgpack'],
|
||||
description=desc,
|
||||
long_description=long_desc,
|
||||
url="http://msgpack.sourceforge.jp/",
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Intended Audience :: Developers',
|
||||
|
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
from Cython.Distutils import build_ext
|
||||
import os
|
||||
|
||||
version = '0.2.0dev'
|
||||
|
||||
msgpack_mod = Extension('msgpack._msgpack',
|
||||
sources=['msgpack/_msgpack.pyx']
|
||||
)
|
||||
|
||||
desc = 'MessagePack (de)serializer.'
|
||||
long_desc = desc + """
|
||||
|
||||
MessagePack_ (de)serializer for Python.
|
||||
|
||||
.. _MessagePack: http://msgpack.sourceforge.jp/
|
||||
|
||||
What's MessagePack? (from http://msgpack.sourceforge.jp/)
|
||||
|
||||
MessagePack is a binary-based efficient data interchange format that is
|
||||
focused on high performance. It is like JSON, but very fast and small.
|
||||
"""
|
||||
|
||||
setup(name='msgpack',
|
||||
author='Naoki INADA',
|
||||
author_email='songofacandy@gmail.com',
|
||||
version=version,
|
||||
cmdclass={'build_ext': build_ext},
|
||||
ext_modules=[msgpack_mod],
|
||||
packages=['msgpack'],
|
||||
description=desc,
|
||||
long_description=long_desc,
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
]
|
||||
)
|
@@ -1,133 +0,0 @@
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
require 'rake/packagetask'
|
||||
require 'rake/gempackagetask'
|
||||
require 'rake/rdoctask'
|
||||
require 'rake/contrib/rubyforgepublisher'
|
||||
require 'rake/contrib/sshpublisher'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
NAME = "msgpack"
|
||||
AUTHOR = "FURUHASHI Sadayuki"
|
||||
EMAIL = "frsyuki _at_ users.sourceforge.jp"
|
||||
DESCRIPTION = "Binary-based efficient data interchange format."
|
||||
RUBYFORGE_PROJECT = "msgpack"
|
||||
HOMEPATH = "http://msgpack.sourceforge.jp/"
|
||||
BIN_FILES = %w( )
|
||||
VERS = "0.3.2"
|
||||
|
||||
#REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
||||
REV = nil
|
||||
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
||||
RDOC_OPTS = [
|
||||
'--title', "#{NAME} documentation",
|
||||
"--charset", "utf-8",
|
||||
"--opname", "index.html",
|
||||
"--line-numbers",
|
||||
"--main", "README",
|
||||
"--inline-source",
|
||||
]
|
||||
|
||||
task :default => [:test]
|
||||
task :package => [:clean]
|
||||
|
||||
Rake::TestTask.new("test") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = "test/**/*_test.rb"
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = NAME
|
||||
s.version = VERS
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.has_rdoc = false
|
||||
s.extra_rdoc_files = ["README", "ChangeLog", "AUTHORS"]
|
||||
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
||||
s.summary = DESCRIPTION
|
||||
s.description = DESCRIPTION
|
||||
s.author = AUTHOR
|
||||
s.email = EMAIL
|
||||
s.homepage = HOMEPATH
|
||||
s.executables = BIN_FILES
|
||||
s.rubyforge_project = RUBYFORGE_PROJECT
|
||||
s.bindir = "bin"
|
||||
s.require_path = "ext"
|
||||
s.autorequire = ""
|
||||
s.test_files = Dir["test/test_*.rb"]
|
||||
|
||||
#s.add_dependency('activesupport', '>=1.3.1')
|
||||
#s.required_ruby_version = '>= 1.8.2'
|
||||
|
||||
s.files = %w(README ChangeLog Rakefile) +
|
||||
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
||||
Dir.glob("ext/**/*.{h,c,rb}") +
|
||||
Dir.glob("examples/**/*.rb") +
|
||||
Dir.glob("tools/*.rb") +
|
||||
Dir.glob("msgpack/*.h")
|
||||
|
||||
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
||||
end
|
||||
|
||||
Rake::GemPackageTask.new(spec) do |p|
|
||||
p.need_tar = true
|
||||
p.gem_spec = spec
|
||||
end
|
||||
|
||||
task :install do
|
||||
name = "#{NAME}-#{VERS}.gem"
|
||||
sh %{rake package}
|
||||
sh %{sudo gem install pkg/#{name}}
|
||||
end
|
||||
|
||||
task :uninstall => [:clean] do
|
||||
sh %{sudo gem uninstall #{NAME}}
|
||||
end
|
||||
|
||||
|
||||
#Rake::RDocTask.new do |rdoc|
|
||||
# rdoc.rdoc_dir = 'html'
|
||||
# rdoc.options += RDOC_OPTS
|
||||
# rdoc.template = "resh"
|
||||
# #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
||||
# if ENV['DOC_FILES']
|
||||
# rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
||||
# else
|
||||
# rdoc.rdoc_files.include('README', 'ChangeLog')
|
||||
# rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
# rdoc.rdoc_files.include('ext/**/*.c')
|
||||
# end
|
||||
#end
|
||||
|
||||
desc "Publish to RubyForge"
|
||||
task :rubyforge => [:rdoc, :package] do
|
||||
require 'rubyforge'
|
||||
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'frsyuki').upload
|
||||
end
|
||||
|
||||
desc 'Package and upload the release to rubyforge.'
|
||||
task :release => [:clean, :package] do |t|
|
||||
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
||||
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
|
||||
pkg = "pkg/#{NAME}-#{VERS}"
|
||||
|
||||
rf = RubyForge.new
|
||||
puts "Logging in"
|
||||
rf.login
|
||||
|
||||
c = rf.userconfig
|
||||
# c["release_notes"] = description if description
|
||||
# c["release_changes"] = changes if changes
|
||||
c["preformatted"] = true
|
||||
|
||||
files = [
|
||||
"#{pkg}.tgz",
|
||||
"#{pkg}.gem"
|
||||
].compact
|
||||
|
||||
puts "Releasing #{NAME} v. #{VERS}"
|
||||
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
|
||||
end
|
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p gem/ext
|
||||
mkdir -p gem/msgpack
|
||||
cp extconf.rb gem/ext/
|
||||
cp pack.c gem/ext/
|
||||
cp pack.h gem/ext/
|
||||
cp rbinit.c gem/ext/
|
||||
cp unpack.c gem/ext/
|
||||
cp unpack.h gem/ext/
|
||||
cat test_case.rb | sed "s/require ['\"]msgpack['\"]/require File.dirname(__FILE__) + '\/test_helper.rb'/" > gem/test/msgpack_test.rb
|
||||
cp ../AUTHORS gem/AUTHORS
|
||||
cp ../ChangeLog gem/ChangeLog
|
||||
cp ../msgpack/pack_define.h gem/msgpack/
|
||||
cp ../msgpack/pack_template.h gem/msgpack/
|
||||
cp ../msgpack/unpack_define.h gem/msgpack/
|
||||
cp ../msgpack/unpack_template.h gem/msgpack/
|
||||
cp ../msgpack/sysdep.h gem/msgpack/
|
||||
|
||||
cd gem && rake --trace package
|
||||
|
26
ruby/makegem.sh
Executable file
26
ruby/makegem.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p ext
|
||||
mkdir -p msgpack
|
||||
cp extconf.rb ext/
|
||||
cp pack.c ext/
|
||||
cp pack.h ext/
|
||||
cp rbinit.c ext/
|
||||
cp unpack.c ext/
|
||||
cp unpack.h ext/
|
||||
cp ../AUTHORS ./
|
||||
cp ../ChangeLog ./
|
||||
cp ../msgpack/pack_define.h msgpack/
|
||||
cp ../msgpack/pack_template.h msgpack/
|
||||
cp ../msgpack/unpack_define.h msgpack/
|
||||
cp ../msgpack/unpack_template.h msgpack/
|
||||
cp ../msgpack/sysdep.h msgpack/
|
||||
cat msgpack_test.rb | sed "s/require ['\"]msgpack['\"]/require File.dirname(__FILE__) + '\/test_helper.rb'/" > test/msgpack_test.rb
|
||||
|
||||
gem build msgpack.gemspec
|
||||
|
||||
# ./msgpack.mingw.sh # on msys
|
||||
# gem push msgpack-$version.gem
|
||||
# gem push msgpack-$version-x86-mingw32.gem
|
||||
# gem push msgpack-$version-mswin32.gem
|
||||
|
12
ruby/msgpack.gemspec
Executable file → Normal file
12
ruby/msgpack.gemspec
Executable file → Normal file
@@ -1,12 +1,16 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::CURRENT
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.name = "msgpack"
|
||||
s.version = "0.3.2"
|
||||
s.summary = "MessagePack"
|
||||
s.version = "0.3.3"
|
||||
s.summary = "MessagePack, a binary-based efficient data interchange format."
|
||||
s.author = "FURUHASHI Sadayuki"
|
||||
s.email = "frsyuki@users.sourceforge.jp"
|
||||
s.homepage = "http://msgpack.sourceforge.jp/"
|
||||
s.rubyforge_project = "msgpack"
|
||||
s.has_rdoc = false
|
||||
s.extra_rdoc_files = ["README", "ChangeLog", "AUTHORS"]
|
||||
s.require_paths = ["lib", "ext"]
|
||||
s.files = ["lib/**/*", "ext/**/*"].map {|g| Dir.glob(g) }.flatten
|
||||
s.files = Dir["lib/**/*", "ext/**/*", "msgpack/**/*", "test/**/*"]
|
||||
s.test_files = Dir["test/test_*.rb"]
|
||||
s.extensions = Dir["ext/**/extconf.rb"]
|
||||
end
|
||||
|
16
ruby/msgpack.mingw.gemspec
Normal file
16
ruby/msgpack.mingw.gemspec
Normal file
@@ -0,0 +1,16 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::CURRENT
|
||||
s.name = "msgpack"
|
||||
s.version = "0.3.3"
|
||||
s.summary = "MessagePack, a binary-based efficient data interchange format."
|
||||
s.author = "FURUHASHI Sadayuki"
|
||||
s.email = "frsyuki@users.sourceforge.jp"
|
||||
s.homepage = "http://msgpack.sourceforge.jp/"
|
||||
s.rubyforge_project = "msgpack"
|
||||
s.has_rdoc = false
|
||||
s.extra_rdoc_files = ["README", "ChangeLog", "AUTHORS"]
|
||||
s.require_paths = ["lib", "ext"]
|
||||
s.files = Dir["lib/**/*", "ext/**/*", "msgpack/**/*", "test/**/*"]
|
||||
s.test_files = Dir["test/test_*.rb"]
|
||||
s.extensions = Dir["ext/**/extconf.rb"]
|
||||
end
|
21
ruby/msgpack.mingw.sh
Executable file
21
ruby/msgpack.mingw.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
if [ -z "$1" ];then
|
||||
echo "usage: $0 <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$1
|
||||
build=msgpack-mingw-build
|
||||
|
||||
./makegem.sh
|
||||
gem build msgpack.mingw.gemspec
|
||||
rm -rf $build
|
||||
mkdir $build
|
||||
cd $build
|
||||
tar xvf ../msgpack-$version-x86-mingw32.gem
|
||||
gunzip metadata.gz
|
||||
sed s/x86-mingw32/mswin32/ metadata > metadata.tmp
|
||||
mv metadata.tmp metadata
|
||||
gzip metadata
|
||||
tar cvf msgpack-$version-mswin32.gem metadata.gz data.tar.gz
|
||||
|
@@ -1,122 +0,0 @@
|
||||
require 'msgpack'
|
||||
|
||||
@up = MessagePack::Unpacker.new
|
||||
|
||||
def check(bytes, should)
|
||||
puts "----"
|
||||
@up.reset
|
||||
src = bytes.pack('C*')
|
||||
ret = @up.execute(src, 0)
|
||||
if ret != src.length
|
||||
puts "** EXTRA BYTES **"
|
||||
end
|
||||
puts bytes.map{|x|"%x"%x}.join(' ')
|
||||
data = @up.data
|
||||
p data
|
||||
if data != should
|
||||
puts "** TEST FAILED **"
|
||||
p should
|
||||
end
|
||||
end
|
||||
|
||||
# SimpleValue
|
||||
check([
|
||||
0x93, 0xc0, 0xc2, 0xc3,
|
||||
], [nil,false,true])
|
||||
|
||||
# Fixnum
|
||||
check([
|
||||
0x92,
|
||||
0x93, 0x00, 0x40, 0x7f,
|
||||
0x93, 0xe0, 0xf0, 0xff,
|
||||
], [[0,64,127], [-32,-16,-1]])
|
||||
|
||||
# FixArray
|
||||
check([
|
||||
0x92,
|
||||
0x90,
|
||||
0x91,
|
||||
0x91, 0xc0,
|
||||
], [[],[[nil]]])
|
||||
|
||||
|
||||
# FixRaw
|
||||
check([
|
||||
0x94,
|
||||
0xa0,
|
||||
0xa1, ?a,
|
||||
0xa2, ?b, ?c,
|
||||
0xa3, ?d, ?e, ?f,
|
||||
], ["","a","bc","def"])
|
||||
|
||||
# FixMap
|
||||
check([
|
||||
0x82,
|
||||
0xc2, 0x81,
|
||||
0xc0, 0xc0,
|
||||
0xc3, 0x81,
|
||||
0xc0, 0x80,
|
||||
], {false=>{nil=>nil}, true=>{nil=>{}}})
|
||||
|
||||
# unsigned int
|
||||
check([
|
||||
0x99,
|
||||
0xcc, 0,
|
||||
0xcc, 128,
|
||||
0xcc, 255,
|
||||
0xcd, 0x00, 0x00,
|
||||
0xcd, 0x80, 0x00,
|
||||
0xcd, 0xff, 0xff,
|
||||
0xce, 0x00, 0x00, 0x00, 0x00,
|
||||
0xce, 0x80, 0x00, 0x00, 0x00,
|
||||
0xce, 0xff, 0xff, 0xff, 0xff,
|
||||
], [0, 128, 255, 0, 32768, 65535, 0, 2147483648, 4294967295])
|
||||
|
||||
# signed int
|
||||
check([
|
||||
0x99,
|
||||
0xd0, 0,
|
||||
0xd0, 128,
|
||||
0xd0, 255,
|
||||
0xd1, 0x00, 0x00,
|
||||
0xd1, 0x80, 0x00,
|
||||
0xd1, 0xff, 0xff,
|
||||
0xd2, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd2, 0x80, 0x00, 0x00, 0x00,
|
||||
0xd2, 0xff, 0xff, 0xff, 0xff,
|
||||
], [0, -128, -1, 0, -32768, -1, 0, -2147483648, -1])
|
||||
|
||||
# raw
|
||||
check([
|
||||
0x96,
|
||||
0xda, 0x00, 0x00,
|
||||
0xda, 0x00, 0x01, ?a,
|
||||
0xda, 0x00, 0x02, ?a, ?b,
|
||||
0xdb, 0x00, 0x00, 0x00, 0x00,
|
||||
0xdb, 0x00, 0x00, 0x00, 0x01, ?a,
|
||||
0xdb, 0x00, 0x00, 0x00, 0x02, ?a, ?b,
|
||||
], ["", "a", "ab", "", "a", "ab"])
|
||||
|
||||
# array
|
||||
check([
|
||||
0x96,
|
||||
0xdc, 0x00, 0x00,
|
||||
0xdc, 0x00, 0x01, 0xc0,
|
||||
0xdc, 0x00, 0x02, 0xc2, 0xc3,
|
||||
0xdd, 0x00, 0x00, 0x00, 0x00,
|
||||
0xdd, 0x00, 0x00, 0x00, 0x01, 0xc0,
|
||||
0xdd, 0x00, 0x00, 0x00, 0x02, 0xc2, 0xc3
|
||||
], [[], [nil], [false,true], [], [nil], [false,true]])
|
||||
|
||||
# map
|
||||
check([
|
||||
0x96,
|
||||
0xde, 0x00, 0x00,
|
||||
0xde, 0x00, 0x01, 0xc0, 0xc2,
|
||||
0xde, 0x00, 0x02, 0xc0, 0xc2, 0xc3, 0xc2,
|
||||
0xdf, 0x00, 0x00, 0x00, 0x00,
|
||||
0xdf, 0x00, 0x00, 0x00, 0x01, 0xc0, 0xc2,
|
||||
0xdf, 0x00, 0x00, 0x00, 0x02, 0xc0, 0xc2, 0xc3, 0xc2,
|
||||
], [{}, {nil=>false}, {true=>false, nil=>false}, {}, {nil=>false}, {true=>false, nil=>false}])
|
||||
|
||||
|
@@ -1,58 +0,0 @@
|
||||
require 'msgpack'
|
||||
|
||||
def check(data)
|
||||
puts "---"
|
||||
pack = data.to_msgpack
|
||||
p data
|
||||
puts pack.unpack('C*').map{|x|"%02x"%x}.join(' ')
|
||||
re = MessagePack::unpack(pack)
|
||||
if re != data
|
||||
p re
|
||||
puts "** TEST FAILED **"
|
||||
end
|
||||
end
|
||||
|
||||
check 0
|
||||
check 1
|
||||
check 127
|
||||
check 128
|
||||
check 255
|
||||
check 256
|
||||
check 65535
|
||||
check 65536
|
||||
check -1
|
||||
check -32
|
||||
check -33
|
||||
check -128
|
||||
check -129
|
||||
check -32768
|
||||
check -32769
|
||||
|
||||
check 1.0
|
||||
|
||||
check ""
|
||||
check "a"
|
||||
check "a"*31
|
||||
check "a"*32
|
||||
|
||||
check nil
|
||||
check true
|
||||
check false
|
||||
|
||||
check []
|
||||
check [[]]
|
||||
check [[], nil]
|
||||
|
||||
check( {nil=>0} )
|
||||
|
||||
check (1<<23)
|
||||
__END__
|
||||
|
||||
ary = []
|
||||
i = 0
|
||||
while i < (1<<16)
|
||||
ary << i
|
||||
i += 1
|
||||
end
|
||||
check ary
|
||||
|
127
ruby/unpack.c
127
ruby/unpack.c
@@ -18,10 +18,16 @@
|
||||
#include "ruby.h"
|
||||
#include "msgpack/unpack_define.h"
|
||||
|
||||
static ID s_sysread;
|
||||
|
||||
typedef struct {
|
||||
int finished;
|
||||
VALUE source;
|
||||
size_t offset;
|
||||
size_t parsed;
|
||||
VALUE buffer;
|
||||
VALUE stream;
|
||||
VALUE streambuf;
|
||||
} unpack_user;
|
||||
|
||||
|
||||
@@ -144,6 +150,9 @@ static void MessagePack_Unpacker_free(void* data)
|
||||
static void MessagePack_Unpacker_mark(msgpack_unpack_t *mp)
|
||||
{
|
||||
unsigned int i;
|
||||
rb_gc_mark(mp->user.buffer);
|
||||
rb_gc_mark(mp->user.stream);
|
||||
rb_gc_mark(mp->user.streambuf);
|
||||
for(i=0; i < mp->top; ++i) {
|
||||
rb_gc_mark(mp->stack[i].obj);
|
||||
rb_gc_mark(mp->stack[i].map_key); /* maybe map_key is not initialized */
|
||||
@@ -164,14 +173,32 @@ static VALUE MessagePack_Unpacker_reset(VALUE self)
|
||||
UNPACKER(self, mp);
|
||||
template_init(mp);
|
||||
init_stack(mp);
|
||||
unpack_user u = {0, Qnil};
|
||||
mp->user = u;
|
||||
mp->user.finished = 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Unpacker_initialize(VALUE self)
|
||||
static VALUE MessagePack_Unpacker_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
return MessagePack_Unpacker_reset(self);
|
||||
VALUE stream;
|
||||
switch(argc) {
|
||||
case 0:
|
||||
stream = Qnil;
|
||||
break;
|
||||
case 1:
|
||||
stream = argv[0];
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
|
||||
}
|
||||
|
||||
MessagePack_Unpacker_reset(self);
|
||||
UNPACKER(self, mp);
|
||||
mp->user.offset = 0;
|
||||
mp->user.parsed = 0;
|
||||
mp->user.buffer = rb_str_new("",0);
|
||||
mp->user.stream = stream;
|
||||
mp->user.streambuf = rb_str_new("",0);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,6 +276,87 @@ static VALUE MessagePack_Unpacker_data(VALUE self)
|
||||
}
|
||||
|
||||
|
||||
static VALUE MessagePack_Unpacker_feed(VALUE self, VALUE data)
|
||||
{
|
||||
UNPACKER(self, mp);
|
||||
StringValue(data);
|
||||
rb_str_cat(mp->user.buffer, RSTRING_PTR(data), RSTRING_LEN(data));
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Unpacker_stream_get(VALUE self)
|
||||
{
|
||||
UNPACKER(self, mp);
|
||||
return mp->user.stream;
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Unpacker_stream_set(VALUE self, VALUE val)
|
||||
{
|
||||
UNPACKER(self, mp);
|
||||
return mp->user.stream = val;
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Unpacker_fill(VALUE self)
|
||||
{
|
||||
UNPACKER(self, mp);
|
||||
|
||||
if(mp->user.stream == Qnil) {
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
size_t len;
|
||||
if(RSTRING_LEN(mp->user.buffer) == 0) {
|
||||
rb_funcall(mp->user.stream, s_sysread, 2, LONG2FIX(64*1024), mp->user.buffer);
|
||||
len = RSTRING_LEN(mp->user.buffer);
|
||||
} else {
|
||||
rb_funcall(mp->user.stream, s_sysread, 2, LONG2FIX(64*1024), mp->user.streambuf);
|
||||
len = RSTRING_LEN(mp->user.streambuf);
|
||||
rb_str_cat(mp->user.buffer, RSTRING_PTR(mp->user.streambuf), RSTRING_LEN(mp->user.streambuf));
|
||||
}
|
||||
|
||||
return LONG2FIX(len);
|
||||
}
|
||||
|
||||
static VALUE MessagePack_Unpacker_each(VALUE self)
|
||||
{
|
||||
UNPACKER(self, mp);
|
||||
int ret;
|
||||
|
||||
#ifdef RETURN_ENUMERATOR
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
if(RSTRING_LEN(mp->user.buffer) <= mp->user.offset) {
|
||||
do_fill:
|
||||
{
|
||||
VALUE len = MessagePack_Unpacker_fill(self);
|
||||
if(len == Qnil || FIX2LONG(len) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp->user.source = mp->user.buffer;
|
||||
ret = template_execute(mp, RSTRING_PTR(mp->user.buffer), RSTRING_LEN(mp->user.buffer), &mp->user.offset);
|
||||
mp->user.source = Qnil;
|
||||
|
||||
if(ret < 0) {
|
||||
rb_raise(eUnpackError, "parse error.");
|
||||
} else if(ret > 0) {
|
||||
VALUE data = template_data(mp);
|
||||
template_init(mp);
|
||||
init_stack(mp);
|
||||
rb_yield(data);
|
||||
} else {
|
||||
goto do_fill;
|
||||
}
|
||||
}
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
||||
static VALUE MessagePack_unpack_impl(VALUE args)
|
||||
{
|
||||
msgpack_unpack_t* mp = (msgpack_unpack_t*)((VALUE*)args)[0];
|
||||
@@ -292,7 +400,7 @@ static VALUE MessagePack_unpack_limit(VALUE self, VALUE data, VALUE limit)
|
||||
msgpack_unpack_t mp;
|
||||
template_init(&mp);
|
||||
init_stack(&mp);
|
||||
unpack_user u = {0, Qnil};
|
||||
unpack_user u = {0, Qnil, 0, 0, Qnil, Qnil, Qnil};
|
||||
mp.user = u;
|
||||
|
||||
rb_gc_disable();
|
||||
@@ -313,17 +421,22 @@ static VALUE MessagePack_unpack(VALUE self, VALUE data)
|
||||
|
||||
void Init_msgpack_unpack(VALUE mMessagePack)
|
||||
{
|
||||
s_sysread = rb_intern("sysread");
|
||||
eUnpackError = rb_define_class_under(mMessagePack, "UnpackError", rb_eStandardError);
|
||||
cUnpacker = rb_define_class_under(mMessagePack, "Unpacker", rb_cObject);
|
||||
rb_define_alloc_func(cUnpacker, MessagePack_Unpacker_alloc);
|
||||
rb_define_method(cUnpacker, "initialize", MessagePack_Unpacker_initialize, 0);
|
||||
rb_define_method(cUnpacker, "initialize", MessagePack_Unpacker_initialize, -1);
|
||||
rb_define_method(cUnpacker, "execute", MessagePack_Unpacker_execute, 2);
|
||||
rb_define_method(cUnpacker, "execute_limit", MessagePack_Unpacker_execute_limit, 3);
|
||||
rb_define_method(cUnpacker, "finished?", MessagePack_Unpacker_finished_p, 0);
|
||||
rb_define_method(cUnpacker, "data", MessagePack_Unpacker_data, 0);
|
||||
rb_define_method(cUnpacker, "reset", MessagePack_Unpacker_reset, 0);
|
||||
rb_define_method(cUnpacker, "feed", MessagePack_Unpacker_feed, 1);
|
||||
rb_define_method(cUnpacker, "fill", MessagePack_Unpacker_fill, 0);
|
||||
rb_define_method(cUnpacker, "each", MessagePack_Unpacker_each, 0);
|
||||
rb_define_method(cUnpacker, "stream", MessagePack_Unpacker_stream_get, 0);
|
||||
rb_define_method(cUnpacker, "stream=", MessagePack_Unpacker_stream_set, 1);
|
||||
rb_define_module_function(mMessagePack, "unpack", MessagePack_unpack, 1);
|
||||
rb_define_module_function(mMessagePack, "unpack_limit", MessagePack_unpack_limit, 2);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user