msgpack 0.3.8-mswin32 → 0.3.9-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/unpack.c +26 -8
- data/lib/1.8/msgpack.so +0 -0
- data/lib/1.9/msgpack.so +0 -0
- data/test/msgpack_test.rb +28 -2
- metadata +3 -3
data/ext/unpack.c
CHANGED
@@ -389,25 +389,43 @@ static VALUE MessagePack_unpack(VALUE self, VALUE data)
|
|
389
389
|
}
|
390
390
|
|
391
391
|
|
392
|
+
static VALUE MessagePack_Unpacker_execute_impl(VALUE self, VALUE data,
|
393
|
+
size_t from, size_t limit)
|
394
|
+
{
|
395
|
+
UNPACKER(self, mp);
|
396
|
+
|
397
|
+
if(from >= limit) {
|
398
|
+
rb_raise(eUnpackError, "offset is bigger than data buffer size.");
|
399
|
+
}
|
400
|
+
|
401
|
+
int ret = template_execute_wrap(mp, data, limit, &from);
|
402
|
+
|
403
|
+
if(ret < 0) {
|
404
|
+
rb_raise(eUnpackError, "parse error.");
|
405
|
+
} else if(ret > 0) {
|
406
|
+
mp->user.finished = 1;
|
407
|
+
return ULONG2NUM(from);
|
408
|
+
} else {
|
409
|
+
mp->user.finished = 0;
|
410
|
+
return ULONG2NUM(from);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
392
414
|
/* compat */
|
393
415
|
static VALUE MessagePack_Unpacker_execute_limit(VALUE self, VALUE data,
|
394
416
|
VALUE off, VALUE limit)
|
395
417
|
{
|
396
418
|
CHECK_STRING_TYPE(data);
|
397
|
-
|
398
|
-
|
399
|
-
int ret = template_execute_wrap(mp, data, NUM2ULONG(limit), &from);
|
400
|
-
return INT2FIX(ret);
|
419
|
+
return MessagePack_Unpacker_execute_impl(self, data,
|
420
|
+
(size_t)NUM2ULONG(off), (size_t)NUM2ULONG(limit));
|
401
421
|
}
|
402
422
|
|
403
423
|
/* compat */
|
404
424
|
static VALUE MessagePack_Unpacker_execute(VALUE self, VALUE data, VALUE off)
|
405
425
|
{
|
406
426
|
CHECK_STRING_TYPE(data);
|
407
|
-
|
408
|
-
|
409
|
-
int ret = template_execute_wrap(mp, data, RSTRING_LEN(data), &from);
|
410
|
-
return INT2FIX(ret);
|
427
|
+
return MessagePack_Unpacker_execute_impl(self, data,
|
428
|
+
(size_t)NUM2ULONG(off), (size_t)RSTRING_LEN(data));
|
411
429
|
}
|
412
430
|
|
413
431
|
/* compat */
|
data/lib/1.8/msgpack.so
CHANGED
Binary file
|
data/lib/1.9/msgpack.so
CHANGED
Binary file
|
data/test/msgpack_test.rb
CHANGED
@@ -204,9 +204,11 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|
204
204
|
|
205
205
|
it "gc mark" do
|
206
206
|
obj = [{["a","b"]=>["c","d"]}, ["e","f"], "d"]
|
207
|
+
num = 4
|
208
|
+
raw = obj.to_msgpack * num
|
207
209
|
pac = MessagePack::Unpacker.new
|
208
210
|
parsed = 0
|
209
|
-
|
211
|
+
raw.split(//).each do |b|
|
210
212
|
pac.feed(b)
|
211
213
|
pac.each {|o|
|
212
214
|
GC.start
|
@@ -215,7 +217,31 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|
215
217
|
}
|
216
218
|
GC.start
|
217
219
|
end
|
218
|
-
assert_equal(parsed,
|
220
|
+
assert_equal(parsed, num)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "streaming backward compatibility" do
|
224
|
+
obj = [{["a","b"]=>["c","d"]}, ["e","f"], "d"]
|
225
|
+
num = 4
|
226
|
+
raw = obj.to_msgpack * num
|
227
|
+
pac = MessagePack::Unpacker.new
|
228
|
+
buffer = ""
|
229
|
+
nread = 0
|
230
|
+
parsed = 0
|
231
|
+
raw.split(//).each do |b|
|
232
|
+
buffer << b
|
233
|
+
nread = pac.execute(buffer, nread)
|
234
|
+
if pac.finished?
|
235
|
+
o = pac.data
|
236
|
+
assert_equal(obj, o)
|
237
|
+
parsed += 1
|
238
|
+
pac.reset
|
239
|
+
buffer.slice!(0, nread)
|
240
|
+
nread = 0
|
241
|
+
next unless buffer.empty?
|
242
|
+
end
|
243
|
+
end
|
244
|
+
assert_equal(parsed, num)
|
219
245
|
end
|
220
246
|
|
221
247
|
private
|
metadata
CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
segments:
|
5
5
|
- 0
|
6
6
|
- 3
|
7
|
-
-
|
8
|
-
version: 0.3.
|
7
|
+
- 9
|
8
|
+
version: 0.3.9
|
9
9
|
platform: mswin32
|
10
10
|
authors:
|
11
11
|
- FURUHASHI Sadayuki
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2010-04-
|
16
|
+
date: 2010-04-23 00:00:00 +09:00
|
17
17
|
default_executable:
|
18
18
|
dependencies: []
|
19
19
|
|