THRIFT-3076 Compatibility with Haxe 3.2.0

Client: Haxe
Patch: Jens Geyer

This closes #510
This commit is contained in:
Jens Geyer 2015-05-30 19:33:44 +02:00
parent b3b7d0457a
commit bbd6fd7773
6 changed files with 44 additions and 26 deletions

View File

@ -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';
}

View File

@ -700,7 +700,6 @@ class TCompactProtocol implements TProtocol {
try
{
return tcompactTypeToType[type];
throw "fuck";
}
catch ( e : Dynamic)
{

View File

@ -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:

View File

@ -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:

View File

@ -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');
}
}

View File

@ -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