msgpack 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -2
- data/.travis.yml +2 -3
- data/ChangeLog +6 -0
- data/Rakefile +5 -1
- data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
- data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +309 -0
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +113 -0
- data/ext/java/org/msgpack/jruby/Packer.java +78 -0
- data/ext/java/org/msgpack/jruby/Types.java +37 -0
- data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
- data/lib/msgpack.rb +11 -4
- data/lib/msgpack/version.rb +1 -1
- data/msgpack.gemspec +11 -6
- data/spec/{packer_spec.rb → cruby/packer_spec.rb} +0 -0
- data/spec/{unpacker_spec.rb → cruby/unpacker_spec.rb} +0 -0
- data/spec/format_spec.rb +32 -30
- data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
- data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
- data/spec/jruby/msgpack_spec.rb +136 -0
- data/spec/pack_spec.rb +67 -0
- data/spec/spec_helper.rb +10 -4
- data/spec/unpack_spec.rb +72 -0
- metadata +30 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjBhYjJiYTBhZjk5OGY0ZDdjYmFiOWE3ZDc5ZTQ0MDgzYTU4N2M3ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODI0N2FmMjRjOTU4ZGUyNDliMTc2OWRkNWE5ZDI0YzYzM2Y4MTQ4Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzBlNTc4N2Y5YjgzNjU2ODVjODY2NDgwYjc3YTViZDlmMGU1YzFiNjExODc2
|
10
|
+
YWJhZTNhODU0MjAxMWE1MThjOWU2NGUyZjZhMmVkNDQ0ZWY5NzlmNzE4M2Rl
|
11
|
+
NTgyNzVmMDU2MTJlOTM4YzA0ODJhM2JhYWJhYjg3YzNiNGM0ZTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzA5MGJjNGM0NGZiMjM2NTU3M2I5Y2I4NzUxYjA3ZDUyNjNlY2JhMmRjOWM1
|
14
|
+
MmJjNWNiMGQ0MTUwNjM5ZmVhMjMwYTQ0ZjNiZjg0ZjZjNDAxNTFlNjJkN2Yz
|
15
|
+
NjBlMWIxZjY0Yjg5MThlNjgzYzU2OGQyMjljN2E2NGUzN2ViZjE=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/Rakefile
CHANGED
@@ -30,8 +30,12 @@ if RUBY_PLATFORM =~ /java/
|
|
30
30
|
|
31
31
|
Rake::JavaExtensionTask.new('msgpack', spec) do |ext|
|
32
32
|
ext.ext_dir = 'ext/java'
|
33
|
+
jruby_home = RbConfig::CONFIG['prefix']
|
34
|
+
jars = ["#{jruby_home}/lib/jruby.jar"]
|
35
|
+
ext.classpath = jars.map { |x| File.expand_path(x) }.join(':')
|
33
36
|
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
|
34
|
-
ext.
|
37
|
+
ext.source_version = '1.6'
|
38
|
+
ext.target_version = '1.6'
|
35
39
|
end
|
36
40
|
|
37
41
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
@@ -0,0 +1,221 @@
|
|
1
|
+
package org.msgpack.jruby;
|
2
|
+
|
3
|
+
|
4
|
+
import java.nio.ByteBuffer;
|
5
|
+
|
6
|
+
import org.jruby.Ruby;
|
7
|
+
import org.jruby.RubyClass;
|
8
|
+
import org.jruby.RubyObject;
|
9
|
+
import org.jruby.RubyHash;
|
10
|
+
import org.jruby.RubyIO;
|
11
|
+
import org.jruby.RubyInteger;
|
12
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
13
|
+
import org.jruby.anno.JRubyClass;
|
14
|
+
import org.jruby.anno.JRubyMethod;
|
15
|
+
import org.jruby.runtime.ThreadContext;
|
16
|
+
import org.jruby.runtime.ObjectAllocator;
|
17
|
+
import org.jruby.util.ByteList;
|
18
|
+
|
19
|
+
import org.jcodings.Encoding;
|
20
|
+
|
21
|
+
|
22
|
+
@JRubyClass(name="MessagePack::Buffer")
|
23
|
+
public class Buffer extends RubyObject {
|
24
|
+
private RubyHash options;
|
25
|
+
private IRubyObject io;
|
26
|
+
private ByteBuffer buffer;
|
27
|
+
private boolean writeMode;
|
28
|
+
private Encoding binaryEncoding;
|
29
|
+
|
30
|
+
private static final int CACHE_LINE_SIZE = 64;
|
31
|
+
private static final int ARRAY_HEADER_SIZE = 24;
|
32
|
+
|
33
|
+
public Buffer(Ruby runtime, RubyClass type) {
|
34
|
+
super(runtime, type);
|
35
|
+
}
|
36
|
+
|
37
|
+
static class BufferAllocator implements ObjectAllocator {
|
38
|
+
public IRubyObject allocate(Ruby runtime, RubyClass type) {
|
39
|
+
return new Buffer(runtime, type);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
@JRubyMethod(name = "initialize", optional = 2)
|
44
|
+
public IRubyObject initialize(ThreadContext ctx, IRubyObject[] args) {
|
45
|
+
if (args.length > 0) {
|
46
|
+
if (args[0].respondsTo("read") && args[0].respondsTo("write")) {
|
47
|
+
this.io = args[0];
|
48
|
+
}
|
49
|
+
if (args[args.length - 1] instanceof RubyHash) {
|
50
|
+
this.options = (RubyHash) args[args.length - 1];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
this.buffer = ByteBuffer.allocate(CACHE_LINE_SIZE - ARRAY_HEADER_SIZE);
|
54
|
+
this.writeMode = true;
|
55
|
+
this.binaryEncoding = ctx.getRuntime().getEncodingService().getAscii8bitEncoding();
|
56
|
+
return this;
|
57
|
+
}
|
58
|
+
|
59
|
+
private void ensureRemainingCapacity(int c) {
|
60
|
+
if (!writeMode) {
|
61
|
+
buffer.compact();
|
62
|
+
writeMode = true;
|
63
|
+
}
|
64
|
+
if (buffer.remaining() < c) {
|
65
|
+
int newLength = Math.max(buffer.capacity() + (buffer.capacity() >> 1), buffer.capacity() + c);
|
66
|
+
newLength += CACHE_LINE_SIZE - ((ARRAY_HEADER_SIZE + newLength) % CACHE_LINE_SIZE);
|
67
|
+
buffer = ByteBuffer.allocate(newLength).put(buffer.array(), 0, buffer.position());
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
private void ensureReadMode() {
|
72
|
+
if (writeMode) {
|
73
|
+
buffer.flip();
|
74
|
+
writeMode = false;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
private int rawSize() {
|
79
|
+
if (writeMode) {
|
80
|
+
return buffer.position();
|
81
|
+
} else {
|
82
|
+
return buffer.limit() - buffer.position();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
@JRubyMethod(name = "clear")
|
87
|
+
public IRubyObject clear(ThreadContext ctx) {
|
88
|
+
buffer.clear();
|
89
|
+
return ctx.getRuntime().getNil();
|
90
|
+
}
|
91
|
+
|
92
|
+
@JRubyMethod(name = "size")
|
93
|
+
public IRubyObject size(ThreadContext ctx) {
|
94
|
+
return ctx.getRuntime().newFixnum(rawSize());
|
95
|
+
}
|
96
|
+
|
97
|
+
@JRubyMethod(name = "empty?")
|
98
|
+
public IRubyObject isEmpty(ThreadContext ctx) {
|
99
|
+
return rawSize() == 0 ? ctx.getRuntime().getTrue() : ctx.getRuntime().getFalse();
|
100
|
+
}
|
101
|
+
|
102
|
+
private IRubyObject bufferWrite(ThreadContext ctx, IRubyObject str) {
|
103
|
+
ByteList bytes = str.asString().getByteList();
|
104
|
+
int length = bytes.length();
|
105
|
+
ensureRemainingCapacity(length);
|
106
|
+
buffer.put(bytes.unsafeBytes(), bytes.begin(), length);
|
107
|
+
return ctx.getRuntime().newFixnum(length);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
@JRubyMethod(name = "write", alias = {"<<"})
|
112
|
+
public IRubyObject write(ThreadContext ctx, IRubyObject str) {
|
113
|
+
if (io == null) {
|
114
|
+
return bufferWrite(ctx, str);
|
115
|
+
} else {
|
116
|
+
return io.callMethod(ctx, "write", str);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
private void feed(ThreadContext ctx) {
|
121
|
+
if (io != null) {
|
122
|
+
bufferWrite(ctx, io.callMethod(ctx, "read"));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
private IRubyObject readCommon(ThreadContext ctx, IRubyObject[] args, boolean raiseOnUnderflow) {
|
127
|
+
feed(ctx);
|
128
|
+
int length = rawSize();
|
129
|
+
if (args != null && args.length == 1) {
|
130
|
+
length = (int) args[0].convertToInteger().getLongValue();
|
131
|
+
}
|
132
|
+
if (raiseOnUnderflow && rawSize() < length) {
|
133
|
+
throw ctx.getRuntime().newEOFError();
|
134
|
+
}
|
135
|
+
int readLength = Math.min(length, rawSize());
|
136
|
+
if (readLength == 0 && length > 0) {
|
137
|
+
return ctx.getRuntime().getNil();
|
138
|
+
} else if (readLength == 0) {
|
139
|
+
return ctx.getRuntime().newString();
|
140
|
+
} else {
|
141
|
+
ensureReadMode();
|
142
|
+
byte[] bytes = new byte[readLength];
|
143
|
+
buffer.get(bytes);
|
144
|
+
ByteList byteList = new ByteList(bytes, binaryEncoding);
|
145
|
+
return ctx.getRuntime().newString(byteList);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
@JRubyMethod(name = "read", optional = 1)
|
150
|
+
public IRubyObject read(ThreadContext ctx, IRubyObject[] args) {
|
151
|
+
return readCommon(ctx, args, false);
|
152
|
+
}
|
153
|
+
|
154
|
+
@JRubyMethod(name = "read_all", optional = 1)
|
155
|
+
public IRubyObject readAll(ThreadContext ctx, IRubyObject[] args) {
|
156
|
+
return readCommon(ctx, args, true);
|
157
|
+
}
|
158
|
+
|
159
|
+
private IRubyObject skipCommon(ThreadContext ctx, IRubyObject _length, boolean raiseOnUnderflow) {
|
160
|
+
feed(ctx);
|
161
|
+
int length = (int) _length.convertToInteger().getLongValue();
|
162
|
+
if (raiseOnUnderflow && rawSize() < length) {
|
163
|
+
throw ctx.getRuntime().newEOFError();
|
164
|
+
}
|
165
|
+
ensureReadMode();
|
166
|
+
int skipLength = Math.min(length, rawSize());
|
167
|
+
buffer.position(buffer.position() + skipLength);
|
168
|
+
return ctx.getRuntime().newFixnum(skipLength);
|
169
|
+
}
|
170
|
+
|
171
|
+
@JRubyMethod(name = "skip")
|
172
|
+
public IRubyObject skip(ThreadContext ctx, IRubyObject length) {
|
173
|
+
return skipCommon(ctx, length, false);
|
174
|
+
}
|
175
|
+
|
176
|
+
@JRubyMethod(name = "skip_all")
|
177
|
+
public IRubyObject skipAll(ThreadContext ctx, IRubyObject length) {
|
178
|
+
return skipCommon(ctx, length, true);
|
179
|
+
}
|
180
|
+
|
181
|
+
@JRubyMethod(name = "to_s", alias = {"to_str"})
|
182
|
+
public IRubyObject toS(ThreadContext ctx) {
|
183
|
+
ensureReadMode();
|
184
|
+
int length = buffer.limit() - buffer.position();
|
185
|
+
ByteList str = new ByteList(buffer.array(), buffer.position(), length, binaryEncoding, true);
|
186
|
+
return ctx.getRuntime().newString(str);
|
187
|
+
}
|
188
|
+
|
189
|
+
@JRubyMethod(name = "to_a")
|
190
|
+
public IRubyObject toA(ThreadContext ctx) {
|
191
|
+
return ctx.getRuntime().newArray(toS(ctx));
|
192
|
+
}
|
193
|
+
|
194
|
+
@JRubyMethod(name = "io")
|
195
|
+
public IRubyObject getIo(ThreadContext ctx) {
|
196
|
+
return io == null ? ctx.getRuntime().getNil() : io;
|
197
|
+
}
|
198
|
+
|
199
|
+
@JRubyMethod(name = "flush")
|
200
|
+
public IRubyObject flush(ThreadContext ctx) {
|
201
|
+
if (io == null) {
|
202
|
+
return ctx.getRuntime().getNil();
|
203
|
+
} else {
|
204
|
+
return io.callMethod(ctx, "flush");
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
@JRubyMethod(name = "close")
|
209
|
+
public IRubyObject close(ThreadContext ctx) {
|
210
|
+
if (io == null) {
|
211
|
+
return ctx.getRuntime().getNil();
|
212
|
+
} else {
|
213
|
+
return io.callMethod(ctx, "close");
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
@JRubyMethod(name = "write_to")
|
218
|
+
public IRubyObject writeTo(ThreadContext ctx, IRubyObject io) {
|
219
|
+
return io.callMethod(ctx, "write", readCommon(ctx, null, false));
|
220
|
+
}
|
221
|
+
}
|
@@ -0,0 +1,201 @@
|
|
1
|
+
package org.msgpack.jruby;
|
2
|
+
|
3
|
+
|
4
|
+
import java.math.BigInteger;
|
5
|
+
import java.nio.ByteBuffer;
|
6
|
+
import java.nio.BufferUnderflowException;
|
7
|
+
import java.util.Iterator;
|
8
|
+
import java.util.Arrays;
|
9
|
+
|
10
|
+
import org.jruby.Ruby;
|
11
|
+
import org.jruby.RubyObject;
|
12
|
+
import org.jruby.RubyClass;
|
13
|
+
import org.jruby.RubyBignum;
|
14
|
+
import org.jruby.RubyString;
|
15
|
+
import org.jruby.RubyHash;
|
16
|
+
import org.jruby.exceptions.RaiseException;
|
17
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
18
|
+
import org.jruby.util.ByteList;
|
19
|
+
|
20
|
+
import org.jcodings.Encoding;
|
21
|
+
import org.jcodings.specific.UTF8Encoding;
|
22
|
+
|
23
|
+
import static org.msgpack.jruby.Types.*;
|
24
|
+
|
25
|
+
|
26
|
+
public class Decoder implements Iterator<IRubyObject> {
|
27
|
+
private final Ruby runtime;
|
28
|
+
private final Encoding binaryEncoding;
|
29
|
+
private final Encoding utf8Encoding;
|
30
|
+
private final RubyClass unpackErrorClass;
|
31
|
+
private final RubyClass underflowErrorClass;
|
32
|
+
|
33
|
+
private ByteBuffer buffer;
|
34
|
+
private boolean symbolizeKeys;
|
35
|
+
|
36
|
+
public Decoder(Ruby runtime) {
|
37
|
+
this(runtime, new byte[] {}, 0, 0);
|
38
|
+
}
|
39
|
+
|
40
|
+
public Decoder(Ruby runtime, byte[] bytes) {
|
41
|
+
this(runtime, bytes, 0, bytes.length);
|
42
|
+
}
|
43
|
+
|
44
|
+
public Decoder(Ruby runtime, byte[] bytes, int offset, int length) {
|
45
|
+
this.runtime = runtime;
|
46
|
+
this.binaryEncoding = runtime.getEncodingService().getAscii8bitEncoding();
|
47
|
+
this.utf8Encoding = UTF8Encoding.INSTANCE;
|
48
|
+
this.unpackErrorClass = runtime.getModule("MessagePack").getClass("UnpackError");
|
49
|
+
this.underflowErrorClass = runtime.getModule("MessagePack").getClass("UnderflowError");
|
50
|
+
feed(bytes, offset, length);
|
51
|
+
}
|
52
|
+
|
53
|
+
public void symbolizeKeys(boolean symbolize) {
|
54
|
+
this.symbolizeKeys = symbolize;
|
55
|
+
}
|
56
|
+
|
57
|
+
public void feed(byte[] bytes) {
|
58
|
+
feed(bytes, 0, bytes.length);
|
59
|
+
}
|
60
|
+
|
61
|
+
public void feed(byte[] bytes, int offset, int length) {
|
62
|
+
if (buffer == null) {
|
63
|
+
buffer = ByteBuffer.wrap(bytes, offset, length);
|
64
|
+
} else {
|
65
|
+
ByteBuffer newBuffer = ByteBuffer.allocate(buffer.remaining() + length);
|
66
|
+
newBuffer.put(buffer);
|
67
|
+
newBuffer.put(bytes, offset, length);
|
68
|
+
newBuffer.flip();
|
69
|
+
buffer = newBuffer;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
public void reset() {
|
74
|
+
buffer.rewind();
|
75
|
+
}
|
76
|
+
|
77
|
+
public int offset() {
|
78
|
+
return buffer.position();
|
79
|
+
}
|
80
|
+
|
81
|
+
private IRubyObject consumeUnsignedLong() {
|
82
|
+
long value = buffer.getLong();
|
83
|
+
if (value < 0) {
|
84
|
+
return RubyBignum.newBignum(runtime, BigInteger.valueOf(value & ((1L<<63)-1)).setBit(63));
|
85
|
+
} else {
|
86
|
+
return runtime.newFixnum(value);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
private IRubyObject consumeString(int size, Encoding encoding) {
|
91
|
+
byte[] bytes = readBytes(size);
|
92
|
+
ByteList byteList = new ByteList(bytes, encoding);
|
93
|
+
return runtime.newString(byteList);
|
94
|
+
}
|
95
|
+
|
96
|
+
private IRubyObject consumeArray(int size) {
|
97
|
+
IRubyObject[] elements = new IRubyObject[size];
|
98
|
+
for (int i = 0; i < size; i++) {
|
99
|
+
elements[i] = next();
|
100
|
+
}
|
101
|
+
return runtime.newArray(elements);
|
102
|
+
}
|
103
|
+
|
104
|
+
private IRubyObject consumeHash(int size) {
|
105
|
+
RubyHash hash = RubyHash.newHash(runtime);
|
106
|
+
for (int i = 0; i < size; i++) {
|
107
|
+
IRubyObject key = next();
|
108
|
+
if (this.symbolizeKeys && key instanceof RubyString) {
|
109
|
+
key = ((RubyString) key).intern();
|
110
|
+
}
|
111
|
+
hash.fastASet(key, next());
|
112
|
+
}
|
113
|
+
return hash;
|
114
|
+
}
|
115
|
+
|
116
|
+
private IRubyObject consumeExtension(int size) {
|
117
|
+
int type = buffer.get();
|
118
|
+
byte[] payload = readBytes(size);
|
119
|
+
return ExtensionValue.newExtensionValue(runtime, type, payload);
|
120
|
+
}
|
121
|
+
|
122
|
+
private byte[] readBytes(int size) {
|
123
|
+
byte[] payload = new byte[size];
|
124
|
+
buffer.get(payload);
|
125
|
+
return payload;
|
126
|
+
}
|
127
|
+
|
128
|
+
@Override
|
129
|
+
public void remove() {
|
130
|
+
throw new UnsupportedOperationException();
|
131
|
+
}
|
132
|
+
|
133
|
+
@Override
|
134
|
+
public boolean hasNext() {
|
135
|
+
return buffer.remaining() > 0;
|
136
|
+
}
|
137
|
+
|
138
|
+
@Override
|
139
|
+
public IRubyObject next() {
|
140
|
+
int position = buffer.position();
|
141
|
+
try {
|
142
|
+
byte b = buffer.get();
|
143
|
+
outer: switch ((b >> 4) & 0xf) {
|
144
|
+
case 0x8: return consumeHash(b & 0x0f);
|
145
|
+
case 0x9: return consumeArray(b & 0x0f);
|
146
|
+
case 0xa:
|
147
|
+
case 0xb: return consumeString(b & 0x1f, utf8Encoding);
|
148
|
+
case 0xc:
|
149
|
+
switch (b) {
|
150
|
+
case NIL: return runtime.getNil();
|
151
|
+
case FALSE: return runtime.getFalse();
|
152
|
+
case TRUE: return runtime.getTrue();
|
153
|
+
case BIN8: return consumeString(buffer.get() & 0xff, binaryEncoding);
|
154
|
+
case BIN16: return consumeString(buffer.getShort() & 0xffff, binaryEncoding);
|
155
|
+
case BIN32: return consumeString(buffer.getInt(), binaryEncoding);
|
156
|
+
case VAREXT8: return consumeExtension(buffer.get());
|
157
|
+
case VAREXT16: return consumeExtension(buffer.getShort());
|
158
|
+
case VAREXT32: return consumeExtension(buffer.getInt());
|
159
|
+
case FLOAT32: return runtime.newFloat(buffer.getFloat());
|
160
|
+
case FLOAT64: return runtime.newFloat(buffer.getDouble());
|
161
|
+
case UINT8: return runtime.newFixnum(buffer.get() & 0xffL);
|
162
|
+
case UINT16: return runtime.newFixnum(buffer.getShort() & 0xffffL);
|
163
|
+
case UINT32: return runtime.newFixnum(buffer.getInt() & 0xffffffffL);
|
164
|
+
case UINT64: return consumeUnsignedLong();
|
165
|
+
default: break outer;
|
166
|
+
}
|
167
|
+
case 0xd:
|
168
|
+
switch (b) {
|
169
|
+
case INT8: return runtime.newFixnum(buffer.get());
|
170
|
+
case INT16: return runtime.newFixnum(buffer.getShort());
|
171
|
+
case INT32: return runtime.newFixnum(buffer.getInt());
|
172
|
+
case INT64: return runtime.newFixnum(buffer.getLong());
|
173
|
+
case FIXEXT1: return consumeExtension(1);
|
174
|
+
case FIXEXT2: return consumeExtension(2);
|
175
|
+
case FIXEXT4: return consumeExtension(4);
|
176
|
+
case FIXEXT8: return consumeExtension(8);
|
177
|
+
case FIXEXT16: return consumeExtension(16);
|
178
|
+
case STR8: return consumeString(buffer.get() & 0xff, utf8Encoding);
|
179
|
+
case STR16: return consumeString(buffer.getShort() & 0xffff, utf8Encoding);
|
180
|
+
case STR32: return consumeString(buffer.getInt(), utf8Encoding);
|
181
|
+
case ARY16: return consumeArray(buffer.getShort() & 0xffff);
|
182
|
+
case ARY32: return consumeArray(buffer.getInt());
|
183
|
+
case MAP16: return consumeHash(buffer.getShort() & 0xffff);
|
184
|
+
case MAP32: return consumeHash(buffer.getInt());
|
185
|
+
default: break outer;
|
186
|
+
}
|
187
|
+
case 0xe:
|
188
|
+
case 0xf: return runtime.newFixnum((0x1f & b) - 0x20);
|
189
|
+
default: return runtime.newFixnum(b);
|
190
|
+
}
|
191
|
+
buffer.position(position);
|
192
|
+
throw runtime.newRaiseException(unpackErrorClass, "Illegal byte sequence");
|
193
|
+
} catch (RaiseException re) {
|
194
|
+
buffer.position(position);
|
195
|
+
throw re;
|
196
|
+
} catch (BufferUnderflowException bue) {
|
197
|
+
buffer.position(position);
|
198
|
+
throw runtime.newRaiseException(underflowErrorClass, "Not enough bytes available");
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|