I could not find a difference between writing signed and unsigned ints. Hence writeInt() and writeUnsignedInt() are identical code (one calls the other).
If I missed something, please let me know... > On Jun 24, 2018, at 3:15 PM, [email protected] wrote: > > This is an automated email from the ASF dual-hosted git repository. > > harbs pushed a commit to branch develop > in repository https://gitbox.apache.org/repos/asf/royale-asjs.git > > > The following commit(s) were added to refs/heads/develop by this push: > new fc9a15f Fixed BinaryData write methods > fc9a15f is described below > > commit fc9a15f1fbf59a02f0a7e45f34a133fbef5af0f8 > Author: Harbs <[email protected]> > AuthorDate: Sun Jun 24 15:15:51 2018 +0300 > > Fixed BinaryData write methods > --- > .../royale/org/apache/royale/utils/BinaryData.as | 53 ++++++++++++++-------- > 1 file changed, 33 insertions(+), 20 deletions(-) > > diff --git > a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as > > b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as > index 6ff7aa7..6dba8d8 100644 > --- > a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as > +++ > b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as > @@ -262,8 +262,7 @@ public class BinaryData implements IBinaryDataInput, > IBinaryDataOutput > if (_position + 1 > _len) { > setBufferSize(_position + 1); > } > - new Uint8Array(ba, _position, 1)[0] = byte; > - _position++; > + getTypedArray()[_position++] = byte; > } > } > /** > @@ -322,14 +321,18 @@ public class BinaryData implements IBinaryDataInput, > IBinaryDataOutput > } > COMPILE::JS > { > - if (!_sysEndian) { > - short = (((short & 0xff00) >>> 8) | ((short & 0xff) <<8 )); > - } > if (_position + 2 > _len) { > setBufferSize(_position + 2); > } > - new Int16Array(ba, _position, 1)[0] = short; > - _position += 2; > + var arr:Uint8Array = getTypedArray(); > + if(endian == Endian.BIG_ENDIAN){ > + arr[_position++] = (short & 0x0000ff00) >> 8; > + arr[_position++] = (short & 0x000000ff); > + } else { > + arr[_position++] = (short & 0x000000ff); > + arr[_position++] = (short & 0x0000ff00) >> 8; > + } > + > } > } > > @@ -351,14 +354,15 @@ public class BinaryData implements IBinaryDataInput, > IBinaryDataOutput > } > COMPILE::JS > { > - if (!_sysEndian) { > - val = ((val & 0xff000000) >>> 24) | ((val & 0x00ff0000) >> > 8) | ((val & 0x0000ff00) << 8) | (val << 24); > - } > - if (_position + 4 > _len) { > - setBufferSize(_position + 4); > - } > - new Uint32Array(ba, _position, 1)[0] = val; > - _position += 4; > + writeInt(val); > + // if (!_sysEndian) { > + // val = ((val & 0xff000000) >>> 24) | ((val & 0x00ff0000) > >> 8) | ((val & 0x0000ff00) << 8) | (val << 24); > + // } > + // if (_position + 4 > _len) { > + // setBufferSize(_position + 4); > + // } > + // new Uint32Array(ba, _position, 1)[0] = val; > + // _position += 4; > } > } > > @@ -380,14 +384,23 @@ public class BinaryData implements IBinaryDataInput, > IBinaryDataOutput > } > COMPILE::JS > { > - if (!_sysEndian) { > - val = (((val & 0xff000000) >>> 24) | ((val & 0x00ff0000) >> > 8) | ((val & 0x0000ff00) << 8) | (val << 24)) >> 0; > - } > if (_position + 4 > _len) { > setBufferSize(_position + 4); > } > - new Int32Array(ba, _position, 1)[0] = val; > - _position += 4; > + var arr:Uint8Array = getTypedArray(); > + if(endian == Endian.BIG_ENDIAN){ > + > + arr[_position++] = (val & 0xff000000) >> 24; > + arr[_position++] = (val & 0x00ff0000) >> 16; > + arr[_position++] = (val & 0x0000ff00) >> 8; > + arr[_position++] = (val & 0x000000ff); > + } else { > + arr[_position++] = (val & 0x000000ff); > + arr[_position++] = (val & 0x0000ff00) >> 8; > + arr[_position++] = (val & 0x00ff0000) >> 16; > + arr[_position++] = (val & 0xff000000) >> 24; > + } > + > } > } > >
