msgpack 0.2.2-mswin32 → 0.3.1-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/msgpack.so +0 -0
- data/ext/pack.c +4 -4
- data/ext/pack.h +2 -2
- data/ext/pack.o +0 -0
- data/ext/rbinit.c +1 -1
- data/ext/rbinit.o +0 -0
- data/ext/unpack.c +94 -78
- data/ext/unpack.h +2 -2
- data/ext/unpack.o +0 -0
- metadata +4 -6
- data/lib/msgpack/version.rb +0 -9
data/ext/msgpack.so
CHANGED
Binary file
|
data/ext/pack.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
|
-
* MessagePack packing routine
|
2
|
+
* MessagePack for Ruby packing routine
|
3
3
|
*
|
4
|
-
* Copyright (C) 2008 FURUHASHI Sadayuki
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
@@ -19,10 +19,10 @@
|
|
19
19
|
#include "msgpack/pack_define.h"
|
20
20
|
|
21
21
|
#define msgpack_pack_inline_func(name) \
|
22
|
-
static inline void
|
22
|
+
static inline void msgpack_pack ## name
|
23
23
|
|
24
24
|
#define msgpack_pack_inline_func_cint(name) \
|
25
|
-
static inline void
|
25
|
+
static inline void msgpack_pack ## name
|
26
26
|
|
27
27
|
#define msgpack_pack_user VALUE
|
28
28
|
|
data/ext/pack.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
|
-
* MessagePack packing routine
|
2
|
+
* MessagePack for Ruby packing routine
|
3
3
|
*
|
4
|
-
* Copyright (C) 2008 FURUHASHI Sadayuki
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
data/ext/pack.o
CHANGED
Binary file
|
data/ext/rbinit.c
CHANGED
data/ext/rbinit.o
CHANGED
Binary file
|
data/ext/unpack.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
|
-
* MessagePack unpacking routine
|
2
|
+
* MessagePack for Ruby unpacking routine
|
3
3
|
*
|
4
|
-
* Copyright (C) 2008 FURUHASHI Sadayuki
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
@@ -21,99 +21,99 @@
|
|
21
21
|
|
22
22
|
typedef struct {
|
23
23
|
int finished;
|
24
|
-
VALUE
|
25
|
-
}
|
24
|
+
VALUE source;
|
25
|
+
} unpack_user;
|
26
26
|
|
27
27
|
|
28
28
|
#define msgpack_unpack_struct(name) \
|
29
|
-
struct
|
29
|
+
struct template ## name
|
30
30
|
|
31
31
|
#define msgpack_unpack_func(ret, name) \
|
32
|
-
ret
|
32
|
+
ret template ## name
|
33
33
|
|
34
34
|
#define msgpack_unpack_callback(name) \
|
35
|
-
|
35
|
+
template_callback ## name
|
36
36
|
|
37
37
|
#define msgpack_unpack_object VALUE
|
38
38
|
|
39
|
-
#define msgpack_unpack_user
|
39
|
+
#define msgpack_unpack_user unpack_user
|
40
40
|
|
41
41
|
|
42
|
-
struct
|
43
|
-
typedef struct
|
42
|
+
struct template_context;
|
43
|
+
typedef struct template_context msgpack_unpack_t;
|
44
44
|
|
45
|
-
static void
|
45
|
+
static void template_init(msgpack_unpack_t* u);
|
46
46
|
|
47
|
-
static VALUE
|
47
|
+
static VALUE template_data(msgpack_unpack_t* u);
|
48
48
|
|
49
|
-
static int
|
49
|
+
static int template_execute(msgpack_unpack_t* u,
|
50
50
|
const char* data, size_t len, size_t* off);
|
51
51
|
|
52
52
|
|
53
|
-
static inline VALUE
|
53
|
+
static inline VALUE template_callback_root(unpack_user* u)
|
54
54
|
{ return Qnil; }
|
55
55
|
|
56
|
-
static inline
|
57
|
-
{
|
56
|
+
static inline int template_callback_uint8(unpack_user* u, uint8_t d, VALUE* o)
|
57
|
+
{ *o = INT2FIX(d); return 0; }
|
58
58
|
|
59
|
-
static inline
|
60
|
-
{
|
59
|
+
static inline int template_callback_uint16(unpack_user* u, uint16_t d, VALUE* o)
|
60
|
+
{ *o = INT2FIX(d); return 0; }
|
61
61
|
|
62
|
-
static inline
|
63
|
-
{
|
62
|
+
static inline int template_callback_uint32(unpack_user* u, uint32_t d, VALUE* o)
|
63
|
+
{ *o = UINT2NUM(d); return 0; }
|
64
64
|
|
65
|
-
static inline
|
66
|
-
{
|
65
|
+
static inline int template_callback_uint64(unpack_user* u, uint64_t d, VALUE* o)
|
66
|
+
{ *o = rb_ull2inum(d); return 0; }
|
67
67
|
|
68
|
-
static inline
|
69
|
-
{
|
68
|
+
static inline int template_callback_int8(unpack_user* u, int8_t d, VALUE* o)
|
69
|
+
{ *o = INT2FIX((long)d); return 0; }
|
70
70
|
|
71
|
-
static inline
|
72
|
-
{
|
71
|
+
static inline int template_callback_int16(unpack_user* u, int16_t d, VALUE* o)
|
72
|
+
{ *o = INT2FIX((long)d); return 0; }
|
73
73
|
|
74
|
-
static inline
|
75
|
-
{
|
74
|
+
static inline int template_callback_int32(unpack_user* u, int32_t d, VALUE* o)
|
75
|
+
{ *o = INT2NUM((long)d); return 0; }
|
76
76
|
|
77
|
-
static inline
|
78
|
-
{
|
77
|
+
static inline int template_callback_int64(unpack_user* u, int64_t d, VALUE* o)
|
78
|
+
{ *o = rb_ll2inum(d); return 0; }
|
79
79
|
|
80
|
-
static inline
|
81
|
-
{
|
80
|
+
static inline int template_callback_float(unpack_user* u, float d, VALUE* o)
|
81
|
+
{ *o = rb_float_new(d); return 0; }
|
82
82
|
|
83
|
-
static inline
|
84
|
-
{
|
83
|
+
static inline int template_callback_double(unpack_user* u, double d, VALUE* o)
|
84
|
+
{ *o = rb_float_new(d); return 0; }
|
85
85
|
|
86
|
-
static inline
|
87
|
-
{
|
86
|
+
static inline int template_callback_nil(unpack_user* u, VALUE* o)
|
87
|
+
{ *o = Qnil; return 0; }
|
88
88
|
|
89
|
-
static inline
|
90
|
-
{
|
89
|
+
static inline int template_callback_true(unpack_user* u, VALUE* o)
|
90
|
+
{ *o = Qtrue; return 0; }
|
91
91
|
|
92
|
-
static inline
|
93
|
-
{
|
92
|
+
static inline int template_callback_false(unpack_user* u, VALUE* o)
|
93
|
+
{ *o = Qfalse; return 0;}
|
94
94
|
|
95
|
-
static inline
|
96
|
-
{
|
95
|
+
static inline int template_callback_array(unpack_user* u, unsigned int n, VALUE* o)
|
96
|
+
{ *o = rb_ary_new2(n); return 0; }
|
97
97
|
|
98
|
-
static inline
|
99
|
-
{ rb_ary_push(*c, o); } // FIXME set value directry RARRAY_PTR(obj)[RARRAY_LEN(obj)++]
|
98
|
+
static inline int template_callback_array_item(unpack_user* u, VALUE* c, VALUE o)
|
99
|
+
{ rb_ary_push(*c, o); return 0; } // FIXME set value directry RARRAY_PTR(obj)[RARRAY_LEN(obj)++]
|
100
100
|
|
101
|
-
static inline
|
102
|
-
{
|
101
|
+
static inline int template_callback_map(unpack_user* u, unsigned int n, VALUE* o)
|
102
|
+
{ *o = rb_hash_new(); return 0; }
|
103
103
|
|
104
|
-
static inline
|
105
|
-
{ rb_hash_aset(*c, k, v); }
|
104
|
+
static inline int template_callback_map_item(unpack_user* u, VALUE* c, VALUE k, VALUE v)
|
105
|
+
{ rb_hash_aset(*c, k, v); return 0; }
|
106
106
|
|
107
|
-
static inline
|
108
|
-
{
|
107
|
+
static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, VALUE* o)
|
108
|
+
{ *o = (l == 0) ? rb_str_new(0,0) : rb_str_substr(u->source, p - b, l); return 0; }
|
109
109
|
|
110
110
|
|
111
111
|
#include "msgpack/unpack_template.h"
|
112
112
|
|
113
113
|
|
114
114
|
#define UNPACKER(from, name) \
|
115
|
-
|
116
|
-
Data_Get_Struct(from,
|
115
|
+
msgpack_unpack_t *name = NULL; \
|
116
|
+
Data_Get_Struct(from, msgpack_unpack_t, name); \
|
117
117
|
if(name == NULL) { \
|
118
118
|
rb_raise(rb_eArgError, "NULL found for " # name " when shouldn't be."); \
|
119
119
|
}
|
@@ -132,7 +132,7 @@ static void MessagePack_Unpacker_free(void* data)
|
|
132
132
|
if(data) { free(data); }
|
133
133
|
}
|
134
134
|
|
135
|
-
static void MessagePack_Unpacker_mark(
|
135
|
+
static void MessagePack_Unpacker_mark(msgpack_unpack_t *mp)
|
136
136
|
{
|
137
137
|
unsigned int i;
|
138
138
|
for(i=0; i < mp->top; ++i) {
|
@@ -144,7 +144,7 @@ static void MessagePack_Unpacker_mark(msgpack_unpacker *mp)
|
|
144
144
|
static VALUE MessagePack_Unpacker_alloc(VALUE klass)
|
145
145
|
{
|
146
146
|
VALUE obj;
|
147
|
-
|
147
|
+
msgpack_unpack_t* mp = ALLOC_N(msgpack_unpack_t, 1);
|
148
148
|
obj = Data_Wrap_Struct(klass, MessagePack_Unpacker_mark,
|
149
149
|
MessagePack_Unpacker_free, mp);
|
150
150
|
return obj;
|
@@ -153,9 +153,9 @@ static VALUE MessagePack_Unpacker_alloc(VALUE klass)
|
|
153
153
|
static VALUE MessagePack_Unpacker_reset(VALUE self)
|
154
154
|
{
|
155
155
|
UNPACKER(self, mp);
|
156
|
-
|
157
|
-
|
158
|
-
mp->user =
|
156
|
+
template_init(mp);
|
157
|
+
unpack_user u = {0, Qnil};
|
158
|
+
mp->user = u;
|
159
159
|
return self;
|
160
160
|
}
|
161
161
|
|
@@ -169,21 +169,20 @@ static VALUE MessagePack_Unpacker_execute_impl(VALUE args)
|
|
169
169
|
{
|
170
170
|
VALUE self = ((VALUE*)args)[0];
|
171
171
|
VALUE data = ((VALUE*)args)[1];
|
172
|
-
VALUE off = ((VALUE*)args)[2];
|
173
172
|
|
174
173
|
UNPACKER(self, mp);
|
175
|
-
size_t from = NUM2UINT(
|
174
|
+
size_t from = NUM2UINT(((VALUE*)args)[2]);
|
176
175
|
char* dptr = RSTRING_PTR(data);
|
177
|
-
long dlen =
|
176
|
+
long dlen = FIX2LONG(((VALUE*)args)[3]);
|
178
177
|
int ret;
|
179
178
|
|
180
179
|
if(from >= dlen) {
|
181
180
|
rb_raise(eUnpackError, "offset is bigger than data buffer size.");
|
182
181
|
}
|
183
182
|
|
184
|
-
mp->user.
|
185
|
-
ret =
|
186
|
-
mp->user.
|
183
|
+
mp->user.source = data;
|
184
|
+
ret = template_execute(mp, dptr, (size_t)dlen, &from);
|
185
|
+
mp->user.source = Qnil;
|
187
186
|
|
188
187
|
if(ret < 0) {
|
189
188
|
rb_raise(eUnpackError, "parse error.");
|
@@ -206,17 +205,24 @@ static VALUE MessagePack_Unpacker_execute_rescue(VALUE nouse)
|
|
206
205
|
#endif
|
207
206
|
}
|
208
207
|
|
209
|
-
static VALUE
|
208
|
+
static VALUE MessagePack_Unpacker_execute_limit(VALUE self, VALUE data,
|
209
|
+
VALUE off, VALUE limit)
|
210
210
|
{
|
211
211
|
// FIXME execute実行中はmp->topが更新されないのでGC markが機能しない
|
212
212
|
rb_gc_disable();
|
213
|
-
VALUE args[
|
213
|
+
VALUE args[4] = {self, data, off, limit};
|
214
214
|
VALUE ret = rb_rescue(MessagePack_Unpacker_execute_impl, (VALUE)args,
|
215
215
|
MessagePack_Unpacker_execute_rescue, Qnil);
|
216
216
|
rb_gc_enable();
|
217
217
|
return ret;
|
218
218
|
}
|
219
219
|
|
220
|
+
static VALUE MessagePack_Unpacker_execute(VALUE self, VALUE data, VALUE off)
|
221
|
+
{
|
222
|
+
return MessagePack_Unpacker_execute_limit(self, data, off,
|
223
|
+
LONG2FIX(RSTRING_LEN(data)));
|
224
|
+
}
|
225
|
+
|
220
226
|
static VALUE MessagePack_Unpacker_finished_p(VALUE self)
|
221
227
|
{
|
222
228
|
UNPACKER(self, mp);
|
@@ -229,23 +235,23 @@ static VALUE MessagePack_Unpacker_finished_p(VALUE self)
|
|
229
235
|
static VALUE MessagePack_Unpacker_data(VALUE self)
|
230
236
|
{
|
231
237
|
UNPACKER(self, mp);
|
232
|
-
return
|
238
|
+
return template_data(mp);
|
233
239
|
}
|
234
240
|
|
235
241
|
|
236
242
|
static VALUE MessagePack_unpack_impl(VALUE args)
|
237
243
|
{
|
238
|
-
|
244
|
+
msgpack_unpack_t* mp = (msgpack_unpack_t*)((VALUE*)args)[0];
|
239
245
|
VALUE data = ((VALUE*)args)[1];
|
240
246
|
|
241
247
|
size_t from = 0;
|
242
248
|
char* dptr = RSTRING_PTR(data);
|
243
|
-
long dlen =
|
249
|
+
long dlen = FIX2LONG(((VALUE*)args)[2]);
|
244
250
|
int ret;
|
245
251
|
|
246
|
-
mp->user.
|
247
|
-
ret =
|
248
|
-
mp->user.
|
252
|
+
mp->user.source = data;
|
253
|
+
ret = template_execute(mp, dptr, (size_t)dlen, &from);
|
254
|
+
mp->user.source = Qnil;
|
249
255
|
|
250
256
|
if(ret < 0) {
|
251
257
|
rb_raise(eUnpackError, "parse error.");
|
@@ -255,7 +261,7 @@ static VALUE MessagePack_unpack_impl(VALUE args)
|
|
255
261
|
if(from < dlen) {
|
256
262
|
rb_raise(eUnpackError, "extra bytes.");
|
257
263
|
}
|
258
|
-
return
|
264
|
+
return template_data(mp);
|
259
265
|
}
|
260
266
|
}
|
261
267
|
|
@@ -269,22 +275,30 @@ static VALUE MessagePack_unpack_rescue(VALUE args)
|
|
269
275
|
#endif
|
270
276
|
}
|
271
277
|
|
272
|
-
static VALUE
|
278
|
+
static VALUE MessagePack_unpack_limit(VALUE self, VALUE data, VALUE limit)
|
273
279
|
{
|
274
280
|
CHECK_STRING_TYPE(data);
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
281
|
+
|
282
|
+
msgpack_unpack_t mp;
|
283
|
+
template_init(&mp);
|
284
|
+
unpack_user u = {0, Qnil};
|
285
|
+
mp.user = u;
|
279
286
|
|
280
287
|
rb_gc_disable();
|
281
|
-
VALUE args[
|
288
|
+
VALUE args[3] = {(VALUE)&mp, data, limit};
|
282
289
|
VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args,
|
283
290
|
MessagePack_unpack_rescue, Qnil);
|
284
291
|
rb_gc_enable();
|
292
|
+
|
285
293
|
return ret;
|
286
294
|
}
|
287
295
|
|
296
|
+
static VALUE MessagePack_unpack(VALUE self, VALUE data)
|
297
|
+
{
|
298
|
+
return MessagePack_unpack_limit(self, data,
|
299
|
+
LONG2FIX(RSTRING_LEN(data)));
|
300
|
+
}
|
301
|
+
|
288
302
|
|
289
303
|
void Init_msgpack_unpack(VALUE mMessagePack)
|
290
304
|
{
|
@@ -293,10 +307,12 @@ void Init_msgpack_unpack(VALUE mMessagePack)
|
|
293
307
|
rb_define_alloc_func(cUnpacker, MessagePack_Unpacker_alloc);
|
294
308
|
rb_define_method(cUnpacker, "initialize", MessagePack_Unpacker_initialize, 0);
|
295
309
|
rb_define_method(cUnpacker, "execute", MessagePack_Unpacker_execute, 2);
|
310
|
+
rb_define_method(cUnpacker, "execute_limit", MessagePack_Unpacker_execute_limit, 3);
|
296
311
|
rb_define_method(cUnpacker, "finished?", MessagePack_Unpacker_finished_p, 0);
|
297
312
|
rb_define_method(cUnpacker, "data", MessagePack_Unpacker_data, 0);
|
298
313
|
rb_define_method(cUnpacker, "reset", MessagePack_Unpacker_reset, 0);
|
299
314
|
rb_define_module_function(mMessagePack, "unpack", MessagePack_unpack, 1);
|
315
|
+
rb_define_module_function(mMessagePack, "unpack_limit", MessagePack_unpack_limit, 2);
|
300
316
|
}
|
301
317
|
|
302
318
|
|
data/ext/unpack.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
|
-
* MessagePack unpacking routine
|
2
|
+
* MessagePack for Ruby unpacking routine
|
3
3
|
*
|
4
|
-
* Copyright (C) 2008 FURUHASHI Sadayuki
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
data/ext/unpack.o
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: mswin32
|
6
6
|
authors:
|
7
7
|
- FURUHASHI Sadayuki
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-04 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,8 +22,6 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- lib/msgpack
|
26
|
-
- lib/msgpack/version.rb
|
27
25
|
- ext/extconf.rb
|
28
26
|
- ext/Makefile
|
29
27
|
- ext/msgpack.so
|
@@ -36,7 +34,7 @@ files:
|
|
36
34
|
- ext/unpack.h
|
37
35
|
- ext/unpack.o
|
38
36
|
has_rdoc: false
|
39
|
-
homepage:
|
37
|
+
homepage: http://msgpack.sourceforge.jp/
|
40
38
|
post_install_message:
|
41
39
|
rdoc_options: []
|
42
40
|
|
@@ -57,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
55
|
version:
|
58
56
|
requirements: []
|
59
57
|
|
60
|
-
rubyforge_project:
|
58
|
+
rubyforge_project: msgpack
|
61
59
|
rubygems_version: 1.3.1
|
62
60
|
signing_key:
|
63
61
|
specification_version: 2
|