THRIFT-5589 Haxe compiler/runtime fixes
Client: hx
Patch: Jens Geyer
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/FieldMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/FieldMetaData.hx
deleted file mode 100644
index 26db113..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/FieldMetaData.hx
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-import flash.utils.Dictionary;
-
-/**
-* This class is used to store meta data about thrift fields. Every field in a
-* a struct should have a corresponding instance of this class describing it.
-*
-*/
-class FieldMetaData {
-
-  public var fieldName : String;
-  public var requirementType : Int;
-  public var valueMetaData:FieldValueMetaData;
-
-  private static var structMap:Dictionary = new Dictionary();
-
-  public function FieldMetaData(name : String, req : Int, vMetaData:FieldValueMetaData) {
-    this.fieldName = name;
-    this.requirementType = req;
-    this.valueMetaData = vMetaData;
-  }
-
-  public static function addStructMetaDataMap(sClass:Class, map:Dictionary) : Void{
-    structMap[sClass] = map;
-  }
-
-  /**
-   * Returns a map with metadata (i.e. instances of FieldMetaData) that
-   * describe the fields of the given class.
-   *
-   * @param sClass The TBase class for which the metadata map is requested
-   */
-  public static function getStructMetaDataMap(sClass:Class):Dictionary {
-    return structMap[sClass];
-  }
-}
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/FieldValueMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/FieldValueMetaData.hx
deleted file mode 100644
index 8879d91..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/FieldValueMetaData.hx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-import org.apache.thrift.protocol.TType;
-
-/**
- * FieldValueMetaData and collection of subclasses to store metadata about
- * the value(s) of a field
- */
-class FieldValueMetaData {
-
-  public var type : Int;
-
-  public function FieldValueMetaData(type : Int) {
-    this.type = type;
-  }
-
-  public function isStruct() : Bool {
-    return type == TType.STRUCT;
-  }
-
-  public function isContainer() : Bool {
-    return type == TType.LIST || type == TType.MAP || type == TType.SET;
-  }
-}
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/ListMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/ListMetaData.hx
deleted file mode 100644
index 40ca31b..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/ListMetaData.hx
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-class ListMetaData extends FieldValueMetaData {
-
-    public var elemMetaData:FieldValueMetaData;
-
-    public function ListMetaData(type : Int, eMetaData:FieldValueMetaData) {
-      super(type);
-      this.elemMetaData = eMetaData;
-    }
-}
- 
\ No newline at end of file
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/MapMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/MapMetaData.hx
deleted file mode 100644
index 5463e62..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/MapMetaData.hx
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-class MapMetaData extends FieldValueMetaData {
-
-    public var keyMetaData:FieldValueMetaData;
-    public var valueMetaData:FieldValueMetaData;
-
-    public function MapMetaData(type : Int, kMetaData:FieldValueMetaData, vMetaData:FieldValueMetaData) {
-      super(type);
-      this.keyMetaData = kMetaData;
-      this.valueMetaData = vMetaData;
-    }
-}
-   
\ No newline at end of file
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/SetMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/SetMetaData.hx
deleted file mode 100644
index a3367f4..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/SetMetaData.hx
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-class SetMetaData extends FieldValueMetaData {
-
-    public var elemMetaData:FieldValueMetaData;
-
-    public function SetMetaData(type : Int, eMetaData:FieldValueMetaData) {
-      super(type);
-      this.elemMetaData = eMetaData;
-    }
-}
diff --git a/lib/haxe/src/org/apache/thrift/meta_data/StructMetaData.hx b/lib/haxe/src/org/apache/thrift/meta_data/StructMetaData.hx
deleted file mode 100644
index 1822dd3..0000000
--- a/lib/haxe/src/org/apache/thrift/meta_data/StructMetaData.hx
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data;
-
-class StructMetaData extends FieldValueMetaData {
-
-    public var structClass:Class;
-
-    public function StructMetaData(type : Int, sClass:Class) {
-      super(type);
-      this.structClass = sClass;
-    }
-}
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolDecorator.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolDecorator.hx
index 011f42b..08598e6 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolDecorator.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolDecorator.hx
@@ -135,6 +135,10 @@
         wrapped.writeBinary( value);
     }
 
+    public function writeUuid(value : String ) : Void {
+        wrapped.writeUuid( value);
+    }
+
     public function readMessageBegin() : TMessage {
         return wrapped.readMessageBegin();
     }
@@ -216,6 +220,10 @@
         return wrapped.readBinary();
     }
 
+    public function readUuid() : String {
+        return wrapped.readUuid();
+    }
+
     public function IncrementRecursionDepth() : Void {
         return wrapped.IncrementRecursionDepth();
     }
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx b/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
index cd8ad17..0130cd2 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
@@ -18,6 +18,7 @@
  */
 
 package org.apache.thrift.transport;
+#if sys
 
 import haxe.io.Bytes;
 import haxe.io.BytesBuffer;
@@ -98,4 +99,5 @@
     }
 
 }
- 
\ No newline at end of file
+ 
+#end
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
index cc34ec4..fe07be9 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
@@ -18,6 +18,7 @@
  */
 
 package org.apache.thrift.transport;
+#if swf
 
 import flash.errors.EOFError;
 import flash.events.Event;
@@ -35,13 +36,13 @@
 import flash.events.EventDispatcher;
 
 
-    /**
-     * HTTP implementation of the TTransport interface. Used for working with a
-     * Thrift web services implementation.
-     * Unlike Http Client, it uses a single POST, and chunk-encoding to transfer all messages.
-     */
+/**
+ * HTTP implementation of the TTransport interface. Used for working with a
+ * Thrift web services implementation.
+ * Unlike Http Client, it uses a single POST, and chunk-encoding to transfer all messages.
+ */
 
-public class TFullDuplexHttpClient extends TEndpointTransport
+class TFullDuplexHttpClient extends TEndpointTransport
 {
 	private var socket : Socket = null;
 	private var host  :  String;
@@ -163,9 +164,9 @@
 	{
 		var debug  :  String = "BUFFER >>";
 		var i  :  Int;
-		for (i = 0; i < buf.length; i++)
+		for (i in 0 ... buf.length)
 		{
-			debug += buf[i] as int;
+			debug += buf.get(i);
 			debug += " ";
 		}
 
@@ -254,4 +255,6 @@
 		return (this.socket != null) && this.socket.connected;
 	}
 
-}
\ No newline at end of file
+}
+
+#end
diff --git a/lib/haxe/src/org/apache/thrift/transport/TSocket.hx b/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
index a743543..2e154c3 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
@@ -213,7 +213,7 @@
         #elseif js
 
         var data = obuffer.getBytes();
-        var outbuf = new js.html.Int8Array(data.length);
+        var outbuf = new js.lib.Int8Array(data.length);
         var len = 0;
         while( len < data.length) {
             outbuf.set( [data.get(len)], len);
diff --git a/lib/haxe/test/HaxeTests.hxproj b/lib/haxe/test/HaxeTests.hxproj
index 3beed82..7ad2392 100644
--- a/lib/haxe/test/HaxeTests.hxproj
+++ b/lib/haxe/test/HaxeTests.hxproj
@@ -4,11 +4,11 @@
   <output>
     <movie outputType="Application" />
     <movie input="" />
-    <movie path="bin/HaxeTests" />
+    <movie path="bin\HaxeTests" />
     <movie fps="30" />
     <movie width="800" />
     <movie height="600" />
-    <movie version="1" />
+    <movie version="0" />
     <movie minorVersion="0" />
     <movie platform="C++" />
     <movie background="#FFFFFF" />
@@ -17,7 +17,7 @@
   <classpaths>
     <class path="src" />
     <class path="gen-haxe" />
-    <class path="../src" />
+    <class path="..\src" />
   </classpaths>
   <!-- Build options -->
   <build>
@@ -26,11 +26,11 @@
     <option noInlineOnDebug="False" />
     <option mainClass="Main" />
     <option enabledebug="False" />
-    <option additional="" />
+    <option additional="--macro include('org.apache.thrift', true)&#xA;--macro include('thrift', true)" />
   </build>
   <!-- haxelib libraries -->
   <haxelib>
-    <!-- example: <library name="..." /> -->
+    <library name="uuid" />
   </haxelib>
   <!-- Class files to compile (other referenced classes will automatically be included) -->
   <compileTargets>
diff --git a/lib/haxe/test/php.hxml b/lib/haxe/test/php.hxml
index 14f2b2d..9fc23b6 100644
--- a/lib/haxe/test/php.hxml
+++ b/lib/haxe/test/php.hxml
@@ -27,7 +27,7 @@
 
 #PHP target
 -php bin/php/
---php-front Main-debug.php
+#--php-front Main-debug.php
 
 #Add debug information
 -debug
diff --git a/lib/haxe/test/src/MultiplexTest.hx b/lib/haxe/test/src/MultiplexTest.hx
index 3818b66..3e2786d 100644
--- a/lib/haxe/test/src/MultiplexTest.hx
+++ b/lib/haxe/test/src/MultiplexTest.hx
@@ -43,12 +43,12 @@
 import Error;
 
 
-class BenchmarkServiceHandler implements BenchmarkService
+class BenchmarkServiceHandler implements BenchmarkService_service
 {
     public function new() {
     }
 
-    public function fibonacci(n : haxe.Int32) : haxe.Int32 {
+	public function fibonacci(n : haxe.Int32) : haxe.Int32 {
         trace('Benchmark.fibonacci($n)');
         var next : Int;
         var prev   = 0;
@@ -60,12 +60,12 @@
             result = next;
             --n;
         }
-        return result;
+		return result;
     }
 }
 
 
-class AggrServiceHandler implements Aggr
+class AggrServiceHandler implements Aggr_service
 {
     private var values : List<haxe.Int32> = new List<haxe.Int32>();
 
@@ -91,7 +91,7 @@
     private inline static var NAME_AGGR             : String  = "Aggr";
 
 
-    public static override function Run(server : Bool) : Void {
+    public static function Run(server : Bool) : Void {
         if ( server) {
             RunMultiplexServer();
         } else {
@@ -102,13 +102,13 @@
 
 
     // run the multiplex server
-    public static override function RunMultiplexServer() : Void  {
+    public static function RunMultiplexServer() : Void  {
        try
        {
-            var benchHandler : BenchmarkService = new BenchmarkServiceHandler();
+            var benchHandler : BenchmarkService_service = new BenchmarkServiceHandler();
             var benchProcessor : TProcessor = new BenchmarkServiceProcessor( benchHandler);
 
-            var aggrHandler : Aggr = new AggrServiceHandler();
+            var aggrHandler : Aggr_service = new AggrServiceHandler();
             var aggrProcessor : TProcessor = new AggrProcessor( aggrHandler);
 
             var multiplex : TMultiplexedProcessor = new TMultiplexedProcessor();
@@ -137,7 +137,7 @@
 
 
     // run multiplex client against multiplex server
-    public static override function RunMultiplexClient() : Void  {
+    public static function RunMultiplexClient() : Void  {
         try
         {
             var trans : TTransport;
@@ -187,7 +187,7 @@
 
 
     // run non-multiplex client against multiplex server to test default fallback
-    public static override function RunDefaultClient() : Void  {
+    public static function RunDefaultClient() : Void  {
         try
         {
             var trans : TTransport;
diff --git a/lib/haxe/test/src/StreamTest.hx b/lib/haxe/test/src/StreamTest.hx
index 244f1ea..9b8706a 100644
--- a/lib/haxe/test/src/StreamTest.hx
+++ b/lib/haxe/test/src/StreamTest.hx
@@ -48,8 +48,9 @@
 
     public static function WriteData() : Xtruct
     {
+		var config : TConfiguration = new TConfiguration();
         var stream : TStream = new TFileStream( tmpfile, CreateNew);
-        var trans : TTransport = new TStreamTransport( null, stream);
+        var trans : TTransport = new TStreamTransport( null, stream, config);
         var prot = new TJSONProtocol( trans);
 
         var data = MakeTestData();
@@ -61,8 +62,9 @@
 
     public static function ReadData() : Xtruct
     {
+		var config : TConfiguration = new TConfiguration();
         var stream : TStream = new TFileStream( tmpfile, Read);
-        var trans : TTransport = new TStreamTransport( stream, null);
+        var trans : TTransport = new TStreamTransport( stream, null, config);
         var prot = new TJSONProtocol( trans);
 
         var data : Xtruct = new Xtruct();
@@ -72,7 +74,7 @@
         return data;
     }
 
-    public static override function Run(server : Bool) : Void
+    public static function Run(server : Bool) : Void
     {
         try {
             var written = WriteData();