Repository: thrift Updated Branches: refs/heads/master df71a2e7a -> 86f7350f9
THRIFT-3076 Compatibility with Haxe 3.2.0 Client: Haxe Patch: Jens Geyer This closes #435 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/86f7350f Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/86f7350f Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/86f7350f Branch: refs/heads/master Commit: 86f7350f90c7432c9415cb43d003ff7e6385c258 Parents: df71a2e Author: Jens Geyer <[email protected]> Authored: Fri Apr 3 00:44:27 2015 +0200 Committer: Jens Geyer <[email protected]> Committed: Sat Apr 11 02:04:09 2015 +0200 ---------------------------------------------------------------------- compiler/cpp/src/generate/t_haxe_generator.cc | 2 +- .../org/apache/thrift/TApplicationException.hx | 2 +- .../org/apache/thrift/helper/BitConverter.hx | 11 ++++ .../src/org/apache/thrift/helper/Int64Map.hx | 53 +++++++++++++++----- .../apache/thrift/protocol/TBinaryProtocol.hx | 5 ++ .../apache/thrift/protocol/TCompactProtocol.hx | 8 +++ .../thrift/protocol/TMultiplexedProcessor.hx | 4 +- .../thrift/protocol/TProtocolException.hx | 2 +- .../thrift/transport/TFullDuplexHttpClient.hx | 14 +++--- .../thrift/transport/TTransportException.hx | 2 +- 10 files changed, 78 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/compiler/cpp/src/generate/t_haxe_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_haxe_generator.cc b/compiler/cpp/src/generate/t_haxe_generator.cc index 520377a..3c4dadf 100644 --- a/compiler/cpp/src/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/generate/t_haxe_generator.cc @@ -200,7 +200,7 @@ public: t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base(); switch (tbase) { case t_base_type::TYPE_STRING: - case t_base_type::TYPE_I64: + //case t_base_type::TYPE_I64: - Int64 is not really nullable, even though it behaved that way before Haxe 3.2.0 return true; default: return false; http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/TApplicationException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/TApplicationException.hx b/lib/haxe/src/org/apache/thrift/TApplicationException.hx index 4fe571d..7fe844f 100644 --- a/lib/haxe/src/org/apache/thrift/TApplicationException.hx +++ b/lib/haxe/src/org/apache/thrift/TApplicationException.hx @@ -34,7 +34,7 @@ class TApplicationException extends TException { private static var MESSAGE_FIELD = { new TField("message", TType.STRING, 1); }; private static var TYPE_FIELD = { new TField("type", TType.I32, 2); }; - // WARNING: These are subject to be extended in the future, so we can't use enums + // WARNING: These are subject to be extended in the future, so we can't use enums // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var UNKNOWN_METHOD : Int = 1; http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/helper/BitConverter.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/helper/BitConverter.hx b/lib/haxe/src/org/apache/thrift/helper/BitConverter.hx index 7f7c8f7..ee0aaa8 100644 --- a/lib/haxe/src/org/apache/thrift/helper/BitConverter.hx +++ b/lib/haxe/src/org/apache/thrift/helper/BitConverter.hx @@ -46,6 +46,7 @@ class BitConverter { */ public static function fixedLongToBytes( n : Int64) : Bytes { var buf = Bytes.alloc(8); + #if( haxe_ver < 3.2) buf.set( 0, Int64.getLow( Int64.and( n, Int64.make(0, 0xff)))); buf.set( 1, Int64.getLow( Int64.and( Int64.shr( n, 8), Int64.make(0, 0xff)))); buf.set( 2, Int64.getLow( Int64.and( Int64.shr( n, 16), Int64.make(0, 0xff)))); @@ -54,6 +55,16 @@ class BitConverter { buf.set( 5, Int64.getLow( Int64.and( Int64.shr( n, 40), Int64.make(0, 0xff)))); buf.set( 6, Int64.getLow( Int64.and( Int64.shr( n, 48), Int64.make(0, 0xff)))); buf.set( 7, Int64.getLow( Int64.and( Int64.shr( n, 56), Int64.make(0, 0xff)))); + #else + buf.set( 0, Int64.and( n, Int64.make(0, 0xff)).low); + buf.set( 1, Int64.and( Int64.shr( n, 8), Int64.make(0, 0xff)).low); + buf.set( 2, Int64.and( Int64.shr( n, 16), Int64.make(0, 0xff)).low); + buf.set( 3, Int64.and( Int64.shr( n, 24), Int64.make(0, 0xff)).low); + buf.set( 4, Int64.and( Int64.shr( n, 32), Int64.make(0, 0xff)).low); + buf.set( 5, Int64.and( Int64.shr( n, 40), Int64.make(0, 0xff)).low); + buf.set( 6, Int64.and( Int64.shr( n, 48), Int64.make(0, 0xff)).low); + buf.set( 7, Int64.and( Int64.shr( n, 56), Int64.make(0, 0xff)).low); + #end return buf; } http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx b/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx index 6d6a6a1..e648b75 100644 --- a/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx +++ b/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx @@ -49,18 +49,47 @@ class Int64Map<T> implements IMap< Int64, T> { return lomap; } + + private function GetLowMap( key : haxe.Int64, canCreate : Bool) : IntMap< T> { + #if( haxe_ver < 3.2) + return GetSubMap( Int64.getHigh(key), false); + #else + return GetSubMap( key.high, false); + #end + } + + + private function GetLowIndex( key : haxe.Int64) : haxe.Int32 { + #if( haxe_ver < 3.2) + return Int64.getLow(key); + #else + return key.low; + #end + } + + + private function NullCheck( key : haxe.Int64) : Bool { + #if( haxe_ver < 3.2) + return (key != null); + #else + return false; // In64 is not nullable anymore (it never really was) + #end + }; + + + /** Maps `key` to `value`. If `key` already has a mapping, the previous value disappears. If `key` is null, the result is unspecified. **/ public function set( key : Int64, value : T ) : Void { - if( key == null) { + if( ! NullCheck(key)) { return; } - var lomap = GetSubMap( Int64.getHigh(key), true); - lomap.set( Int64.getLow(key), value); + var lomap = GetLowMap( key, true); + lomap.set( GetLowIndex(key), value); } @@ -79,16 +108,16 @@ class Int64Map<T> implements IMap< Int64, T> { **/ public function get( key : Int64) : Null<T> { - if( key == null) { + if( ! NullCheck(key)) { return null; } - var lomap = GetSubMap( Int64.getHigh(key), false); + var lomap = GetLowMap( key, true); if( lomap == null) { return null; } - return lomap.get( Int64.getLow(key)); + return lomap.get( GetLowIndex(key)); } /** @@ -96,16 +125,16 @@ class Int64Map<T> implements IMap< Int64, T> { If `key` is null, the result is unspecified. **/ public function exists( key : Int64) : Bool { - if( key == null) { + if( ! NullCheck(key)) { return false; } - var lomap = GetSubMap( Int64.getHigh(key), false); + var lomap = GetLowMap( key, true); if( lomap == null) { return false; } - return lomap.exists( Int64.getLow(key)); + return lomap.exists( GetLowIndex(key)); } /** @@ -113,16 +142,16 @@ class Int64Map<T> implements IMap< Int64, T> { false otherwise. If `key` is null, the result is unspecified. **/ public function remove( key : Int64) : Bool { - if( key == null) { + if( ! NullCheck(key)) { return false; } - var lomap = GetSubMap( Int64.getHigh(key), false); + var lomap = GetLowMap( key, true); if( lomap == null) { return false; } - return lomap.remove( Int64.getLow(key)); + return lomap.remove( GetLowIndex(key)); } http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/protocol/TBinaryProtocol.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TBinaryProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TBinaryProtocol.hx index c37b74e..377e7ef 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TBinaryProtocol.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TBinaryProtocol.hx @@ -136,10 +136,15 @@ class TBinaryProtocol implements TProtocol { public function writeI64(i64 : haxe.Int64) : Void { var out = new BytesOutput(); out.bigEndian = true; + #if( haxe_ver < 3.2) var hi = Int64.getHigh(i64); var lo = Int64.getLow(i64); out.writeInt32(hi); out.writeInt32(lo); + #else + out.writeInt32(i64.high); + out.writeInt32(i64.low); + #end trans_.write(out.getBytes(), 0, 8); } http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx index 0781114..e945789 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx @@ -389,12 +389,20 @@ class TCompactProtocol implements TProtocol { { if( Int64.isZero( Int64.and( n, Int64.neg(Int64.make(0,0x7F))))) { + #if( haxe_ver < 3.2) varint64out.addByte( Int64.getLow(n)); + #else + varint64out.addByte( n.low); + #end break; } else { + #if ( haxe_ver < 3.2) varint64out.addByte( (Int64.getLow(n) & 0x7F) | 0x80); + #else + varint64out.addByte( (n.low & 0x7F) | 0x80); + #end n = Int64.shr( n, 7); n = Int64.and( n, Int64.make(0x01FFFFFF,0xFFFFFFFF)); // clean out the shifted 7 bits } http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/protocol/TMultiplexedProcessor.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMultiplexedProcessor.hx b/lib/haxe/src/org/apache/thrift/protocol/TMultiplexedProcessor.hx index 9e25fcf..50aa3cd 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TMultiplexedProcessor.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TMultiplexedProcessor.hx @@ -51,9 +51,9 @@ class TMultiplexedProcessor implements TProcessor private var serviceProcessorMap : StringMap<TProcessor> = new StringMap<TProcessor>(); private var defaultProcessor : TProcessor = null; - public function new() { + public function new() { } - + /** * 'Register' a service with this TMultiplexedProcessor. This allows us to broker * requests to individual services by using the service name to select them at request time. http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx index 2e0f9f5..a3b37a5 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx @@ -23,7 +23,7 @@ import org.apache.thrift.TException; class TProtocolException extends TException { - // WARNING: These are subject to be extended in the future, so we can't use enums + // WARNING: These are subject to be extended in the future, so we can't use enums // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var INVALID_DATA : Int = 1; http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx index a4dc671..1972853 100644 --- a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx +++ b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx @@ -192,13 +192,13 @@ import flash.events.EventDispatcher; { this.output = this.socket; this.input = this.socket; - this.output.writeUTF( "CONNECT " + resource + " HTTP/1.1\n" - + "Host : " + host + ":" + port + "\r\n" - + "User-Agent : Thrift/Haxe\r\n" - + "Transfer-Encoding : chunked\r\n" - + "content-type : application/x-thrift\r\n" - + "Accept : */*\r\n" - + "\r\n"); + this.output.writeUTF( "CONNECT " + resource + " HTTP/1.1\n" + + "Host : " + host + ":" + port + "\r\n" + + "User-Agent : Thrift/Haxe\r\n" + + "Transfer-Encoding : chunked\r\n" + + "content-type : application/x-thrift\r\n" + + "Accept : */*\r\n" + + "\r\n"); this.eventDispatcher.dispatchEvent(event); } http://git-wip-us.apache.org/repos/asf/thrift/blob/86f7350f/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx index 036b9f5..ad028dd 100644 --- a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx +++ b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx @@ -23,7 +23,7 @@ import org.apache.thrift.TException; class TTransportException extends TException { - // WARNING: These are subject to be extended in the future, so we can't use enums + // WARNING: These are subject to be extended in the future, so we can't use enums // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var NOT_OPEN : Int = 1;
