msgpack 0.6.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
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,193 @@
1
+ module MessagePack
2
+
3
+ class Buffer
4
+ #
5
+ # Creates a MessagePack::Buffer instance.
6
+ #
7
+ # @overload initialize(options={})
8
+ # @param options [Hash]
9
+ #
10
+ # @overload initialize(io, options={})
11
+ # @param io [IO]
12
+ # @param options [Hash]
13
+ # This buffer writes written data into the IO when it is filled.
14
+ # This buffer reads data from the IO when it is empty.
15
+ #
16
+ # _io_ must respond to readpartial(length, [,string]) or read(string) method and
17
+ # write(string) or append(string) method.
18
+ #
19
+ # Supported options:
20
+ #
21
+ # * *:io_buffer_size* buffer size to read data from the internal IO. (default: 32768)
22
+ # * *:read_reference_threshold* the threshold size to enable zero-copy deserialize optimization. Read strings longer than this threshold will refer the original string instead of copying it. (default: 256) (supported in MRI only)
23
+ # * *:write_reference_threshold* the threshold size to enable zero-copy serialize optimization. The buffer refers written strings longer than this threshold instead of copying it. (default: 524288) (supported in MRI only)
24
+ #
25
+ def initialize(*args)
26
+ end
27
+
28
+ #
29
+ # Makes the buffer empty
30
+ #
31
+ # @return nil
32
+ #
33
+ def clear
34
+ end
35
+
36
+ #
37
+ # Returns byte size of the buffer.
38
+ #
39
+ # @return nil
40
+ #
41
+ def size
42
+ end
43
+
44
+ #
45
+ # Returns _true_ if the buffer is empty.
46
+ # This method is slightly faster than _size_.
47
+ #
48
+ # @return [Boolean]
49
+ #
50
+ def empty?
51
+ end
52
+
53
+ #
54
+ # Appends the given data to the buffer.
55
+ #
56
+ # @param data [String]
57
+ # @return [Integer] byte size written
58
+ #
59
+ def write(data)
60
+ end
61
+
62
+ #
63
+ # Appends the given data to the buffer.
64
+ #
65
+ # @param data [String]
66
+ # @return [Buffer] self
67
+ #
68
+ def <<(data)
69
+ end
70
+
71
+ #
72
+ # Consumes _n_ bytes from the head of the buffer and returns consumed data.
73
+ # If the size of the buffer is less than _n_, it reads all of data in the buffer.
74
+ #
75
+ # If _n_ is 0, it does nothing and returns an empty string.
76
+ # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
77
+ #
78
+ # @overload read
79
+ #
80
+ # @overload read(n)
81
+ # @param n [Integer] bytes to read
82
+ #
83
+ # @overload read(n, buffer)
84
+ # @param n [Integer] bytes to read
85
+ # @param buffer [String] buffer to read into
86
+ #
87
+ # @return [String]
88
+ #
89
+ def read(n)
90
+ end
91
+
92
+ #
93
+ # Consumes _n_ bytes from the head of the buffer and returns consumed data.
94
+ # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
95
+ #
96
+ # If _n_ is 0, it does nothing and returns an empty string.
97
+ # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
98
+ #
99
+ # @overload read_all
100
+ #
101
+ # @overload read_all(n)
102
+ # @param n [Integer] bytes to read
103
+ #
104
+ # @overload read_all(n, buffer)
105
+ # @param n [Integer] bytes to read
106
+ # @param buffer [String] buffer to read into
107
+ #
108
+ # @return [String]
109
+ #
110
+ def read_all(n, buffer=nil)
111
+ end
112
+
113
+ #
114
+ # Consumes _n_ bytes from the head of the buffer.
115
+ # If the size of the buffer is less than _n_, it skips all of data in the buffer and returns integer less than _n_.
116
+ #
117
+ # If _n_ is 0, it does nothing and returns _0_.
118
+ #
119
+ # @param n [Integer] byte size to skip
120
+ # @return [Integer] byte size actually skipped
121
+ #
122
+ def skip(n)
123
+ end
124
+
125
+ #
126
+ # Consumes _n_ bytes from the head of the buffer.
127
+ # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
128
+ # If _n_ is 0, it does nothing.
129
+ #
130
+ # @param n [Integer] byte size to skip
131
+ # @return [Buffer] self
132
+ #
133
+ def skip_all(n)
134
+ end
135
+
136
+ #
137
+ # Returns all data in the buffer as a string.
138
+ # Destructive update to the returned string does NOT effect the buffer.
139
+ #
140
+ # @return [String]
141
+ #
142
+ def to_str
143
+ end
144
+
145
+ #
146
+ # Returns content of the buffer as an array of strings.
147
+ #
148
+ # This method is sometimes faster than to_s because the internal
149
+ # structure of the buffer is a queue of buffer chunks.
150
+ #
151
+ # @return [Array] array of strings
152
+ #
153
+ def to_a
154
+ end
155
+
156
+ #
157
+ # Internal io
158
+ #
159
+ # @return IO
160
+ #
161
+ attr_reader :io
162
+
163
+ #
164
+ # Flushes data in the internal buffer to the internal IO.
165
+ # If internal IO is not set, it does nothing.
166
+ #
167
+ # @return [Buffer] self
168
+ #
169
+ def flush
170
+ end
171
+
172
+ #
173
+ # Closes internal IO if its set.
174
+ # If internal IO is not set, it does nothing
175
+ #
176
+ # @return nil
177
+ #
178
+ def close
179
+ end
180
+
181
+ #
182
+ # Writes all of data in the internal buffer into the given IO.
183
+ # This method consumes and removes data from the internal buffer.
184
+ # _io_ must respond to write(data) method.
185
+ #
186
+ # @param io [IO]
187
+ # @return [Integer] byte size of written data
188
+ #
189
+ def write_to(io)
190
+ end
191
+ end
192
+
193
+ end
@@ -0,0 +1,101 @@
1
+
2
+ class NilClass
3
+ #
4
+ # Same as MessagePack.to_msgpack(self[, io]).
5
+ #
6
+ # @return [String] serialized data
7
+ #
8
+ def to_msgpack(io=nil)
9
+ end
10
+ end
11
+
12
+ class TrueClass
13
+ #
14
+ # Same as MessagePack.to_msgpack(self[, io]).
15
+ #
16
+ # @return [String] serialized data
17
+ #
18
+ def to_msgpack(io=nil)
19
+ end
20
+ end
21
+
22
+ class FalseClass
23
+ #
24
+ # Same as MessagePack.to_msgpack(self[, io]).
25
+ #
26
+ # @return [String] serialized data
27
+ #
28
+ def to_msgpack(io=nil)
29
+ end
30
+ end
31
+
32
+ class Fixnum < Integer
33
+ #
34
+ # Same as MessagePack.to_msgpack(self[, io]).
35
+ #
36
+ # @return [String] serialized data
37
+ #
38
+ def to_msgpack(io=nil)
39
+ end
40
+ end
41
+
42
+ class Bignum < Integer
43
+ #
44
+ # Same as MessagePack.to_msgpack(self[, io]).
45
+ #
46
+ # @return [String] serialized data
47
+ #
48
+ def to_msgpack(io=nil)
49
+ end
50
+ end
51
+
52
+ class Float < Numeric
53
+ #
54
+ # Same as MessagePack.to_msgpack(self[, io]).
55
+ #
56
+ # @return [String] serialized data
57
+ #
58
+ def to_msgpack(io=nil)
59
+ end
60
+ end
61
+
62
+ class String
63
+ #
64
+ # Same as MessagePack.to_msgpack(self[, io]).
65
+ #
66
+ # @return [String] serialized data
67
+ #
68
+ def to_msgpack(io=nil)
69
+ end
70
+ end
71
+
72
+ class Array
73
+ #
74
+ # Same as MessagePack.to_msgpack(self[, io]).
75
+ #
76
+ # @return [String] serialized data
77
+ #
78
+ def to_msgpack(io=nil)
79
+ end
80
+ end
81
+
82
+ class Hash
83
+ #
84
+ # Same as MessagePack.to_msgpack(self[, io]).
85
+ #
86
+ # @return [String] serialized data
87
+ #
88
+ def to_msgpack(io=nil)
89
+ end
90
+ end
91
+
92
+ class Symbol
93
+ #
94
+ # Same as MessagePack.to_msgpack(self[, io]).
95
+ #
96
+ # @return [String] serialized data
97
+ #
98
+ def to_msgpack(io=nil)
99
+ end
100
+ end
101
+
@@ -0,0 +1,14 @@
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 TypeError < StandardError
13
+ end
14
+ end
@@ -0,0 +1,134 @@
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 serialzied objects into the IO when the internal buffer is filled.
18
+ # _io_ must respond to write(string) or append(string) method.
19
+ #
20
+ # See also Buffer#initialize for options.
21
+ #
22
+ def initialize(*args)
23
+ end
24
+
25
+ #
26
+ # Internal buffer
27
+ #
28
+ # @return MessagePack::Buffer
29
+ #
30
+ attr_reader :buffer
31
+
32
+ #
33
+ # Serializes an object into internal buffer, and flushes to io if necessary.
34
+ #
35
+ # If it could not serialize the object, it raises
36
+ # NoMethodError: undefined method `to_msgpack' for #<the_object>.
37
+ #
38
+ # @param obj [Object] object to serialize
39
+ # @return [Packer] self
40
+ #
41
+ def write(obj)
42
+ end
43
+
44
+ alias pack write
45
+
46
+ #
47
+ # Serializes a nil object. Same as write(nil).
48
+ #
49
+ def write_nil
50
+ end
51
+
52
+ #
53
+ # Write a header of an array whose size is _n_.
54
+ # For example, write_array_header(1).write(true) is same as write([ true ]).
55
+ #
56
+ # @return [Packer] self
57
+ #
58
+ def write_array_header(n)
59
+ end
60
+
61
+ #
62
+ # Write a header of an map whose size is _n_.
63
+ # For example, write_map_header(1).write('key').write(true) is same as write('key'=>true).
64
+ #
65
+ # @return [Packer] self
66
+ #
67
+ def write_map_header(n)
68
+ end
69
+
70
+ #
71
+ # Flushes data in the internal buffer to the internal IO. Same as _buffer.flush.
72
+ # If internal IO is not set, it does nothing.
73
+ #
74
+ # @return [Packer] self
75
+ #
76
+ def flush
77
+ end
78
+
79
+ #
80
+ # Makes the internal buffer empty. Same as _buffer.clear_.
81
+ #
82
+ # @return nil
83
+ #
84
+ def clear
85
+ end
86
+
87
+ #
88
+ # Returns size of the internal buffer. Same as buffer.size.
89
+ #
90
+ # @return [Integer]
91
+ #
92
+ def size
93
+ end
94
+
95
+ #
96
+ # Returns _true_ if the internal buffer is empty. Same as buffer.empty?.
97
+ # This method is slightly faster than _size_.
98
+ #
99
+ # @return [Boolean]
100
+ #
101
+ def empty?
102
+ end
103
+
104
+ #
105
+ # Returns all data in the buffer as a string. Same as buffer.to_str.
106
+ #
107
+ # @return [String]
108
+ #
109
+ def to_str
110
+ end
111
+
112
+ alias to_s to_str
113
+
114
+ #
115
+ # Returns content of the internal buffer as an array of strings. Same as buffer.to_a.
116
+ # This method is faster than _to_str_.
117
+ #
118
+ # @return [Array] array of strings
119
+ #
120
+ def to_a
121
+ end
122
+
123
+ #
124
+ # Writes all of data in the internal buffer into the given IO. Same as buffer.write_to(io).
125
+ # This method consumes and removes data from the internal buffer.
126
+ # _io_ must respond to write(data) method.
127
+ #
128
+ # @param io [IO]
129
+ # @return [Integer] byte size of written data
130
+ #
131
+ def write_to(io)
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,146 @@
1
+ module MessagePack
2
+
3
+ #
4
+ # MessagePack::Unpacker is a class to deserialize objects.
5
+ #
6
+ class Unpacker
7
+ #
8
+ # Creates a MessagePack::Unpacker instance.
9
+ #
10
+ # @overload initialize(options={})
11
+ # @param options [Hash]
12
+ #
13
+ # @overload initialize(io, options={})
14
+ # @param io [IO]
15
+ # @param options [Hash]
16
+ # This unpacker reads data from the _io_ to fill the internal buffer.
17
+ # _io_ must respond to readpartial(length [,string]) or read(length [,string]) method.
18
+ #
19
+ # Supported options:
20
+ #
21
+ # * *:symbolize_keys* deserialize keys of Hash objects as Symbol instead of String
22
+ #
23
+ # See also Buffer#initialize for other options.
24
+ #
25
+ def initialize(*args)
26
+ end
27
+
28
+ #
29
+ # Internal buffer
30
+ #
31
+ # @return [MessagePack::Buffer]
32
+ #
33
+ attr_reader :buffer
34
+
35
+ #
36
+ # Deserializes an object from the io or internal buffer and returns it.
37
+ #
38
+ # This method reads data from io into the internal buffer and deserializes an object
39
+ # from the buffer. It repeats reading data from the io until enough data is available
40
+ # to deserialize at least one object. After deserializing one object, unused data is
41
+ # left in the internal buffer.
42
+ #
43
+ # If there're not enough data to deserialize one object, this method raises EOFError.
44
+ # If data format is invalid, this method raises MessagePack::MalformedFormatError.
45
+ # If the object nests too deeply, this method raises MessagePack::StackError.
46
+ #
47
+ # @return [Object] deserialized object
48
+ #
49
+ def read
50
+ end
51
+
52
+ alias unpack read
53
+
54
+ #
55
+ # Deserializes an object and ignores it. This method is faster than _read_.
56
+ #
57
+ # This method could raise the same errors with _read_.
58
+ #
59
+ # @return nil
60
+ #
61
+ def skip
62
+ end
63
+
64
+ #
65
+ # Deserializes a nil value if it exists and returns _true_.
66
+ # Otherwise, if a byte exists but the byte doesn't represent nil value,
67
+ # returns _false_.
68
+ #
69
+ # If there're not enough data, this method raises EOFError.
70
+ #
71
+ # @return [Boolean]
72
+ #
73
+ def skip_nil
74
+ end
75
+
76
+ #
77
+ # Read a header of an array and returns its size.
78
+ # It converts a serialized array into a stream of elements.
79
+ #
80
+ # If the serialized object is not an array, it raises MessagePack::TypeError.
81
+ # If there're not enough data, this method raises EOFError.
82
+ #
83
+ # @return [Integer] size of the array
84
+ #
85
+ def read_array_header
86
+ end
87
+
88
+ #
89
+ # Reads a header of an map and returns its size.
90
+ # It converts a serialized map into a stream of key-value pairs.
91
+ #
92
+ # If the serialized object is not a map, it raises MessagePack::TypeError.
93
+ # If there're not enough data, this method raises EOFError.
94
+ #
95
+ # @return [Integer] size of the map
96
+ #
97
+ def read_map_header
98
+ end
99
+
100
+ #
101
+ # Appends data into the internal buffer.
102
+ # This method is equivalent to unpacker.buffer.append(data).
103
+ #
104
+ # @param data [String]
105
+ # @return [Unpacker] self
106
+ #
107
+ def feed(data)
108
+ end
109
+
110
+ #
111
+ # Repeats to deserialize objects.
112
+ #
113
+ # It repeats until the io or internal buffer does not include any complete objects.
114
+ #
115
+ # If the an IO is set, it repeats to read data from the IO when the buffer
116
+ # becomes empty until the IO raises EOFError.
117
+ #
118
+ # This method could raise same errors with _read_ excepting EOFError.
119
+ #
120
+ # @yieldparam object [Object] deserialized object
121
+ # @return nil
122
+ #
123
+ def each(&block)
124
+ end
125
+
126
+ #
127
+ # Appends data into the internal buffer and repeats to deserialize objects.
128
+ # This method is equivalent to unpacker.feed(data) && unpacker.each { ... }.
129
+ #
130
+ # @param data [String]
131
+ # @yieldparam object [Object] deserialized object
132
+ # @return nil
133
+ #
134
+ def feed_each(data, &block)
135
+ end
136
+
137
+ #
138
+ # Clears the internal buffer and resets deserialization state of the unpacker.
139
+ #
140
+ # @return nil
141
+ #
142
+ def reset
143
+ end
144
+ end
145
+
146
+ end