msgpack 0.6.0-x86-mswin32-60

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 (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +26 -0
  4. data/ChangeLog +129 -0
  5. data/Dockerfile +62 -0
  6. data/LICENSE +177 -0
  7. data/README.rdoc +141 -0
  8. data/Rakefile +68 -0
  9. data/bench/pack.rb +23 -0
  10. data/bench/pack_log.rb +33 -0
  11. data/bench/pack_log_long.rb +65 -0
  12. data/bench/run.sh +14 -0
  13. data/bench/run_long.sh +35 -0
  14. data/bench/unpack.rb +21 -0
  15. data/bench/unpack_log.rb +34 -0
  16. data/bench/unpack_log_long.rb +67 -0
  17. data/doclib/msgpack.rb +77 -0
  18. data/doclib/msgpack/buffer.rb +193 -0
  19. data/doclib/msgpack/core_ext.rb +101 -0
  20. data/doclib/msgpack/error.rb +14 -0
  21. data/doclib/msgpack/packer.rb +134 -0
  22. data/doclib/msgpack/unpacker.rb +146 -0
  23. data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
  24. data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
  25. data/ext/java/org/msgpack/jruby/Encoder.java +308 -0
  26. data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
  27. data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +107 -0
  28. data/ext/java/org/msgpack/jruby/Packer.java +78 -0
  29. data/ext/java/org/msgpack/jruby/Types.java +37 -0
  30. data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
  31. data/ext/msgpack/buffer.c +695 -0
  32. data/ext/msgpack/buffer.h +447 -0
  33. data/ext/msgpack/buffer_class.c +507 -0
  34. data/ext/msgpack/buffer_class.h +32 -0
  35. data/ext/msgpack/compat.h +114 -0
  36. data/ext/msgpack/core_ext.c +129 -0
  37. data/ext/msgpack/core_ext.h +26 -0
  38. data/ext/msgpack/extconf.rb +30 -0
  39. data/ext/msgpack/packer.c +168 -0
  40. data/ext/msgpack/packer.h +441 -0
  41. data/ext/msgpack/packer_class.c +302 -0
  42. data/ext/msgpack/packer_class.h +30 -0
  43. data/ext/msgpack/rbinit.c +33 -0
  44. data/ext/msgpack/rmem.c +94 -0
  45. data/ext/msgpack/rmem.h +109 -0
  46. data/ext/msgpack/sysdep.h +115 -0
  47. data/ext/msgpack/sysdep_endian.h +50 -0
  48. data/ext/msgpack/sysdep_types.h +46 -0
  49. data/ext/msgpack/unpacker.c +771 -0
  50. data/ext/msgpack/unpacker.h +122 -0
  51. data/ext/msgpack/unpacker_class.c +405 -0
  52. data/ext/msgpack/unpacker_class.h +32 -0
  53. data/lib/msgpack.rb +13 -0
  54. data/lib/msgpack/version.rb +3 -0
  55. data/msgpack.gemspec +31 -0
  56. data/msgpack.org.md +46 -0
  57. data/spec/cases.json +1 -0
  58. data/spec/cases.msg +0 -0
  59. data/spec/cases_compact.msg +0 -0
  60. data/spec/cases_spec.rb +39 -0
  61. data/spec/cruby/buffer_io_spec.rb +256 -0
  62. data/spec/cruby/buffer_packer.rb +29 -0
  63. data/spec/cruby/buffer_spec.rb +572 -0
  64. data/spec/cruby/buffer_unpacker.rb +19 -0
  65. data/spec/cruby/packer_spec.rb +120 -0
  66. data/spec/cruby/unpacker_spec.rb +305 -0
  67. data/spec/format_spec.rb +282 -0
  68. data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
  69. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
  70. data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
  71. data/spec/jruby/msgpack_spec.rb +142 -0
  72. data/spec/pack_spec.rb +67 -0
  73. data/spec/random_compat.rb +24 -0
  74. data/spec/spec_helper.rb +27 -0
  75. data/spec/unpack_spec.rb +60 -0
  76. metadata +208 -0
@@ -0,0 +1,32 @@
1
+ /*
2
+ * MessagePack for Ruby
3
+ *
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ #ifndef MSGPACK_RUBY_BUFFER_CLASS_H__
19
+ #define MSGPACK_RUBY_BUFFER_CLASS_H__
20
+
21
+ #include "buffer.h"
22
+
23
+ extern VALUE cMessagePack_Buffer;
24
+
25
+ void MessagePack_Buffer_module_init(VALUE mMessagePack);
26
+
27
+ VALUE MessagePack_Buffer_wrap(msgpack_buffer_t* b, VALUE owner);
28
+
29
+ void MessagePack_Buffer_initialize(msgpack_buffer_t* b, VALUE io, VALUE options);
30
+
31
+ #endif
32
+
@@ -0,0 +1,114 @@
1
+ /*
2
+ * MessagePack for Ruby
3
+ *
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ #ifndef MSGPACK_RUBY_COMPAT_H__
19
+ #define MSGPACK_RUBY_COMPAT_H__
20
+
21
+ #include <stdbool.h>
22
+ #include "ruby.h"
23
+
24
+ #if defined(HAVE_RUBY_ST_H)
25
+ # include "ruby/st.h" /* ruby hash on Ruby 1.9 */
26
+ #elif defined(HAVE_ST_H)
27
+ # include "st.h" /* ruby hash on Ruby 1.8 */
28
+ #endif
29
+
30
+
31
+ /*
32
+ * COMPAT_HAVE_ENCODING
33
+ */
34
+ #ifdef HAVE_RUBY_ENCODING_H
35
+ # include "ruby/encoding.h"
36
+ # define COMPAT_HAVE_ENCODING
37
+ #endif
38
+
39
+ #if defined(__MACRUBY__) /* MacRuby */
40
+ # undef COMPAT_HAVE_ENCODING
41
+ #endif
42
+
43
+
44
+ /*
45
+ * define STR_DUP_LIKELY_DOES_COPY
46
+ * check rb_str_dup actually copies the string or not
47
+ */
48
+ #if defined(RUBY_VM) && defined(FL_ALL) && defined(FL_USER1) && defined(FL_USER3) /* MRI 1.9 */
49
+ # define STR_DUP_LIKELY_DOES_COPY(str) FL_ALL(str, FL_USER1|FL_USER3) /* same as STR_ASSOC_P(str) */
50
+
51
+ #elif defined(FL_TEST) && defined(ELTS_SHARED) /* MRI 1.8 */
52
+ # define STR_DUP_LIKELY_DOES_COPY(str) (!FL_TEST(str, ELTS_SHARED))
53
+
54
+ //#elif defined(RUBINIUS) || defined(JRUBY) /* Rubinius and JRuby */
55
+ #else
56
+ # define STR_DUP_LIKELY_DOES_COPY(str) (1)
57
+
58
+ #endif
59
+
60
+
61
+ /*
62
+ * SIZET2NUM
63
+ */
64
+ #ifndef SIZET2NUM /* MRI 1.8 */
65
+ # define SIZET2NUM(v) ULL2NUM(v)
66
+ #endif
67
+
68
+
69
+ /*
70
+ * rb_errinfo()
71
+ */
72
+ #if defined(RUBY_VM) /* MRI 1.9 */
73
+ # define COMPAT_RERAISE rb_exc_raise(rb_errinfo())
74
+
75
+ #elif defined(JRUBY) /* JRuby */
76
+ # define COMPAT_RERAISE rb_exc_raise(rb_gv_get("$!"))
77
+
78
+ #else /* MRI 1.8 and Rubinius */
79
+ # define COMPAT_RERAISE rb_exc_raise(ruby_errinfo)
80
+ #endif
81
+
82
+
83
+ /*
84
+ * RBIGNUM_POSITIVE_P
85
+ */
86
+ #ifndef RBIGNUM_POSITIVE_P
87
+ # if defined(RUBINIUS) /* Rubinius <= v1.2.3 */
88
+ # define RBIGNUM_POSITIVE_P(b) (rb_funcall(b, rb_intern(">="), 1, INT2FIX(0)) == Qtrue)
89
+
90
+ # elif defined(JRUBY) /* JRuby */
91
+ # define RBIGNUM_POSITIVE_P(b) (rb_funcall(b, rb_intern(">="), 1, INT2FIX(0)) == Qtrue)
92
+ # define rb_big2ull(b) rb_num2ull(b)
93
+ /*#define rb_big2ll(b) rb_num2ll(b)*/
94
+
95
+ # else /* MRI 1.8 */
96
+ # define RBIGNUM_POSITIVE_P(b) (RBIGNUM(b)->sign)
97
+ # endif
98
+ #endif
99
+
100
+
101
+ /*
102
+ * RSTRING_PTR, RSTRING_LEN
103
+ */
104
+ #ifndef RSTRING_PTR /* MRI 1.8.5 */
105
+ # define RSTRING_PTR(s) (RSTRING(s)->ptr)
106
+ #endif
107
+
108
+ #ifndef RSTRING_LEN /* MRI 1.8.5 */
109
+ # define RSTRING_LEN(s) (RSTRING(s)->len)
110
+ #endif
111
+
112
+
113
+ #endif
114
+
@@ -0,0 +1,129 @@
1
+ /*
2
+ * MessagePack for Ruby
3
+ *
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "core_ext.h"
20
+ #include "packer.h"
21
+ #include "packer_class.h"
22
+
23
+ static inline VALUE delegete_to_pack(int argc, VALUE* argv, VALUE self)
24
+ {
25
+ if(argc == 0) {
26
+ return MessagePack_pack(1, &self);
27
+ } else if(argc == 1) {
28
+ /* write to io */
29
+ VALUE argv2[2];
30
+ argv2[0] = self;
31
+ argv2[1] = argv[0];
32
+ return MessagePack_pack(2, argv2);
33
+ } else {
34
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..1)", argc);
35
+ }
36
+ }
37
+
38
+ #define ENSURE_PACKER(argc, argv, packer, pk) \
39
+ if(argc != 1 || rb_class_of(argv[0]) != cMessagePack_Packer) { \
40
+ return delegete_to_pack(argc, argv, self); \
41
+ } \
42
+ VALUE packer = argv[0]; \
43
+ msgpack_packer_t *pk; \
44
+ Data_Get_Struct(packer, msgpack_packer_t, pk);
45
+
46
+ static VALUE NilClass_to_msgpack(int argc, VALUE* argv, VALUE self)
47
+ {
48
+ ENSURE_PACKER(argc, argv, packer, pk);
49
+ msgpack_packer_write_nil(pk);
50
+ return packer;
51
+ }
52
+
53
+ static VALUE TrueClass_to_msgpack(int argc, VALUE* argv, VALUE self)
54
+ {
55
+ ENSURE_PACKER(argc, argv, packer, pk);
56
+ msgpack_packer_write_true(pk);
57
+ return packer;
58
+ }
59
+
60
+ static VALUE FalseClass_to_msgpack(int argc, VALUE* argv, VALUE self)
61
+ {
62
+ ENSURE_PACKER(argc, argv, packer, pk);
63
+ msgpack_packer_write_false(pk);
64
+ return packer;
65
+ }
66
+
67
+ static VALUE Fixnum_to_msgpack(int argc, VALUE* argv, VALUE self)
68
+ {
69
+ ENSURE_PACKER(argc, argv, packer, pk);
70
+ msgpack_packer_write_fixnum_value(pk, self);
71
+ return packer;
72
+ }
73
+
74
+ static VALUE Bignum_to_msgpack(int argc, VALUE* argv, VALUE self)
75
+ {
76
+ ENSURE_PACKER(argc, argv, packer, pk);
77
+ msgpack_packer_write_bignum_value(pk, self);
78
+ return packer;
79
+ }
80
+
81
+ static VALUE Float_to_msgpack(int argc, VALUE* argv, VALUE self)
82
+ {
83
+ ENSURE_PACKER(argc, argv, packer, pk);
84
+ msgpack_packer_write_float_value(pk, self);
85
+ return packer;
86
+ }
87
+
88
+ static VALUE String_to_msgpack(int argc, VALUE* argv, VALUE self)
89
+ {
90
+ ENSURE_PACKER(argc, argv, packer, pk);
91
+ msgpack_packer_write_string_value(pk, self);
92
+ return packer;
93
+ }
94
+
95
+ static VALUE Array_to_msgpack(int argc, VALUE* argv, VALUE self)
96
+ {
97
+ ENSURE_PACKER(argc, argv, packer, pk);
98
+ msgpack_packer_write_array_value(pk, self);
99
+ return packer;
100
+ }
101
+
102
+ static VALUE Hash_to_msgpack(int argc, VALUE* argv, VALUE self)
103
+ {
104
+ ENSURE_PACKER(argc, argv, packer, pk);
105
+ msgpack_packer_write_hash_value(pk, self);
106
+ return packer;
107
+ }
108
+
109
+ static VALUE Symbol_to_msgpack(int argc, VALUE* argv, VALUE self)
110
+ {
111
+ ENSURE_PACKER(argc, argv, packer, pk);
112
+ msgpack_packer_write_symbol_value(pk, self);
113
+ return packer;
114
+ }
115
+
116
+ void MessagePack_core_ext_module_init()
117
+ {
118
+ rb_define_method(rb_cNilClass, "to_msgpack", NilClass_to_msgpack, -1);
119
+ rb_define_method(rb_cTrueClass, "to_msgpack", TrueClass_to_msgpack, -1);
120
+ rb_define_method(rb_cFalseClass, "to_msgpack", FalseClass_to_msgpack, -1);
121
+ rb_define_method(rb_cFixnum, "to_msgpack", Fixnum_to_msgpack, -1);
122
+ rb_define_method(rb_cBignum, "to_msgpack", Bignum_to_msgpack, -1);
123
+ rb_define_method(rb_cFloat, "to_msgpack", Float_to_msgpack, -1);
124
+ rb_define_method(rb_cString, "to_msgpack", String_to_msgpack, -1);
125
+ rb_define_method(rb_cArray, "to_msgpack", Array_to_msgpack, -1);
126
+ rb_define_method(rb_cHash, "to_msgpack", Hash_to_msgpack, -1);
127
+ rb_define_method(rb_cSymbol, "to_msgpack", Symbol_to_msgpack, -1);
128
+ }
129
+
@@ -0,0 +1,26 @@
1
+ /*
2
+ * MessagePack for Ruby
3
+ *
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ #ifndef MSGPACK_RUBY_CORE_EXT_H__
19
+ #define MSGPACK_RUBY_CORE_EXT_H__
20
+
21
+ #include "compat.h"
22
+
23
+ void MessagePack_core_ext_module_init();
24
+
25
+ #endif
26
+
@@ -0,0 +1,30 @@
1
+ require 'mkmf'
2
+
3
+ have_header("ruby/st.h")
4
+ have_header("st.h")
5
+ have_func("rb_str_replace", ["ruby.h"])
6
+ have_func("rb_intern_str", ["ruby.h"])
7
+ have_func("rb_sym2str", ["ruby.h"])
8
+ have_func("rb_str_intern", ["ruby.h"])
9
+
10
+ unless RUBY_PLATFORM.include? 'mswin'
11
+ $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
12
+ end
13
+ #$CFLAGS << %[ -DDISABLE_RMEM]
14
+ #$CFLAGS << %[ -DDISABLE_RMEM_REUSE_INTERNAL_FRAGMENT]
15
+ #$CFLAGS << %[ -DDISABLE_BUFFER_READ_REFERENCE_OPTIMIZE]
16
+ #$CFLAGS << %[ -DDISABLE_BUFFER_READ_TO_S_OPTIMIZE]
17
+
18
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
19
+ # msgpack-ruby doesn't modify data came from RSTRING_PTR(str)
20
+ $CFLAGS << %[ -DRSTRING_NOT_MODIFIED]
21
+ # Rubinius C extensions don't grab GVL while rmem is not thread safe
22
+ $CFLAGS << %[ -DDISABLE_RMEM]
23
+ end
24
+
25
+ if warnflags = CONFIG['warnflags']
26
+ warnflags.slice!(/ -Wdeclaration-after-statement/)
27
+ end
28
+
29
+ create_makefile('msgpack/msgpack')
30
+
@@ -0,0 +1,168 @@
1
+ /*
2
+ * MessagePack for Ruby
3
+ *
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "packer.h"
20
+
21
+ #ifdef RUBINIUS
22
+ static ID s_to_iter;
23
+ static ID s_next;
24
+ static ID s_key;
25
+ static ID s_value;
26
+ #endif
27
+
28
+ void msgpack_packer_static_init()
29
+ {
30
+ #ifdef RUBINIUS
31
+ s_to_iter = rb_intern("to_iter");
32
+ s_next = rb_intern("next");
33
+ s_key = rb_intern("key");
34
+ s_value = rb_intern("value");
35
+ #endif
36
+ }
37
+
38
+ void msgpack_packer_static_destroy()
39
+ { }
40
+
41
+ void msgpack_packer_init(msgpack_packer_t* pk)
42
+ {
43
+ memset(pk, 0, sizeof(msgpack_packer_t));
44
+
45
+ msgpack_buffer_init(PACKER_BUFFER_(pk));
46
+
47
+ pk->io = Qnil;
48
+ }
49
+
50
+ void msgpack_packer_destroy(msgpack_packer_t* pk)
51
+ {
52
+ msgpack_buffer_destroy(PACKER_BUFFER_(pk));
53
+ }
54
+
55
+ void msgpack_packer_mark(msgpack_packer_t* pk)
56
+ {
57
+ rb_gc_mark(pk->io);
58
+
59
+ /* See MessagePack_Buffer_wrap */
60
+ /* msgpack_buffer_mark(PACKER_BUFFER_(pk)); */
61
+ rb_gc_mark(pk->buffer_ref);
62
+ }
63
+
64
+ void msgpack_packer_reset(msgpack_packer_t* pk)
65
+ {
66
+ msgpack_buffer_clear(PACKER_BUFFER_(pk));
67
+
68
+ pk->io = Qnil;
69
+ pk->io_write_all_method = 0;
70
+ pk->buffer_ref = Qnil;
71
+ }
72
+
73
+
74
+ void msgpack_packer_write_array_value(msgpack_packer_t* pk, VALUE v)
75
+ {
76
+ /* actual return type of RARRAY_LEN is long */
77
+ unsigned long len = RARRAY_LEN(v);
78
+ if(len > 0xffffffffUL) {
79
+ rb_raise(rb_eArgError, "size of array is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
80
+ }
81
+ unsigned int len32 = (unsigned int)len;
82
+ msgpack_packer_write_array_header(pk, len32);
83
+
84
+ unsigned int i;
85
+ for(i=0; i < len32; ++i) {
86
+ VALUE e = rb_ary_entry(v, i);
87
+ msgpack_packer_write_value(pk, e);
88
+ }
89
+ }
90
+
91
+ static int write_hash_foreach(VALUE key, VALUE value, VALUE pk_value)
92
+ {
93
+ if (key == Qundef) {
94
+ return ST_CONTINUE;
95
+ }
96
+ msgpack_packer_t* pk = (msgpack_packer_t*) pk_value;
97
+ msgpack_packer_write_value(pk, key);
98
+ msgpack_packer_write_value(pk, value);
99
+ return ST_CONTINUE;
100
+ }
101
+
102
+ void msgpack_packer_write_hash_value(msgpack_packer_t* pk, VALUE v)
103
+ {
104
+ /* actual return type of RHASH_SIZE is long (if SIZEOF_LONG == SIZEOF_VOIDP
105
+ * or long long (if SIZEOF_LONG_LONG == SIZEOF_VOIDP. See st.h. */
106
+ unsigned long len = RHASH_SIZE(v);
107
+ if(len > 0xffffffffUL) {
108
+ rb_raise(rb_eArgError, "size of array is too long to pack: %ld bytes should be <= %lu", len, 0xffffffffUL);
109
+ }
110
+ unsigned int len32 = (unsigned int)len;
111
+ msgpack_packer_write_map_header(pk, len32);
112
+
113
+ #ifdef RUBINIUS
114
+ VALUE iter = rb_funcall(v, s_to_iter, 0);
115
+ VALUE entry = Qnil;
116
+ while(RTEST(entry = rb_funcall(iter, s_next, 1, entry))) {
117
+ VALUE key = rb_funcall(entry, s_key, 0);
118
+ VALUE val = rb_funcall(entry, s_value, 0);
119
+ write_hash_foreach(key, val, (VALUE) pk);
120
+ }
121
+ #else
122
+ rb_hash_foreach(v, write_hash_foreach, (VALUE) pk);
123
+ #endif
124
+ }
125
+
126
+ static void _msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v)
127
+ {
128
+ rb_funcall(v, pk->to_msgpack_method, 1, pk->to_msgpack_arg);
129
+ }
130
+
131
+ void msgpack_packer_write_value(msgpack_packer_t* pk, VALUE v)
132
+ {
133
+ switch(rb_type(v)) {
134
+ case T_NIL:
135
+ msgpack_packer_write_nil(pk);
136
+ break;
137
+ case T_TRUE:
138
+ msgpack_packer_write_true(pk);
139
+ break;
140
+ case T_FALSE:
141
+ msgpack_packer_write_false(pk);
142
+ break;
143
+ case T_FIXNUM:
144
+ msgpack_packer_write_fixnum_value(pk, v);
145
+ break;
146
+ case T_SYMBOL:
147
+ msgpack_packer_write_symbol_value(pk, v);
148
+ break;
149
+ case T_STRING:
150
+ msgpack_packer_write_string_value(pk, v);
151
+ break;
152
+ case T_ARRAY:
153
+ msgpack_packer_write_array_value(pk, v);
154
+ break;
155
+ case T_HASH:
156
+ msgpack_packer_write_hash_value(pk, v);
157
+ break;
158
+ case T_BIGNUM:
159
+ msgpack_packer_write_bignum_value(pk, v);
160
+ break;
161
+ case T_FLOAT:
162
+ msgpack_packer_write_float_value(pk, v);
163
+ break;
164
+ default:
165
+ _msgpack_packer_write_other_value(pk, v);
166
+ }
167
+ }
168
+