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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21e348c774582d02431d9bc7f4aa05c613b3d666
4
- data.tar.gz: 8d5759682e567269c62ec32bedd6f09c33bba599
3
+ metadata.gz: 3a014d37f6cbf3267793aed00ba70a6e266258f5
4
+ data.tar.gz: 67bf9d737f954bc1317e8bad8a9fd08ae6fd94bc
5
5
  SHA512:
6
- metadata.gz: cf93dbee6bae73dc955856bbd61199489d125e01a79639a811cb8351261967cf0af10cae3d102a768042b54ef9e110a6ddcbe8e4a594d15b621a48d101f31306
7
- data.tar.gz: 8f2f8256abcc4cdd6a091c8a58ceddbd9f80d7ad663f63f0d6b5b28119f357fda37b82dee86db8090049759e7c137ca64f9937d93cf3afff850ab11ba38ff4f0
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 = 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: 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-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