Repository: thrift Updated Branches: refs/heads/master b3b7d0457 -> bbd6fd777
THRIFT-3076 Compatibility with Haxe 3.2.0 Client: Haxe Patch: Jens Geyer This closes #510 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/bbd6fd77 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/bbd6fd77 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/bbd6fd77 Branch: refs/heads/master Commit: bbd6fd777319773b45b258b3ec9e49516a2ce4aa Parents: b3b7d04 Author: Jens Geyer <[email protected]> Authored: Sat May 30 19:33:44 2015 +0200 Committer: Jens Geyer <[email protected]> Committed: Sun May 31 00:39:41 2015 +0200 ---------------------------------------------------------------------- .../src/org/apache/thrift/helper/Int64Map.hx | 13 ++++---- .../apache/thrift/protocol/TCompactProtocol.hx | 1 - lib/haxe/test/Makefile.am | 11 ++++--- test/haxe/Makefile.am | 7 +++-- test/haxe/src/TestClient.hx | 33 +++++++++++++------- tutorial/haxe/Makefile.am | 5 ++- 6 files changed, 44 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/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 e648b75..8845fd0 100644 --- a/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx +++ b/lib/haxe/src/org/apache/thrift/helper/Int64Map.hx @@ -52,9 +52,9 @@ class Int64Map<T> implements IMap< Int64, T> { private function GetLowMap( key : haxe.Int64, canCreate : Bool) : IntMap< T> { #if( haxe_ver < 3.2) - return GetSubMap( Int64.getHigh(key), false); + return GetSubMap( Int64.getHigh(key), canCreate); #else - return GetSubMap( key.high, false); + return GetSubMap( key.high, canCreate); #end } @@ -70,10 +70,10 @@ class Int64Map<T> implements IMap< Int64, T> { private function NullCheck( key : haxe.Int64) : Bool { #if( haxe_ver < 3.2) - return (key != null); + return (key != null); #else - return false; // In64 is not nullable anymore (it never really was) - #end + return true; // Int64 is not nullable anymore (it never really was) + #end }; @@ -183,9 +183,10 @@ class Int64Map<T> implements IMap< Int64, T> { if( first) { first = false; } else { - result += ", "; + result += ","; } + result += " "; var value = this.get(key); result += Int64.toStr(key) + ' => $value'; } http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/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 e945789..c4d0ced 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx @@ -700,7 +700,6 @@ class TCompactProtocol implements TProtocol { try { return tcompactTypeToType[type]; - throw "fuck"; } catch ( e : Dynamic) { http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/lib/haxe/test/Makefile.am ---------------------------------------------------------------------- diff --git a/lib/haxe/test/Makefile.am b/lib/haxe/test/Makefile.am index 91cfc90..7d29f81 100644 --- a/lib/haxe/test/Makefile.am +++ b/lib/haxe/test/Makefile.am @@ -36,9 +36,12 @@ gen-haxe/thrift/test/BenchmarkService.hx: $(BENCHMARK) all-local: $(BIN_CPP) -$(BIN_CPP): gen-haxe/thrift/test/ThriftTest.hx \ - gen-haxe/thrift/test/Aggr.hx \ - gen-haxe/thrift/test/BenchmarkService.hx +$(BIN_CPP): \ + src/*.hx \ + ../src/org/apache/thrift/**/*.hx \ + gen-haxe/thrift/test/ThriftTest.hx \ + gen-haxe/thrift/test/Aggr.hx \ + gen-haxe/thrift/test/BenchmarkService.hx $(HAXE) --cwd . cpp.hxml @@ -49,7 +52,7 @@ $(BIN_CPP): gen-haxe/thrift/test/ThriftTest.hx \ # $(HAXE) --cwd . javascript # $(HAXE) --cwd . neko # $(HAXE) --cwd . php -# $(HAXE) --cwd . python # needs Haxe 3.1.4 +# $(HAXE) --cwd . python # needs Haxe 3.2.0 clean-local: http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/test/haxe/Makefile.am ---------------------------------------------------------------------- diff --git a/test/haxe/Makefile.am b/test/haxe/Makefile.am index 1e537d3..37ccfc3 100644 --- a/test/haxe/Makefile.am +++ b/test/haxe/Makefile.am @@ -28,7 +28,10 @@ gen-haxe/thrift/test/ThriftTest.hx: $(THRIFTTEST) all-local: $(BIN_CPP) -$(BIN_CPP): gen-haxe/thrift/test/ThriftTest.hx +$(BIN_CPP): \ + src/*.hx \ + ../../lib/haxe/src/org/apache/thrift/**/*.hx \ + gen-haxe/thrift/test/ThriftTest.hx $(HAXE) --cwd . cpp.hxml @@ -39,7 +42,7 @@ $(BIN_CPP): gen-haxe/thrift/test/ThriftTest.hx # $(HAXE) --cwd . javascript # $(HAXE) --cwd . neko # $(HAXE) --cwd . php -# $(HAXE) --cwd . python # needs Haxe 3.1.4 +# $(HAXE) --cwd . python # needs Haxe 3.2.0 clean-local: http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/test/haxe/src/TestClient.hx ---------------------------------------------------------------------- diff --git a/test/haxe/src/TestClient.hx b/test/haxe/src/TestClient.hx index 5193c47..8e43c76 100644 --- a/test/haxe/src/TestClient.hx +++ b/test/haxe/src/TestClient.hx @@ -92,8 +92,8 @@ class TestResults { public function PrintSummary() : Void { var total = successCnt + errorCnt; - var sp = (100 * successCnt) / total; - var ep = (100 * errorCnt) / total; + var sp = Math.round((1000 * successCnt) / total) / 10; + var ep = Math.round((1000 * errorCnt) / total) / 10; trace('==========================='); trace('Tests executed $total'); @@ -134,17 +134,17 @@ class TestClient { exitCode = rslt.CalculateExitCode(); } - difft = Timer.stamp() - difft; + difft = Math.round( 1000 * (Timer.stamp() - difft)) / 1000; trace('total test time: $difft seconds'); } catch (e : TException) { - trace('$e'); + trace('TException: $e'); exitCode = 0xFF; } catch (e : Dynamic) { - trace('$e'); + trace('Exception: $e'); exitCode = 0xFF; } @@ -219,10 +219,12 @@ class TestClient { protocol = new TCompactProtocol(transport); } - - // run the test code + // some quick and basic unit tests HaxeBasicsTest( args, rslt); ModuleUnitTests( args, rslt); + + // now run the test code + trace('- ${args.numIterations} iterations'); for( i in 0 ... args.numIterations) { ClientTest( transport, protocol, args, rslt); } @@ -250,6 +252,9 @@ class TestClient { map32.set( 0, -123); map64.set( Int64.make(0,0), -123); + //trace('map32 = $map32'); + //trace('map64 = $map64'); + rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10"); rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11"); rslt.Expect( map32.exists( -517) == map64.exists( Int64.neg(Int64.make(0,517))), "Int64Map<Int32> Test #12"); @@ -385,12 +390,12 @@ class TestClient { } catch (e : TException) { - trace('$e'); + rslt.Expect( false, 'unable to open transport: $e'); return; } catch (e : Dynamic) { - trace('$e'); + rslt.Expect( false, 'unable to open transport: $e'); return; } @@ -726,10 +731,14 @@ class TestClient { var pos = mm.get(4); var neg = mm.get(-4); rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)"); - for (i in 0 ... 5) { + for (i in 1 ... 5) { rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i'); rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i'); - } + } + rslt.Expect( ! pos.exists(0), '!pos.exists(0)'); + rslt.Expect( ! neg.exists(-0), '!neg.exists(-0)'); + rslt.Expect( ! pos.exists(42), '!pos.exists(42)'); + rslt.Expect( ! neg.exists(-42), '!neg.exists(-42)'); rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS); @@ -877,7 +886,7 @@ class TestClient { for ( k in 0 ... 1000) { client.testVoid(); } - difft = Timer.stamp() - difft; + difft = Math.round( 1000 * (Timer.stamp() - difft)) / 1000; trace('$difft ms per testVoid() call'); } } http://git-wip-us.apache.org/repos/asf/thrift/blob/bbd6fd77/tutorial/haxe/Makefile.am ---------------------------------------------------------------------- diff --git a/tutorial/haxe/Makefile.am b/tutorial/haxe/Makefile.am index a781b5a..c3c5204 100644 --- a/tutorial/haxe/Makefile.am +++ b/tutorial/haxe/Makefile.am @@ -26,7 +26,10 @@ all-local: bin/Main-debug check: gen-haxe/tutorial/calculator.hx -bin/Main-debug: gen-haxe/tutorial/calculator.hx +bin/Main-debug: \ + src/*.hx \ + ../../lib/haxe/src/org/apache/thrift/**/*.hx \ + gen-haxe/tutorial/calculator.hx $(HAXE) --cwd . cpp.hxml tutorialserver: all
