msgpack 1.0.0-x86-mingw32 → 1.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/ext/java/org/msgpack/jruby/Unpacker.java +3 -2
- data/ext/msgpack/packer_ext_registry.h +18 -19
- data/lib/msgpack/version.rb +1 -1
- data/spec/packer_spec.rb +26 -0
- data/spec/unpacker_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a014d37f6cbf3267793aed00ba70a6e266258f5
|
4
|
+
data.tar.gz: 67bf9d737f954bc1317e8bad8a9fd08ae6fd94bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6702616da4687ccb356ec498940306b2cdbd36e9c3e9632f7f3efe9f0685b824336befc28a6270303b96205fd1778c592e6f855a4376fd73100ec821b3d0c2a4
|
7
|
+
data.tar.gz: a9c4fde5ee2b9662fd0b59e641e1ecfcbf8738826ee16451d92aa267290718f978fe385b1f2f42a99efda041ce5691ecaff7027b5aff4f62ea835a9eda99dc2b
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
2016-10-17 version 1.0.1:
|
2
|
+
|
3
|
+
* Fix a bug to crash at packer when ext type is registered for superclass of packed object
|
4
|
+
* Fix JRuby implementation about inconsistent API of Unpacker constructor
|
5
|
+
|
1
6
|
2016-07-08 version 1.0.0:
|
2
7
|
|
3
8
|
* Fix to be able to pack Symbol with ext types
|
@@ -51,7 +51,7 @@ public class Unpacker extends RubyObject {
|
|
51
51
|
}
|
52
52
|
}
|
53
53
|
|
54
|
-
@JRubyMethod(name = "initialize", optional =
|
54
|
+
@JRubyMethod(name = "initialize", optional = 2, visibility = PRIVATE)
|
55
55
|
public IRubyObject initialize(ThreadContext ctx, IRubyObject[] args) {
|
56
56
|
symbolizeKeys = false;
|
57
57
|
allowUnknownExt = false;
|
@@ -66,7 +66,8 @@ public class Unpacker extends RubyObject {
|
|
66
66
|
if (au != null) {
|
67
67
|
allowUnknownExt = au.isTrue();
|
68
68
|
}
|
69
|
-
}
|
69
|
+
}
|
70
|
+
if (!(args[0] instanceof RubyHash)) {
|
70
71
|
setStream(ctx, args[0]);
|
71
72
|
}
|
72
73
|
}
|
@@ -26,10 +26,7 @@ typedef struct msgpack_packer_ext_registry_t msgpack_packer_ext_registry_t;
|
|
26
26
|
|
27
27
|
struct msgpack_packer_ext_registry_t {
|
28
28
|
VALUE hash;
|
29
|
-
|
30
|
-
* lookup cache for subclasses of registered classes
|
31
|
-
*/
|
32
|
-
VALUE cache;
|
29
|
+
VALUE cache; // lookup cache for ext types inherited from a super class
|
33
30
|
};
|
34
31
|
|
35
32
|
void msgpack_packer_ext_registry_static_init();
|
@@ -49,7 +46,7 @@ void msgpack_packer_ext_registry_dup(msgpack_packer_ext_registry_t* src,
|
|
49
46
|
VALUE msgpack_packer_ext_registry_put(msgpack_packer_ext_registry_t* pkrg,
|
50
47
|
VALUE ext_class, int ext_type, VALUE proc, VALUE arg);
|
51
48
|
|
52
|
-
static int
|
49
|
+
static int msgpack_packer_ext_find_superclass(VALUE key, VALUE value, VALUE arg)
|
53
50
|
{
|
54
51
|
VALUE *args = (VALUE *) arg;
|
55
52
|
if(key == Qundef) {
|
@@ -66,16 +63,16 @@ static int msgpack_packer_ext_find_inherited(VALUE key, VALUE value, VALUE arg)
|
|
66
63
|
static inline VALUE msgpack_packer_ext_registry_lookup(msgpack_packer_ext_registry_t* pkrg,
|
67
64
|
VALUE ext_class, int* ext_type_result)
|
68
65
|
{
|
69
|
-
VALUE
|
70
|
-
if(
|
71
|
-
*ext_type_result = FIX2INT(rb_ary_entry(
|
72
|
-
return rb_ary_entry(
|
66
|
+
VALUE type = rb_hash_lookup(pkrg->hash, ext_class);
|
67
|
+
if(type != Qnil) {
|
68
|
+
*ext_type_result = FIX2INT(rb_ary_entry(type, 0));
|
69
|
+
return rb_ary_entry(type, 1);
|
73
70
|
}
|
74
71
|
|
75
|
-
VALUE
|
76
|
-
if(
|
77
|
-
*ext_type_result = FIX2INT(rb_ary_entry(
|
78
|
-
return rb_ary_entry(
|
72
|
+
VALUE type_inht = rb_hash_lookup(pkrg->cache, ext_class);
|
73
|
+
if(type_inht != Qnil) {
|
74
|
+
*ext_type_result = FIX2INT(rb_ary_entry(type_inht, 0));
|
75
|
+
return rb_ary_entry(type_inht, 1);
|
79
76
|
}
|
80
77
|
|
81
78
|
/*
|
@@ -84,12 +81,14 @@ static inline VALUE msgpack_packer_ext_registry_lookup(msgpack_packer_ext_regist
|
|
84
81
|
VALUE args[2];
|
85
82
|
args[0] = ext_class;
|
86
83
|
args[1] = Qnil;
|
87
|
-
rb_hash_foreach(pkrg->hash,
|
88
|
-
|
89
|
-
VALUE
|
90
|
-
if(
|
91
|
-
|
92
|
-
|
84
|
+
rb_hash_foreach(pkrg->hash, msgpack_packer_ext_find_superclass, (VALUE) args);
|
85
|
+
|
86
|
+
VALUE superclass = args[1];
|
87
|
+
if(superclass != Qnil) {
|
88
|
+
VALUE superclass_type = rb_hash_lookup(pkrg->hash, superclass);
|
89
|
+
rb_hash_aset(pkrg->cache, ext_class, superclass_type);
|
90
|
+
*ext_type_result = FIX2INT(rb_ary_entry(superclass_type, 0));
|
91
|
+
return rb_ary_entry(superclass_type, 1);
|
93
92
|
}
|
94
93
|
|
95
94
|
return Qnil;
|
data/lib/msgpack/version.rb
CHANGED
data/spec/packer_spec.rb
CHANGED
@@ -324,6 +324,32 @@ describe MessagePack::Packer do
|
|
324
324
|
expect(two[:packer]).to eq(:to_msgpack_ext)
|
325
325
|
end
|
326
326
|
|
327
|
+
context 'when it has no ext type but a super class has' do
|
328
|
+
before { stub_const('Value', Class.new) }
|
329
|
+
before do
|
330
|
+
Value.class_eval do
|
331
|
+
def to_msgpack_ext
|
332
|
+
'value_msgpacked'
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
before { packer.register_type(0x01, Value, :to_msgpack_ext) }
|
337
|
+
|
338
|
+
context "when it is a child class" do
|
339
|
+
before { stub_const('InheritedValue', Class.new(Value)) }
|
340
|
+
subject { packer.pack(InheritedValue.new).to_s }
|
341
|
+
|
342
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
343
|
+
|
344
|
+
context "when it is a grandchild class" do
|
345
|
+
before { stub_const('InheritedTwiceValue', Class.new(InheritedValue)) }
|
346
|
+
subject { packer.pack(InheritedTwiceValue.new).to_s }
|
347
|
+
|
348
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
327
353
|
context 'when registering a type for symbols' do
|
328
354
|
before { packer.register_type(0x00, ::Symbol, :to_msgpack_ext) }
|
329
355
|
|
data/spec/unpacker_spec.rb
CHANGED
@@ -564,6 +564,17 @@ describe MessagePack::Unpacker do
|
|
564
564
|
objects.should == [{'foo' => 'bar'}, {'hello' => {'world' => [1, 2, 3]}}, {'x' => 'y'}]
|
565
565
|
end
|
566
566
|
end
|
567
|
+
|
568
|
+
context 'with a stream and symbolize_keys passed to the constructor' do
|
569
|
+
it 'yields each object in the stream, with symbolized keys' do
|
570
|
+
objects = []
|
571
|
+
unpacker = described_class.new(StringIO.new(buffer1 + buffer2 + buffer3), symbolize_keys: true)
|
572
|
+
unpacker.each do |obj|
|
573
|
+
objects << obj
|
574
|
+
end
|
575
|
+
objects.should == [{:foo => 'bar'}, {:hello => {:world => [1, 2, 3]}}, {:x => 'y'}]
|
576
|
+
end
|
577
|
+
end
|
567
578
|
end
|
568
579
|
|
569
580
|
describe '#feed_each' do
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|