msgpack 0.7.4 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,144 +0,0 @@
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
- #include "extension_value_class.h"
23
-
24
- static inline VALUE delegete_to_pack(int argc, VALUE* argv, VALUE self)
25
- {
26
- if(argc == 0) {
27
- return MessagePack_pack(1, &self);
28
- } else if(argc == 1) {
29
- /* write to io */
30
- VALUE argv2[2];
31
- argv2[0] = self;
32
- argv2[1] = argv[0];
33
- return MessagePack_pack(2, argv2);
34
- } else {
35
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..1)", argc);
36
- }
37
- }
38
-
39
- #define ENSURE_PACKER(argc, argv, packer, pk) \
40
- if(argc != 1 || rb_class_of(argv[0]) != cMessagePack_Packer) { \
41
- return delegete_to_pack(argc, argv, self); \
42
- } \
43
- VALUE packer = argv[0]; \
44
- msgpack_packer_t *pk; \
45
- Data_Get_Struct(packer, msgpack_packer_t, pk);
46
-
47
- static VALUE NilClass_to_msgpack(int argc, VALUE* argv, VALUE self)
48
- {
49
- ENSURE_PACKER(argc, argv, packer, pk);
50
- msgpack_packer_write_nil(pk);
51
- return packer;
52
- }
53
-
54
- static VALUE TrueClass_to_msgpack(int argc, VALUE* argv, VALUE self)
55
- {
56
- ENSURE_PACKER(argc, argv, packer, pk);
57
- msgpack_packer_write_true(pk);
58
- return packer;
59
- }
60
-
61
- static VALUE FalseClass_to_msgpack(int argc, VALUE* argv, VALUE self)
62
- {
63
- ENSURE_PACKER(argc, argv, packer, pk);
64
- msgpack_packer_write_false(pk);
65
- return packer;
66
- }
67
-
68
- static VALUE Fixnum_to_msgpack(int argc, VALUE* argv, VALUE self)
69
- {
70
- ENSURE_PACKER(argc, argv, packer, pk);
71
- msgpack_packer_write_fixnum_value(pk, self);
72
- return packer;
73
- }
74
-
75
- static VALUE Bignum_to_msgpack(int argc, VALUE* argv, VALUE self)
76
- {
77
- ENSURE_PACKER(argc, argv, packer, pk);
78
- msgpack_packer_write_bignum_value(pk, self);
79
- return packer;
80
- }
81
-
82
- static VALUE Float_to_msgpack(int argc, VALUE* argv, VALUE self)
83
- {
84
- ENSURE_PACKER(argc, argv, packer, pk);
85
- msgpack_packer_write_float_value(pk, self);
86
- return packer;
87
- }
88
-
89
- static VALUE String_to_msgpack(int argc, VALUE* argv, VALUE self)
90
- {
91
- ENSURE_PACKER(argc, argv, packer, pk);
92
- msgpack_packer_write_string_value(pk, self);
93
- return packer;
94
- }
95
-
96
- static VALUE Array_to_msgpack(int argc, VALUE* argv, VALUE self)
97
- {
98
- ENSURE_PACKER(argc, argv, packer, pk);
99
- msgpack_packer_write_array_value(pk, self);
100
- return packer;
101
- }
102
-
103
- static VALUE Hash_to_msgpack(int argc, VALUE* argv, VALUE self)
104
- {
105
- ENSURE_PACKER(argc, argv, packer, pk);
106
- msgpack_packer_write_hash_value(pk, self);
107
- return packer;
108
- }
109
-
110
- static VALUE Symbol_to_msgpack(int argc, VALUE* argv, VALUE self)
111
- {
112
- ENSURE_PACKER(argc, argv, packer, pk);
113
- msgpack_packer_write_symbol_value(pk, self);
114
- return packer;
115
- }
116
-
117
- static VALUE ExtensionValue_to_msgpack(int argc, VALUE* argv, VALUE self)
118
- {
119
- ENSURE_PACKER(argc, argv, packer, pk);
120
- int ext_type = FIX2INT(RSTRUCT_GET(self, 0));
121
- if(ext_type < -128 || ext_type > 127) {
122
- rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
123
- }
124
- VALUE payload = RSTRUCT_GET(self, 1);
125
- StringValue(payload);
126
- msgpack_packer_write_ext(pk, ext_type, payload);
127
- return packer;
128
- }
129
-
130
- void MessagePack_core_ext_module_init()
131
- {
132
- rb_define_method(rb_cNilClass, "to_msgpack", NilClass_to_msgpack, -1);
133
- rb_define_method(rb_cTrueClass, "to_msgpack", TrueClass_to_msgpack, -1);
134
- rb_define_method(rb_cFalseClass, "to_msgpack", FalseClass_to_msgpack, -1);
135
- rb_define_method(rb_cFixnum, "to_msgpack", Fixnum_to_msgpack, -1);
136
- rb_define_method(rb_cBignum, "to_msgpack", Bignum_to_msgpack, -1);
137
- rb_define_method(rb_cFloat, "to_msgpack", Float_to_msgpack, -1);
138
- rb_define_method(rb_cString, "to_msgpack", String_to_msgpack, -1);
139
- rb_define_method(rb_cArray, "to_msgpack", Array_to_msgpack, -1);
140
- rb_define_method(rb_cHash, "to_msgpack", Hash_to_msgpack, -1);
141
- rb_define_method(rb_cSymbol, "to_msgpack", Symbol_to_msgpack, -1);
142
- rb_define_method(cMessagePack_ExtensionValue, "to_msgpack", ExtensionValue_to_msgpack, -1);
143
- }
144
-
@@ -1,26 +0,0 @@
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
-