Skip to content

Commit fbfc347

Browse files
committed
- MpDecoder accepts #formatVersion 2008 and 2013 settings
- Added PackUnpack tests for new Binary type - Added tests for String (formerly Raw) type
1 parent 1b38454 commit fbfc347

File tree

25 files changed

+97
-30
lines changed

25 files changed

+97
-30
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
decode customization
2+
bytesAsRaw
3+
"For older MP specification"
4+
| map |
5+
map := self actionMap.
6+
map at: MpConstants str8 put: #signalError.
7+
map at: MpConstants str16 put: #readRaw16.
8+
map at: MpConstants str32 put: #readRaw32.
9+
10+
self isBytesAsString: false

repository/MessagePack-Core.package/MpDecodeTypeMapper.class/methodProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"defineUnsignedIntegerActionTo:" : "mu 4/30/2011 22:46",
1616
"on:" : "mu 11/20/2011 16:50" },
1717
"instance" : {
18+
"bytesAsRaw" : "mu 8/26/2013 00:20",
1819
"bytesAsString" : "mu 8/12/2013 00:12",
1920
"decoder" : "mu 4/29/2011 23:40",
2021
"decoder:" : "mu 4/29/2011 23:40",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
building
2+
buildTypeMapper: aTypeMapper
3+
self settings formatVersion = 2008 ifTrue: [
4+
aTypeMapper bytesAsRaw.
5+
self settings bytesAsString ifTrue: [aTypeMapper bytesAsString].
6+
].
7+
^ aTypeMapper
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
reading
2+
readFixStr: firstByte
3+
self settings formatVersion = 2008 ifTrue: [^self readFixRaw: firstByte].
4+
^self readFixString: firstByte

repository/MessagePack-Core.package/MpDecoder.class/instance/readObjectOf.ifNotApplied..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readObjectOf: type ifNotApplied: aBlock
66
fixMapOrArray := type bitShift: -4.
77
fixMapOrArray = 2r1000 ifTrue: [^ self readFixMap: type].
88
fixMapOrArray = 2r1001 ifTrue: [^ self readFixArray: type].
9-
^ self readFixRaw: type.
9+
^ self readFixStr: type.
1010
].
1111
(type bitShift: -5) = 2r111 ifTrue: [^ self readNegativeFixNum: type].
1212
^self typeMapper readObjectOf: type ifNotApplied: aBlock
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
reading
22
readRaw16
33
"Obsolete"
4-
^self readStr16
4+
| size |
5+
size := MpPortableUtil default readUint16From: self readStream.
6+
^self readStream next: size
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
reading
22
readRaw32
33
"Obsolete"
4-
^self readStr32
4+
| size |
5+
size := MpPortableUtil default readUint32From: self readStream.
6+
^self readStream next: size
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
reading
22
readStr16
3-
^self readBin16
3+
^self readString16
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
reading
22
readStr32
3-
^self readBin32
3+
^self readString32
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
reading
22
readStr8
3-
| size |
4-
size := self readStream next.
5-
^(self readStream next: size) asString
3+
^self readString8

0 commit comments

Comments
 (0)