diff options
author | Mark Erickson <merickson@apache.org> | 2016-04-07 21:12:25 -0500 |
---|---|---|
committer | Mark Erickson <merickson@apache.org> | 2016-04-07 21:12:25 -0500 |
commit | 8b0b7e5eb419eaa47294fa0a70ab96b3a9a07d0b (patch) | |
tree | 4455039736aeca8122f5452cb96400c0fb5561b0 /lib/dart | |
parent | ca714c4397ed78bd880f0dd76526e3817ecc08f0 (diff) | |
download | thrift-8b0b7e5eb419eaa47294fa0a70ab96b3a9a07d0b.tar.gz |
THRIFT-3780 Use fixnum Int64 to write/read binary encoded i64
Client: Dart
Patch: Steven Osborne <steven.osborne@webfilings.com>
This closes #983
Diffstat (limited to 'lib/dart')
-rw-r--r-- | lib/dart/lib/src/protocol/t_binary_protocol.dart | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/dart/lib/src/protocol/t_binary_protocol.dart b/lib/dart/lib/src/protocol/t_binary_protocol.dart index f73223c59..a785d811c 100644 --- a/lib/dart/lib/src/protocol/t_binary_protocol.dart +++ b/lib/dart/lib/src/protocol/t_binary_protocol.dart @@ -124,11 +124,15 @@ class TBinaryProtocol extends TProtocol { transport.write(_i32Out.buffer.asUint8List(), 0, 4); } - final ByteData _i64Out = new ByteData(8); + final Uint8List _i64Out = new Uint8List(8); void writeI64(int i64) { if (i64 == null) i64 = 0; - _i64Out.setInt64(0, i64); - transport.write(_i64Out.buffer.asUint8List(), 0, 8); + var i = new Int64(i64); + var bts = i.toBytes(); + for (var j = 0; j < 8; j++) { + _i64Out[j] = bts[8 - j - 1]; + } + transport.write(_i64Out, 0, 8); } void writeString(String s) { @@ -247,7 +251,8 @@ class TBinaryProtocol extends TProtocol { final Uint8List _i64In = new Uint8List(8); int readI64() { transport.readAll(_i64In, 0, 8); - return _i64In.buffer.asByteData().getInt64(0); + var i = new Int64.fromBytesBigEndian(_i64In); + return i.toInt(); } final Uint8List _doubleIn = new Uint8List(8); |