msgpack 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +2 -1
- data/ext/msgpack/unpacker.c +35 -13
- data/lib/msgpack/version.rb +1 -1
- data/spec/factory_spec.rb +21 -0
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c5ae461c691018c21ea088c4b629510c0626a31c16e640d7128d1d4be70276a
|
4
|
+
data.tar.gz: 32ac330fedeb8fdcf90e172df4480d05564185ef9b3e72f430c83de04eea90b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5a1c96cbfdc2030c38cf559a61aaacc466a5b4fcaaa6af809b8d062f3042a44ee6df0f731fe77bbdf1ebba0a123da2b9db033e7117baabcc6e9664dd6f56ef
|
7
|
+
data.tar.gz: 07c313bd70f92996b0131a0c5ce9836f025dd4fa98fdbe365ad04fa860b2bd6ca81c62fbd90cc2296a75eddd2a9b648b3ca48b8838a40ffab72a5845dfd6e724
|
data/ChangeLog
CHANGED
@@ -415,6 +415,7 @@ public class Encoder {
|
|
415
415
|
if (entry.isRecursive()) {
|
416
416
|
ByteBuffer oldBuffer = buffer;
|
417
417
|
buffer = ByteBuffer.allocate(CACHE_LINE_SIZE - ARRAY_HEADER_SIZE);
|
418
|
+
boolean previousRecursiveExtension = recursiveExtension;
|
418
419
|
recursiveExtension = true;
|
419
420
|
|
420
421
|
ByteList payload;
|
@@ -423,7 +424,7 @@ public class Encoder {
|
|
423
424
|
proc.callMethod(runtime.getCurrentContext(), "call", args);
|
424
425
|
payload = new ByteList(buffer.array(), 0, buffer.position(), binaryEncoding, false);
|
425
426
|
} finally {
|
426
|
-
recursiveExtension =
|
427
|
+
recursiveExtension = previousRecursiveExtension;
|
427
428
|
buffer = oldBuffer;
|
428
429
|
}
|
429
430
|
appendExt(type, payload);
|
data/ext/msgpack/unpacker.c
CHANGED
@@ -52,6 +52,16 @@ void msgpack_unpacker_static_destroy()
|
|
52
52
|
|
53
53
|
#define HEAD_BYTE_REQUIRED 0xc1
|
54
54
|
|
55
|
+
static inline msgpack_unpacker_stack_t* _msgpack_unpacker_new_stack(void) {
|
56
|
+
#ifdef UNPACKER_STACK_RMEM
|
57
|
+
return msgpack_rmem_alloc(&s_stack_rmem);
|
58
|
+
/*memset(uk->stack, 0, MSGPACK_UNPACKER_STACK_CAPACITY);*/
|
59
|
+
#else
|
60
|
+
/*uk->stack = calloc(MSGPACK_UNPACKER_STACK_CAPACITY, sizeof(msgpack_unpacker_stack_t));*/
|
61
|
+
return xmalloc(MSGPACK_UNPACKER_STACK_CAPACITY * sizeof(msgpack_unpacker_stack_t));
|
62
|
+
#endif
|
63
|
+
}
|
64
|
+
|
55
65
|
msgpack_unpacker_t* _msgpack_unpacker_new(void)
|
56
66
|
{
|
57
67
|
msgpack_unpacker_t* uk = ZALLOC_N(msgpack_unpacker_t, 1);
|
@@ -63,26 +73,23 @@ msgpack_unpacker_t* _msgpack_unpacker_new(void)
|
|
63
73
|
uk->last_object = Qnil;
|
64
74
|
uk->reading_raw = Qnil;
|
65
75
|
|
66
|
-
|
67
|
-
uk->stack = msgpack_rmem_alloc(&s_stack_rmem);
|
68
|
-
/*memset(uk->stack, 0, MSGPACK_UNPACKER_STACK_CAPACITY);*/
|
69
|
-
#else
|
70
|
-
/*uk->stack = calloc(MSGPACK_UNPACKER_STACK_CAPACITY, sizeof(msgpack_unpacker_stack_t));*/
|
71
|
-
uk->stack = xmalloc(MSGPACK_UNPACKER_STACK_CAPACITY * sizeof(msgpack_unpacker_stack_t));
|
72
|
-
#endif
|
76
|
+
uk->stack = _msgpack_unpacker_new_stack();
|
73
77
|
uk->stack_capacity = MSGPACK_UNPACKER_STACK_CAPACITY;
|
74
78
|
|
75
79
|
return uk;
|
76
80
|
}
|
77
81
|
|
82
|
+
static inline void _msgpack_unpacker_free_stack(msgpack_unpacker_stack_t* stack) {
|
83
|
+
#ifdef UNPACKER_STACK_RMEM
|
84
|
+
msgpack_rmem_free(&s_stack_rmem, stack);
|
85
|
+
#else
|
86
|
+
xfree(stack);
|
87
|
+
#endif
|
88
|
+
}
|
89
|
+
|
78
90
|
void _msgpack_unpacker_destroy(msgpack_unpacker_t* uk)
|
79
91
|
{
|
80
|
-
|
81
|
-
msgpack_rmem_free(&s_stack_rmem, uk->stack);
|
82
|
-
#else
|
83
|
-
xfree(uk->stack);
|
84
|
-
#endif
|
85
|
-
|
92
|
+
_msgpack_unpacker_free_stack(uk->stack);
|
86
93
|
msgpack_buffer_destroy(UNPACKER_BUFFER_(uk));
|
87
94
|
}
|
88
95
|
|
@@ -297,7 +304,22 @@ static inline int read_raw_body_begin(msgpack_unpacker_t* uk, int raw_type)
|
|
297
304
|
reset_head_byte(uk);
|
298
305
|
size_t ext_size = uk->reading_raw_remaining;
|
299
306
|
uk->reading_raw_remaining = 0;
|
307
|
+
|
308
|
+
msgpack_unpacker_stack_t* stack = uk->stack;
|
309
|
+
size_t stack_depth = uk->stack_depth;
|
310
|
+
size_t stack_capacity = uk->stack_capacity;
|
311
|
+
|
312
|
+
uk->stack = _msgpack_unpacker_new_stack();
|
313
|
+
uk->stack_depth = 0;
|
314
|
+
uk->stack_capacity = MSGPACK_UNPACKER_STACK_CAPACITY;
|
315
|
+
|
300
316
|
obj = rb_funcall(proc, s_call, 1, uk->buffer.owner);
|
317
|
+
|
318
|
+
_msgpack_unpacker_free_stack(uk->stack);
|
319
|
+
uk->stack = stack;
|
320
|
+
uk->stack_depth = stack_depth;
|
321
|
+
uk->stack_capacity = stack_capacity;
|
322
|
+
|
301
323
|
msgpack_buffer_skip(UNPACKER_BUFFER_(uk), ext_size);
|
302
324
|
return object_complete(uk, obj);
|
303
325
|
}
|
data/lib/msgpack/version.rb
CHANGED
data/spec/factory_spec.rb
CHANGED
@@ -423,6 +423,27 @@ describe MessagePack::Factory do
|
|
423
423
|
3,
|
424
424
|
]
|
425
425
|
end
|
426
|
+
|
427
|
+
it 'can be nested' do
|
428
|
+
factory = MessagePack::Factory.new
|
429
|
+
factory.register_type(
|
430
|
+
0x02,
|
431
|
+
Set,
|
432
|
+
packer: ->(set, packer) do
|
433
|
+
packer.write(set.to_a)
|
434
|
+
nil
|
435
|
+
end,
|
436
|
+
unpacker: ->(unpacker) do
|
437
|
+
unpacker.read.to_set
|
438
|
+
end,
|
439
|
+
recursive: true,
|
440
|
+
)
|
441
|
+
|
442
|
+
expected = Set[1, Set[2, Set[3]]]
|
443
|
+
payload = factory.dump(expected)
|
444
|
+
expect(payload).to be == "\xC7\v\x02\x92\x01\xC7\x06\x02\x92\x02\xD5\x02\x91\x03".b
|
445
|
+
expect(factory.load(factory.dump(expected))).to be == expected
|
446
|
+
end
|
426
447
|
end
|
427
448
|
end
|
428
449
|
|
data/spec/spec_helper.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
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: 2022-04-
|
13
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|