msgpack 1.6.0 → 1.7.2

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +25 -0
  3. data/README.md +27 -0
  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 +16 -17
  11. data/ext/msgpack/buffer.h +2 -8
  12. data/ext/msgpack/buffer_class.c +76 -5
  13. data/ext/msgpack/buffer_class.h +1 -0
  14. data/ext/msgpack/extconf.rb +18 -26
  15. data/ext/msgpack/factory_class.c +27 -61
  16. data/ext/msgpack/packer.c +13 -14
  17. data/ext/msgpack/packer.h +0 -4
  18. data/ext/msgpack/packer_class.c +19 -54
  19. data/ext/msgpack/packer_ext_registry.c +31 -28
  20. data/ext/msgpack/packer_ext_registry.h +10 -14
  21. data/ext/msgpack/rbinit.c +1 -1
  22. data/ext/msgpack/rmem.c +3 -4
  23. data/ext/msgpack/unpacker.c +12 -25
  24. data/ext/msgpack/unpacker.h +0 -4
  25. data/ext/msgpack/unpacker_class.c +14 -49
  26. data/ext/msgpack/unpacker_ext_registry.c +4 -16
  27. data/ext/msgpack/unpacker_ext_registry.h +3 -7
  28. data/lib/msgpack/buffer.rb +9 -0
  29. data/lib/msgpack/factory.rb +90 -63
  30. data/lib/msgpack/packer.rb +10 -1
  31. data/lib/msgpack/unpacker.rb +14 -1
  32. data/lib/msgpack/version.rb +1 -1
  33. data/lib/msgpack.rb +1 -0
  34. data/msgpack.gemspec +6 -3
  35. metadata +19 -48
  36. data/.github/workflows/ci.yaml +0 -57
  37. data/.gitignore +0 -23
  38. data/.rubocop.yml +0 -36
  39. data/Gemfile +0 -9
  40. data/Rakefile +0 -70
  41. data/appveyor.yml +0 -18
  42. data/bench/bench.rb +0 -78
  43. data/bin/console +0 -8
  44. data/doclib/msgpack/buffer.rb +0 -193
  45. data/doclib/msgpack/core_ext.rb +0 -101
  46. data/doclib/msgpack/error.rb +0 -19
  47. data/doclib/msgpack/extension_value.rb +0 -9
  48. data/doclib/msgpack/factory.rb +0 -145
  49. data/doclib/msgpack/packer.rb +0 -209
  50. data/doclib/msgpack/time.rb +0 -22
  51. data/doclib/msgpack/timestamp.rb +0 -44
  52. data/doclib/msgpack/unpacker.rb +0 -183
  53. data/doclib/msgpack.rb +0 -87
  54. data/msgpack.org.md +0 -46
  55. data/spec/bigint_spec.rb +0 -26
  56. data/spec/cases.json +0 -1
  57. data/spec/cases.msg +0 -0
  58. data/spec/cases_compact.msg +0 -0
  59. data/spec/cases_spec.rb +0 -39
  60. data/spec/cruby/buffer_io_spec.rb +0 -255
  61. data/spec/cruby/buffer_packer.rb +0 -29
  62. data/spec/cruby/buffer_spec.rb +0 -592
  63. data/spec/cruby/buffer_unpacker.rb +0 -19
  64. data/spec/cruby/unpacker_spec.rb +0 -70
  65. data/spec/ext_value_spec.rb +0 -99
  66. data/spec/exttypes.rb +0 -51
  67. data/spec/factory_spec.rb +0 -706
  68. data/spec/format_spec.rb +0 -301
  69. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  70. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  71. data/spec/jruby/unpacker_spec.rb +0 -186
  72. data/spec/msgpack_spec.rb +0 -214
  73. data/spec/pack_spec.rb +0 -61
  74. data/spec/packer_spec.rb +0 -575
  75. data/spec/random_compat.rb +0 -24
  76. data/spec/spec_helper.rb +0 -72
  77. data/spec/timestamp_spec.rb +0 -159
  78. data/spec/unpack_spec.rb +0 -57
  79. data/spec/unpacker_spec.rb +0 -869
@@ -1,101 +0,0 @@
1
-
2
- class NilClass
3
- #
4
- # Same as MessagePack.to_msgpack(self[, packer]).
5
- #
6
- # @return [String] serialized data
7
- #
8
- def to_msgpack(packer=nil)
9
- end
10
- end
11
-
12
- class TrueClass
13
- #
14
- # Same as MessagePack.to_msgpack(self[, packer]).
15
- #
16
- # @return [String] serialized data
17
- #
18
- def to_msgpack(packer=nil)
19
- end
20
- end
21
-
22
- class FalseClass
23
- #
24
- # Same as MessagePack.to_msgpack(self[, packer]).
25
- #
26
- # @return [String] serialized data
27
- #
28
- def to_msgpack(packer=nil)
29
- end
30
- end
31
-
32
- class Fixnum < Integer
33
- #
34
- # Same as MessagePack.to_msgpack(self[, packer]).
35
- #
36
- # @return [String] serialized data
37
- #
38
- def to_msgpack(packer=nil)
39
- end
40
- end
41
-
42
- class Bignum < Integer
43
- #
44
- # Same as MessagePack.to_msgpack(self[, packer]).
45
- #
46
- # @return [String] serialized data
47
- #
48
- def to_msgpack(packer=nil)
49
- end
50
- end
51
-
52
- class Float < Numeric
53
- #
54
- # Same as MessagePack.to_msgpack(self[, packer]).
55
- #
56
- # @return [String] serialized data
57
- #
58
- def to_msgpack(packer=nil)
59
- end
60
- end
61
-
62
- class String
63
- #
64
- # Same as MessagePack.to_msgpack(self[, packer]).
65
- #
66
- # @return [String] serialized data
67
- #
68
- def to_msgpack(packer=nil)
69
- end
70
- end
71
-
72
- class Array
73
- #
74
- # Same as MessagePack.to_msgpack(self[, packer]).
75
- #
76
- # @return [String] serialized data
77
- #
78
- def to_msgpack(packer=nil)
79
- end
80
- end
81
-
82
- class Hash
83
- #
84
- # Same as MessagePack.to_msgpack(self[, packer]).
85
- #
86
- # @return [String] serialized data
87
- #
88
- def to_msgpack(packer=nil)
89
- end
90
- end
91
-
92
- class Symbol
93
- #
94
- # Same as MessagePack.to_msgpack(self[, packer]).
95
- #
96
- # @return [String] serialized data
97
- #
98
- def to_msgpack(packer=nil)
99
- end
100
- end
101
-
@@ -1,19 +0,0 @@
1
- module MessagePack
2
-
3
- class UnpackError < StandardError
4
- end
5
-
6
- class MalformedFormatError < UnpackError
7
- end
8
-
9
- class StackError < UnpackError
10
- end
11
-
12
- class UnexpectedTypeError < UnpackError
13
- include TypeError
14
- end
15
-
16
- class UnknownExtTypeError < UnpackError
17
- include TypeError
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::ExtensionValue is a struct to represent unknown ext type object.
5
- # Its contents are accessed by type and payload (messagepack bytes representation) methods.
6
- # And it is extended to add to_msgpack object.
7
- #
8
- ExtensionValue = Struct.new(:type, :payload)
9
- end
@@ -1,145 +0,0 @@
1
- module MessagePack
2
- #
3
- # MessagePack::Factory is a class to generate Packer and Unpacker which has
4
- # same set of ext types.
5
- #
6
- class Factory
7
- #
8
- # Creates a MessagePack::Factory instance
9
- #
10
- def initialize
11
- end
12
-
13
- #
14
- # Creates a MessagePack::Packer instance, which has ext types already registered.
15
- # Options are passed to MessagePack::Packer#initialized.
16
- #
17
- # See also Packer#initialize for options.
18
- #
19
- def packer(*args)
20
- end
21
-
22
- #
23
- # Serialize the passed value
24
- #
25
- # If it could not serialize the object, it raises
26
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
27
- #
28
- # @param obj [Object] object to serialize
29
- # @param options [Hash]
30
- # @return [String] serialized object
31
- #
32
- # See Packer#initialize for supported options.
33
- #
34
- def dump(obj, options=nil)
35
- end
36
- alias pack dump
37
-
38
- #
39
- # Creates a MessagePack::Unpacker instance, which has ext types already registered.
40
- # Options are passed to MessagePack::Unpacker#initialized.
41
- #
42
- # See also Unpacker#initialize for options.
43
- #
44
- def unpacker(*args)
45
- end
46
-
47
- #
48
- # Deserializes an object from the string or io and returns it.
49
- #
50
- # If there're not enough data to deserialize one object, this method raises EOFError.
51
- # If data format is invalid, this method raises MessagePack::MalformedFormatError.
52
- # If the object nests too deeply, this method raises MessagePack::StackError.
53
- #
54
- # @param data [String]
55
- # @param options [Hash]
56
- # @return [Object] deserialized object
57
- #
58
- # See Unpacker#initialize for supported options.
59
- #
60
- def load(data, options=nil)
61
- end
62
- alias unpack load
63
-
64
- #
65
- # Register a type and Class to be registered for packer and/or unpacker.
66
- # If options are not specified, factory will use :to_msgpack_ext for packer, and
67
- # :from_msgpack_ext for unpacker.
68
- #
69
- # @param type [Fixnum] type id of registered Class (0-127)
70
- # @param klass [Class] Class to be associated with type id
71
- # @param options [Hash] specify method name or Proc which are used by packer/unpacker
72
- # @return nil
73
- #
74
- # Supported options:
75
- #
76
- # * *:packer* specify symbol or proc object for packer
77
- # * *:unpacker* specify symbol or proc object for unpacker
78
- # * *:optimized_symbols_parsing* specify true to use the optimized symbols parsing (not supported on JRuby now)
79
- # * *recursive* specify true to receive the packer or unpacker as argument to generate the extension body manually.
80
- #
81
- def register_type(type, klass, options={})
82
- end
83
-
84
- #
85
- # Returns a list of registered types, ordered by type id.
86
- #
87
- # @param selector [Symbol] specify to list types registered for :packer, :unpacker or :both (default)
88
- # @return Array
89
- #
90
- def registered_types(selector=:both)
91
- end
92
-
93
- #
94
- # Returns true/false which indicate specified class or type id is registered or not.
95
- #
96
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
97
- # @param selector [Symbol] specify to check for :packer, :unpacker or :both (default)
98
- # @return true or false
99
- #
100
- def type_registered?(klass_or_type, selector=:both)
101
- end
102
-
103
- #
104
- # Creates a MessagePack::PooledFactory instance of the given size.
105
- #
106
- # PooledFactory keeps Packer and Unpacker instance in a pool for improved performance.
107
- # Note that the size defines how many instances are kept in cache, not the maximum of instances
108
- # that can be created. If the pool limit is reached, a new instance is created anyway.
109
- #
110
- # @param size [Fixnum] specify how many Packer and Unpacker to keep in cache (default 1)
111
- # @param options [Hash] Combined options for Packer and Unpacker. See Packer#initialize and Unpacker#initialize
112
- # for supported options.
113
- def pool(size=1, **options)
114
- end
115
-
116
- class Pool
117
- #
118
- # Deserializes an object from the string or io and returns it.
119
- #
120
- # If there're not enough data to deserialize one object, this method raises EOFError.
121
- # If data format is invalid, this method raises MessagePack::MalformedFormatError.
122
- # If the object nests too deeply, this method raises MessagePack::StackError.
123
- #
124
- # @param data [String]
125
- # @return [Object] deserialized object
126
- #
127
- # See Unpacker#initialize for supported options.
128
- #
129
- def load(data)
130
- end
131
-
132
- #
133
- # Serialize the passed value
134
- #
135
- # If it could not serialize the object, it raises
136
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
137
- #
138
- # @param obj [Object] object to serialize
139
- # @return [String] serialized object
140
- #
141
- def dump(object)
142
- end
143
- end
144
- end
145
- end
@@ -1,209 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::Packer is a class to serialize objects.
5
- #
6
- class Packer
7
- #
8
- # Creates a MessagePack::Packer instance.
9
- # See Buffer#initialize for supported options.
10
- #
11
- # @overload initialize(options={})
12
- # @param options [Hash]
13
- #
14
- # @overload initialize(io, options={})
15
- # @param io [IO]
16
- # @param options [Hash]
17
- # This packer writes serialized objects into the IO when the internal buffer is filled.
18
- # _io_ must respond to write(string) or append(string) method.
19
- #
20
- # Supported options:
21
- #
22
- # * *:compatibility_mode* serialize in older versions way, without str8 and bin types
23
- #
24
- # See also Buffer#initialize for other options.
25
- #
26
- def initialize(*args)
27
- end
28
-
29
- #
30
- # Register a new ext type to serialize it. This method should be called with one of
31
- # method name or block, which returns bytes(ASCII-8BIT String) representation of
32
- # object to be serialized.
33
- #
34
- # @overload register_type(type, klass, &block)
35
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
36
- # @param klass [Class] Class to be serialized with specified type id
37
- # @yieldparam object [Object] object to be serialized
38
- #
39
- # @overload register_type(type, klass, method_name)
40
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
41
- # @param klass [Class] Class to be serialized with specified type id
42
- # @param method_name [Symbol] method which returns bytes of serialized representation
43
- #
44
- # @return nil
45
- #
46
- def register_type(type, klass, method_name, &block)
47
- end
48
-
49
- #
50
- # Returns a list of registered types, ordered by type id.
51
- # Each element is a Hash object includes keys :type, :class and :packer.
52
- #
53
- # @return Array
54
- #
55
- def registered_types
56
- end
57
-
58
- #
59
- # Returns true/false which indicate specified class or type id is registered or not.
60
- #
61
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
62
- # @return true or false
63
- #
64
- def type_registered?(klass_or_type)
65
- end
66
-
67
- #
68
- # Internal buffer
69
- #
70
- # @return MessagePack::Buffer
71
- #
72
- attr_reader :buffer
73
-
74
- #
75
- # Serializes an object into internal buffer, and flushes to io if necessary.
76
- #
77
- # If it could not serialize the object, it raises
78
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
79
- #
80
- # @param obj [Object] object to serialize
81
- # @return [Packer] self
82
- #
83
- def write(obj)
84
- end
85
-
86
- alias pack write
87
-
88
- #
89
- # Serializes a nil object. Same as write(nil).
90
- #
91
- def write_nil
92
- end
93
-
94
- #
95
- # Serializes a string object as binary data. Same as write("string".encode(Encoding::BINARY)).
96
- #
97
- def write_bin(obj)
98
- end
99
-
100
- #
101
- # Write a header of an array whose size is _n_.
102
- # For example, write_array_header(1).write(true) is same as write([ true ]).
103
- #
104
- # @return [Packer] self
105
- #
106
- def write_array_header(n)
107
- end
108
-
109
- #
110
- # Write a header of an map whose size is _n_.
111
- # For example, write_map_header(1).write('key').write(true) is same as write('key'=>true).
112
- #
113
- # @return [Packer] self
114
- #
115
- def write_map_header(n)
116
- end
117
-
118
- #
119
- # Write a header of a binary string whose size is _n_. Useful if you want to append large binary data without loading it into memory at once.
120
- # For example,
121
- # MessagePack::Packer.new(io).write_bin_header(12).flush
122
- # io.write('chunk1')
123
- # io.write('chunk2')
124
- # is the same as
125
- # write('chunk1chunk2'.encode(Encoding::BINARY)).
126
- #
127
- # @return [Packer] self
128
- #
129
- def write_bin_header(n)
130
- end
131
-
132
- #
133
- # Serializes _value_ as 32-bit single precision float into internal buffer.
134
- # _value_ will be approximated with the nearest possible single precision float, thus
135
- # being potentially lossy. However, the serialized string will only take up 5 bytes
136
- # instead of 9 bytes compared to directly serializing a 64-bit double precision Ruby Float.
137
- #
138
- # @param value [Numeric]
139
- # @return [Packer] self
140
- #
141
- def write_float32(value)
142
- end
143
-
144
- #
145
- # Flushes data in the internal buffer to the internal IO. Same as _buffer.flush.
146
- # If internal IO is not set, it does nothing.
147
- #
148
- # @return [Packer] self
149
- #
150
- def flush
151
- end
152
-
153
- #
154
- # Makes the internal buffer empty. Same as _buffer.clear_.
155
- #
156
- # @return nil
157
- #
158
- def reset
159
- end
160
- alias clear reset
161
-
162
- #
163
- # Returns size of the internal buffer. Same as buffer.size.
164
- #
165
- # @return [Integer]
166
- #
167
- def size
168
- end
169
-
170
- #
171
- # Returns _true_ if the internal buffer is empty. Same as buffer.empty?.
172
- # This method is slightly faster than _size_.
173
- #
174
- # @return [Boolean]
175
- #
176
- def empty?
177
- end
178
-
179
- #
180
- # Returns all data in the buffer as a string. Same as buffer.to_str.
181
- #
182
- # @return [String]
183
- #
184
- def to_str
185
- end
186
-
187
- alias to_s to_str
188
-
189
- #
190
- # Returns content of the internal buffer as an array of strings. Same as buffer.to_a.
191
- # This method is faster than _to_str_.
192
- #
193
- # @return [Array] array of strings
194
- #
195
- def to_a
196
- end
197
-
198
- #
199
- # Writes all of data in the internal buffer into the given IO. Same as buffer.write_to(io).
200
- # This method consumes and removes data from the internal buffer.
201
- # _io_ must respond to write(data) method.
202
- #
203
- # @param io [IO]
204
- # @return [Integer] byte size of written data
205
- #
206
- def write_to(io)
207
- end
208
- end
209
- end
@@ -1,22 +0,0 @@
1
- module MessagePack
2
-
3
- # MessagePack::Time provides packer and unpacker functions for a timestamp type.
4
- # @example Setup for DefaultFactory
5
- # MessagePack::DefaultFactory.register_type(
6
- # MessagePack::Timestamp::TYPE,
7
- # Time,
8
- # packer: MessagePack::Time::Packer,
9
- # unpacker: MessagePack::Time::Unpacker
10
- # )
11
- class Time
12
- # A packer function that packs a Time instance to a MessagePack timestamp.
13
- Packer = lambda { |payload|
14
- # ...
15
- }
16
-
17
- # An unpacker function that unpacks a MessagePack timestamp to a Time instance.
18
- Unpacker = lambda { |time|
19
- # ...
20
- }
21
- end
22
- end
@@ -1,44 +0,0 @@
1
- module MessagePack
2
- # A utility class for MessagePack timestamp type
3
- class Timestamp
4
- #
5
- # The timestamp extension type defined in the MessagePack spec.
6
- #
7
- # See https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type for details.
8
- #
9
- TYPE = -1
10
-
11
- # @return [Integer] Second part of the timestamp.
12
- attr_reader :sec
13
-
14
- # @return [Integer] Nanosecond part of the timestamp.
15
- attr_reader :nsec
16
-
17
- # @param [Integer] sec
18
- # @param [Integer] nsec
19
- def initialize(sec, nsec)
20
- end
21
-
22
- # @example An unpacker implementation for the Time class
23
- # lambda do |payload|
24
- # tv = MessagePack::Timestamp.from_msgpack_ext(payload)
25
- # Time.at(tv.sec, tv.nsec, :nanosecond)
26
- # end
27
- #
28
- # @param [String] data
29
- # @return [MessagePack::Timestamp]
30
- def self.from_msgpack_ext(data)
31
- end
32
-
33
- # @example A packer implementation for the Time class
34
- # unpacker = lambda do |time|
35
- # MessagePack::Timestamp.to_msgpack_ext(time.tv_sec, time.tv_nsec)
36
- # end
37
- #
38
- # @param [Integer] sec
39
- # @param [Integer] nsec
40
- # @return [String]
41
- def self.to_msgpack_ext(sec, nsec)
42
- end
43
- end
44
- end