Permalink
Browse files

Revert "fixed single bite conversion from signed to unsigned for 'b' …

…frames"

This reverts commit 4e7a877.

Breaks some of the tests.
  • Loading branch information...
1 parent b60a62a commit 7753748f33ff2333cbc2c451cc65acda95fc8cd0 @michaelklishin michaelklishin committed Dec 19, 2013
@@ -81,8 +81,8 @@ def self.decode(data)
when TYPE_BOOLEAN
v, offset = TableValueDecoder.decode_boolean(data, offset)
v
- when TYPE_BYTE then
- v, offset = TableValueDecoder.decode_byte(data, offset)
+ when TYPE_SIGNED_8BIT then
+ v, offset = TableValueDecoder.decode_short_short(data, offset)
v
when TYPE_SIGNED_16BIT then
v, offset = TableValueDecoder.decode_short(data, offset)
@@ -50,8 +50,8 @@ def self.decode_array(data, initial_offset)
when TYPE_BOOLEAN
v, offset = decode_boolean(data, offset)
v
- when TYPE_BYTE then
- v, offset = decode_byte(data, offset)
+ when TYPE_SIGNED_8BIT then
+ v, offset = decode_short_short(data, offset)
v
when TYPE_SIGNED_16BIT then
v, offset = decode_short(data, offset)
@@ -173,13 +173,11 @@ def self.decode_hash(data, offset)
[v, offset]
end # self.decode_hash(data, offset)
- # Decodes/Converts a byte value from the data at the provided offset.
- #
- # @param [Array] data - A big-endian ordered array of bytes.
- # @param [Fixnum] offset - The offset which bytes the byte is consumed.
- # @return [Array] - The Fixnum value and new offset pair.
- def self.decode_byte(data, offset)
- [data.slice(offset, 1).unpack(PACK_CHAR).first, offset += 1]
+
+ def self.decode_short_short(data, offset)
+ v = data.slice(offset, 1).unpack(PACK_INT8).first
+ offset += 1
+ [v, offset]
end
def self.decode_short(data, offset)
@@ -9,7 +9,7 @@ module TypeConstants
TYPE_DECIMAL = 'D'.freeze
TYPE_HASH = 'F'.freeze
TYPE_ARRAY = 'A'.freeze
- TYPE_BYTE = 'b'.freeze
+ TYPE_SIGNED_8BIT = 'b'.freeze
TYPE_64BIT_FLOAT = 'd'.freeze
TYPE_32BIT_FLOAT = 'f'.freeze
TYPE_SIGNED_64BIT = 'l'.freeze
@@ -64,27 +64,9 @@ module Protocol
input = Float32Bit.new(10.0)
data = TableValueEncoder.encode(input)
- value, offset = described_class.decode_decode_byte(data, 1)
+ value, offset = described_class.decode_32bit_float(data, 1)
value.should == 10.0
end
-
- context "8bit/byte decoding" do
- let(:examples) {
- {
- 0x00 => "\x00",
- 0x01 => "\x01",
- 0x10 => "\x10",
- 255 => "\xFF" # not -1
- }
- }
-
- it "is capable of decoding byte values" do
- examples.each do |key, value|
- described_class.decode_byte(value, 0).first.should == key
- end
- end
- end
-
end
end
end

0 comments on commit 7753748

Please sign in to comment.