msgpack 0.7.4 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -1
- data/.rubocop.yml +3 -0
- data/.travis.yml +27 -14
- data/ChangeLog +89 -1
- data/Gemfile +6 -1
- data/README.rdoc +55 -1
- data/Rakefile +5 -1
- data/bench/pack_symbols.rb +28 -0
- data/bench/run_symbols.sh +26 -0
- data/doclib/msgpack.rb +2 -2
- data/doclib/msgpack/core_ext.rb +20 -20
- data/doclib/msgpack/factory.rb +33 -0
- data/doclib/msgpack/packer.rb +20 -0
- data/doclib/msgpack/time.rb +22 -0
- data/doclib/msgpack/timestamp.rb +44 -0
- data/ext/java/org/msgpack/jruby/Buffer.java +4 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +48 -18
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +67 -38
- data/ext/java/org/msgpack/jruby/Factory.java +20 -8
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +0 -92
- data/ext/java/org/msgpack/jruby/Packer.java +114 -11
- data/ext/java/org/msgpack/jruby/Unpacker.java +15 -8
- data/ext/msgpack/buffer.h +14 -0
- data/ext/msgpack/buffer_class.c +1 -1
- data/ext/msgpack/compat.h +10 -0
- data/ext/msgpack/factory_class.c +24 -17
- data/ext/msgpack/factory_class.h +0 -2
- data/ext/msgpack/packer.c +5 -4
- data/ext/msgpack/packer.h +13 -1
- data/ext/msgpack/packer_class.c +130 -43
- data/ext/msgpack/packer_class.h +0 -2
- data/ext/msgpack/packer_ext_registry.c +2 -2
- data/ext/msgpack/packer_ext_registry.h +64 -25
- data/ext/msgpack/rbinit.c +0 -2
- data/ext/msgpack/unpacker.c +3 -3
- data/ext/msgpack/unpacker_class.c +25 -56
- data/ext/msgpack/unpacker_class.h +0 -2
- data/ext/msgpack/unpacker_ext_registry.c +2 -2
- data/ext/msgpack/unpacker_ext_registry.h +3 -3
- data/lib/msgpack.rb +36 -0
- data/lib/msgpack/core_ext.rb +139 -0
- data/lib/msgpack/factory.rb +21 -0
- data/lib/msgpack/symbol.rb +9 -0
- data/lib/msgpack/time.rb +29 -0
- data/lib/msgpack/timestamp.rb +76 -0
- data/lib/msgpack/version.rb +8 -1
- data/msgpack.gemspec +6 -7
- data/spec/cruby/buffer_spec.rb +6 -1
- data/spec/factory_spec.rb +134 -0
- data/spec/msgpack_spec.rb +52 -0
- data/spec/packer_spec.rb +200 -0
- data/spec/timestamp_spec.rb +121 -0
- data/spec/unpacker_spec.rb +29 -0
- metadata +29 -23
- data/ext/msgpack/core_ext.c +0 -144
- data/ext/msgpack/core_ext.h +0 -26
data/ext/msgpack/core_ext.c
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* MessagePack for Ruby
|
3
|
-
*
|
4
|
-
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
-
*
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
* you may not use this file except in compliance with the License.
|
8
|
-
* You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
* See the License for the specific language governing permissions and
|
16
|
-
* limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
#include "core_ext.h"
|
20
|
-
#include "packer.h"
|
21
|
-
#include "packer_class.h"
|
22
|
-
#include "extension_value_class.h"
|
23
|
-
|
24
|
-
static inline VALUE delegete_to_pack(int argc, VALUE* argv, VALUE self)
|
25
|
-
{
|
26
|
-
if(argc == 0) {
|
27
|
-
return MessagePack_pack(1, &self);
|
28
|
-
} else if(argc == 1) {
|
29
|
-
/* write to io */
|
30
|
-
VALUE argv2[2];
|
31
|
-
argv2[0] = self;
|
32
|
-
argv2[1] = argv[0];
|
33
|
-
return MessagePack_pack(2, argv2);
|
34
|
-
} else {
|
35
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..1)", argc);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
#define ENSURE_PACKER(argc, argv, packer, pk) \
|
40
|
-
if(argc != 1 || rb_class_of(argv[0]) != cMessagePack_Packer) { \
|
41
|
-
return delegete_to_pack(argc, argv, self); \
|
42
|
-
} \
|
43
|
-
VALUE packer = argv[0]; \
|
44
|
-
msgpack_packer_t *pk; \
|
45
|
-
Data_Get_Struct(packer, msgpack_packer_t, pk);
|
46
|
-
|
47
|
-
static VALUE NilClass_to_msgpack(int argc, VALUE* argv, VALUE self)
|
48
|
-
{
|
49
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
50
|
-
msgpack_packer_write_nil(pk);
|
51
|
-
return packer;
|
52
|
-
}
|
53
|
-
|
54
|
-
static VALUE TrueClass_to_msgpack(int argc, VALUE* argv, VALUE self)
|
55
|
-
{
|
56
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
57
|
-
msgpack_packer_write_true(pk);
|
58
|
-
return packer;
|
59
|
-
}
|
60
|
-
|
61
|
-
static VALUE FalseClass_to_msgpack(int argc, VALUE* argv, VALUE self)
|
62
|
-
{
|
63
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
64
|
-
msgpack_packer_write_false(pk);
|
65
|
-
return packer;
|
66
|
-
}
|
67
|
-
|
68
|
-
static VALUE Fixnum_to_msgpack(int argc, VALUE* argv, VALUE self)
|
69
|
-
{
|
70
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
71
|
-
msgpack_packer_write_fixnum_value(pk, self);
|
72
|
-
return packer;
|
73
|
-
}
|
74
|
-
|
75
|
-
static VALUE Bignum_to_msgpack(int argc, VALUE* argv, VALUE self)
|
76
|
-
{
|
77
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
78
|
-
msgpack_packer_write_bignum_value(pk, self);
|
79
|
-
return packer;
|
80
|
-
}
|
81
|
-
|
82
|
-
static VALUE Float_to_msgpack(int argc, VALUE* argv, VALUE self)
|
83
|
-
{
|
84
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
85
|
-
msgpack_packer_write_float_value(pk, self);
|
86
|
-
return packer;
|
87
|
-
}
|
88
|
-
|
89
|
-
static VALUE String_to_msgpack(int argc, VALUE* argv, VALUE self)
|
90
|
-
{
|
91
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
92
|
-
msgpack_packer_write_string_value(pk, self);
|
93
|
-
return packer;
|
94
|
-
}
|
95
|
-
|
96
|
-
static VALUE Array_to_msgpack(int argc, VALUE* argv, VALUE self)
|
97
|
-
{
|
98
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
99
|
-
msgpack_packer_write_array_value(pk, self);
|
100
|
-
return packer;
|
101
|
-
}
|
102
|
-
|
103
|
-
static VALUE Hash_to_msgpack(int argc, VALUE* argv, VALUE self)
|
104
|
-
{
|
105
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
106
|
-
msgpack_packer_write_hash_value(pk, self);
|
107
|
-
return packer;
|
108
|
-
}
|
109
|
-
|
110
|
-
static VALUE Symbol_to_msgpack(int argc, VALUE* argv, VALUE self)
|
111
|
-
{
|
112
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
113
|
-
msgpack_packer_write_symbol_value(pk, self);
|
114
|
-
return packer;
|
115
|
-
}
|
116
|
-
|
117
|
-
static VALUE ExtensionValue_to_msgpack(int argc, VALUE* argv, VALUE self)
|
118
|
-
{
|
119
|
-
ENSURE_PACKER(argc, argv, packer, pk);
|
120
|
-
int ext_type = FIX2INT(RSTRUCT_GET(self, 0));
|
121
|
-
if(ext_type < -128 || ext_type > 127) {
|
122
|
-
rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
|
123
|
-
}
|
124
|
-
VALUE payload = RSTRUCT_GET(self, 1);
|
125
|
-
StringValue(payload);
|
126
|
-
msgpack_packer_write_ext(pk, ext_type, payload);
|
127
|
-
return packer;
|
128
|
-
}
|
129
|
-
|
130
|
-
void MessagePack_core_ext_module_init()
|
131
|
-
{
|
132
|
-
rb_define_method(rb_cNilClass, "to_msgpack", NilClass_to_msgpack, -1);
|
133
|
-
rb_define_method(rb_cTrueClass, "to_msgpack", TrueClass_to_msgpack, -1);
|
134
|
-
rb_define_method(rb_cFalseClass, "to_msgpack", FalseClass_to_msgpack, -1);
|
135
|
-
rb_define_method(rb_cFixnum, "to_msgpack", Fixnum_to_msgpack, -1);
|
136
|
-
rb_define_method(rb_cBignum, "to_msgpack", Bignum_to_msgpack, -1);
|
137
|
-
rb_define_method(rb_cFloat, "to_msgpack", Float_to_msgpack, -1);
|
138
|
-
rb_define_method(rb_cString, "to_msgpack", String_to_msgpack, -1);
|
139
|
-
rb_define_method(rb_cArray, "to_msgpack", Array_to_msgpack, -1);
|
140
|
-
rb_define_method(rb_cHash, "to_msgpack", Hash_to_msgpack, -1);
|
141
|
-
rb_define_method(rb_cSymbol, "to_msgpack", Symbol_to_msgpack, -1);
|
142
|
-
rb_define_method(cMessagePack_ExtensionValue, "to_msgpack", ExtensionValue_to_msgpack, -1);
|
143
|
-
}
|
144
|
-
|
data/ext/msgpack/core_ext.h
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* MessagePack for Ruby
|
3
|
-
*
|
4
|
-
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
-
*
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
* you may not use this file except in compliance with the License.
|
8
|
-
* You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
* See the License for the specific language governing permissions and
|
16
|
-
* limitations under the License.
|
17
|
-
*/
|
18
|
-
#ifndef MSGPACK_RUBY_CORE_EXT_H__
|
19
|
-
#define MSGPACK_RUBY_CORE_EXT_H__
|
20
|
-
|
21
|
-
#include "compat.h"
|
22
|
-
|
23
|
-
void MessagePack_core_ext_module_init();
|
24
|
-
|
25
|
-
#endif
|
26
|
-
|