msgpack 1.0.0-x64-mingw32 → 1.0.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8fc0b1cda291d95b4bbd36e756affa017689c30
4
- data.tar.gz: eed3786878debaaa858254407cc00c37206103e0
3
+ metadata.gz: 0dd82629ce300339d5d352fc42ad7668dd91058a
4
+ data.tar.gz: 4869b8f60711c120d7dbd303983d761b7eaff64d
5
5
  SHA512:
6
- metadata.gz: aae0c2ceb7304d2b5ff2023e8a9280afd52ca0b28f7c7118abc6591fe19ac91a0290d29061974315ead4b689697d8d015b9ef10f57413703fdb7ea2efe28b485
7
- data.tar.gz: 43d04ccdf06088d505a638225cfb729588654eee8d6dd2f63cfde9b701c8b46ff1e9e3eda2db5c231c8652d33b3a335f2f9e2875904ce77f59ae73f6935351d6
6
+ metadata.gz: 9de324ec910f95659aef11c7ec674a37424162fc18e59691ae8a311924f257c8f0b34949ade17957ccfc8328282e3d12aaa9819a06c359503699d1dfd57f0be9
7
+ data.tar.gz: 91eb41d2bb085d1aac45fdf25e46b72da09384fa50a1dca66df6d6dd850efe03a20aa59c442792acc6ab0ee84a9b26caf42d3d3fb2fd75ef0a138239aa7efdb8
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 = 1, visibility = PRIVATE)
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
- } else if (!(args[0] instanceof RubyHash)) {
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 msgpack_packer_ext_find_inherited(VALUE key, VALUE value, VALUE arg)
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 e = rb_hash_lookup(pkrg->hash, ext_class);
70
- if(e != Qnil) {
71
- *ext_type_result = FIX2INT(rb_ary_entry(e, 0));
72
- return rb_ary_entry(e, 1);
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 c = rb_hash_lookup(pkrg->cache, ext_class);
76
- if(c != Qnil) {
77
- *ext_type_result = FIX2INT(rb_ary_entry(c, 0));
78
- return rb_ary_entry(c, 1);
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, msgpack_packer_ext_find_inherited, (VALUE) args);
88
-
89
- VALUE hit = args[1];
90
- if(hit != Qnil) {
91
- rb_hash_aset(pkrg->cache, ext_class, hit);
92
- return hit;
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;
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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
 
@@ -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.0
4
+ version: 1.0.1
5
5
  platform: x64-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-07-08 00:00:00.000000000 Z
13
+ date: 2016-10-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler