THRIFT-5593 Implement uuid for Haxe
Client: hx
Patch: Jens Geyer

Relies on https://github.com/flashultra/uuid/issues/4 being fixed, thus may require using the most recent uuid package from Github instead of the Haxelib package.
diff --git a/test/haxe/TestClientServer.hxproj b/test/haxe/TestClientServer.hxproj
index 30fecf3..6750415 100644
--- a/test/haxe/TestClientServer.hxproj
+++ b/test/haxe/TestClientServer.hxproj
@@ -8,9 +8,9 @@
     <movie fps="30" />
     <movie width="800" />
     <movie height="600" />
-    <movie version="1" />
+    <movie version="0" />
     <movie minorVersion="0" />
-    <movie platform="C++" />
+    <movie platform="C#" />
     <movie background="#FFFFFF" />
   </output>
   <!-- Other classes to be compiled into your SWF -->
@@ -30,7 +30,7 @@
   </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/test/haxe/cpp.hxml b/test/haxe/cpp.hxml
index 6adb52d..1b581a9 100644
--- a/test/haxe/cpp.hxml
+++ b/test/haxe/cpp.hxml
@@ -31,11 +31,11 @@
 #To produce 64 bit binaries the file should define the HXCPP_M64 compile variable:
 #-D HXCPP_M64
 
+# libs
+-lib uuid
+
 #Add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/csharp.hxml b/test/haxe/csharp.hxml
index 295c017..8dd891c 100644
--- a/test/haxe/csharp.hxml
+++ b/test/haxe/csharp.hxml
@@ -26,13 +26,13 @@
 -main Main
 
 #CSHARP target
--cs bin/Tutorial.exe
+-cs bin/ThriftTest.exe
+
+# libs
+-lib uuid
 
 #Add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/flash.hxml b/test/haxe/flash.hxml
index a1f0568..e60515e 100644
--- a/test/haxe/flash.hxml
+++ b/test/haxe/flash.hxml
@@ -26,7 +26,10 @@
 -main Main
 
 #Flash target
--swf bin/Tutorial.swf
+-swf bin/ThriftTest.swf
+
+# libs
+-lib uuid
 
 #Add debug information
 -debug
@@ -35,7 +38,4 @@
 # --macro allowPackage("sys")
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/java.hxml b/test/haxe/java.hxml
index c615565..807a92a 100644
--- a/test/haxe/java.hxml
+++ b/test/haxe/java.hxml
@@ -26,13 +26,13 @@
 -main Main
 
 #Java target
--java bin/Tutorial.jar
+-java bin/ThriftTest.jar
+
+# libs
+-lib uuid
 
 #Add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/javascript.hxml b/test/haxe/javascript.hxml
index b2b3876..892e84b 100644
--- a/test/haxe/javascript.hxml
+++ b/test/haxe/javascript.hxml
@@ -26,7 +26,7 @@
 -main Main
 
 #JavaScript target
--js bin/Tutorial.js
+-js bin/ThriftTest.js
 
 #You can use -D source-map-content (requires Haxe 3.1+) to have the .hx 
 #files directly embedded into the map file, this way you only have to 
@@ -34,11 +34,11 @@
 #you modify your .hx files.
 -D source-map-content
 
+# libs
+-lib uuid
+
 #Generate source map and add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/neko.hxml b/test/haxe/neko.hxml
index 6161f69..20c1ea6 100644
--- a/test/haxe/neko.hxml
+++ b/test/haxe/neko.hxml
@@ -26,13 +26,13 @@
 -main Main
 
 #neko target
--neko bin/Tutorial.n
+-neko bin/ThriftTest.n
+
+# libs
+-lib uuid
 
 #Add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/php-web-server.hxml b/test/haxe/php-web-server.hxml
index 102ae97..4c121fb 100644
--- a/test/haxe/php-web-server.hxml
+++ b/test/haxe/php-web-server.hxml
@@ -39,7 +39,4 @@
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
diff --git a/test/haxe/php.hxml b/test/haxe/php.hxml
index 4edb86c..6d44227 100644
--- a/test/haxe/php.hxml
+++ b/test/haxe/php.hxml
@@ -36,7 +36,4 @@
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
diff --git a/test/haxe/python.hxml b/test/haxe/python.hxml
index f2c19fa..0079fdb 100644
--- a/test/haxe/python.hxml
+++ b/test/haxe/python.hxml
@@ -26,13 +26,13 @@
 -main Main
 
 #Python target
--python bin/Tutorial.py
+-python bin/ThriftTest.py
+
+# libs
+-lib uuid
 
 #Add debug information
 -debug
 
 #dead code elimination : remove unused code
-#"-dce no" : do not remove unused code
-#"-dce std" : remove unused code in the std lib (default)
-#"-dce full" : remove all unused code
 -dce full
\ No newline at end of file
diff --git a/test/haxe/src/TestClient.hx b/test/haxe/src/TestClient.hx
index 579dc00..3a07562 100644
--- a/test/haxe/src/TestClient.hx
+++ b/test/haxe/src/TestClient.hx
@@ -27,6 +27,8 @@
 import haxe.ds.StringMap;
 import haxe.ds.ObjectMap;
 
+import uuid.Uuid;
+
 import org.apache.thrift.*;
 import org.apache.thrift.helper.*;
 import org.apache.thrift.protocol.*;
@@ -366,6 +368,14 @@
             rslt.Expect( false, 'ZigZag.UnitTest: $e  Test #101');
         }
 
+        try {
+            UuidHelper.UnitTest();
+            rslt.Expect( true, 'UuidHelper.UnitTest  Test #102');
+        }
+        catch( e : Dynamic) {
+            rslt.Expect( false, 'UuidHelper.UnitTest: $e  Test #102');
+        }
+
         #end
     }
 
@@ -537,6 +547,19 @@
         trace(' = $dub');
         rslt.Expect(dub == 5.325098235, '$dub == 5.325098235');
 
+
+		var uuidOut : String = UuidHelper.CanonicalUuid("{00112233-4455-6677-8899-AABBCCDDEEFF}");
+        trace('testUuid(${uuidOut}');
+        try {
+            var uuidIn = client.testUuid(uuidOut);
+            trace('testUuid() = ${uuidIn}');
+            rslt.Expect( uuidIn == uuidOut, '${uuidIn} == ${uuidOut}');
+        }
+        catch (e : TApplicationException) {
+            trace('testUuid(${uuidOut}): '+e.errorMsg);  // may not be supported by the server
+        }
+
+        
         var binOut = PrepareTestData(true);
         trace('testBinary('+BytesToHex(binOut)+')');
         try {
diff --git a/test/haxe/src/TestServerHandler.hx b/test/haxe/src/TestServerHandler.hx
index 0e19105..34e471b 100644
--- a/test/haxe/src/TestServerHandler.hx
+++ b/test/haxe/src/TestServerHandler.hx
@@ -25,6 +25,7 @@
 import org.apache.thrift.server.*;
 import org.apache.thrift.meta_data.*;
 import org.apache.thrift.helper.*;
+import uuid.Uuid;
 
 import haxe.Int32;
 import haxe.Int64;
@@ -147,6 +148,19 @@
     }
 
     /**
+     * Prints 'testUuid("%s")' 
+     * @param Uuid  thing - the uuid to print
+     * @return Uuid  - returns the uuid 'thing'
+     *
+     * @param thing
+     */
+    public function testUuid(thing : String) : String
+    {
+        trace('testUuid($thing)');
+        return thing;
+    }
+
+    /**
     * Prints 'testStruct("{%s}")' where thing has been formatted
     *  into a string of comma separated values
     * @param Xtruct thing - the Xtruct to print