THRIFT-5370 Haxe 4 compatibility incl TConfiguration & MAX_MESSAGE_SIZE
Client: haxe
Patch: Jens Geyer

This closes #2349
diff --git a/test/haxe/Makefile.am b/test/haxe/Makefile.am
index 6c0483e..d37aaa7 100644
--- a/test/haxe/Makefile.am
+++ b/test/haxe/Makefile.am
@@ -34,6 +34,13 @@
 		../../lib/haxe/src/org/apache/thrift/**/*.hx \
 		gen-haxe/thrift/test/ThriftTest.hx
 	$(HAXE) --cwd .  cpp.hxml
+	
+#	$(HAXE) --cwd .  csharp
+#	$(HAXE) --cwd .  flash
+#	$(HAXE) --cwd .  java
+#	$(HAXE) --cwd .  javascript
+#	$(HAXE) --cwd .  neko
+#	$(HAXE) --cwd .  python
 
 $(BIN_PHP): \
 		src/*.hx \
@@ -49,15 +56,6 @@
 
 
 
-#TODO: other haxe targets
-#    $(HAXE)  --cwd .  csharp
-#    $(HAXE)  --cwd .  flash
-#    $(HAXE)  --cwd .  java
-#    $(HAXE)  --cwd .  javascript
-#    $(HAXE)  --cwd .  neko
-#    $(HAXE)  --cwd .  python  # needs Haxe 3.2.0
-
-
 clean-local:
 	$(RM) -r gen-haxe bin
 
diff --git a/test/haxe/TestClientServer.hxproj b/test/haxe/TestClientServer.hxproj
index 6696d80..44faa37 100644
--- a/test/haxe/TestClientServer.hxproj
+++ b/test/haxe/TestClientServer.hxproj
@@ -4,7 +4,7 @@
   <output>
     <movie outputType="Application" />
     <movie input="" />
-    <movie path="bin/TestClientServer" />
+    <movie path="bin\TestClientServer" />
     <movie fps="30" />
     <movie width="800" />
     <movie height="600" />
@@ -17,7 +17,7 @@
   <classpaths>
     <class path="src" />
     <class path="gen-haxe" />
-    <class path="../../lib/haxe/src" />
+    <class path="..\..\lib\haxe\src" />
   </classpaths>
   <!-- Build options -->
   <build>
diff --git a/test/haxe/make_all.bat b/test/haxe/make_all.bat
index eaeba89..966bfa5 100644
--- a/test/haxe/make_all.bat
+++ b/test/haxe/make_all.bat
@@ -30,16 +30,19 @@
 if errorlevel 1 goto STOP
 
 rem # invoke Haxe compiler for all targets
+rd .buildtemp /S /Q
 for %%a in (*.hxml) do (
-	rem * filter Python, as it is not supported by Haxe 3.1.3 (but will be in 3.1.4)
-	if not "%%a"=="python.hxml" (
-		echo --------------------------
-		echo Building %%a ...
-		echo --------------------------
-		haxe  --cwd .  %%a
-	)
+	echo --------------------------
+	echo Building %%a ...
+	echo --------------------------
+	haxe  --cwd .  %%a
+	if not exist ".buildtemp" mkdir ".buildtemp"
+	move bin ".buildtemp\%%a"
+	if errorlevel 1 pause
 )
 
+rd bin /S /Q
+rename .buildtemp bin
 
 echo.
 echo done.
diff --git a/test/haxe/php-web-server.hxml b/test/haxe/php-web-server.hxml
index 395a852..f628c3a 100644
--- a/test/haxe/php-web-server.hxml
+++ b/test/haxe/php-web-server.hxml
@@ -26,8 +26,8 @@
 -main Main
 
 #PHP target
--php bin/php-web-server/
---php-front Main-debug.php
+-php bin/php-web-server
+-D php-front=Main-debug.php
 
 #defines
 -D phpwebserver
diff --git a/test/haxe/php.hxml b/test/haxe/php.hxml
index 9651898..c3aa97f 100644
--- a/test/haxe/php.hxml
+++ b/test/haxe/php.hxml
@@ -26,8 +26,8 @@
 -main Main
 
 #PHP target
--php bin/php/
---php-front Main-debug.php
+-php bin/php
+-D php-front=Main-debug.php
 
 
 #Add debug information
diff --git a/test/haxe/src/Arguments.hx b/test/haxe/src/Arguments.hx
index 56e5253..023f250 100644
--- a/test/haxe/src/Arguments.hx
+++ b/test/haxe/src/Arguments.hx
@@ -92,7 +92,7 @@
     #if sys
 
     private static function GetHelp() : String {
-        var sProg = Path.withoutDirectory( Sys.executablePath());
+        var sProg = Path.withoutDirectory( Sys.programPath());
         return "\n"
             +sProg+"  [client|server]  [options]\n"
             +"\n"
diff --git a/test/haxe/src/TestClient.hx b/test/haxe/src/TestClient.hx
index 853319e..579dc00 100644
--- a/test/haxe/src/TestClient.hx
+++ b/test/haxe/src/TestClient.hx
@@ -35,7 +35,7 @@
 import org.apache.thrift.meta_data.*;
 
 #if cpp
-import cpp.vm.Thread;
+import sys.thread.Thread;
 #else
 // no thread support (yet)
 #end
diff --git a/test/haxe/src/TestServer.hx b/test/haxe/src/TestServer.hx
index 450c8f2..d44c68c 100644
--- a/test/haxe/src/TestServer.hx
+++ b/test/haxe/src/TestServer.hx
@@ -39,20 +39,24 @@
             switch( args.transport) {
             case socket:
                 trace("- socket port "+args.port);
+				#if (flash || html5 || js)
+				throw "Transport not supported on this platform";
+                #else
                 transport = new TServerSocket( args.port);
+				#end
             case http:
                 trace("- http");
-                #if !phpwebserver
-                  throw "HTTP server not implemented yet";
-                 //transport = new THttpServer( targetHost);
+                #if phpwebserver
+                transport = new TWrappingServerTransport( 
+					new TStreamTransport(
+						new TFileStream("php://input", Read),
+						new TFileStream("php://output", Append),
+						null
+					)
+				);
                 #else
-                transport =    new TWrappingServerTransport(
-                        new TStreamTransport(
-                          new TFileStream("php://input", Read),
-                          new TFileStream("php://output", Append)
-                          )
-                        );
-
+				throw "Transport not supported on this platform";
+                //transport = new THttpServer( targetHost);
                 #end
             default:
                 throw "Unhandled transport";
@@ -86,7 +90,7 @@
 
 
             // Processor
-            var handler = new TestServerHandler();
+            var handler : ThriftTest_service = new TestServerHandler();
             var processor = new ThriftTestProcessor(handler);
 
             // Simple Server
diff --git a/test/haxe/src/TestServerHandler.hx b/test/haxe/src/TestServerHandler.hx
index b8a2590..0e19105 100644
--- a/test/haxe/src/TestServerHandler.hx
+++ b/test/haxe/src/TestServerHandler.hx
@@ -36,7 +36,7 @@
 import thrift.test.*;  // generated code
 
 
-class TestServerHandler implements ThriftTest {
+class TestServerHandler implements ThriftTest_service {
 
     public var server:TServer;
 
@@ -465,8 +465,10 @@
     */
     public function testOneway(secondsToSleep:haxe.Int32):Void
     {
+		#if sys
         trace("testOneway(" + secondsToSleep + "), sleeping...");
         Sys.sleep(secondsToSleep);
+		#end
         trace("testOneway finished");
     }