msgpack 0.7.4 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -1
  3. data/.rubocop.yml +3 -0
  4. data/.travis.yml +27 -14
  5. data/ChangeLog +89 -1
  6. data/Gemfile +6 -1
  7. data/README.rdoc +55 -1
  8. data/Rakefile +5 -1
  9. data/bench/pack_symbols.rb +28 -0
  10. data/bench/run_symbols.sh +26 -0
  11. data/doclib/msgpack.rb +2 -2
  12. data/doclib/msgpack/core_ext.rb +20 -20
  13. data/doclib/msgpack/factory.rb +33 -0
  14. data/doclib/msgpack/packer.rb +20 -0
  15. data/doclib/msgpack/time.rb +22 -0
  16. data/doclib/msgpack/timestamp.rb +44 -0
  17. data/ext/java/org/msgpack/jruby/Buffer.java +4 -0
  18. data/ext/java/org/msgpack/jruby/Encoder.java +48 -18
  19. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +67 -38
  20. data/ext/java/org/msgpack/jruby/Factory.java +20 -8
  21. data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +0 -92
  22. data/ext/java/org/msgpack/jruby/Packer.java +114 -11
  23. data/ext/java/org/msgpack/jruby/Unpacker.java +15 -8
  24. data/ext/msgpack/buffer.h +14 -0
  25. data/ext/msgpack/buffer_class.c +1 -1
  26. data/ext/msgpack/compat.h +10 -0
  27. data/ext/msgpack/factory_class.c +24 -17
  28. data/ext/msgpack/factory_class.h +0 -2
  29. data/ext/msgpack/packer.c +5 -4
  30. data/ext/msgpack/packer.h +13 -1
  31. data/ext/msgpack/packer_class.c +130 -43
  32. data/ext/msgpack/packer_class.h +0 -2
  33. data/ext/msgpack/packer_ext_registry.c +2 -2
  34. data/ext/msgpack/packer_ext_registry.h +64 -25
  35. data/ext/msgpack/rbinit.c +0 -2
  36. data/ext/msgpack/unpacker.c +3 -3
  37. data/ext/msgpack/unpacker_class.c +25 -56
  38. data/ext/msgpack/unpacker_class.h +0 -2
  39. data/ext/msgpack/unpacker_ext_registry.c +2 -2
  40. data/ext/msgpack/unpacker_ext_registry.h +3 -3
  41. data/lib/msgpack.rb +36 -0
  42. data/lib/msgpack/core_ext.rb +139 -0
  43. data/lib/msgpack/factory.rb +21 -0
  44. data/lib/msgpack/symbol.rb +9 -0
  45. data/lib/msgpack/time.rb +29 -0
  46. data/lib/msgpack/timestamp.rb +76 -0
  47. data/lib/msgpack/version.rb +8 -1
  48. data/msgpack.gemspec +6 -7
  49. data/spec/cruby/buffer_spec.rb +6 -1
  50. data/spec/factory_spec.rb +134 -0
  51. data/spec/msgpack_spec.rb +52 -0
  52. data/spec/packer_spec.rb +200 -0
  53. data/spec/timestamp_spec.rb +121 -0
  54. data/spec/unpacker_spec.rb +29 -0
  55. metadata +29 -23
  56. data/ext/msgpack/core_ext.c +0 -144
  57. data/ext/msgpack/core_ext.h +0 -26
data/ext/msgpack/buffer.h CHANGED
@@ -262,6 +262,20 @@ static inline size_t msgpack_buffer_append_string(msgpack_buffer_t* b, VALUE str
262
262
  return length;
263
263
  }
264
264
 
265
+ static inline size_t msgpack_buffer_append_string_reference(msgpack_buffer_t* b, VALUE string)
266
+ {
267
+ size_t length = RSTRING_LEN(string);
268
+
269
+ if(length > MSGPACK_BUFFER_STRING_WRITE_REFERENCE_MINIMUM) {
270
+ _msgpack_buffer_append_long_string(b, string);
271
+
272
+ } else {
273
+ msgpack_buffer_append(b, RSTRING_PTR(string), length);
274
+ }
275
+
276
+ return length;
277
+ }
278
+
265
279
 
266
280
  /*
267
281
  * IO functions
@@ -54,7 +54,7 @@ static void Buffer_free(void* data)
54
54
 
55
55
  static VALUE Buffer_alloc(VALUE klass)
56
56
  {
57
- msgpack_buffer_t* b = ALLOC_N(msgpack_buffer_t, 1);
57
+ msgpack_buffer_t* b = ZALLOC_N(msgpack_buffer_t, 1);
58
58
  msgpack_buffer_init(b);
59
59
 
60
60
  return Data_Wrap_Struct(klass, msgpack_buffer_mark, Buffer_free, b);
data/ext/msgpack/compat.h CHANGED
@@ -28,6 +28,16 @@
28
28
  #endif
29
29
 
30
30
 
31
+ /*
32
+ * ZALLOC_N (ruby 2.2 or later)
33
+ */
34
+ #ifndef RB_ZALLOC_N
35
+ # define RB_ZALLOC_N(type,n) ((type*)ruby_xcalloc((size_t)(n),sizeof(type)))
36
+ #endif
37
+ #ifndef ZALLOC_N
38
+ # define ZALLOC_N(type,n) RB_ZALLOC_N(type,n)
39
+ #endif
40
+
31
41
  /*
32
42
  * COMPAT_HAVE_ENCODING
33
43
  */
@@ -24,7 +24,6 @@
24
24
  #include "unpacker_class.h"
25
25
 
26
26
  VALUE cMessagePack_Factory;
27
- VALUE cMessagePack_DefaultFactory;
28
27
 
29
28
  struct msgpack_factory_t;
30
29
  typedef struct msgpack_factory_t msgpack_factory_t;
@@ -32,6 +31,7 @@ typedef struct msgpack_factory_t msgpack_factory_t;
32
31
  struct msgpack_factory_t {
33
32
  msgpack_packer_ext_registry_t pkrg;
34
33
  msgpack_unpacker_ext_registry_t ukrg;
34
+ bool has_symbol_ext_type;
35
35
  };
36
36
 
37
37
  #define FACTORY(from, name) \
@@ -59,10 +59,7 @@ void Factory_mark(msgpack_factory_t* fc)
59
59
 
60
60
  static VALUE Factory_alloc(VALUE klass)
61
61
  {
62
- msgpack_factory_t* fc = ALLOC_N(msgpack_factory_t, 1);
63
-
64
- msgpack_packer_ext_registry_init(&fc->pkrg);
65
- msgpack_unpacker_ext_registry_init(&fc->ukrg);
62
+ msgpack_factory_t* fc = ZALLOC_N(msgpack_factory_t, 1);
66
63
 
67
64
  VALUE self = Data_Wrap_Struct(klass, Factory_mark, Factory_free, fc);
68
65
  return self;
@@ -72,6 +69,11 @@ static VALUE Factory_initialize(int argc, VALUE* argv, VALUE self)
72
69
  {
73
70
  FACTORY(self, fc);
74
71
 
72
+ msgpack_packer_ext_registry_init(&fc->pkrg);
73
+ msgpack_unpacker_ext_registry_init(&fc->ukrg);
74
+
75
+ fc->has_symbol_ext_type = false;
76
+
75
77
  switch (argc) {
76
78
  case 0:
77
79
  break;
@@ -95,6 +97,7 @@ VALUE MessagePack_Factory_packer(int argc, VALUE* argv, VALUE self)
95
97
 
96
98
  msgpack_packer_ext_registry_destroy(&pk->ext_registry);
97
99
  msgpack_packer_ext_registry_dup(&fc->pkrg, &pk->ext_registry);
100
+ pk->has_symbol_ext_type = fc->has_symbol_ext_type;
98
101
 
99
102
  return packer;
100
103
  }
@@ -137,11 +140,15 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
137
140
  FACTORY(self, fc);
138
141
 
139
142
  int ext_type;
140
- VALUE ext_class;
143
+ VALUE ext_module;
141
144
  VALUE options;
142
145
  VALUE packer_arg, unpacker_arg;
143
146
  VALUE packer_proc, unpacker_proc;
144
147
 
148
+ if (OBJ_FROZEN(self)) {
149
+ rb_raise(rb_eRuntimeError, "can't modify frozen Factory");
150
+ }
151
+
145
152
  switch (argc) {
146
153
  case 2:
147
154
  /* register_type(0x7f, Time) */
@@ -161,14 +168,14 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
161
168
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..3)", argc);
162
169
  }
163
170
 
164
- ext_type = rb_num2int(argv[0]);
171
+ ext_type = NUM2INT(argv[0]);
165
172
  if(ext_type < -128 || ext_type > 127) {
166
173
  rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
167
174
  }
168
175
 
169
- ext_class = argv[1];
170
- if(rb_type(ext_class) != T_CLASS) {
171
- rb_raise(rb_eArgError, "expected Class but found %s.", rb_obj_classname(ext_class));
176
+ ext_module = argv[1];
177
+ if(rb_type(ext_module) != T_MODULE && rb_type(ext_module) != T_CLASS) {
178
+ rb_raise(rb_eArgError, "expected Module/Class but found %s.", rb_obj_classname(ext_module));
172
179
  }
173
180
 
174
181
  packer_proc = Qnil;
@@ -180,15 +187,19 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
180
187
 
181
188
  if(unpacker_arg != Qnil) {
182
189
  if(rb_type(unpacker_arg) == T_SYMBOL || rb_type(unpacker_arg) == T_STRING) {
183
- unpacker_proc = rb_obj_method(ext_class, unpacker_arg);
190
+ unpacker_proc = rb_obj_method(ext_module, unpacker_arg);
184
191
  } else {
185
192
  unpacker_proc = rb_funcall(unpacker_arg, rb_intern("method"), 1, ID2SYM(rb_intern("call")));
186
193
  }
187
194
  }
188
195
 
189
- msgpack_packer_ext_registry_put(&fc->pkrg, ext_class, ext_type, packer_proc, packer_arg);
196
+ msgpack_packer_ext_registry_put(&fc->pkrg, ext_module, ext_type, packer_proc, packer_arg);
190
197
 
191
- msgpack_unpacker_ext_registry_put(&fc->ukrg, ext_class, ext_type, unpacker_proc, unpacker_arg);
198
+ if (ext_module == rb_cSymbol) {
199
+ fc->has_symbol_ext_type = true;
200
+ }
201
+
202
+ msgpack_unpacker_ext_registry_put(&fc->ukrg, ext_module, ext_type, unpacker_proc, unpacker_arg);
192
203
 
193
204
  return Qnil;
194
205
  }
@@ -206,8 +217,4 @@ void MessagePack_Factory_module_init(VALUE mMessagePack)
206
217
 
207
218
  rb_define_private_method(cMessagePack_Factory, "registered_types_internal", Factory_registered_types_internal, 0);
208
219
  rb_define_method(cMessagePack_Factory, "register_type", Factory_register_type, -1);
209
-
210
- cMessagePack_DefaultFactory = Factory_alloc(cMessagePack_Factory);
211
- Factory_initialize(0, NULL, cMessagePack_DefaultFactory);
212
- rb_define_const(mMessagePack, "DefaultFactory", cMessagePack_DefaultFactory);
213
220
  }
@@ -23,8 +23,6 @@
23
23
 
24
24
  extern VALUE cMessagePack_Factory;
25
25
 
26
- extern VALUE cMessagePack_DefaultFactory;
27
-
28
26
  extern VALUE MessagePack_Factory_packer(int argc, VALUE* argv, VALUE self);
29
27
 
30
28
  extern VALUE MessagePack_Factory_unpacker(int argc, VALUE* argv, VALUE self);
data/ext/msgpack/packer.c CHANGED
@@ -121,11 +121,12 @@ void msgpack_packer_write_hash_value(msgpack_packer_t* pk, VALUE v)
121
121
  #endif
122
122
  }
123
123
 
124
- static void _msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v)
124
+ void msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v)
125
125
  {
126
126
  int ext_type;
127
- VALUE proc = msgpack_packer_ext_registry_lookup(&pk->ext_registry,
128
- rb_obj_class(v), &ext_type);
127
+
128
+ VALUE proc = msgpack_packer_ext_registry_lookup(&pk->ext_registry, v, &ext_type);
129
+
129
130
  if(proc != Qnil) {
130
131
  VALUE payload = rb_funcall(proc, s_call, 1, v);
131
132
  StringValue(payload);
@@ -169,7 +170,7 @@ void msgpack_packer_write_value(msgpack_packer_t* pk, VALUE v)
169
170
  msgpack_packer_write_float_value(pk, v);
170
171
  break;
171
172
  default:
172
- _msgpack_packer_write_other_value(pk, v);
173
+ msgpack_packer_write_other_value(pk, v);
173
174
  }
174
175
  }
175
176
 
data/ext/msgpack/packer.h CHANGED
@@ -32,6 +32,7 @@ struct msgpack_packer_t {
32
32
  msgpack_buffer_t buffer;
33
33
 
34
34
  bool compatibility_mode;
35
+ bool has_symbol_ext_type;
35
36
 
36
37
  ID to_msgpack_method;
37
38
  VALUE to_msgpack_arg;
@@ -448,7 +449,7 @@ static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE
448
449
  #endif
449
450
  }
450
451
 
451
- static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE v)
452
+ static inline void msgpack_packer_write_symbol_string_value(msgpack_packer_t* pk, VALUE v)
452
453
  {
453
454
  #ifdef HAVE_RB_SYM2STR
454
455
  /* rb_sym2str is added since MRI 2.2.0 */
@@ -462,6 +463,17 @@ static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE
462
463
  #endif
463
464
  }
464
465
 
466
+ void msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v);
467
+
468
+ static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE v)
469
+ {
470
+ if (pk->has_symbol_ext_type) {
471
+ msgpack_packer_write_other_value(pk, v);
472
+ } else {
473
+ msgpack_packer_write_symbol_string_value(pk, v);
474
+ }
475
+ }
476
+
465
477
  static inline void msgpack_packer_write_fixnum_value(msgpack_packer_t* pk, VALUE v)
466
478
  {
467
479
  #ifdef JRUBY
@@ -56,14 +56,12 @@ static void Packer_mark(msgpack_packer_t* pk)
56
56
 
57
57
  VALUE MessagePack_Packer_alloc(VALUE klass)
58
58
  {
59
- msgpack_packer_t* pk = ALLOC_N(msgpack_packer_t, 1);
59
+ msgpack_packer_t* pk = ZALLOC_N(msgpack_packer_t, 1);
60
60
  msgpack_packer_init(pk);
61
61
 
62
62
  VALUE self = Data_Wrap_Struct(klass, Packer_mark, Packer_free, pk);
63
63
 
64
64
  msgpack_packer_set_to_msgpack_method(pk, s_to_msgpack, self);
65
- msgpack_packer_ext_registry_init(&pk->ext_registry);
66
- pk->buffer_ref = MessagePack_Buffer_wrap(PACKER_BUFFER_(pk), self);
67
65
 
68
66
  return self;
69
67
  }
@@ -97,6 +95,9 @@ VALUE MessagePack_Packer_initialize(int argc, VALUE* argv, VALUE self)
97
95
 
98
96
  PACKER(self, pk);
99
97
 
98
+ msgpack_packer_ext_registry_init(&pk->ext_registry);
99
+ pk->buffer_ref = MessagePack_Buffer_wrap(PACKER_BUFFER_(pk), self);
100
+
100
101
  MessagePack_Buffer_set_options(PACKER_BUFFER_(pk), io, options);
101
102
 
102
103
  if(options != Qnil) {
@@ -135,6 +136,100 @@ static VALUE Packer_write_nil(VALUE self)
135
136
  return self;
136
137
  }
137
138
 
139
+ static VALUE Packer_write_true(VALUE self)
140
+ {
141
+ PACKER(self, pk);
142
+ msgpack_packer_write_true(pk);
143
+ return self;
144
+ }
145
+
146
+ static VALUE Packer_write_false(VALUE self)
147
+ {
148
+ PACKER(self, pk);
149
+ msgpack_packer_write_false(pk);
150
+ return self;
151
+ }
152
+
153
+ static VALUE Packer_write_float(VALUE self, VALUE obj)
154
+ {
155
+ PACKER(self, pk);
156
+ msgpack_packer_write_float_value(pk, obj);
157
+ return self;
158
+ }
159
+
160
+ static VALUE Packer_write_string(VALUE self, VALUE obj)
161
+ {
162
+ PACKER(self, pk);
163
+ Check_Type(obj, T_STRING);
164
+ msgpack_packer_write_string_value(pk, obj);
165
+ return self;
166
+ }
167
+
168
+ static VALUE Packer_write_bin(VALUE self, VALUE obj)
169
+ {
170
+ PACKER(self, pk);
171
+ Check_Type(obj, T_STRING);
172
+
173
+ VALUE enc = rb_enc_from_encoding(rb_ascii8bit_encoding());
174
+ obj = rb_str_encode(obj, enc, 0, Qnil);
175
+
176
+ msgpack_packer_write_string_value(pk, obj);
177
+ return self;
178
+ }
179
+
180
+ static VALUE Packer_write_array(VALUE self, VALUE obj)
181
+ {
182
+ PACKER(self, pk);
183
+ Check_Type(obj, T_ARRAY);
184
+ msgpack_packer_write_array_value(pk, obj);
185
+ return self;
186
+ }
187
+
188
+ static VALUE Packer_write_hash(VALUE self, VALUE obj)
189
+ {
190
+ PACKER(self, pk);
191
+ Check_Type(obj, T_HASH);
192
+ msgpack_packer_write_hash_value(pk, obj);
193
+ return self;
194
+ }
195
+
196
+ static VALUE Packer_write_symbol(VALUE self, VALUE obj)
197
+ {
198
+ PACKER(self, pk);
199
+ Check_Type(obj, T_SYMBOL);
200
+ msgpack_packer_write_symbol_value(pk, obj);
201
+ return self;
202
+ }
203
+
204
+ static VALUE Packer_write_int(VALUE self, VALUE obj)
205
+ {
206
+ PACKER(self, pk);
207
+
208
+ if (FIXNUM_P(obj)) {
209
+ msgpack_packer_write_fixnum_value(pk, obj);
210
+ } else {
211
+ Check_Type(obj, T_BIGNUM);
212
+ msgpack_packer_write_bignum_value(pk, obj);
213
+ }
214
+ return self;
215
+ }
216
+
217
+ static VALUE Packer_write_extension(VALUE self, VALUE obj)
218
+ {
219
+ PACKER(self, pk);
220
+ Check_Type(obj, T_STRUCT);
221
+
222
+ int ext_type = FIX2INT(RSTRUCT_GET(obj, 0));
223
+ if(ext_type < -128 || ext_type > 127) {
224
+ rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
225
+ }
226
+ VALUE payload = RSTRUCT_GET(obj, 1);
227
+ StringValue(payload);
228
+ msgpack_packer_write_ext(pk, ext_type, payload);
229
+
230
+ return self;
231
+ }
232
+
138
233
  static VALUE Packer_write_array_header(VALUE self, VALUE n)
139
234
  {
140
235
  PACKER(self, pk);
@@ -149,6 +244,13 @@ static VALUE Packer_write_map_header(VALUE self, VALUE n)
149
244
  return self;
150
245
  }
151
246
 
247
+ static VALUE Packer_write_bin_header(VALUE self, VALUE n)
248
+ {
249
+ PACKER(self, pk);
250
+ msgpack_packer_write_bin_header(pk, NUM2UINT(n));
251
+ return self;
252
+ }
253
+
152
254
  static VALUE Packer_write_float32(VALUE self, VALUE numeric)
153
255
  {
154
256
  if(!rb_obj_is_kind_of(numeric, rb_cNumeric)) {
@@ -163,7 +265,7 @@ static VALUE Packer_write_float32(VALUE self, VALUE numeric)
163
265
  static VALUE Packer_write_ext(VALUE self, VALUE type, VALUE data)
164
266
  {
165
267
  PACKER(self, pk);
166
- int ext_type = rb_num2int(type);
268
+ int ext_type = NUM2INT(type);
167
269
  if(ext_type < -128 || ext_type > 127) {
168
270
  rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
169
271
  }
@@ -249,7 +351,7 @@ static VALUE Packer_register_type(int argc, VALUE* argv, VALUE self)
249
351
  PACKER(self, pk);
250
352
 
251
353
  int ext_type;
252
- VALUE ext_class;
354
+ VALUE ext_module;
253
355
  VALUE proc;
254
356
  VALUE arg;
255
357
 
@@ -274,36 +376,31 @@ static VALUE Packer_register_type(int argc, VALUE* argv, VALUE self)
274
376
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..3)", argc);
275
377
  }
276
378
 
277
- ext_type = rb_num2int(argv[0]);
379
+ ext_type = NUM2INT(argv[0]);
278
380
  if(ext_type < -128 || ext_type > 127) {
279
381
  rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
280
382
  }
281
383
 
282
- ext_class = argv[1];
283
- if(rb_type(ext_class) != T_CLASS) {
284
- rb_raise(rb_eArgError, "expected Class but found %s.", rb_obj_classname(ext_class));
384
+ ext_module = argv[1];
385
+ if(rb_type(ext_module) != T_MODULE && rb_type(ext_module) != T_CLASS) {
386
+ rb_raise(rb_eArgError, "expected Module/Class but found %s.", rb_obj_classname(ext_module));
285
387
  }
286
388
 
287
- msgpack_packer_ext_registry_put(&pk->ext_registry, ext_class, ext_type, proc, arg);
389
+ msgpack_packer_ext_registry_put(&pk->ext_registry, ext_module, ext_type, proc, arg);
390
+
391
+ if (ext_module == rb_cSymbol) {
392
+ pk->has_symbol_ext_type = true;
393
+ }
288
394
 
289
395
  return Qnil;
290
396
  }
291
397
 
292
- VALUE MessagePack_pack(int argc, VALUE* argv)
398
+ VALUE Packer_full_pack(VALUE self)
293
399
  {
294
- VALUE v;
295
-
296
- if (argc < 0 || argc > 3) {
297
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", argc);
298
- }
299
- v = argv[0];
400
+ VALUE retval;
300
401
 
301
- VALUE self = MessagePack_Factory_packer(argc - 1, argv + 1, cMessagePack_DefaultFactory);
302
402
  PACKER(self, pk);
303
403
 
304
- msgpack_packer_write_value(pk, v);
305
-
306
- VALUE retval;
307
404
  if(msgpack_buffer_has_io(PACKER_BUFFER_(pk))) {
308
405
  msgpack_buffer_flush(PACKER_BUFFER_(pk));
309
406
  retval = Qnil;
@@ -313,27 +410,9 @@ VALUE MessagePack_pack(int argc, VALUE* argv)
313
410
 
314
411
  msgpack_buffer_clear(PACKER_BUFFER_(pk)); /* to free rmem before GC */
315
412
 
316
- #ifdef RB_GC_GUARD
317
- /* This prevents compilers from optimizing out the `self` variable
318
- * from stack. Otherwise GC free()s it. */
319
- RB_GC_GUARD(self);
320
- #endif
321
-
322
413
  return retval;
323
414
  }
324
415
 
325
- static VALUE MessagePack_dump_module_method(int argc, VALUE* argv, VALUE mod)
326
- {
327
- UNUSED(mod);
328
- return MessagePack_pack(argc, argv);
329
- }
330
-
331
- static VALUE MessagePack_pack_module_method(int argc, VALUE* argv, VALUE mod)
332
- {
333
- UNUSED(mod);
334
- return MessagePack_pack(argc, argv);
335
- }
336
-
337
416
  void MessagePack_Packer_module_init(VALUE mMessagePack)
338
417
  {
339
418
  s_to_msgpack = rb_intern("to_msgpack");
@@ -352,8 +431,19 @@ void MessagePack_Packer_module_init(VALUE mMessagePack)
352
431
  rb_define_method(cMessagePack_Packer, "write", Packer_write, 1);
353
432
  rb_define_alias(cMessagePack_Packer, "pack", "write");
354
433
  rb_define_method(cMessagePack_Packer, "write_nil", Packer_write_nil, 0);
434
+ rb_define_method(cMessagePack_Packer, "write_true", Packer_write_true, 0);
435
+ rb_define_method(cMessagePack_Packer, "write_false", Packer_write_false, 0);
436
+ rb_define_method(cMessagePack_Packer, "write_float", Packer_write_float, 1);
437
+ rb_define_method(cMessagePack_Packer, "write_string", Packer_write_string, 1);
438
+ rb_define_method(cMessagePack_Packer, "write_bin", Packer_write_bin, 1);
439
+ rb_define_method(cMessagePack_Packer, "write_array", Packer_write_array, 1);
440
+ rb_define_method(cMessagePack_Packer, "write_hash", Packer_write_hash, 1);
441
+ rb_define_method(cMessagePack_Packer, "write_symbol", Packer_write_symbol, 1);
442
+ rb_define_method(cMessagePack_Packer, "write_int", Packer_write_int, 1);
443
+ rb_define_method(cMessagePack_Packer, "write_extension", Packer_write_extension, 1);
355
444
  rb_define_method(cMessagePack_Packer, "write_array_header", Packer_write_array_header, 1);
356
445
  rb_define_method(cMessagePack_Packer, "write_map_header", Packer_write_map_header, 1);
446
+ rb_define_method(cMessagePack_Packer, "write_bin_header", Packer_write_bin_header, 1);
357
447
  rb_define_method(cMessagePack_Packer, "write_ext", Packer_write_ext, 2);
358
448
  rb_define_method(cMessagePack_Packer, "write_float32", Packer_write_float32, 1);
359
449
  rb_define_method(cMessagePack_Packer, "flush", Packer_flush, 0);
@@ -376,8 +466,5 @@ void MessagePack_Packer_module_init(VALUE mMessagePack)
376
466
  //rb_gc_register_address(&s_packer_value);
377
467
  //Data_Get_Struct(s_packer_value, msgpack_packer_t, s_packer);
378
468
 
379
- /* MessagePack.pack(x) */
380
- rb_define_module_function(mMessagePack, "pack", MessagePack_pack_module_method, -1);
381
- rb_define_module_function(mMessagePack, "dump", MessagePack_dump_module_method, -1);
469
+ rb_define_method(cMessagePack_Packer, "full_pack", Packer_full_pack, 0);
382
470
  }
383
-