msgpack 1.5.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +55 -0
  3. data/README.md +30 -1
  4. data/ext/java/org/msgpack/jruby/Buffer.java +3 -3
  5. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +11 -20
  6. data/ext/java/org/msgpack/jruby/ExtensionValue.java +1 -1
  7. data/ext/java/org/msgpack/jruby/Factory.java +11 -50
  8. data/ext/java/org/msgpack/jruby/Packer.java +9 -24
  9. data/ext/java/org/msgpack/jruby/Unpacker.java +15 -32
  10. data/ext/msgpack/buffer.c +54 -69
  11. data/ext/msgpack/buffer.h +16 -18
  12. data/ext/msgpack/buffer_class.c +138 -37
  13. data/ext/msgpack/buffer_class.h +1 -0
  14. data/ext/msgpack/compat.h +0 -99
  15. data/ext/msgpack/extconf.rb +25 -39
  16. data/ext/msgpack/factory_class.c +75 -86
  17. data/ext/msgpack/packer.c +12 -39
  18. data/ext/msgpack/packer.h +1 -11
  19. data/ext/msgpack/packer_class.c +73 -99
  20. data/ext/msgpack/packer_class.h +11 -0
  21. data/ext/msgpack/packer_ext_registry.c +31 -28
  22. data/ext/msgpack/packer_ext_registry.h +10 -14
  23. data/ext/msgpack/rbinit.c +1 -1
  24. data/ext/msgpack/rmem.c +3 -4
  25. data/ext/msgpack/sysdep.h +5 -2
  26. data/ext/msgpack/unpacker.c +66 -94
  27. data/ext/msgpack/unpacker.h +13 -12
  28. data/ext/msgpack/unpacker_class.c +64 -80
  29. data/ext/msgpack/unpacker_class.h +11 -0
  30. data/ext/msgpack/unpacker_ext_registry.c +4 -16
  31. data/ext/msgpack/unpacker_ext_registry.h +3 -7
  32. data/lib/msgpack/buffer.rb +9 -0
  33. data/lib/msgpack/factory.rb +90 -63
  34. data/lib/msgpack/packer.rb +10 -1
  35. data/lib/msgpack/unpacker.rb +14 -1
  36. data/lib/msgpack/version.rb +1 -1
  37. data/lib/msgpack.rb +1 -0
  38. data/msgpack.gemspec +7 -3
  39. metadata +33 -56
  40. data/.github/workflows/ci.yaml +0 -57
  41. data/.gitignore +0 -23
  42. data/.rubocop.yml +0 -36
  43. data/Gemfile +0 -9
  44. data/Rakefile +0 -70
  45. data/appveyor.yml +0 -18
  46. data/bench/pack.rb +0 -23
  47. data/bench/pack_log.rb +0 -33
  48. data/bench/pack_log_long.rb +0 -65
  49. data/bench/pack_symbols.rb +0 -28
  50. data/bench/run.sh +0 -14
  51. data/bench/run_long.sh +0 -35
  52. data/bench/run_symbols.sh +0 -26
  53. data/bench/unpack.rb +0 -21
  54. data/bench/unpack_log.rb +0 -34
  55. data/bench/unpack_log_long.rb +0 -67
  56. data/doclib/msgpack/buffer.rb +0 -193
  57. data/doclib/msgpack/core_ext.rb +0 -101
  58. data/doclib/msgpack/error.rb +0 -19
  59. data/doclib/msgpack/extension_value.rb +0 -9
  60. data/doclib/msgpack/factory.rb +0 -145
  61. data/doclib/msgpack/packer.rb +0 -209
  62. data/doclib/msgpack/time.rb +0 -22
  63. data/doclib/msgpack/timestamp.rb +0 -44
  64. data/doclib/msgpack/unpacker.rb +0 -183
  65. data/doclib/msgpack.rb +0 -87
  66. data/msgpack.org.md +0 -46
  67. data/spec/bigint_spec.rb +0 -26
  68. data/spec/cases.json +0 -1
  69. data/spec/cases.msg +0 -0
  70. data/spec/cases_compact.msg +0 -0
  71. data/spec/cases_spec.rb +0 -39
  72. data/spec/cruby/buffer_io_spec.rb +0 -255
  73. data/spec/cruby/buffer_packer.rb +0 -29
  74. data/spec/cruby/buffer_spec.rb +0 -575
  75. data/spec/cruby/buffer_unpacker.rb +0 -19
  76. data/spec/cruby/unpacker_spec.rb +0 -70
  77. data/spec/ext_value_spec.rb +0 -99
  78. data/spec/exttypes.rb +0 -51
  79. data/spec/factory_spec.rb +0 -654
  80. data/spec/format_spec.rb +0 -301
  81. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  82. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  83. data/spec/jruby/unpacker_spec.rb +0 -186
  84. data/spec/msgpack_spec.rb +0 -214
  85. data/spec/pack_spec.rb +0 -61
  86. data/spec/packer_spec.rb +0 -575
  87. data/spec/random_compat.rb +0 -24
  88. data/spec/spec_helper.rb +0 -65
  89. data/spec/timestamp_spec.rb +0 -159
  90. data/spec/unpack_spec.rb +0 -57
  91. data/spec/unpacker_spec.rb +0 -847
@@ -37,15 +37,10 @@ struct msgpack_factory_t {
37
37
  int symbol_ext_type;
38
38
  };
39
39
 
40
- #define FACTORY(from, name) \
41
- msgpack_factory_t *name = NULL; \
42
- Data_Get_Struct(from, msgpack_factory_t, name); \
43
- if(name == NULL) { \
44
- rb_raise(rb_eArgError, "NULL found for " # name " when shouldn't be."); \
45
- }
46
-
47
- static void Factory_free(msgpack_factory_t* fc)
40
+ static void Factory_free(void *ptr)
48
41
  {
42
+ msgpack_factory_t *fc = ptr;
43
+
49
44
  if(fc == NULL) {
50
45
  return;
51
46
  }
@@ -54,25 +49,56 @@ static void Factory_free(msgpack_factory_t* fc)
54
49
  xfree(fc);
55
50
  }
56
51
 
57
- void Factory_mark(msgpack_factory_t* fc)
52
+ void Factory_mark(void *ptr)
58
53
  {
54
+ msgpack_factory_t *fc = ptr;
59
55
  msgpack_packer_ext_registry_mark(&fc->pkrg);
60
56
  msgpack_unpacker_ext_registry_mark(fc->ukrg);
61
57
  }
62
58
 
63
- static VALUE Factory_alloc(VALUE klass)
59
+ static size_t Factory_memsize(const void *ptr)
64
60
  {
65
- msgpack_factory_t* fc = ZALLOC_N(msgpack_factory_t, 1);
61
+ const msgpack_factory_t *fc = ptr;
62
+ size_t total_size = sizeof(msgpack_factory_t);
66
63
 
67
- VALUE self = Data_Wrap_Struct(klass, Factory_mark, Factory_free, fc);
68
- return self;
64
+ if (fc->ukrg) {
65
+ total_size += sizeof(msgpack_unpacker_ext_registry_t) / (fc->ukrg->borrow_count + 1);
66
+ }
67
+
68
+ return total_size;
69
+ }
70
+
71
+ static const rb_data_type_t factory_data_type = {
72
+ .wrap_struct_name = "msgpack:factory",
73
+ .function = {
74
+ .dmark = Factory_mark,
75
+ .dfree = Factory_free,
76
+ .dsize = Factory_memsize,
77
+ },
78
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
79
+ };
80
+
81
+ static inline msgpack_factory_t *Factory_get(VALUE object)
82
+ {
83
+ msgpack_factory_t *factory;
84
+ TypedData_Get_Struct(object, msgpack_factory_t, &factory_data_type, factory);
85
+ if (!factory) {
86
+ rb_raise(rb_eArgError, "Uninitialized Factory object");
87
+ }
88
+ return factory;
89
+ }
90
+
91
+ static VALUE Factory_alloc(VALUE klass)
92
+ {
93
+ msgpack_factory_t *fc;
94
+ return TypedData_Make_Struct(klass, msgpack_factory_t, &factory_data_type, fc);
69
95
  }
70
96
 
71
97
  static VALUE Factory_initialize(int argc, VALUE* argv, VALUE self)
72
98
  {
73
- FACTORY(self, fc);
99
+ msgpack_factory_t *fc = Factory_get(self);
74
100
 
75
- msgpack_packer_ext_registry_init(&fc->pkrg);
101
+ msgpack_packer_ext_registry_init(self, &fc->pkrg);
76
102
  // fc->ukrg is lazily initialized
77
103
 
78
104
  fc->has_symbol_ext_type = false;
@@ -92,20 +118,20 @@ static VALUE Factory_dup(VALUE self)
92
118
  {
93
119
  VALUE clone = Factory_alloc(rb_obj_class(self));
94
120
 
95
- FACTORY(self, fc);
96
- FACTORY(clone, cloned_fc);
121
+ msgpack_factory_t *fc = Factory_get(self);
122
+ msgpack_factory_t *cloned_fc = Factory_get(clone);
97
123
 
98
124
  cloned_fc->has_symbol_ext_type = fc->has_symbol_ext_type;
99
125
  cloned_fc->pkrg = fc->pkrg;
100
126
  msgpack_unpacker_ext_registry_borrow(fc->ukrg, &cloned_fc->ukrg);
101
- msgpack_packer_ext_registry_dup(&fc->pkrg, &cloned_fc->pkrg);
127
+ msgpack_packer_ext_registry_dup(clone, &fc->pkrg, &cloned_fc->pkrg);
102
128
 
103
129
  return clone;
104
130
  }
105
131
 
106
132
  static VALUE Factory_freeze(VALUE self) {
107
133
  if(!rb_obj_frozen_p(self)) {
108
- FACTORY(self, fc);
134
+ msgpack_factory_t *fc = Factory_get(self);
109
135
 
110
136
  if (RTEST(fc->pkrg.hash)) {
111
137
  rb_hash_freeze(fc->pkrg.hash);
@@ -113,7 +139,7 @@ static VALUE Factory_freeze(VALUE self) {
113
139
  // If the factory is frozen, we can safely share the packer cache between
114
140
  // all packers. So we eagerly create it now so it's available when #packer
115
141
  // is called.
116
- fc->pkrg.cache = rb_hash_new();
142
+ RB_OBJ_WRITE(self, &fc->pkrg.cache, rb_hash_new());
117
143
  }
118
144
  }
119
145
 
@@ -125,16 +151,14 @@ static VALUE Factory_freeze(VALUE self) {
125
151
 
126
152
  VALUE MessagePack_Factory_packer(int argc, VALUE* argv, VALUE self)
127
153
  {
128
- FACTORY(self, fc);
154
+ msgpack_factory_t *fc = Factory_get(self);
129
155
 
130
156
  VALUE packer = MessagePack_Packer_alloc(cMessagePack_Packer);
131
157
  MessagePack_Packer_initialize(argc, argv, packer);
132
158
 
133
- msgpack_packer_t* pk;
134
- Data_Get_Struct(packer, msgpack_packer_t, pk);
135
-
159
+ msgpack_packer_t* pk = MessagePack_Packer_get(packer);
136
160
  msgpack_packer_ext_registry_destroy(&pk->ext_registry);
137
- msgpack_packer_ext_registry_dup(&fc->pkrg, &pk->ext_registry);
161
+ msgpack_packer_ext_registry_borrow(packer, &fc->pkrg, &pk->ext_registry);
138
162
  pk->has_bigint_ext_type = fc->has_bigint_ext_type;
139
163
  pk->has_symbol_ext_type = fc->has_symbol_ext_type;
140
164
 
@@ -143,13 +167,12 @@ VALUE MessagePack_Factory_packer(int argc, VALUE* argv, VALUE self)
143
167
 
144
168
  VALUE MessagePack_Factory_unpacker(int argc, VALUE* argv, VALUE self)
145
169
  {
146
- FACTORY(self, fc);
170
+ msgpack_factory_t *fc = Factory_get(self);
147
171
 
148
172
  VALUE unpacker = MessagePack_Unpacker_alloc(cMessagePack_Unpacker);
149
173
  MessagePack_Unpacker_initialize(argc, argv, unpacker);
150
174
 
151
- msgpack_unpacker_t* uk;
152
- Data_Get_Struct(unpacker, msgpack_unpacker_t, uk);
175
+ msgpack_unpacker_t* uk = MessagePack_Unpacker_get(unpacker);
153
176
  msgpack_unpacker_ext_registry_borrow(fc->ukrg, &uk->ext_registry);
154
177
  uk->optimized_symbol_ext_type = fc->optimized_symbol_ext_type;
155
178
  uk->symbol_ext_type = fc->symbol_ext_type;
@@ -159,12 +182,12 @@ VALUE MessagePack_Factory_unpacker(int argc, VALUE* argv, VALUE self)
159
182
 
160
183
  static VALUE Factory_registered_types_internal(VALUE self)
161
184
  {
162
- FACTORY(self, fc);
185
+ msgpack_factory_t *fc = Factory_get(self);
163
186
 
164
187
  VALUE uk_mapping = rb_hash_new();
165
188
  if (fc->ukrg) {
166
189
  for(int i=0; i < 256; i++) {
167
- if(fc->ukrg->array[i] != Qnil) {
190
+ if(!NIL_P(fc->ukrg->array[i])) {
168
191
  rb_hash_aset(uk_mapping, INT2FIX(i - 128), fc->ukrg->array[i]);
169
192
  }
170
193
  }
@@ -177,73 +200,39 @@ static VALUE Factory_registered_types_internal(VALUE self)
177
200
  );
178
201
  }
179
202
 
180
- static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
203
+ static VALUE Factory_register_type_internal(VALUE self, VALUE rb_ext_type, VALUE ext_module, VALUE options)
181
204
  {
182
- FACTORY(self, fc);
205
+ msgpack_factory_t *fc = Factory_get(self);
183
206
 
184
- int ext_type;
185
- int flags = 0;
186
- VALUE ext_module;
187
- VALUE options = Qnil;
188
- VALUE packer_arg, unpacker_arg;
189
- VALUE packer_proc, unpacker_proc;
207
+ Check_Type(rb_ext_type, T_FIXNUM);
190
208
 
191
- if (OBJ_FROZEN(self)) {
192
- rb_raise(rb_eRuntimeError, "can't modify frozen Factory");
209
+ if(rb_type(ext_module) != T_MODULE && rb_type(ext_module) != T_CLASS) {
210
+ rb_raise(rb_eArgError, "expected Module/Class but found %s.", rb_obj_classname(ext_module));
193
211
  }
194
212
 
195
- switch (argc) {
196
- case 2:
197
- /* register_type(0x7f, Time) */
198
- packer_arg = ID2SYM(rb_intern("to_msgpack_ext"));
199
- unpacker_arg = ID2SYM(rb_intern("from_msgpack_ext"));
200
- break;
201
- case 3:
202
- /* register_type(0x7f, Time, packer: proc-like, unapcker: proc-like) */
203
- options = argv[2];
204
- if(rb_type(options) != T_HASH) {
205
- rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(options));
206
- }
207
- packer_arg = rb_hash_aref(options, ID2SYM(rb_intern("packer")));
208
- unpacker_arg = rb_hash_aref(options, ID2SYM(rb_intern("unpacker")));
209
- break;
210
- default:
211
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..3)", argc);
212
- }
213
+ int flags = 0;
213
214
 
214
- if (options != Qnil) {
215
+ VALUE packer_proc = Qnil;
216
+ VALUE unpacker_proc = Qnil;
217
+ if(!NIL_P(options)) {
215
218
  Check_Type(options, T_HASH);
219
+ packer_proc = rb_hash_aref(options, ID2SYM(rb_intern("packer")));
220
+ unpacker_proc = rb_hash_aref(options, ID2SYM(rb_intern("unpacker")));
216
221
  }
217
222
 
218
- ext_type = NUM2INT(argv[0]);
219
- if(ext_type < -128 || ext_type > 127) {
220
- rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
221
- }
222
-
223
- ext_module = argv[1];
224
- if(rb_type(ext_module) != T_MODULE && rb_type(ext_module) != T_CLASS) {
225
- rb_raise(rb_eArgError, "expected Module/Class but found %s.", rb_obj_classname(ext_module));
226
- }
227
-
228
- packer_proc = Qnil;
229
- unpacker_proc = Qnil;
230
-
231
- if(packer_arg != Qnil) {
232
- packer_proc = rb_funcall(packer_arg, rb_intern("to_proc"), 0);
223
+ if (OBJ_FROZEN(self)) {
224
+ rb_raise(rb_eFrozenError, "can't modify frozen MessagePack::Factory");
233
225
  }
234
226
 
235
- if(unpacker_arg != Qnil) {
236
- if(rb_type(unpacker_arg) == T_SYMBOL || rb_type(unpacker_arg) == T_STRING) {
237
- unpacker_proc = rb_obj_method(ext_module, unpacker_arg);
238
- } else if (rb_respond_to(unpacker_arg, rb_intern("call"))) {
239
- unpacker_proc = unpacker_arg;
240
- } else {
241
- unpacker_proc = rb_funcall(unpacker_arg, rb_intern("method"), 1, ID2SYM(rb_intern("call")));
242
- }
227
+ int ext_type = NUM2INT(rb_ext_type);
228
+ if(ext_type < -128 || ext_type > 127) {
229
+ rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
243
230
  }
244
231
 
245
232
  if(ext_module == rb_cSymbol) {
246
- fc->has_symbol_ext_type = true;
233
+ if(NIL_P(options) || RTEST(rb_hash_aref(options, ID2SYM(rb_intern("packer"))))) {
234
+ fc->has_symbol_ext_type = true;
235
+ }
247
236
  if(RTEST(options) && RTEST(rb_hash_aref(options, ID2SYM(rb_intern("optimized_symbols_parsing"))))) {
248
237
  fc->optimized_symbol_ext_type = true;
249
238
  }
@@ -263,8 +252,8 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
263
252
  }
264
253
  }
265
254
 
266
- msgpack_packer_ext_registry_put(&fc->pkrg, ext_module, ext_type, flags, packer_proc, packer_arg);
267
- msgpack_unpacker_ext_registry_put(&fc->ukrg, ext_module, ext_type, flags, unpacker_proc, unpacker_arg);
255
+ msgpack_packer_ext_registry_put(self, &fc->pkrg, ext_module, ext_type, flags, packer_proc);
256
+ msgpack_unpacker_ext_registry_put(self, &fc->ukrg, ext_module, ext_type, flags, unpacker_proc);
268
257
 
269
258
  return Qnil;
270
259
  }
@@ -283,5 +272,5 @@ void MessagePack_Factory_module_init(VALUE mMessagePack)
283
272
  rb_define_method(cMessagePack_Factory, "unpacker", MessagePack_Factory_unpacker, -1);
284
273
 
285
274
  rb_define_private_method(cMessagePack_Factory, "registered_types_internal", Factory_registered_types_internal, 0);
286
- rb_define_method(cMessagePack_Factory, "register_type", Factory_register_type, -1);
275
+ rb_define_private_method(cMessagePack_Factory, "register_type_internal", Factory_register_type_internal, 3);
287
276
  }
data/ext/msgpack/packer.c CHANGED
@@ -17,35 +17,14 @@
17
17
  */
18
18
 
19
19
  #include "packer.h"
20
+ #include "buffer_class.h"
20
21
 
21
- #ifdef RUBINIUS
22
- static ID s_to_iter;
23
- static ID s_next;
24
- static ID s_key;
25
- static ID s_value;
22
+ #if !defined(HAVE_RB_PROC_CALL_WITH_BLOCK)
23
+ #define rb_proc_call_with_block(recv, argc, argv, block) rb_funcallv(recv, rb_intern("call"), argc, argv)
26
24
  #endif
27
25
 
28
- static ID s_call;
29
-
30
- void msgpack_packer_static_init()
31
- {
32
- #ifdef RUBINIUS
33
- s_to_iter = rb_intern("to_iter");
34
- s_next = rb_intern("next");
35
- s_key = rb_intern("key");
36
- s_value = rb_intern("value");
37
- #endif
38
-
39
- s_call = rb_intern("call");
40
- }
41
-
42
- void msgpack_packer_static_destroy()
43
- { }
44
-
45
26
  void msgpack_packer_init(msgpack_packer_t* pk)
46
27
  {
47
- memset(pk, 0, sizeof(msgpack_packer_t));
48
-
49
28
  msgpack_buffer_init(PACKER_BUFFER_(pk));
50
29
  }
51
30
 
@@ -59,6 +38,7 @@ void msgpack_packer_mark(msgpack_packer_t* pk)
59
38
  /* See MessagePack_Buffer_wrap */
60
39
  /* msgpack_buffer_mark(PACKER_BUFFER_(pk)); */
61
40
  rb_gc_mark(pk->buffer_ref);
41
+ rb_gc_mark(pk->to_msgpack_arg);
62
42
  }
63
43
 
64
44
  void msgpack_packer_reset(msgpack_packer_t* pk)
@@ -108,31 +88,20 @@ void msgpack_packer_write_hash_value(msgpack_packer_t* pk, VALUE v)
108
88
  unsigned int len32 = (unsigned int)len;
109
89
  msgpack_packer_write_map_header(pk, len32);
110
90
 
111
- #ifdef RUBINIUS
112
- VALUE iter = rb_funcall(v, s_to_iter, 0);
113
- VALUE entry = Qnil;
114
- while(RTEST(entry = rb_funcall(iter, s_next, 1, entry))) {
115
- VALUE key = rb_funcall(entry, s_key, 0);
116
- VALUE val = rb_funcall(entry, s_value, 0);
117
- write_hash_foreach(key, val, (VALUE) pk);
118
- }
119
- #else
120
91
  rb_hash_foreach(v, write_hash_foreach, (VALUE) pk);
121
- #endif
122
92
  }
123
93
 
124
94
  struct msgpack_call_proc_args_t;
125
95
  typedef struct msgpack_call_proc_args_t msgpack_call_proc_args_t;
126
96
  struct msgpack_call_proc_args_t {
127
97
  VALUE proc;
128
- VALUE arg;
129
- VALUE packer;
98
+ VALUE args[2];
130
99
  };
131
100
 
132
101
  VALUE msgpack_packer_try_calling_proc(VALUE value)
133
102
  {
134
103
  msgpack_call_proc_args_t *args = (msgpack_call_proc_args_t *)value;
135
- return rb_funcall(args->proc, s_call, 2, args->arg, args->packer);
104
+ return rb_proc_call_with_block(args->proc, 2, args->args, Qnil);
136
105
  }
137
106
 
138
107
  bool msgpack_packer_try_write_with_ext_type_lookup(msgpack_packer_t* pk, VALUE v)
@@ -146,11 +115,13 @@ bool msgpack_packer_try_write_with_ext_type_lookup(msgpack_packer_t* pk, VALUE v
146
115
  }
147
116
 
148
117
  if(ext_flags & MSGPACK_EXT_RECURSIVE) {
118
+ VALUE held_buffer = MessagePack_Buffer_hold(&pk->buffer);
119
+
149
120
  msgpack_buffer_t parent_buffer = pk->buffer;
150
121
  msgpack_buffer_init(PACKER_BUFFER_(pk));
151
122
 
152
123
  int exception_occured = 0;
153
- msgpack_call_proc_args_t args = { proc, v, pk->to_msgpack_arg };
124
+ msgpack_call_proc_args_t args = { proc, { v, pk->to_msgpack_arg } };
154
125
  rb_protect(msgpack_packer_try_calling_proc, (VALUE)&args, &exception_occured);
155
126
 
156
127
  if (exception_occured) {
@@ -164,8 +135,10 @@ bool msgpack_packer_try_write_with_ext_type_lookup(msgpack_packer_t* pk, VALUE v
164
135
  pk->buffer = parent_buffer;
165
136
  msgpack_packer_write_ext(pk, ext_type, payload);
166
137
  }
138
+
139
+ RB_GC_GUARD(held_buffer);
167
140
  } else {
168
- VALUE payload = rb_funcall(proc, s_call, 1, v);
141
+ VALUE payload = rb_proc_call_with_block(proc, 1, &v, Qnil);
169
142
  StringValue(payload);
170
143
  msgpack_packer_write_ext(pk, ext_type, payload);
171
144
  }
data/ext/msgpack/packer.h CHANGED
@@ -47,10 +47,6 @@ struct msgpack_packer_t {
47
47
 
48
48
  #define PACKER_BUFFER_(pk) (&(pk)->buffer)
49
49
 
50
- void msgpack_packer_static_init();
51
-
52
- void msgpack_packer_static_destroy();
53
-
54
50
  void msgpack_packer_init(msgpack_packer_t* pk);
55
51
 
56
52
  void msgpack_packer_destroy(msgpack_packer_t* pk);
@@ -408,13 +404,7 @@ static inline bool msgpack_packer_is_utf8_compat_string(VALUE v, int encindex)
408
404
  {
409
405
  return encindex == msgpack_rb_encindex_utf8
410
406
  || encindex == msgpack_rb_encindex_usascii
411
- #ifdef ENC_CODERANGE_ASCIIONLY
412
- /* Because ENC_CODERANGE_ASCIIONLY does not scan string, it may return ENC_CODERANGE_UNKNOWN unlike */
413
- /* rb_enc_str_asciionly_p. It is always faster than rb_str_encode if it is available. */
414
- /* Very old Rubinius (< v1.3.1) doesn't have ENC_CODERANGE_ASCIIONLY. */
415
- || (rb_enc_asciicompat(rb_enc_from_index(encindex)) && ENC_CODERANGE_ASCIIONLY(v))
416
- #endif
417
- ;
407
+ || (rb_enc_asciicompat(rb_enc_from_index(encindex)) && ENC_CODERANGE_ASCIIONLY(v));
418
408
  }
419
409
 
420
410
  static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE v)