summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am18
-rw-r--r--NEWS0
-rw-r--r--README70
-rw-r--r--README.md37
-rw-r--r--c/Makefile.am29
-rw-r--r--c/bench.c323
-rw-r--r--c/bench.mk9
-rw-r--r--cpp/AUTHORS (renamed from AUTHORS)0
-rw-r--r--cpp/COPYING (renamed from COPYING)0
-rw-r--r--cpp/ChangeLog (renamed from ChangeLog)0
-rw-r--r--cpp/LICENSE (renamed from LICENSE)0
-rw-r--r--cpp/Makefile.am56
-rw-r--r--cpp/NOTICE (renamed from NOTICE)0
-rw-r--r--cpp/bench.cpp188
-rw-r--r--cpp/bench.mk9
-rwxr-xr-xcpp/bootstrap (renamed from bootstrap)11
-rw-r--r--cpp/configure.in (renamed from configure.in)36
-rw-r--r--cpp/msgpack.h (renamed from c/msgpack.h)0
-rw-r--r--cpp/msgpack/object.h (renamed from c/msgpack/object.h)0
-rw-r--r--cpp/msgpack/pack.h (renamed from c/msgpack/pack.h)0
-rw-r--r--cpp/msgpack/sbuffer.h (renamed from c/msgpack/sbuffer.h)0
-rw-r--r--cpp/msgpack/unpack.h (renamed from c/msgpack/unpack.h)0
-rw-r--r--cpp/msgpack/vrefbuffer.h (renamed from c/msgpack/vrefbuffer.h)0
-rw-r--r--cpp/msgpack/zbuffer.h (renamed from c/msgpack/zbuffer.h)0
-rw-r--r--cpp/msgpack/zone.h (renamed from c/msgpack/zone.h)0
-rw-r--r--cpp/msgpack_test.cpp (renamed from cpp/test.cpp)0
-rw-r--r--cpp/msgpack_vc8.postbuild.bat49
-rw-r--r--cpp/msgpack_vc8.sln (renamed from msgpack_vc8.sln)0
-rw-r--r--[-rwxr-xr-x]cpp/msgpack_vc8.vcproj (renamed from msgpack_vc8.vcproj)0
-rw-r--r--cpp/msgpackc_test.cpp (renamed from c/test.cpp)0
-rw-r--r--cpp/object.c (renamed from c/object.c)0
-rwxr-xr-xcpp/preprocess (renamed from cpp/preprocess.sh)4
-rw-r--r--cpp/unpack.c (renamed from c/unpack.c)0
-rw-r--r--cpp/vrefbuffer.c (renamed from c/vrefbuffer.c)0
-rw-r--r--cpp/zone.c (renamed from c/zone.c)0
-rw-r--r--msgpack_vc8.postbuild.bat41
36 files changed, 159 insertions, 721 deletions
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 04f62d2..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-if ENABLE_CXX
-SUBDIRS = c cpp
-else
-SUBDIRS = c
-endif
-
-nobase_include_HEADERS = \
- msgpack/pack_define.h \
- msgpack/pack_template.h \
- msgpack/unpack_define.h \
- msgpack/unpack_template.h \
- msgpack/sysdep.h
-
-EXTRA_DIST = \
- msgpack_vc8.vcproj \
- msgpack_vc8.sln \
- msgpack_vc8.postbuild.bat
-
diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/NEWS
+++ /dev/null
diff --git a/README b/README
deleted file mode 100644
index 6ca10d6..0000000
--- a/README
+++ /dev/null
@@ -1,70 +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.
-
- gcc >= 4.1 is required to build.
-
-
-*Installation
-
- Simply run ./configure && make && make install to install C and C++ binding.
-
- $ ./configure
- $ make
- $ sudo make install
-
- To install Ruby binding, run ./makegem.sh script on ruby/ directory and install
- generated gem package.
-
- $ cd ruby
- $ ./makegem.sh
- $ gem install 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-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.
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..066c45e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+MessagePack
+===========
+Extremely efficient object serialization library. It's like JSON, but very fast and small.
+
+
+## What's MessagePack?
+
+MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.
+
+Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. \[1,2,3\] (3 elements array) is serialized in 4 bytes using MessagePack as follows:
+
+ require 'msgpack'
+ msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"
+ MessagePack.unpack(msg) #=> [1,2,3]
+
+
+## Performance
+
+![Serialization + Deserialization Speed Test](http://msgpack.sourceforge.net/index/speedtest.png)
+
+In this test, it measured the elapsed time of serializing and deserializing 200,000 target objects. The target object consists of the three integers and 512 bytes string.
+The source code of this test is available from [frsyuki' serializer-speed-test repository.](http://github.com/frsyuki/serializer-speed-test)
+
+
+## Getting Started
+
+Usage and other documents about implementations in each language are found at [the web site.](http://msgpack.sourceforge.net/)
+
+
+## Learn More
+
+ - [Project Web Site](http://msgpack.sourceforge.net/)
+ - [MessagePack format specification](http://msgpack.sourceforge.net/spec)
+ - [Repository at github](http://github.com/msgpack/msgpack)
+ - [Wiki](http://msgpack.sourceforge.net/start)
+ - [MessagePack-RPC](http://github.com/msgpack/msgpack-rpc)
+
diff --git a/c/Makefile.am b/c/Makefile.am
deleted file mode 100644
index bbe547c..0000000
--- a/c/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-lib_LTLIBRARIES = libmsgpackc.la
-
-libmsgpackc_la_SOURCES = \
- unpack.c \
- object.c \
- vrefbuffer.c \
- zone.c
-
-nobase_include_HEADERS = \
- msgpack.h \
- msgpack/sbuffer.h \
- msgpack/vrefbuffer.h \
- msgpack/zbuffer.h \
- msgpack/pack.h \
- msgpack/unpack.h \
- msgpack/object.h \
- msgpack/zone.h
-
-# -version-info CURRENT:REVISION:AGE
-libmsgpackc_la_LDFLAGS = -version-info 2:0:0
-
-check_PROGRAMS = \
- msgpackc_test
-
-msgpackc_test_SOURCES = test.cpp
-msgpackc_test_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/c
-msgpackc_test_LDADD = libmsgpackc.la -lgtest_main
-
-TESTS = $(check_PROGRAMS)
diff --git a/c/bench.c b/c/bench.c
deleted file mode 100644
index d72a10d..0000000
--- a/c/bench.c
+++ /dev/null
@@ -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;
-}
-
-
diff --git a/c/bench.mk b/c/bench.mk
deleted file mode 100644
index c765e31..0000000
--- a/c/bench.mk
+++ /dev/null
@@ -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 $@
-
diff --git a/AUTHORS b/cpp/AUTHORS
index ababacb..ababacb 100644
--- a/AUTHORS
+++ b/cpp/AUTHORS
diff --git a/COPYING b/cpp/COPYING
index 4388e8f..4388e8f 100644
--- a/COPYING
+++ b/cpp/COPYING
diff --git a/ChangeLog b/cpp/ChangeLog
index e69de29..e69de29 100644
--- a/ChangeLog
+++ b/cpp/ChangeLog
diff --git a/LICENSE b/cpp/LICENSE
index d645695..d645695 100644
--- a/LICENSE
+++ b/cpp/LICENSE
diff --git a/cpp/Makefile.am b/cpp/Makefile.am
index c1b4981..aba7e28 100644
--- a/cpp/Makefile.am
+++ b/cpp/Makefile.am
@@ -1,9 +1,38 @@
-lib_LTLIBRARIES = libmsgpack.la
+lib_LTLIBRARIES = libmsgpackc.la libmsgpack.la
+
+libmsgpackc_la_SOURCES = \
+ unpack.c \
+ object.c \
+ vrefbuffer.c \
+ zone.c
+
+# -version-info CURRENT:REVISION:AGE
+libmsgpackc_la_LDFLAGS = -version-info 2:0:0
+
libmsgpack_la_SOURCES = \
object.cpp
+libmsgpack_la_LIBADD = -lmsgpackc
+
+# -version-info CURRENT:REVISION:AGE
+libmsgpack_la_LDFLAGS = -version-info 2:0:0
+
+
nobase_include_HEADERS = \
+ msgpack/pack_define.h \
+ msgpack/pack_template.h \
+ msgpack/unpack_define.h \
+ msgpack/unpack_template.h \
+ msgpack/sysdep.h \
+ msgpack.h \
+ msgpack/sbuffer.h \
+ msgpack/vrefbuffer.h \
+ msgpack/zbuffer.h \
+ msgpack/pack.h \
+ msgpack/unpack.h \
+ msgpack/object.h \
+ msgpack/zone.h \
msgpack.hpp \
msgpack/sbuffer.hpp \
msgpack/vrefbuffer.hpp \
@@ -30,16 +59,31 @@ nobase_include_HEADERS = \
msgpack/type/tr1/unordered_map.hpp \
msgpack/type/tr1/unordered_set.hpp
-libmsgpack_la_LIBADD = -L../c -lmsgpackc
-# -version-info CURRENT:REVISION:AGE
-libmsgpack_la_LDFLAGS = -version-info 2:0:0
+# work around for duplicated object file name
+libmsgpackc_la_CFLAGS = $(AM_CFLAGS)
+libmsgpackc_la_CXXFLAGS = $(AM_CXXFLAGS)
+libmsgpack_la_CFLAGS = $(AM_CFLAGS)
+libmsgpack_la_CXXFLAGS = $(AM_CXXFLAGS)
+
+
+EXTRA_DIST = \
+ msgpack_vc8.vcproj \
+ msgpack_vc8.sln \
+ msgpack_vc8.postbuild.bat
+
check_PROGRAMS = \
- msgpack_test
+ msgpackc_test \
+ msgpack_test
-msgpack_test_SOURCES = test.cpp
+msgpackc_test_SOURCES = msgpackc_test.cpp
+msgpackc_test_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/c
+msgpackc_test_LDADD = libmsgpackc.la -lgtest_main
+
+msgpack_test_SOURCES = msgpack_test.cpp
msgpack_test_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/c -I$(top_srcdir)/cpp
msgpack_test_LDADD = libmsgpack.la -lgtest_main
TESTS = $(check_PROGRAMS)
+
diff --git a/NOTICE b/cpp/NOTICE
index e706f2a..e706f2a 100644
--- a/NOTICE
+++ b/cpp/NOTICE
diff --git a/cpp/bench.cpp b/cpp/bench.cpp
deleted file mode 100644
index aa303fa..0000000
--- a/cpp/bench.cpp
+++ /dev/null
@@ -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;
-}
-
diff --git a/cpp/bench.mk b/cpp/bench.mk
deleted file mode 100644
index 8da2b7f..0000000
--- a/cpp/bench.mk
+++ /dev/null
@@ -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 $@
-
diff --git a/bootstrap b/cpp/bootstrap
index 8ac504b..4a04e0a 100755
--- a/bootstrap
+++ b/cpp/bootstrap
@@ -32,7 +32,16 @@ fi
mkdir -p ac
-(cd cpp && ./preprocess.sh $@; cd ..)
+test -f AUTHORS || touch AUTHORS
+test -f COPYING || touch COPYING
+test -f ChangeLog || touch ChangeLog
+test -f NEWS || touch NEWS
+test -f README || touch README
+
+if ! ./preprocess; then
+ exit 1
+fi
+
ACLOCAL="aclocal"
diff --git a/configure.in b/cpp/configure.in
index 0f2c5d0..a4cb4d8 100644
--- a/configure.in
+++ b/cpp/configure.in
@@ -1,35 +1,21 @@
-AC_INIT(msgpack/unpack_template.h)
+AC_INIT(object.cpp)
AC_CONFIG_AUX_DIR(ac)
AM_INIT_AUTOMAKE(msgpack, 0.4.3)
AC_CONFIG_HEADER(config.h)
AC_SUBST(CFLAGS)
-if test "" = "$CFLAGS"; then
- CFLAGS="-g -O4"
-fi
+CFLAGS="-O4 -Wall $CFLAGS"
-AC_PROG_CC
+AC_SUBST(CXXFLAGS)
+CXXFLAGS="-O4 -Wall $CXXFLAGS"
-CFLAGS="-O4 -Wall $CFLAGS -I.."
-
-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)
-if test "$enable_cxx" != "no"; then
- AC_SUBST(CXXFLAGS)
- if test "" = "$CXXFLAGS"; then
- CXXFLAGS="-g -O4"
- fi
-fi
-
-# FIXME enable_cxx
+AC_PROG_CC
AC_PROG_CXX
-CXXFLAGS="-O4 -Wall $CXXFLAGS -I.. -I../c"
+AC_PROG_LIBTOOL
+AM_PROG_AS
+AM_PROG_CC_C_O
-# FIXME enable_cxx
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS(tr1/unordered_map)
AC_CHECK_HEADERS(tr1/unordered_set)
@@ -53,9 +39,5 @@ add CFLAGS="--march=i686" and CXXFLAGS="-march=i668" options to ./configure as f
])
fi
-AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no")
-
-AC_PROG_LIBTOOL
-
-AC_OUTPUT([Makefile c/Makefile cpp/Makefile])
+AC_OUTPUT([Makefile])
diff --git a/c/msgpack.h b/cpp/msgpack.h
index 21729f4..21729f4 100644
--- a/c/msgpack.h
+++ b/cpp/msgpack.h
diff --git a/c/msgpack/object.h b/cpp/msgpack/object.h
index 9a014be..9a014be 100644
--- a/c/msgpack/object.h
+++ b/cpp/msgpack/object.h
diff --git a/c/msgpack/pack.h b/cpp/msgpack/pack.h
index 1525e0f..1525e0f 100644
--- a/c/msgpack/pack.h
+++ b/cpp/msgpack/pack.h
diff --git a/c/msgpack/sbuffer.h b/cpp/msgpack/sbuffer.h
index bc0a8fd..bc0a8fd 100644
--- a/c/msgpack/sbuffer.h
+++ b/cpp/msgpack/sbuffer.h
diff --git a/c/msgpack/unpack.h b/cpp/msgpack/unpack.h
index e17d0d8..e17d0d8 100644
--- a/c/msgpack/unpack.h
+++ b/cpp/msgpack/unpack.h
diff --git a/c/msgpack/vrefbuffer.h b/cpp/msgpack/vrefbuffer.h
index 38ead67..38ead67 100644
--- a/c/msgpack/vrefbuffer.h
+++ b/cpp/msgpack/vrefbuffer.h
diff --git a/c/msgpack/zbuffer.h b/cpp/msgpack/zbuffer.h
index 2a32206..2a32206 100644
--- a/c/msgpack/zbuffer.h
+++ b/cpp/msgpack/zbuffer.h
diff --git a/c/msgpack/zone.h b/cpp/msgpack/zone.h
index ce5be6d..ce5be6d 100644
--- a/c/msgpack/zone.h
+++ b/cpp/msgpack/zone.h
diff --git a/cpp/test.cpp b/cpp/msgpack_test.cpp
index 113914a..113914a 100644
--- a/cpp/test.cpp
+++ b/cpp/msgpack_test.cpp
diff --git a/cpp/msgpack_vc8.postbuild.bat b/cpp/msgpack_vc8.postbuild.bat
new file mode 100644
index 0000000..1bdfabe
--- /dev/null
+++ b/cpp/msgpack_vc8.postbuild.bat
@@ -0,0 +1,49 @@
+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
+IF EXIST bootstrap (
+ 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\
+) ELSE (
+ 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 msgpack.h include\
+copy msgpack\sbuffer.h include\msgpack\
+copy msgpack\vrefbuffer.h include\msgpack\
+copy msgpack\pack.h include\msgpack\
+copy msgpack\unpack.h include\msgpack\
+copy msgpack\object.h include\msgpack\
+copy msgpack\zone.h include\msgpack\
+copy msgpack.hpp include\
+copy msgpack\sbuffer.hpp include\msgpack\
+copy msgpack\vrefbuffer.hpp include\msgpack\
+copy msgpack\pack.hpp include\msgpack\
+copy msgpack\unpack.hpp include\msgpack\
+copy msgpack\object.hpp include\msgpack\
+copy msgpack\zone.hpp include\msgpack\
+copy msgpack\type.hpp include\msgpack\type\
+copy msgpack\type\bool.hpp include\msgpack\type\
+copy msgpack\type\float.hpp include\msgpack\type\
+copy msgpack\type\int.hpp include\msgpack\type\
+copy msgpack\type\list.hpp include\msgpack\type\
+copy msgpack\type\deque.hpp include\msgpack\type\
+copy msgpack\type\map.hpp include\msgpack\type\
+copy msgpack\type\nil.hpp include\msgpack\type\
+copy msgpack\type\pair.hpp include\msgpack\type\
+copy msgpack\type\raw.hpp include\msgpack\type\
+copy msgpack\type\set.hpp include\msgpack\type\
+copy msgpack\type\string.hpp include\msgpack\type\
+copy msgpack\type\vector.hpp include\msgpack\type\
+copy msgpack\type\tuple.hpp include\msgpack\type\
+copy msgpack\type\define.hpp include\msgpack\type\
+copy msgpack\type\tr1\unordered_map.hpp include\msgpack\type\
+copy msgpack\type\tr1\unordered_set.hpp include\msgpack\type\
+
diff --git a/msgpack_vc8.sln b/cpp/msgpack_vc8.sln
index 84718af..84718af 100644
--- a/msgpack_vc8.sln
+++ b/cpp/msgpack_vc8.sln
diff --git a/msgpack_vc8.vcproj b/cpp/msgpack_vc8.vcproj
index a3fa28f..a3fa28f 100755..100644
--- a/msgpack_vc8.vcproj
+++ b/cpp/msgpack_vc8.vcproj
diff --git a/c/test.cpp b/cpp/msgpackc_test.cpp
index f5646ea..f5646ea 100644
--- a/c/test.cpp
+++ b/cpp/msgpackc_test.cpp
diff --git a/c/object.c b/cpp/object.c
index a22ce21..a22ce21 100644
--- a/c/object.c
+++ b/cpp/object.c
diff --git a/cpp/preprocess.sh b/cpp/preprocess
index 2e06c10..63af4c6 100755
--- a/cpp/preprocess.sh
+++ b/cpp/preprocess
@@ -14,4 +14,8 @@ preprocess() {
preprocess msgpack/type/tuple.hpp
preprocess msgpack/type/define.hpp
preprocess msgpack/zone.hpp
+cp -f ../msgpack/pack_define.h msgpack/
+cp -f ../msgpack/pack_template.h msgpack/
+cp -f ../msgpack/unpack_define.h msgpack/
+cp -f ../msgpack/unpack_template.h msgpack/
diff --git a/c/unpack.c b/cpp/unpack.c
index 4334974..4334974 100644
--- a/c/unpack.c
+++ b/cpp/unpack.c
diff --git a/c/vrefbuffer.c b/cpp/vrefbuffer.c
index 136372f..136372f 100644
--- a/c/vrefbuffer.c
+++ b/cpp/vrefbuffer.c
diff --git a/c/zone.c b/cpp/zone.c
index 3d0634e..3d0634e 100644
--- a/c/zone.c
+++ b/cpp/zone.c
diff --git a/msgpack_vc8.postbuild.bat b/msgpack_vc8.postbuild.bat
deleted file mode 100644
index 7ee2586..0000000
--- a/msgpack_vc8.postbuild.bat
+++ /dev/null
@@ -1,41 +0,0 @@
-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\
-