From 22f3189ed74b4e70abc6cec0b6c1448770c46955 Mon Sep 17 00:00:00 2001 From: Sam MacPherson Date: Mon, 24 Mar 2014 20:01:13 -0400 Subject: [PATCH 001/209] https support for cpp --- std/haxe/Http.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/std/haxe/Http.hx b/std/haxe/Http.hx index b1ef74b600b..ed31d962399 100644 --- a/std/haxe/Http.hx +++ b/std/haxe/Http.hx @@ -412,8 +412,12 @@ class Http { #elseif java sock = new java.net.SslSocket(); #elseif hxssl + #if neko sock = new neko.tls.Socket(); #else + sock = new sys.ssl.Socket(); + #end + #else throw "Https is only supported with -lib hxssl"; #end } else From 58dacd94e5bc5ef6d69139175894909bed1e9180 Mon Sep 17 00:00:00 2001 From: Jonas Malaco Filho Date: Wed, 18 Mar 2015 20:56:46 -0300 Subject: [PATCH 002/209] Better support for BaseCode on the interpreter For now, don't use the base_encode and base_decode primitives in interp; they have only been implemented to handle hex and base64 variants. Instead, use the cross-platform encoding/decoding methods written in Haxe. --- std/haxe/crypto/BaseCode.hx | 8 ++++---- tests/unit/src/unit/TestMisc.hx | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/std/haxe/crypto/BaseCode.hx b/std/haxe/crypto/BaseCode.hx index 11b2e935f90..ebb8952da61 100644 --- a/std/haxe/crypto/BaseCode.hx +++ b/std/haxe/crypto/BaseCode.hx @@ -42,7 +42,7 @@ class BaseCode { } public function encodeBytes( b : haxe.io.Bytes ) : haxe.io.Bytes { - #if neko + #if (neko && !interp) return haxe.io.Bytes.ofData( base_encode(b.getData(),base.getData()) ); #else var nbits = this.nbits; @@ -79,7 +79,7 @@ class BaseCode { } public function decodeBytes( b : haxe.io.Bytes ) : haxe.io.Bytes { - #if neko + #if (neko && !interp) return haxe.io.Bytes.ofData( base_decode(b.getData(),base.getData()) ); #else var nbits = this.nbits; @@ -109,7 +109,7 @@ class BaseCode { } public function encodeString( s : String ) { - #if neko + #if (neko && !interp) return neko.NativeString.toString( base_encode(neko.NativeString.ofString(s),base.getData()) ); #else return encodeBytes(haxe.io.Bytes.ofString(s)).toString(); @@ -117,7 +117,7 @@ class BaseCode { } public function decodeString( s : String ) { - #if neko + #if (neko && !interp) return neko.NativeString.toString( base_decode(neko.NativeString.ofString(s),base.getData()) ); #else return decodeBytes(haxe.io.Bytes.ofString(s)).toString(); diff --git a/tests/unit/src/unit/TestMisc.hx b/tests/unit/src/unit/TestMisc.hx index b7ca5ab548a..fc8045e1ad2 100644 --- a/tests/unit/src/unit/TestMisc.hx +++ b/tests/unit/src/unit/TestMisc.hx @@ -309,9 +309,15 @@ class TestMisc extends Test { } function testBaseCode() { + // alternative base64 var b = new haxe.crypto.BaseCode(haxe.io.Bytes.ofString("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-")); eq( b.encodeString("Héllow"), "iceFr6NLtM" ); eq( b.decodeString("iceFr6NLtM"), "Héllow" ); + + // base32-hex + var b = new haxe.crypto.BaseCode(haxe.io.Bytes.ofString("0123456789ABCDEFGHIJKLMNOPQRSTUV")); + eq( b.encodeString("foo"), "CPNMU" ); + eq( b.decodeString("CPNMU"), "foo" ); } function testUrlEncode() { From d73d9f76a2ceba18f7c63370d9e94727034fd215 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 20 Mar 2015 15:11:55 +0800 Subject: [PATCH 003/209] [TravisCI] do not build for tags (close #4058) --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7cf46c6b7d9..3034a18e606 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,12 @@ script: - haxe -neko RunCi.n -main RunCi -lib hx-yaml - neko RunCi.n +branches: + except: + # A hack to prevent building for tags, assuming they all start with a number. + # https://github.com/travis-ci/travis-ci/issues/1532 + - /^[0-9]/ + notifications: webhooks: urls: From 2e6a795207a45d2b53283940cd4ab2bb636d21f2 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 20 Mar 2015 15:18:43 +0800 Subject: [PATCH 004/209] [AppVeyor] do not build for tags (see #4058) [ci skip] --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 23616cdc4b8..3f6ff43a299 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,6 +22,8 @@ environment: # WODI_ARCH: 64 # MINGW_ARCH: x86_64 +skip_tags: true + init: - 'echo System architecture: %PLATFORM%' From 74063437f58e511e0caebd5d0fac86dc8506bb21 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 20 Mar 2015 12:44:37 +0300 Subject: [PATCH 005/209] add test for haxe.CallStack.exceptionStack inside a catch block --- tests/unit/src/unitstd/haxe/CallStack.unit.hx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/src/unitstd/haxe/CallStack.unit.hx b/tests/unit/src/unitstd/haxe/CallStack.unit.hx index 3e527f14e18..9ddad72c17f 100644 --- a/tests/unit/src/unitstd/haxe/CallStack.unit.hx +++ b/tests/unit/src/unitstd/haxe/CallStack.unit.hx @@ -3,3 +3,10 @@ Std.is(stack, Array) == true; var stack = haxe.CallStack.exceptionStack(); Std.is(stack, Array) == true; + +try { + throw false; +} catch (_:Dynamic) { + var stack = haxe.CallStack.exceptionStack(); + Std.is(stack, Array) == true; +} From 0c4b1910e1ec3bda2b9fd0fea2ea8fa42a840ee8 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 10:52:37 +0100 Subject: [PATCH 006/209] add tests for Bytes.fastGet (closes #4032) --- tests/unit/src/unit/TestBytes.hx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/unit/src/unit/TestBytes.hx b/tests/unit/src/unit/TestBytes.hx index 759a8408073..47c6717e819 100644 --- a/tests/unit/src/unit/TestBytes.hx +++ b/tests/unit/src/unit/TestBytes.hx @@ -1,5 +1,7 @@ package unit; +import haxe.io.Bytes.fastGet as fget; + class TestBytes extends Test { function test() { @@ -103,4 +105,25 @@ class TestBytes extends Test { //readAll eq(input.readAll().toString(), "One é accent"); } -} + + function testFastGet() { + var b = haxe.io.Bytes.alloc(10); + var bd = b.getData(); + for( i in 0...10 ) + eq(fget(bd, i),0); + b.set(1,20); + eq(fget(bd, 1), 20); + b.set(1,0xF756); + eq(fget(bd, 1), 0x56); + var b2 = haxe.io.Bytes.ofString("ABCD"); + var bd2 = b2.getData(); + eq(fget(bd2, 0), "A".code); + eq(fget(bd2, 1), "B".code); + eq(fget(bd2, 2), "C".code); + eq(fget(bd2, 3), "D".code); + var b3 = haxe.io.Bytes.ofString("é"); + var bd3 = b3.getData(); + eq(fget(bd3, 0), 0xC3); + eq(fget(bd3, 1), 0xA9); + } +} \ No newline at end of file From 5dea112bbc1b534049dfcaa7f494fe839a2863c6 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 11:53:58 +0100 Subject: [PATCH 007/209] [ci] activate android 4 testing again --- tests/unit/src/RunSauceLabs.hx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/src/RunSauceLabs.hx b/tests/unit/src/RunSauceLabs.hx index 8ee814a4c9b..b878b528a02 100644 --- a/tests/unit/src/RunSauceLabs.hx +++ b/tests/unit/src/RunSauceLabs.hx @@ -116,12 +116,12 @@ class RunSauceLabs { "version": "8.1", "device-orientation": "portrait" }, - //{ - //"browserName": "android", - //"platform": "Linux", - //"version": "4.0", - //"device-orientation": "portrait" - //}, + { + "browserName": "android", + "platform": "Linux", + "version": "4.0", + "device-orientation": "portrait" + }, { "browserName": "android", "platform": "Linux", From f518e14616b142326d88f1a49eb35b3659704199 Mon Sep 17 00:00:00 2001 From: frabbit Date: Fri, 20 Mar 2015 14:16:14 +0100 Subject: [PATCH 008/209] [js] guard CallStack.exceptionStack when called without previous error --- std/haxe/CallStack.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/std/haxe/CallStack.hx b/std/haxe/CallStack.hx index f3af3c8eba7..6ec69a678f7 100644 --- a/std/haxe/CallStack.hx +++ b/std/haxe/CallStack.hx @@ -40,6 +40,7 @@ class CallStack { static var lastException:js.Error; static function getStack(e:js.Error):Array { + if (e == null) return []; // https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi var oldValue = (untyped Error).prepareStackTrace; (untyped Error).prepareStackTrace = function (error, callsites :Array) { From 47778f99f24d6a817cad590e4c072bc999e69e46 Mon Sep 17 00:00:00 2001 From: frabbit Date: Fri, 20 Mar 2015 14:40:41 +0100 Subject: [PATCH 009/209] add test for calling CallStack exceptionStack without previous error --- tests/unit/src/unitstd/haxe/CallStack.unit.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/src/unitstd/haxe/CallStack.unit.hx b/tests/unit/src/unitstd/haxe/CallStack.unit.hx index 9ddad72c17f..641e95b5b13 100644 --- a/tests/unit/src/unitstd/haxe/CallStack.unit.hx +++ b/tests/unit/src/unitstd/haxe/CallStack.unit.hx @@ -10,3 +10,11 @@ try { var stack = haxe.CallStack.exceptionStack(); Std.is(stack, Array) == true; } +#if js +var old = @:privateAccess haxe.CallStack.lastException; +@:privateAccess haxe.CallStack.lastException = null; +var stack = haxe.CallStack.exceptionStack(); +Std.is(stack, Array) == true; +stack.length == 0; +@:privateAccess haxe.CallStack.lastException = old; +#end \ No newline at end of file From d464df1a66b1c502dc97b327d172144d9e942f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Fri, 20 Mar 2015 13:34:53 -0300 Subject: [PATCH 010/209] [java/cs] Save output files as binary. See #3759 --- gencommon.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencommon.ml b/gencommon.ml index af18e116984..7993e3423ac 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -975,7 +975,7 @@ let write_file gen w source_dir path extension out_files = end else true in if should_write then begin - let f = open_out s_path in + let f = open_out_bin s_path in output_string f contents; close_out f end; From f3d1597898201c72623956c118d4eeb258f47f9c Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Fri, 20 Mar 2015 13:01:20 -0400 Subject: [PATCH 011/209] Use Rest for varargs in js.html. --- std/js/html/Console.hx | 30 +++++++++++++++--------------- std/js/html/DOMTokenList.hx | 4 ++-- std/js/html/Document.hx | 2 +- std/js/html/HTMLDocument.hx | 4 ++-- std/js/html/Window.hx | 8 ++++---- std/js/html/WorkerGlobalScope.hx | 10 +++++----- std/js/html/rtc/PeerConnection.hx | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/std/js/html/Console.hx b/std/js/html/Console.hx index f95f11b2054..aca4d1fcd08 100644 --- a/std/js/html/Console.hx +++ b/std/js/html/Console.hx @@ -27,22 +27,22 @@ package js.html; @:native("Console") extern class Console { - function log( ?data : Dynamic ) : Void; - function info( ?data : Dynamic ) : Void; - function warn( ?data : Dynamic ) : Void; - function error( ?data : Dynamic ) : Void; - function exception( ?data : Dynamic ) : Void; - function debug( ?data : Dynamic ) : Void; - function table( ?data : Dynamic ) : Void; + function log( data : haxe.extern.Rest ) : Void; + function info( data : haxe.extern.Rest ) : Void; + function warn( data : haxe.extern.Rest ) : Void; + function error( data : haxe.extern.Rest ) : Void; + function exception( data : haxe.extern.Rest ) : Void; + function debug( data : haxe.extern.Rest ) : Void; + function table( data : haxe.extern.Rest ) : Void; function trace() : Void; - function dir( ?data : Dynamic ) : Void; - function group( ?data : Dynamic ) : Void; - function groupCollapsed( ?data : Dynamic ) : Void; - function groupEnd( ?data : Dynamic ) : Void; + function dir( data : haxe.extern.Rest ) : Void; + function group( data : haxe.extern.Rest ) : Void; + function groupCollapsed( data : haxe.extern.Rest ) : Void; + function groupEnd( data : haxe.extern.Rest ) : Void; function time( ?time : Dynamic ) : Void; function timeEnd( ?time : Dynamic ) : Void; - function profile( ?data : Dynamic ) : Void; - function profileEnd( ?data : Dynamic ) : Void; - function assert( condition : Bool, ?data : Dynamic ) : Void; - function count( ?data : Dynamic ) : Void; + function profile( data : haxe.extern.Rest ) : Void; + function profileEnd( data : haxe.extern.Rest ) : Void; + function assert( condition : Bool, data : haxe.extern.Rest ) : Void; + function count( data : haxe.extern.Rest ) : Void; } \ No newline at end of file diff --git a/std/js/html/DOMTokenList.hx b/std/js/html/DOMTokenList.hx index 9a7418d474c..a6d4808f6f5 100644 --- a/std/js/html/DOMTokenList.hx +++ b/std/js/html/DOMTokenList.hx @@ -33,9 +33,9 @@ extern class DOMTokenList implements ArrayAccess /** @throws DOMError */ function contains( token : String ) : Bool; /** @throws DOMError */ - function add( ?tokens : String ) : Void; + function add( tokens : haxe.extern.Rest ) : Void; /** @throws DOMError */ - function remove( ?tokens : String ) : Void; + function remove( tokens : haxe.extern.Rest ) : Void; /** @throws DOMError */ function toggle( token : String, ?force : Bool ) : Bool; } \ No newline at end of file diff --git a/std/js/html/Document.hx b/std/js/html/Document.hx index b1793080b9d..1c188c2db6c 100644 --- a/std/js/html/Document.hx +++ b/std/js/html/Document.hx @@ -191,7 +191,7 @@ extern class Document extends Node /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; function createTouch( ?view : Window, ?target : EventTarget, ?identifier : Int = 0, ?pageX : Int = 0, ?pageY : Int = 0, ?screenX : Int = 0, ?screenY : Int = 0, ?clientX : Int = 0, ?clientY : Int = 0, ?radiusX : Int = 0, ?radiusY : Int = 0, ?rotationAngle : Float = 0.0, ?force : Float = 0.0 ) : Touch; - @:overload( function( touch : Touch, ?touches : Touch ) : TouchList {} ) + @:overload( function( touch : Touch, touches : haxe.extern.Rest ) : TouchList {} ) @:overload( function() : TouchList {} ) function createTouchList( touches : Array ) : TouchList; /** @throws DOMError */ diff --git a/std/js/html/HTMLDocument.hx b/std/js/html/HTMLDocument.hx index b6cab0df0c2..56c5590a05a 100644 --- a/std/js/html/HTMLDocument.hx +++ b/std/js/html/HTMLDocument.hx @@ -55,9 +55,9 @@ extern class HTMLDocument extends Document /** @throws DOMError */ function close() : Void; /** @throws DOMError */ - function write( ?text : String ) : Void; + function write( text : haxe.extern.Rest ) : Void; /** @throws DOMError */ - function writeln( ?text : String ) : Void; + function writeln( text : haxe.extern.Rest ) : Void; /** @throws DOMError */ function execCommand( commandId : String, ?showUI : Bool = false, ?value : String = "" ) : Bool; /** @throws DOMError */ diff --git a/std/js/html/Window.hx b/std/js/html/Window.hx index cddb9c79a6d..01c3c419cca 100644 --- a/std/js/html/Window.hx +++ b/std/js/html/Window.hx @@ -226,13 +226,13 @@ extern class Window extends EventTarget /** @throws DOMError */ function atob( atob : String ) : String; /** @throws DOMError */ - @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int = 0, ?arguments : Dynamic ) : Int {} ) - function setTimeout( handler : String, ?timeout : Int = 0, ?unused : Dynamic ) : Int; + @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int = 0, arguments : haxe.extern.Rest ) : Int {} ) + function setTimeout( handler : String, ?timeout : Int = 0, unused : haxe.extern.Rest ) : Int; /** @throws DOMError */ function clearTimeout( ?handle : Int = 0 ) : Void; /** @throws DOMError */ - @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int, ?arguments : Dynamic ) : Int {} ) - function setInterval( handler : String, ?timeout : Int, ?unused : Dynamic ) : Int; + @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int, arguments : haxe.extern.Rest ) : Int {} ) + function setInterval( handler : String, ?timeout : Int, unused : haxe.extern.Rest ) : Int; /** @throws DOMError */ function clearInterval( ?handle : Int = 0 ) : Void; } \ No newline at end of file diff --git a/std/js/html/WorkerGlobalScope.hx b/std/js/html/WorkerGlobalScope.hx index d5af3fe13fd..d6db799e2b9 100644 --- a/std/js/html/WorkerGlobalScope.hx +++ b/std/js/html/WorkerGlobalScope.hx @@ -39,20 +39,20 @@ extern class WorkerGlobalScope extends EventTarget function close() : Void; /** @throws DOMError */ - function importScripts( ?urls : String ) : Void; + function importScripts( urls : haxe.extern.Rest ) : Void; function dump( ?str : String ) : Void; /** @throws DOMError */ function btoa( btoa : String ) : String; /** @throws DOMError */ function atob( atob : String ) : String; /** @throws DOMError */ - @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int = 0, ?arguments : Dynamic ) : Int {} ) - function setTimeout( handler : String, ?timeout : Int = 0, ?unused : Dynamic ) : Int; + @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int = 0, arguments : haxe.extern.Rest ) : Int {} ) + function setTimeout( handler : String, ?timeout : Int = 0, unused : haxe.extern.Rest ) : Int; /** @throws DOMError */ function clearTimeout( ?handle : Int = 0 ) : Void; /** @throws DOMError */ - @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int, ?arguments : Dynamic ) : Int {} ) - function setInterval( handler : String, ?timeout : Int, ?unused : Dynamic ) : Int; + @:overload( function( handler : haxe.Constraints.Function, ?timeout : Int, arguments : haxe.extern.Rest ) : Int {} ) + function setInterval( handler : String, ?timeout : Int, unused : haxe.extern.Rest ) : Int; /** @throws DOMError */ function clearInterval( ?handle : Int = 0 ) : Void; } \ No newline at end of file diff --git a/std/js/html/rtc/PeerConnection.hx b/std/js/html/rtc/PeerConnection.hx index 4ea67867953..f856968134f 100644 --- a/std/js/html/rtc/PeerConnection.hx +++ b/std/js/html/rtc/PeerConnection.hx @@ -67,7 +67,7 @@ extern class PeerConnection extends js.html.EventTarget function getStreamById( streamId : String ) : js.html.MediaStream; function addStream( stream : js.html.MediaStream ) : Void; function removeStream( stream : js.html.MediaStream ) : Void; - function addTrack( track : js.html.MediaStreamTrack, stream : js.html.MediaStream, ?moreStreams : js.html.MediaStream ) : RtpSender; + function addTrack( track : js.html.MediaStreamTrack, stream : js.html.MediaStream, moreStreams : haxe.extern.Rest ) : RtpSender; function removeTrack( sender : RtpSender ) : Void; function getSenders() : Array; function getReceivers() : Array; From 4f3745715e9c33f23583ecb20a14261420e9fbdf Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 18:12:34 +0100 Subject: [PATCH 012/209] start 3.2.0 changelog [skip ci] --- extra/CHANGES.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 5f135d53f71..a3c8ab6663d 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -1,3 +1,9 @@ +2015-??-??: 3.2.0 + + Bugfixes: + + js : function accepting a variable number of arguments now use haxe.extern.Rest + 2015-03-15: 3.2.0-RC1 This release removes support for Flash 8 target From 81fa71647bc1110ce5b6482498bf432311eebeda Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 20 Mar 2015 20:15:52 +0300 Subject: [PATCH 013/209] reword js.html haxe.extern.Rest change [skip ci] --- extra/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index a3c8ab6663d..c1262956cad 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -2,7 +2,7 @@ Bugfixes: - js : function accepting a variable number of arguments now use haxe.extern.Rest + js : added variable number of arguments support in js.html.* classes 2015-03-15: 3.2.0-RC1 From ed769667f26a7f81f18b2a72a8ade7d070c4a8c5 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 19:09:37 +0100 Subject: [PATCH 014/209] add anti-helpdesk clause [skip ci] --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 325247470d7..1420963034c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,6 @@ Things to check before/while filing an issue: +- Check if you actually suspect that there's an issue in the Haxe code. If you find yourself writing "How do I..." you may want to consider a different communication channel. Refer to http://haxe.org/community/community-support.html for more information. - Reduce your code to a minimal example (see http://sscce.org/). In particular avoid library dependencies: If you cannot reproduce your issue without using a specific library, it might not be a Haxe issue to begin with. - Check if your problems are already resolved in the Haxe development version (for builds see http://builds.haxe.org/). - Most targets produce readable code. If you suspect the generated code to be wrong, try checking the output. Note that you can add `-D dump=pretty` to your compilation parameters and find the code which is passed to the generators in a `dump` sub directory. From 4c0d5458e4e2fcd60db3206172ef8539a21c8ee7 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 19:37:28 +0100 Subject: [PATCH 015/209] [php] support interpolation in `__php__` code (see #4060) --- extra/CHANGES.txt | 6 +++++- genphp.ml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index c1262956cad..dfe5df12bc4 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -4,6 +4,10 @@ js : added variable number of arguments support in js.html.* classes + General improvements and optimizations: + + php : support interpolation in __php__ code + 2015-03-15: 3.2.0-RC1 This release removes support for Flash 8 target @@ -55,7 +59,7 @@ cpp : fixed issue with NativeArray in --no-inline mode php : fixed issue with invalid references for closures in for-loops php : fixed Reflect.compare and string comparison for numeric strings - cs/java : fixed various issues with -java-lib and -net-lib. + cs/java : fixed various issues with -java-lib and -net-lib. cs/java : added @:libType to skip checking on -java-lib / -net-lib types cs/java : compilation server now works with C#/Java [experimental support] cs : fixed Type.enumIndex / switch on C# native enums diff --git a/genphp.ml b/genphp.ml index e9afeb083a7..ab75c54d6d9 100644 --- a/genphp.ml +++ b/genphp.ml @@ -589,6 +589,8 @@ and gen_call ctx e el = | TLocal { v_name = "__php__" }, [{ eexpr = TConst (TString code) }] -> (*--php-prefix*) spr ctx (prefix_init_replace ctx.com code) + | TLocal { v_name = "__php__" }, { eexpr = TConst (TString code); epos = p } :: tl -> + Codegen.interpolate_code ctx.com code tl (spr ctx) (gen_expr ctx) p | TLocal { v_name = "__instanceof__" }, [e1;{ eexpr = TConst (TString t) }] -> gen_value ctx e1; print ctx " instanceof %s" t; From 15e8bb321dffa5671fa374d461164af213bd7044 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 20 Mar 2015 19:52:55 +0100 Subject: [PATCH 016/209] [js] do not try to be too clever about enum printing We just keep `__string_rec` as soon as we keep the enum because at that point it doesn't really matter anymore anyway. There are too many problems where enums might be printed hidden behind Dynamic or something else otherwise. --- extra/CHANGES.txt | 1 + filters.ml | 6 ------ genjs.ml | 6 +++--- std/js/Boot.hx | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index dfe5df12bc4..e745ee13501 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -3,6 +3,7 @@ Bugfixes: js : added variable number of arguments support in js.html.* classes + js : fixed DCE issue related to printing enums General improvements and optimizations: diff --git a/filters.ml b/filters.ml index 6aebc45e204..818df27cd6c 100644 --- a/filters.ml +++ b/filters.ml @@ -705,12 +705,6 @@ let rename_local_vars ctx e = e let check_unification ctx e t = - begin match follow e.etype,follow t with - | TEnum _,TDynamic _ -> - Hashtbl.replace ctx.curclass.cl_module.m_extra.m_features "may_print_enum" true; - | _ -> - () - end; begin match e.eexpr,t with | TLocal v,TType({t_path = ["cs"],("Ref" | "Out")},_) -> (* TODO: this smells of hack, but we have to deal with it somehow *) diff --git a/genjs.ml b/genjs.ml index c40dfa094d6..fdcdcba4312 100644 --- a/genjs.ml +++ b/genjs.ml @@ -1099,14 +1099,14 @@ let generate_enum ctx e = | TFun (args,_) -> let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in print ctx "function(%s) { var $x = [\"%s\",%d,%s]; $x.__enum__ = %s;" sargs f.ef_name f.ef_index sargs p; - if has_feature ctx "may_print_enum" then + if has_feature ctx "has_enum" then spr ctx " $x.toString = $estr;"; spr ctx " return $x; }"; ctx.separator <- true; | _ -> print ctx "[\"%s\",%d]" f.ef_name f.ef_index; newline ctx; - if has_feature ctx "may_print_enum" then begin + if has_feature ctx "has_enum" then begin print ctx "%s%s.toString = $estr" p (field f.ef_name); newline ctx; end; @@ -1329,7 +1329,7 @@ let generate com = (* TODO: fix $estr *) let vars = [] in let vars = (if has_feature ctx "Type.resolveClass" || has_feature ctx "Type.resolveEnum" then ("$hxClasses = " ^ (if ctx.js_modern then "{}" else "$hxClasses || {}")) :: vars else vars) in - let vars = if has_feature ctx "may_print_enum" + let vars = if has_feature ctx "has_enum" then ("$estr = function() { return " ^ (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js"],"Boot" })) ^ ".__string_rec(this,''); }") :: vars else vars in (match List.rev vars with diff --git a/std/js/Boot.hx b/std/js/Boot.hx index 7b58c139001..4096bb7a53c 100755 --- a/std/js/Boot.hx +++ b/std/js/Boot.hx @@ -93,7 +93,7 @@ class Boot { } } - @:ifFeature("may_print_enum") + @:ifFeature("has_enum") private static function __string_rec(o,s:String) { untyped { if( o == null ) From f280bbb06f43980c9dd0e537d32bd7e95eba153a Mon Sep 17 00:00:00 2001 From: frabbit Date: Fri, 20 Mar 2015 23:54:08 +0100 Subject: [PATCH 017/209] add bytes test to make sure that bytesdata has call-by-reference semantics --- tests/unit/src/unit/TestBytes.hx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/src/unit/TestBytes.hx b/tests/unit/src/unit/TestBytes.hx index 47c6717e819..d4fa3813cd6 100644 --- a/tests/unit/src/unit/TestBytes.hx +++ b/tests/unit/src/unit/TestBytes.hx @@ -126,4 +126,15 @@ class TestBytes extends Test { eq(fget(bd3, 0), 0xC3); eq(fget(bd3, 1), 0xA9); } + + function testBytesDataEquality () { + var b1 = haxe.io.Bytes.ofString("AB"); + var x = b1.getData(); + var b2 = haxe.io.Bytes.ofData(x); + + b2.set(0, "C".code); + + eq(b1.getString(0,2), b2.getString(0,2)); + + } } \ No newline at end of file From e167230369663bbe34e74331ba6e52417209d44f Mon Sep 17 00:00:00 2001 From: Hugh Date: Sat, 21 Mar 2015 09:52:23 +0800 Subject: [PATCH 018/209] Apply default arguement code to dynamic functions too. Closes https://github.com/HaxeFoundation/hxcpp/issues/189 --- gencpp.ml | 10 ++++++++-- tests/unit/src/unit/hxcpp_issues/Issue189.hx | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/unit/src/unit/hxcpp_issues/Issue189.hx diff --git a/gencpp.ml b/gencpp.ml index 73ead2ee588..f0d65a3564c 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -2565,13 +2565,19 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface let func_name = "__default_" ^ (remap_name) in output ("HX_BEGIN_DEFAULT_FUNC(" ^ func_name ^ "," ^ class_name ^ ")\n"); output return_type; - output (" run(" ^ (gen_arg_list function_def.tf_args "") ^ ")"); + output (" run(" ^ (gen_arg_list function_def.tf_args "__o_") ^ ")"); ctx.ctx_dump_src_pos <- dump_src; if (is_void) then begin - ctx.ctx_writer#begin_block; + ctx.ctx_writer#begin_block; + generate_default_values ctx function_def.tf_args "__o_"; gen_expression ctx false function_def.tf_expr; output "return null();\n"; ctx.ctx_writer#end_block; + end else if (has_default_values function_def.tf_args) then begin + ctx.ctx_writer#begin_block; + generate_default_values ctx function_def.tf_args "__o_"; + gen_expression ctx false function_def.tf_expr; + ctx.ctx_writer#end_block; end else gen_expression ctx false (to_block function_def.tf_expr); diff --git a/tests/unit/src/unit/hxcpp_issues/Issue189.hx b/tests/unit/src/unit/hxcpp_issues/Issue189.hx new file mode 100644 index 00000000000..aa4f5b4673b --- /dev/null +++ b/tests/unit/src/unit/hxcpp_issues/Issue189.hx @@ -0,0 +1,12 @@ +package unit.hxcpp_issues; + + +class Issue189 extends Test { + function dynamicWidthDefaults(first=true, second=6, third=10.5) : Float { + return first ? second : third; + } + function test() { + eq(dynamicWidthDefaults(),10.5); + } +} + From 3e92340c54b2fe13603e7b7f761cdcfecc0cedd2 Mon Sep 17 00:00:00 2001 From: Hugh Date: Sat, 21 Mar 2015 10:04:26 +0800 Subject: [PATCH 019/209] [cpp] Correct version of test --- tests/unit/src/unit/hxcpp_issues/Issue189.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/src/unit/hxcpp_issues/Issue189.hx b/tests/unit/src/unit/hxcpp_issues/Issue189.hx index aa4f5b4673b..0bf119b5aeb 100644 --- a/tests/unit/src/unit/hxcpp_issues/Issue189.hx +++ b/tests/unit/src/unit/hxcpp_issues/Issue189.hx @@ -2,11 +2,12 @@ package unit.hxcpp_issues; class Issue189 extends Test { - function dynamicWidthDefaults(first=true, second=6, third=10.5) : Float { + dynamic function dynamicWidthDefaults(first=true, second=6, third=10.5) : Float { return first ? second : third; } function test() { - eq(dynamicWidthDefaults(),10.5); + eq(dynamicWidthDefaults(),6); + eq(dynamicWidthDefaults(false),10.5); } } From 78cd9e99e6ef9b04477444790db6d9790b17e41a Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sat, 21 Mar 2015 06:49:37 +0100 Subject: [PATCH 020/209] disable test (see #4060) --- tests/unit/src/unit/TestBytes.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/src/unit/TestBytes.hx b/tests/unit/src/unit/TestBytes.hx index d4fa3813cd6..d0755dfb6ba 100644 --- a/tests/unit/src/unit/TestBytes.hx +++ b/tests/unit/src/unit/TestBytes.hx @@ -106,6 +106,7 @@ class TestBytes extends Test { eq(input.readAll().toString(), "One é accent"); } + #if !php // https://github.com/HaxeFoundation/haxe/issues/4060 function testFastGet() { var b = haxe.io.Bytes.alloc(10); var bd = b.getData(); @@ -126,6 +127,7 @@ class TestBytes extends Test { eq(fget(bd3, 0), 0xC3); eq(fget(bd3, 1), 0xA9); } + #end function testBytesDataEquality () { var b1 = haxe.io.Bytes.ofString("AB"); From d0df45651bcf0eb6118514d4cda0dac114cebda6 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sat, 21 Mar 2015 07:24:42 +0100 Subject: [PATCH 021/209] [php] ignore more --- tests/unit/src/unit/TestBytes.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/src/unit/TestBytes.hx b/tests/unit/src/unit/TestBytes.hx index d0755dfb6ba..c0bdfcda951 100644 --- a/tests/unit/src/unit/TestBytes.hx +++ b/tests/unit/src/unit/TestBytes.hx @@ -127,7 +127,6 @@ class TestBytes extends Test { eq(fget(bd3, 0), 0xC3); eq(fget(bd3, 1), 0xA9); } - #end function testBytesDataEquality () { var b1 = haxe.io.Bytes.ofString("AB"); @@ -139,4 +138,5 @@ class TestBytes extends Test { eq(b1.getString(0,2), b2.getString(0,2)); } + #end } \ No newline at end of file From ac30dd5dc7df5cdb9f598ffd4f0ed3ed432e83ed Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Sat, 21 Mar 2015 16:10:48 +0300 Subject: [PATCH 022/209] [cs] remove workaround for unity's #line bug as it's now fixed by d464df1a66b1c502dc97b327d172144d9e942f49 (see #3759) --- common.ml | 3 --- gencs.ml | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/common.ml b/common.ml index 679ab9dc75d..73d10da44c8 100644 --- a/common.ml +++ b/common.ml @@ -240,7 +240,6 @@ module Define = struct | SwfScriptTimeout | SwfUseDoAbc | Sys - | Unity46LineNumbers | Unsafe | UseNekoc | UseRttiDoc @@ -325,8 +324,6 @@ module Define = struct | SwfScriptTimeout -> ("swf_script_timeout", "Maximum ActionScript processing time before script stuck dialog box displays (in seconds)") | SwfUseDoAbc -> ("swf_use_doabc", "Use DoAbc swf-tag instead of DoAbcDefine") | Sys -> ("sys","Defined for all system platforms") - (* see https://github.com/HaxeFoundation/haxe/issues/3759 *) - | Unity46LineNumbers -> ("unity46_line_numbers", "Fixes line numbers in generated C# files for Unity 4.6 Mono compiler") | Unsafe -> ("unsafe","Allow unsafe code when targeting C#") | UseNekoc -> ("use_nekoc","Use nekoc compiler instead of internal one") | UseRttiDoc -> ("use_rtti_doc","Allows access to documentation during compilation") diff --git a/gencs.ml b/gencs.ml index 5812e7b8116..c25e9339386 100644 --- a/gencs.ml +++ b/gencs.ml @@ -1138,8 +1138,7 @@ let configure gen = else fun w p -> let cur_line = Lexer.get_error_line p in let file = Common.get_full_path p.pfile in - let line = if Common.defined gen.gcon Define.Unity46LineNumbers then cur_line - 1 else cur_line in - if cur_line <> ((!last_line)+1) then begin print w "#line %d \"%s\"" line (Ast.s_escape file); newline w end; + if cur_line <> ((!last_line)+1) then begin print w "#line %d \"%s\"" cur_line (Ast.s_escape file); newline w end; last_line := cur_line in let line_reset_directive = From 89a6b13b5b68c1d3576f97c267783062ade507fb Mon Sep 17 00:00:00 2001 From: Hugh Date: Sun, 22 Mar 2015 12:12:10 +0800 Subject: [PATCH 023/209] Do not call tmp variable 'result'. Closes https://github.com/HaxeFoundation/hxcpp/issues/192 --- gencpp.ml | 10 +++++----- tests/unit/src/unit/hxcpp_issues/Issue192.hx | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 tests/unit/src/unit/hxcpp_issues/Issue192.hx diff --git a/gencpp.ml b/gencpp.ml index f0d65a3564c..696a226dc8a 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -3507,16 +3507,16 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_cpp (ptr_name ^ " " ^ class_name ^ "::__new(" ^constructor_type_args ^")\n"); let create_result () = - output_cpp ("{ " ^ ptr_name ^ " result = new " ^ class_name ^ "();\n"); + output_cpp ("{ " ^ ptr_name ^ " _result_ = new " ^ class_name ^ "();\n"); in create_result (); - output_cpp ("\tresult->__construct(" ^ constructor_args ^ ");\n"); - output_cpp ("\treturn result;}\n\n"); + output_cpp ("\t_result_->__construct(" ^ constructor_args ^ ");\n"); + output_cpp ("\treturn _result_;}\n\n"); output_cpp ("Dynamic " ^ class_name ^ "::__Create(hx::DynamicArray inArgs)\n"); create_result (); - output_cpp ("\tresult->__construct(" ^ (array_arg_list constructor_var_list) ^ ");\n"); - output_cpp ("\treturn result;}\n\n"); + output_cpp ("\t_result_->__construct(" ^ (array_arg_list constructor_var_list) ^ ");\n"); + output_cpp ("\treturn _result_;}\n\n"); if ( (List.length implemented) > 0 ) then begin output_cpp ("hx::Object *" ^ class_name ^ "::__ToInterface(const hx::type_info &inType) {\n"); List.iter (fun interface_name -> diff --git a/tests/unit/src/unit/hxcpp_issues/Issue192.hx b/tests/unit/src/unit/hxcpp_issues/Issue192.hx new file mode 100644 index 00000000000..c2679e370ad --- /dev/null +++ b/tests/unit/src/unit/hxcpp_issues/Issue192.hx @@ -0,0 +1,10 @@ +package unit.hxcpp_issues; + +class ConstuctorWithArgCalledResult { + public function new(result:Int) { } +} + +class Issue192 extends Test { + function test() new ConstuctorWithArgCalledResult(1); +} + From b703429a3db3b8256c7d9841379fe2fd825b8eb3 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Sun, 22 Mar 2015 12:53:43 +0300 Subject: [PATCH 024/209] [js] only lookup js.Boot.HaxeError when TThrow is detected --- filters.ml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/filters.ml b/filters.ml index 818df27cd6c..deda737dec0 100644 --- a/filters.ml +++ b/filters.ml @@ -140,19 +140,17 @@ let rec add_final_return e = | _ -> e let rec wrap_js_exceptions com e = - let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in - let cerr = match terr with TClassDecl c -> c | _ -> assert false in - let rec is_error t = match follow t with | TInst ({cl_path = (["js"],"Error")},_) -> true | TInst ({cl_super = Some (csup,tl)}, _) -> is_error (TInst (csup,tl)) | _ -> false in - let rec loop e = match e.eexpr with | TThrow eerr when not (is_error eerr.etype) -> + let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in + let cerr = match terr with TClassDecl c -> c | _ -> assert false in let ewrap = { eerr with eexpr = TNew (cerr,[],[eerr]) } in { e with eexpr = TThrow ewrap } | _ -> From 472859f91cac991d57e74a95a0d53529d48d3477 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Sun, 22 Mar 2015 12:57:30 -0400 Subject: [PATCH 025/209] Don't need that specialized htmlelement error anymore. --- main.ml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/main.ml b/main.ml index 737bee15e04..b43ea8e627c 100644 --- a/main.ml +++ b/main.ml @@ -141,8 +141,7 @@ let deprecated = [ "Class not found : neko.zip.Reader", "neko.zip.Reader has been removed, use haxe.zip.Reader instead"; "Class not found : neko.zip.Writer", "neko.zip.Writer has been removed, use haxe.zip.Writer instead"; "Class not found : haxe.Public", "Use @:publicFields instead of implementing or extending haxe.Public"; - "#Xml has no field createProlog", "Xml.createProlog was renamed to Xml.createProcessingInstruction"; - "Module js.html.HtmlElement is loaded with a different case than js.html.HTMLElement", "htmlelement" + "#Xml has no field createProlog", "Xml.createProlog was renamed to Xml.createProcessingInstruction" ] let limit_string s offset = @@ -159,10 +158,7 @@ let limit_string s offset = let error ctx msg p = let msg = try List.assoc msg deprecated with Not_found -> msg in - if msg = "htmlelement" then - message ctx "There was a problem with HtmlElement, please refer to https://github.com/HaxeFoundation/html-externs/blob/master/README.md#htmlelement" null_pos - else - message ctx msg p; + message ctx msg p; ctx.has_error <- true let htmlescape s = From a5f45ec708a9cdabe2902796b445b58edc7ac67b Mon Sep 17 00:00:00 2001 From: Hugh Date: Mon, 23 Mar 2015 13:10:51 +0800 Subject: [PATCH 026/209] [cpp] Use hx::Throw instead of creating a temp dynamic when accessing a known-null object. Closes https://github.com/HaxeFoundation/hxcpp/issues/193 --- gencpp.ml | 3 +- tests/unit/src/unit/hxcpp_issues/Issue193.hx | 32 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/unit/src/unit/hxcpp_issues/Issue193.hx diff --git a/gencpp.ml b/gencpp.ml index 696a226dc8a..d3f521aa62a 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -2160,7 +2160,8 @@ and gen_expression ctx retval expression = end (* Get precidence matching haxe ? *) | TBinop (op,expr1,expr2) -> gen_bin_op op expr1 expr2 - | TField (expr,_) | TEnumParameter (expr,_,_) when (is_null expr) -> output "Dynamic()" + | TField (expr,_) | TEnumParameter (expr,_,_) when (is_null expr) -> + output "hx::Throw(HX_CSTRING(\"Invalid field access on null object\"))" | TEnumParameter (expr,ef,i) -> let enum = match follow ef.ef_type with | TEnum(en,_) | TFun(_,TEnum(en,_)) -> en diff --git a/tests/unit/src/unit/hxcpp_issues/Issue193.hx b/tests/unit/src/unit/hxcpp_issues/Issue193.hx new file mode 100644 index 00000000000..1b2457916d4 --- /dev/null +++ b/tests/unit/src/unit/hxcpp_issues/Issue193.hx @@ -0,0 +1,32 @@ +package unit.hxcpp_issues; + +import haxe.macro.Context; +import haxe.macro.Expr; + +#if !macro +@:build(unit.hxcpp_issues.Issue193.build()) +#end +class Issue193 extends Test +{ + var field:Int; + + inline function incField() field++; + + inline static function doInc(t:Issue193) t.incField(); + + macro public static function build ():Array { + var fields = Context.getBuildFields(); + var newField = macro { + doInc(null); + }; + fields.push ({ name: "genField", access: [ APublic ], kind: FFun({ args: [], expr: newField, params: [], ret: null }), pos: Context.currentPos() }); + return fields; + } + + function test() + { + var field = Reflect.field(this,"genField"); + t(field!=null); + } +} + From 523c860c6985d47108cdebd40e0b90765d95d4a4 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 23 Mar 2015 10:31:15 +0100 Subject: [PATCH 027/209] fix detection of `@:generic` classes with constructor constraints (closes #4070) --- .gitignore | 1 + extra/CHANGES.txt | 1 + filters.ml | 10 +++++++++- tests/misc/projects/Issue4070/Main.hx | 18 ++++++++++++++++++ tests/misc/projects/Issue4070/compile.hxml | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/misc/projects/Issue4070/Main.hx create mode 100644 tests/misc/projects/Issue4070/compile.hxml diff --git a/.gitignore b/.gitignore index 273360239ae..4e62178bf31 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ tests/misc/projects/*/*.n tests/unit/bin/ tests/*.n tests/misc/projects/Issue3756/cpp/ +tests/misc/projects/Issue4070/cpp/ diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index e745ee13501..0207fff4e01 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -2,6 +2,7 @@ Bugfixes: + all : fixed detection of @:generic classes with constructor constraints js : added variable number of arguments support in js.html.* classes js : fixed DCE issue related to printing enums diff --git a/filters.ml b/filters.ml index deda737dec0..af5db1be28a 100644 --- a/filters.ml +++ b/filters.ml @@ -761,7 +761,15 @@ let save_class_state ctx t = match t with (* PASS 2 begin *) -let is_removable_class c = c.cl_kind = KGeneric && (Codegen.has_ctor_constraint c || Meta.has Meta.Remove c.cl_meta) +let is_removable_class c = + c.cl_kind = KGeneric && + (Meta.has Meta.Remove c.cl_meta || + List.exists (fun (_,t) -> match follow t with + | TInst(c,_) -> + Codegen.has_ctor_constraint c + | _ -> + false + ) c.cl_params) let remove_generic_base ctx t = match t with | TClassDecl c when is_removable_class c -> diff --git a/tests/misc/projects/Issue4070/Main.hx b/tests/misc/projects/Issue4070/Main.hx new file mode 100644 index 00000000000..441bb43e3c1 --- /dev/null +++ b/tests/misc/projects/Issue4070/Main.hx @@ -0,0 +1,18 @@ +class Test { + public function new() {} +} + +class Main { + public static function main() { + new Generic(); + } +} + +@:generic +class Generic { + var t:T; + + public function new() { + t = new T(); + } +} \ No newline at end of file diff --git a/tests/misc/projects/Issue4070/compile.hxml b/tests/misc/projects/Issue4070/compile.hxml new file mode 100644 index 00000000000..7280d089f70 --- /dev/null +++ b/tests/misc/projects/Issue4070/compile.hxml @@ -0,0 +1,2 @@ +-main Main +-cpp cpp \ No newline at end of file From ab8e617953a289d65fa84045fe401da8d0f54f9d Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 23 Mar 2015 10:55:56 +0100 Subject: [PATCH 028/209] disable null test because it's broken on multiple targets --- .../src/unit/hxcpp_issues/{Issue193.hx => Issue193.hx.disabled} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/unit/src/unit/hxcpp_issues/{Issue193.hx => Issue193.hx.disabled} (100%) diff --git a/tests/unit/src/unit/hxcpp_issues/Issue193.hx b/tests/unit/src/unit/hxcpp_issues/Issue193.hx.disabled similarity index 100% rename from tests/unit/src/unit/hxcpp_issues/Issue193.hx rename to tests/unit/src/unit/hxcpp_issues/Issue193.hx.disabled From 81560c154896eb37e08ee247a40cdd8de56f3184 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 23 Mar 2015 11:32:09 +0100 Subject: [PATCH 029/209] disable test because we don't have hxcpp in the misc tests at the moment --- .../projects/Issue4070/{compile.hxml => compile.hxml.disabled} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/misc/projects/Issue4070/{compile.hxml => compile.hxml.disabled} (100%) diff --git a/tests/misc/projects/Issue4070/compile.hxml b/tests/misc/projects/Issue4070/compile.hxml.disabled similarity index 100% rename from tests/misc/projects/Issue4070/compile.hxml rename to tests/misc/projects/Issue4070/compile.hxml.disabled From d3d3f9cb113fb6b69075aa4680467e147182a215 Mon Sep 17 00:00:00 2001 From: hughsando Date: Tue, 24 Mar 2015 22:26:42 +0800 Subject: [PATCH 030/209] [cpp] Add magic GENCPP_SOURCE_DIRECTORY variable to make native code interaction easier --- gencpp.ml | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index d3f521aa62a..5c475bb92e3 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -347,7 +347,7 @@ let get_meta_string meta key = -let get_meta_string_path ctx meta key = +let get_meta_string_path meta key = let rec loop = function | [] -> "" | (k,[Ast.EConst (Ast.String name),_], pos) :: _ when k=key-> @@ -367,6 +367,28 @@ let get_meta_string_path ctx meta key = loop meta ;; + +let get_meta_string_full_filename meta key = + let rec loop = function + | [] -> "" + | (k,_, pos) :: _ when k=key-> + if (Filename.is_relative pos.pfile) then + Gencommon.normalize (Filename.concat (Sys.getcwd()) pos.pfile) + else + pos.pfile + | _ :: l -> loop l + in + loop meta +;; + +let get_meta_string_full_dirname meta key = + let name = get_meta_string_full_filename meta key in + try + Gencommon.normalize (Filename.dirname name) + with Invalid_argument _ -> "" +;; + + let get_field_access_meta field_access key = match field_access with | FInstance(_,_,class_field) @@ -376,6 +398,14 @@ match field_access with let get_code meta key = let code = get_meta_string meta key in + let magic_var = "${GENCPP_SOURCE_DIRECTORY}" in + let code = if ExtString.String.exists code magic_var then begin + let source_directory = get_meta_string_full_dirname meta key in + let _,code = ExtString.String.replace code magic_var source_directory in + code + end else + code + in if (code<>"") then code ^ "\n" else code ;; @@ -2741,7 +2771,7 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de end in let add_extern_class klass = - let include_file = get_meta_string_path ctx klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in + let include_file = get_meta_string_path klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in if (include_file<>"") then add_type ( path_of_string include_file ) else if (not for_depends) && (has_meta_key klass.cl_meta Meta.Include) then @@ -3463,7 +3493,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_cpp "#include \n"; output_cpp ( get_class_code class_def Meta.CppFileCode ); - let inc = get_meta_string_path ctx class_def.cl_meta Meta.CppInclude in + let inc = get_meta_string_path class_def.cl_meta Meta.CppInclude in if (inc<>"") then output_cpp ("#include \"" ^ inc ^ "\"\n"); @@ -4086,7 +4116,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla List.iter ( gen_forward_decl h_file ) referenced; output_h ( get_class_code class_def Meta.HeaderCode ); - let inc = get_meta_string_path ctx class_def.cl_meta Meta.HeaderInclude in + let inc = get_meta_string_path class_def.cl_meta Meta.HeaderInclude in if (inc<>"") then output_h ("#include \"" ^ inc ^ "\"\n"); @@ -5480,7 +5510,7 @@ let generate_source common_ctx = (match object_def with | TClassDecl class_def when is_extern_class class_def -> build_xml := !build_xml ^ (get_class_code class_def Meta.BuildXml); - let source = get_meta_string_path common_ctx class_def.cl_meta Meta.SourceFile in + let source = get_meta_string_path class_def.cl_meta Meta.SourceFile in if (source<>"") then extern_src := source :: !extern_src; | TClassDecl class_def -> From 42aaf1155df00a57d57f84d10edc480dbb82aba8 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 24 Mar 2015 22:46:12 +0800 Subject: [PATCH 031/209] [AppVeyor] shows cygwin setup log --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3f6ff43a299..b93fdc20135 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,7 +30,7 @@ init: install: - 'git submodule update --init --recursive' # Install ocaml using wodi - - '%CYG_ROOT%/setup-%CYG_ARCH%.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ >NUL' + - '%CYG_ROOT%/setup-%CYG_ARCH%.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz"' - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh"' From 9fcddbefaef8790ff885530fc30218d227c87870 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 24 Mar 2015 23:00:37 +0800 Subject: [PATCH 032/209] [AppVeyor] get a new copy of the cygwin setup exe --- appveyor.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b93fdc20135..5f419c2551f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,13 +24,11 @@ environment: skip_tags: true -init: - - 'echo System architecture: %PLATFORM%' - install: - 'git submodule update --init --recursive' # Install ocaml using wodi - - '%CYG_ROOT%/setup-%CYG_ARCH%.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++' + - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" + - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz"' - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh"' From e440045f8112168c41254fac8d19809a2d5b7f78 Mon Sep 17 00:00:00 2001 From: Hugh Date: Tue, 24 Mar 2015 23:49:12 +0800 Subject: [PATCH 033/209] [cpp] Fix signature of loadPrime function --- std/cpp/Lib.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/cpp/Lib.hx b/std/cpp/Lib.hx index a152edc4cdd..602d5c73bf9 100644 --- a/std/cpp/Lib.hx +++ b/std/cpp/Lib.hx @@ -52,11 +52,11 @@ class Lib { @:analyzer(no_simplification) public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic { - var factory:Callable< RawConstPointer -> RawPointer > = + var factory:Callable< ConstCharStar -> Object > = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail); if (factory!=null) { - var func:Dynamic = factory.call(signature.raw()); + var func:Dynamic = factory.call(signature); if (func==null && !quietFail) throw '$prim does not have signature $signature'; return func; From baea4b6a3fd0cc79457bb0d116cc92457bc5beed Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 24 Mar 2015 23:53:43 +0800 Subject: [PATCH 034/209] [AppVeyor] Only display cygwin setup log when there is an error. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5f419c2551f..88bbc25542c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,7 +28,7 @@ install: - 'git submodule update --init --recursive' # Install ocaml using wodi - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++' + - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ >log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz"' - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh"' From 6871736796b509be0425feaca1aa85d135fdb3d3 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 24 Mar 2015 16:56:24 +0100 Subject: [PATCH 035/209] check variable initialization before running the simplifier (closes #4076) --- extra/CHANGES.txt | 1 + filters.ml | 2 +- tests/unit/src/unit/issues/Issue4076.hx | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/unit/src/unit/issues/Issue4076.hx diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 0207fff4e01..6c515d81b1e 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -3,6 +3,7 @@ Bugfixes: all : fixed detection of @:generic classes with constructor constraints + all : fixed variable initialization check issue in loop condition js : added variable number of arguments support in js.html.* classes js : fixed DCE issue related to printing enums diff --git a/filters.ml b/filters.ml index af5db1be28a..d5b27b7d399 100644 --- a/filters.ml +++ b/filters.ml @@ -1125,6 +1125,7 @@ let run com tctx main = Codegen.UnificationCallback.run (check_unification tctx); Codegen.AbstractCast.handle_abstract_casts tctx; blockify_ast; + check_local_vars_init; ( if (Common.defined com Define.NoSimplify) || (Common.defined com Define.Cppia) || ( match com.platform with Cpp -> false | _ -> true ) then fun e -> e @@ -1137,7 +1138,6 @@ let run com tctx main = save(); e ); if com.foptimize then (fun e -> Optimizer.reduce_expression tctx (Optimizer.inline_constructors tctx e)) else Optimizer.sanitize com; - check_local_vars_init; captured_vars com; promote_complex_rhs com; if com.config.pf_add_final_return then add_final_return else (fun e -> e); diff --git a/tests/unit/src/unit/issues/Issue4076.hx b/tests/unit/src/unit/issues/Issue4076.hx new file mode 100644 index 00000000000..e7e511e1b0d --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4076.hx @@ -0,0 +1,11 @@ +package unit.issues; + +class Issue4076 extends Test { + function test() { + var i:Int; + var b = true; + while (b && ((i = 18) < 18)) { + ++i; + } + } +} \ No newline at end of file From 8a3053968e4487c62c8f3818f24926dd3757b62f Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 01:10:45 +0800 Subject: [PATCH 036/209] [ci] fixed local variable uninitialized error --- tests/RunCi.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index adecc5c84d3..3ab67578ede 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -124,12 +124,12 @@ class RunCi { var proc = new Process("haxelib", ["path", libName]); var result; var code = proc.exitCode(); - while(true) { + do { result = proc.stdout.readLine(); if (!result.startsWith("-L")) { break; } - } + } while(true); proc.close(); if (code != 0) { throw 'Failed to get haxelib path ($result)'; From 997add478a2bd5b5f7be08d61a1a34a56e1a1f88 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 03:43:43 +0800 Subject: [PATCH 037/209] [CI] Reduce noise. --- appveyor.yml | 20 ++++++++++---------- tests/RunCi.hx | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 88bbc25542c..c65d735e1ec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,30 +28,30 @@ install: - 'git submodule update --init --recursive' # Install ocaml using wodi - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ >log.txt || type log.txt' - - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz"' - - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh"' - - '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip"' + - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin" > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz" > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh" > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip" > log.txt || type log.txt' - 'set PATH=%PATH%;%CYG_ROOT%/opt/wodi%WODI_ARCH%/bin' # Install neko - cinst make -y - 'git clone --recursive https://github.com/HaxeFoundation/neko.git %NEKO_ROOT%' - 'cd %NEKO_ROOT%' - set PATH=%PATH%;%NEKO_ROOT%/bin - - msbuild neko_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild libs/libs_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + - msbuild neko_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" > log.txt || type log.txt + - msbuild libs/libs_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" > log.txt || type log.txt - copy /y libs\include\gc\gc.dll bin - cd %NEKO_ROOT%/src - neko ../boot/nekoc tools/install.neko - - neko tools/install -nolibs + - neko tools/install -nolibs > log.txt || type log.txt - neko -version build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" - haxelib setup "%HAXELIB_ROOT%" diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 3ab67578ede..5c2a6bb3eb7 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -485,13 +485,13 @@ class RunCi { //pass case TravisCI: changeDirectory(repoDir); - runCommand("make", ["BYTECODE=1"]); - runCommand("sudo", ["make", "install"]); + runCommand("make", ["BYTECODE=1", "OCAMLOPT=ocamlopt.opt", "-s"]); + runCommand("sudo", ["make", "install", "-s"]); changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); case AppVeyor: changeDirectory(repoDir); - runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} BYTECODE=1']); + runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLOPT=ocamlopt.opt BYTECODE=1']); changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); } From 26ca107f298f634796797e4edec574a0b5cfa2b1 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 04:19:02 +0800 Subject: [PATCH 038/209] [CI] when BYTECODE=1, set OCAMLC=ocamlc.opt --- tests/RunCi.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 5c2a6bb3eb7..23aae510257 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -491,7 +491,7 @@ class RunCi { runCommand("haxe", ["compile-macro.hxml"]); case AppVeyor: changeDirectory(repoDir); - runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLOPT=ocamlopt.opt BYTECODE=1']); + runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt BYTECODE=1']); changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); } From 5169e0abf5b4595b60a60415a17c07a0c2f61e5a Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 06:38:51 +0800 Subject: [PATCH 039/209] [test] Modified RunCi such that it is easier to be run on local machines. Briefly documented it in README.md. --- tests/README.md | 24 ++++++++++ tests/RunCi.hx | 107 ++++++++++++++++++++++++++++++------------- tests/unit/README.md | 7 --- 3 files changed, 99 insertions(+), 39 deletions(-) create mode 100644 tests/README.md delete mode 100644 tests/unit/README.md diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 00000000000..49a9cf6fb86 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,24 @@ +# Tests + +We have a number of test suites, which are placed in their own folders in this directory. + +"RunCi.hx" is the script used by our CIs to run all the test suites. It is possible to run it in local machines too: + + 1. Change to this directory. + 2. Install lib used by the script: `haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src`. + 3. Compile the script: `haxe -neko RunCi.n -main RunCi -lib hx-yaml`. + 4. Define the test target by 'export TEST=$TARGET', where "$TARGET" should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). + 5. Run it: `neko RunCi.n`. + +Note that the script will try to look for test dependencies and install them if they are not found. Look at the `getXXXDependencies` functions for the details. + +## Unit tests + +The "unit" folder contains a set of unit tests for the Haxe std library. Unit tests can be run separately instead of using "RunCi.hx", which runs all test suites. + +Assuming all test dependencies has been installed, we compile and run the unit tests for all targets at once as follows: + + 1. Change to the "unit" directory. + 2. Compile: `haxe compile.hxml`. + 3. Start a dev server: `nekotools server`. + 4. Open `http://localhost:2000/unit.html` in your browser. \ No newline at end of file diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 23aae510257..8c60f4356e7 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -43,7 +43,7 @@ enum Ci { AppVeyor: Setting file: "appveyor.yml". - Build result: https://ci.appveyor.com/project/Simn/haxe + Build result: https://ci.appveyor.com/project/HaxeFoundation/haxe */ class RunCi { static function successMsg(msg:String):Void { @@ -93,7 +93,7 @@ class RunCi { var name:String = (altName == null) ? repository : altName; try { getHaxelibPath(name); - infoMsg('Warning: $name has already been installed.'); + infoMsg('$name has already been installed.'); } catch (e:Dynamic) { var args:Array = ["git", name, 'https://github.com/$account/$repository']; if (branch != null) { @@ -110,7 +110,7 @@ class RunCi { static function haxelibInstall(library:String):Void { try { getHaxelibPath(library); - infoMsg('Warning: $library has already been installed.'); + infoMsg('$library has already been installed.'); } catch (e:Dynamic) { runCommand("haxelib", ["install", library]); } @@ -290,11 +290,21 @@ class RunCi { } } + static function commandSucceed(cmd:String, args:Array):Bool { + return try { + new Process(cmd, args).exitCode() == 0; + } catch(e:Dynamic) false; + } + static function getPhpDependencies() { switch (systemName) { case "Linux": - runCommand("sudo", ["apt-get", "install", "php5", "-qq"], true); - runCommand("sudo", ["apt-get", "install", "php5-mysql", "php5-sqlite", "-qq"], true); + if (commandSucceed("php", ["-v"])) { + infoMsg('php has already been installed.'); + } else { + runCommand("sudo", ["apt-get", "install", "php5", "-qq"], true); + runCommand("sudo", ["apt-get", "install", "php5-mysql", "php5-sqlite", "-qq"], true); + } case "Mac": //pass } @@ -315,13 +325,18 @@ class RunCi { //install and build hxcpp - haxelibInstallGit("HaxeFoundation", "hxcpp", true); - var oldDir = Sys.getCwd(); - changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/tools/hxcpp/"); - runCommand("haxe", ["compile.hxml"]); - changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/project/"); - runCommand("neko", ["build.n"]); - changeDirectory(oldDir); + try { + getHaxelibPath("hxcpp"); + infoMsg('hxcpp has already been installed.'); + } catch(e:Dynamic) { + haxelibInstallGit("HaxeFoundation", "hxcpp", true); + var oldDir = Sys.getCwd(); + changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/tools/hxcpp/"); + runCommand("haxe", ["compile.hxml"]); + changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/project/"); + runCommand("neko", ["build.n"]); + changeDirectory(oldDir); + } gotCppDependencies = true; } @@ -335,7 +350,11 @@ class RunCi { static function getJSDependencies() { switch (systemName) { case "Linux": - runCommand("sudo", ["apt-get", "install", "nodejs", "-qq"], true); + if (commandSucceed("node", ["-v"])) { + infoMsg('node has already been installed.'); + } else { + runCommand("sudo", ["apt-get", "install", "nodejs", "-qq"], true); + } case "Mac": //pass } @@ -346,10 +365,16 @@ class RunCi { static function getCsDependencies() { switch (systemName) { case "Linux": - runCommand("sudo", ["apt-get", "install", "mono-devel", "mono-mcs", "-qq"], true); + if (commandSucceed("mono", ["--version"])) + infoMsg('mono has already been installed.'); + else + runCommand("sudo", ["apt-get", "install", "mono-devel", "mono-mcs", "-qq"], true); runCommand("mono", ["--version"]); case "Mac": - runCommand("brew", ["install", "mono"], true); + if (commandSucceed("mono", ["--version"])) + infoMsg('mono has already been installed.'); + else + runCommand("brew", ["install", "mono"], true); runCommand("mono", ["--version"]); case "Windows": //pass @@ -391,21 +416,35 @@ class RunCi { static function getPythonDependencies():Array { switch (systemName) { case "Linux": - runCommand("sudo", ["apt-get", "install", "python3", "-qq"], true); + if (commandSucceed("python3", ["-V"])) + infoMsg('python3 has already been installed.'); + else + runCommand("sudo", ["apt-get", "install", "python3", "-qq"], true); runCommand("python3", ["-V"]); - var pypyVersion = "pypy3-2.4.0-linux64"; - runCommand("wget", ['https://bitbucket.org/pypy/pypy/downloads/${pypyVersion}.tar.bz2'], true); - runCommand("tar", ["-xf", '${pypyVersion}.tar.bz2']); - var pypy = FileSystem.fullPath('${pypyVersion}/bin/pypy3'); + var pypy = "pypy3"; + if (commandSucceed(pypy, ["-V"])) { + infoMsg('pypy3 has already been installed.'); + } else { + var pypyVersion = "pypy3-2.4.0-linux64"; + runCommand("wget", ['https://bitbucket.org/pypy/pypy/downloads/${pypyVersion}.tar.bz2'], true); + runCommand("tar", ["-xf", '${pypyVersion}.tar.bz2']); + pypy = FileSystem.fullPath('${pypyVersion}/bin/pypy3'); + } runCommand(pypy, ["-V"]); return ["python3", pypy]; case "Mac": - runCommand("brew", ["install", "python3"], true); + if (commandSucceed("python3", ["-V"])) + infoMsg('python3 has already been installed.'); + else + runCommand("brew", ["install", "python3"], true); runCommand("python3", ["-V"]); - runCommand("brew", ["install", "pypy3"], true); + if (commandSucceed("pypy3", ["-V"])) + infoMsg('pypy3 has already been installed.'); + else + runCommand("brew", ["install", "pypy3"], true); runCommand("pypy3", ["-V"]); return ["python3", "pypy3"]; @@ -650,16 +689,20 @@ class RunCi { setupFlashPlayerDebugger(); //setup flex sdk - var flexVersion = "4.14.0"; - runCommand("wget", ['http://archive.apache.org/dist/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true); - runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]); - var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin'; - Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + flexsdkPath + "/bin"); - var playerglobalswcFolder = flexsdkPath + "/player"; - FileSystem.createDirectory(playerglobalswcFolder + "/11.1"); - runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true); - File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder'); - runCommand("mxmlc", ["--version"]); + if (commandSucceed("mxmlc", ["--version"])) { + infoMsg('mxmlc has already been installed.'); + } else { + var flexVersion = "4.14.0"; + runCommand("wget", ['http://archive.apache.org/dist/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true); + runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]); + var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin'; + Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + flexsdkPath + "/bin"); + var playerglobalswcFolder = flexsdkPath + "/player"; + FileSystem.createDirectory(playerglobalswcFolder + "/11.1"); + runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true); + File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder'); + runCommand("mxmlc", ["--version"]); + } runCommand("haxe", ["compile-as3.hxml", "-D", "fdb"]); runFlash("bin/unit9_as3.swf"); diff --git a/tests/unit/README.md b/tests/unit/README.md deleted file mode 100644 index 8d8e62614ca..00000000000 --- a/tests/unit/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Unit test - -Here in this folder is a set of tests for the Haxe compiler. To compile and run the tests: - - 1. `haxe compile.hxml` - 2. `nekotools server` - 3. open `http://localhost:2000/unit.html` in your browser \ No newline at end of file From ef94b345b975f8afb7d823247ca992df81cb74c7 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 06:43:12 +0800 Subject: [PATCH 040/209] minor [skip ci] --- tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index 49a9cf6fb86..186d86313d1 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,7 +7,7 @@ We have a number of test suites, which are placed in their own folders in this d 1. Change to this directory. 2. Install lib used by the script: `haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src`. 3. Compile the script: `haxe -neko RunCi.n -main RunCi -lib hx-yaml`. - 4. Define the test target by 'export TEST=$TARGET', where "$TARGET" should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). + 4. Define the test target by `export TEST=$TARGET`, where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). 5. Run it: `neko RunCi.n`. Note that the script will try to look for test dependencies and install them if they are not found. Look at the `getXXXDependencies` functions for the details. @@ -21,4 +21,4 @@ Assuming all test dependencies has been installed, we compile and run the unit t 1. Change to the "unit" directory. 2. Compile: `haxe compile.hxml`. 3. Start a dev server: `nekotools server`. - 4. Open `http://localhost:2000/unit.html` in your browser. \ No newline at end of file + 4. Open `http://localhost:2000/unit.html` in your browser. From 85a9b51d7ee82c5eeb9fbe71caf6ee9ba7714da2 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 24 Mar 2015 21:37:05 +0800 Subject: [PATCH 041/209] [test] use xml to store arguments, such that we can test "\n" and to leave comments. --- tests/RunCi.hx | 5 ++++- tests/sys/args.txt | 3 --- tests/sys/args.xml | 9 +++++++++ tests/sys/compile-each.hxml | 2 +- tests/sys/src/TestSys.hx | 5 ++++- 5 files changed, 18 insertions(+), 6 deletions(-) delete mode 100644 tests/sys/args.txt create mode 100644 tests/sys/args.xml diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 8c60f4356e7..7a3beb4e2cb 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -471,7 +471,10 @@ class RunCi { static function main():Void { Sys.putEnv("OCAMLRUNPARAM", "b"); - var args = ~/\r?\n/g.split(File.getContent('$sysDir/args.txt')); + var args = [ + for (arg in new haxe.xml.Fast(Xml.parse(File.getContent('$sysDir/args.xml'))).node.args.nodes.arg) + arg.innerData + ]; var tests:Array = switch (ci) { case null: diff --git a/tests/sys/args.txt b/tests/sys/args.txt deleted file mode 100644 index e834157ec3b..00000000000 --- a/tests/sys/args.txt +++ /dev/null @@ -1,3 +0,0 @@ -foo -12 -a b %PATH% $HOME c\&<>["]#{}|%$ \ No newline at end of file diff --git a/tests/sys/args.xml b/tests/sys/args.xml new file mode 100644 index 00000000000..e8268cd6d22 --- /dev/null +++ b/tests/sys/args.xml @@ -0,0 +1,9 @@ + + + + + + +[\"]#{}|%$\""]]> + + \ No newline at end of file diff --git a/tests/sys/compile-each.hxml b/tests/sys/compile-each.hxml index dee27cc027b..e12ee3ad561 100644 --- a/tests/sys/compile-each.hxml +++ b/tests/sys/compile-each.hxml @@ -1,4 +1,4 @@ -debug -cp src --resource args.txt +-resource args.xml -main Main \ No newline at end of file diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 4b89b0835d5..6f541024f17 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -3,7 +3,10 @@ class TestSys extends haxe.unit.TestCase { #if !interp function testArgs() { var args = Sys.args(); - var expectedArgs = ~/\r?\n/g.split(haxe.Resource.getString("args.txt")); + var expectedArgs = [ + for (arg in new haxe.xml.Fast(Xml.parse(haxe.Resource.getString("args.xml"))).node.args.nodes.arg) + arg.innerData + ]; // trace(args); assertEquals(expectedArgs.length, args.length); for (i in 0...expectedArgs.length) { From b1ffbf79e027c03c6215d8ead445715c3cf19828 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 24 Mar 2015 22:44:31 +0800 Subject: [PATCH 042/209] [test] Added more sys arguments. --- tests/sys/args.xml | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/sys/args.xml b/tests/sys/args.xml index e8268cd6d22..1a3deb3edbc 100644 --- a/tests/sys/args.xml +++ b/tests/sys/args.xml @@ -1,3 +1,7 @@ + @@ -6,4 +10,48 @@ [\"]#{}|%$\""]]> + + + + + + + +]]> + +>]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c3952764120511f53142966f8d3d570b3ac3c7d6 Mon Sep 17 00:00:00 2001 From: frabbit Date: Wed, 25 Mar 2015 10:16:25 +0100 Subject: [PATCH 043/209] [python] fix modulo operator for negative numbers --- genpy.ml | 7 ++++++- std/haxe/Int32.hx | 2 +- std/python/internal/HxOverrides.hx | 6 +++++- tests/unit/src/unit/issues/Issue4068.hx | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4068.hx diff --git a/genpy.ml b/genpy.ml index 047ffaaec7e..f9d7c85bf16 100644 --- a/genpy.ml +++ b/genpy.ml @@ -1260,7 +1260,12 @@ module Printer = struct Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2) | _,_ -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (snd ops) (print_expr pctx e2)) | TBinop(OpMod,e1,e2) when (is_type1 "" "Int")(e1.etype) && (is_type1 "" "Int")(e2.etype) -> - Printf.sprintf "(%s %% %s)" (print_expr pctx e1) (print_expr pctx e2) + (match e1.eexpr with + | TConst(TInt(x)) when (Int32.to_int x) >= 0 -> + (* constant optimization *) + Printf.sprintf "%s %% %s" (print_expr pctx e1) (print_expr pctx e2) + | _ -> + Printf.sprintf "HxOverrides.mod(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)) | TBinop(OpMod,e1,e2) -> Printf.sprintf "HxOverrides.modf(%s, %s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpUShr,e1,e2) -> diff --git a/std/haxe/Int32.hx b/std/haxe/Int32.hx index aad42ce40c2..8cce274a6c8 100644 --- a/std/haxe/Int32.hx +++ b/std/haxe/Int32.hx @@ -192,7 +192,7 @@ abstract Int32(Int) from Int to Int { // we might be on 64-bit php, so sign extend from 32-bit return (x << extraBits) >> extraBits; #elseif python - return (x + python.Syntax.opPow(2, 31)) % python.Syntax.opPow(2, 32) - python.Syntax.opPow(2, 31); + return python.Syntax.pythonCode("{0} % {1}", (x + python.Syntax.opPow(2, 31)), python.Syntax.opPow(2, 32)) - python.Syntax.opPow(2, 31); #else return (x); #end diff --git a/std/python/internal/HxOverrides.hx b/std/python/internal/HxOverrides.hx index 8290b85f43e..f3398d69a75 100644 --- a/std/python/internal/HxOverrides.hx +++ b/std/python/internal/HxOverrides.hx @@ -124,7 +124,11 @@ class HxOverrides { @:ifFeature("binop_%") static public function modf(a:Float, b:Float) { - return Syntax.pythonCode("float('nan') if (b == 0.0) else a % b if a > 0 else -(-a % b)"); + return Syntax.pythonCode("float('nan') if (b == 0.0) else a % b if a >= 0 else -(-a % b)"); + } + @:ifFeature("binop_%") + static public function mod(a:Int, b:Int) { + return Syntax.pythonCode("a % b if a >= 0 else -(-a % b)"); } @:ifFeature("dynamic_array_read") diff --git a/tests/unit/src/unit/issues/Issue4068.hx b/tests/unit/src/unit/issues/Issue4068.hx new file mode 100644 index 00000000000..8a4c70c3c7a --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4068.hx @@ -0,0 +1,20 @@ +package unit.issues; + +class Issue4068 extends Test { + function test() { + eq(-30 % 100, -30); + eq(0 % 100, 0); + eq(-100 % 100, 0); + eq(-30.0 % 100.0, -30.0); + eq(30 % 100, 30); + eq(30.0 % 100.0, 30.0); + + function i (x) return x; + + eq(i(-30) % i(100), i(-30)); + eq(i(0) % i(100), i(0)); + eq(i(-100) % i(100), i(0) ); + eq(i(30) % i(100), i(30)); + } + +} \ No newline at end of file From 39dc01e0580a1dd132d4cf5182b5fb14eccc6dd2 Mon Sep 17 00:00:00 2001 From: hughsando Date: Wed, 25 Mar 2015 19:22:18 +0800 Subject: [PATCH 044/209] [cpp] Mark toPointer as extern --- std/cpp/ConstCharStar.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cpp/ConstCharStar.hx b/std/cpp/ConstCharStar.hx index b7e8ff8ccd4..f22e5e371ce 100644 --- a/std/cpp/ConstCharStar.hx +++ b/std/cpp/ConstCharStar.hx @@ -7,7 +7,7 @@ abstract ConstCharStar( RawConstPointer ) to(RawConstPointer) @:from static public inline function fromString(s:String) return new ConstCharStar(s); - @:to + @:to @:extern public inline function toPointer() return this; } From 633169f6122c1cd470db639913b894884603892b Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 19:21:27 +0800 Subject: [PATCH 045/209] [test] Comment out argument test cases that fail on Windows. --- tests/sys/args.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/sys/args.xml b/tests/sys/args.xml index 1a3deb3edbc..bf097d46b9b 100644 --- a/tests/sys/args.xml +++ b/tests/sys/args.xml @@ -8,8 +8,6 @@ We may compare and update the test cases of other popular langs/libs: https://gi -[\"]#{}|%$\""]]> - @@ -33,10 +31,10 @@ We may compare and update the test cases of other popular langs/libs: https://gi - + - + @@ -52,6 +50,9 @@ We may compare and update the test cases of other popular langs/libs: https://gi ]]> --> - + + + + \ No newline at end of file From b7952d1df2bd40dca456acc76b322ca09210d85d Mon Sep 17 00:00:00 2001 From: hughsando Date: Wed, 25 Mar 2015 20:04:31 +0800 Subject: [PATCH 046/209] [cpp] Add some helper functions for loading dlls --- std/cpp/Lib.hx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/std/cpp/Lib.hx b/std/cpp/Lib.hx index 602d5c73bf9..0267795b14e 100644 --- a/std/cpp/Lib.hx +++ b/std/cpp/Lib.hx @@ -94,6 +94,15 @@ class Lib { return result; } + public static function pushDllSearchPath(inPath:String) : Void + untyped __global__.__hxcpp_push_dll_path(inPath); + + public static function getDllExtension() : String + return untyped __global__.__hxcpp_get_dll_extension(); + + public static function getBinDirectory() : String + return untyped __global__.__hxcpp_get_bin_dir(); + /** Returns bytes referencing the content of a string. Use with extreme caution - changing constant strings will crash. From c4a3794769b331372f62c8950fe3aa47578abab0 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 19:36:41 +0800 Subject: [PATCH 047/209] [AppVeyor] Run Java and C++ too. --- tests/RunCi.hx | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 7a3beb4e2cb..4f3d164db71 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -216,7 +216,7 @@ class RunCi { Sys.exit(1); } - static function runExe(exe:String, ?args:Array):Void { + static function runCs(exe:String, ?args:Array):Void { if (args == null) args = []; exe = FileSystem.fullPath(exe); switch (systemName) { @@ -227,6 +227,12 @@ class RunCi { } } + static function runCpp(bin:String, ?args:Array):Void { + if (args == null) args = []; + bin = FileSystem.fullPath(bin); + runCommand(bin, args); + } + static function parseCommand(cmd:String) { var args = []; var offset = 0; @@ -331,9 +337,9 @@ class RunCi { } catch(e:Dynamic) { haxelibInstallGit("HaxeFoundation", "hxcpp", true); var oldDir = Sys.getCwd(); - changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/tools/hxcpp/"); + changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/"); runCommand("haxe", ["compile.hxml"]); - changeDirectory(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/project/"); + changeDirectory(getHaxelibPath("hxcpp") + "project/"); runCommand("neko", ["build.n"]); changeDirectory(oldDir); } @@ -482,7 +488,7 @@ class RunCi { case TravisCI: [Sys.getEnv("TEST")]; case AppVeyor: - [Neko, Cs, Macro]; + [Neko, Cs, Java, Cpp, Macro]; } Sys.println('Going to test: $tests'); @@ -572,17 +578,17 @@ class RunCi { case Cpp: getCppDependencies(); runCommand("haxe", ["compile-cpp.hxml"]); - runCommand("./bin/cpp/Test-debug", []); + runCpp("bin/cpp/Test-debug", []); runCommand("rm", ["-rf", "cpp"]); runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"]); - runCommand("./bin/cpp/Test-debug", []); + runCpp("bin/cpp/Test-debug", []); changeDirectory(sysDir); runCommand("haxe", ["compile-cpp.hxml"]); changeDirectory("bin/cpp"); - runCommand("./Main-debug", args); + runCpp("Main-debug", args); case Js: getJSDependencies(); @@ -655,33 +661,33 @@ class RunCi { }; runCommand("haxe", ['compile-cs$compl.hxml']); - runExe("bin/cs/bin/Test-Debug.exe"); + runCs("bin/cs/bin/Test-Debug.exe"); runCommand("haxe", ['compile-cs-unsafe$compl.hxml']); - runExe("bin/cs_unsafe/bin/Test-Debug.exe"); + runCs("bin/cs_unsafe/bin/Test-Debug.exe"); runCommand("haxe", ['compile-cs$compl.hxml',"-D","erase_generics"]); - runExe("bin/cs/bin/Test-Debug.exe"); + runCs("bin/cs/bin/Test-Debug.exe"); runCommand("haxe", ['compile-cs-unsafe$compl.hxml',"-D","erase_generics"]); - runExe("bin/cs_unsafe/bin/Test-Debug.exe"); + runCs("bin/cs_unsafe/bin/Test-Debug.exe"); runCommand("haxe", ['compile-cs$compl.hxml',"-D","no_root"]); - runExe("bin/cs/bin/Test-Debug.exe"); + runCs("bin/cs/bin/Test-Debug.exe"); runCommand("haxe", ['compile-cs-unsafe$compl.hxml',"-D","no_root","-D","erase_generics"]); - runExe("bin/cs_unsafe/bin/Test-Debug.exe"); + runCs("bin/cs_unsafe/bin/Test-Debug.exe"); changeDirectory(sysDir); runCommand("haxe", ["compile-cs.hxml"]); changeDirectory("bin/cs"); - runExe("bin/Main-Debug.exe", args); + runCs("bin/Main-Debug.exe", args); changeDirectory(miscDir + "csTwoLibs"); for (i in 1...5) { runCommand("haxe", ['compile-$i.hxml']); - runExe("bin/main/bin/Main.exe"); + runCs("bin/main/bin/Main.exe"); } case Flash9: From 70b1356da7d3c548e4328c38db1ad0b4ef935bb6 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 25 Mar 2015 22:02:42 +0800 Subject: [PATCH 048/209] [AppVeyor] Try to fit into the 60 min time limit. --- tests/RunCi.hx | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 4f3d164db71..dd12567573c 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -502,24 +502,24 @@ class RunCi { changeDirectory(miscDir); runCommand("haxe", ["compile.hxml"]); - //generate documentation - haxelibInstallGit("Simn", "hxparse", "development", "src", true); - haxelibInstallGit("Simn", "hxtemplo", true); - haxelibInstallGit("Simn", "hxargs", true); - haxelibInstallGit("dpeek", "haxe-markdown", "master", "src", true, "markdown"); - - haxelibInstallGit("HaxeFoundation", "hxcpp", true); - haxelibInstallGit("HaxeFoundation", "hxjava", true); - haxelibInstallGit("HaxeFoundation", "hxcs", true); - - haxelibInstallGit("dpeek", "dox", true); - changeDirectory(getHaxelibPath("dox")); - runCommand("haxe", ["run.hxml"]); - runCommand("haxe", ["gen.hxml"]); switch (ci) { case AppVeyor: - //do not build zip to save time + //save time... case _: + //generate documentation + haxelibInstallGit("Simn", "hxparse", "development", "src", true); + haxelibInstallGit("Simn", "hxtemplo", true); + haxelibInstallGit("Simn", "hxargs", true); + haxelibInstallGit("dpeek", "haxe-markdown", "master", "src", true, "markdown"); + + haxelibInstallGit("HaxeFoundation", "hxcpp", true); + haxelibInstallGit("HaxeFoundation", "hxjava", true); + haxelibInstallGit("HaxeFoundation", "hxcs", true); + + haxelibInstallGit("dpeek", "dox", true); + changeDirectory(getHaxelibPath("dox")); + runCommand("haxe", ["run.hxml"]); + runCommand("haxe", ["gen.hxml"]); haxelibRun(["dox", "-o", "bin/api.zip", "-i", "bin/xml"]); } @@ -580,10 +580,14 @@ class RunCi { runCommand("haxe", ["compile-cpp.hxml"]); runCpp("bin/cpp/Test-debug", []); - runCommand("rm", ["-rf", "cpp"]); - - runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"]); - runCpp("bin/cpp/Test-debug", []); + switch (ci) { + case AppVeyor: + //save time... + case _: + runCommand("rm", ["-rf", "cpp"]); + runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"]); + runCpp("bin/cpp/Test-debug", []); + } changeDirectory(sysDir); runCommand("haxe", ["compile-cpp.hxml"]); From 7f86f1ae47526ed791a545dff7dbf8ae08977425 Mon Sep 17 00:00:00 2001 From: hughsando Date: Wed, 25 Mar 2015 23:07:42 +0800 Subject: [PATCH 049/209] [cpp] Move cpp.Prime.load into its own file, and allow for neko compatibility --- std/cpp/Callable.hx | 17 ++++++ std/cpp/Lib.hx | 47 ----------------- std/cpp/Prime.hx | 123 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 47 deletions(-) create mode 100644 std/cpp/Prime.hx diff --git a/std/cpp/Callable.hx b/std/cpp/Callable.hx index c23e74456cc..6488a1dc072 100644 --- a/std/cpp/Callable.hx +++ b/std/cpp/Callable.hx @@ -1,5 +1,22 @@ package cpp; +#if cpp + typedef Callable = Function +#else + +@:noPackageRestrict +abstract Callable(T) +{ + public var call(get,never):T; + + inline public function new(inValue:T) this = inValue; + + inline function get_call():T return this; +} + + +#end + diff --git a/std/cpp/Lib.hx b/std/cpp/Lib.hx index 0267795b14e..425c3f5fa16 100644 --- a/std/cpp/Lib.hx +++ b/std/cpp/Lib.hx @@ -21,24 +21,9 @@ */ package cpp; -#if macro -import haxe.macro.Context; -import haxe.macro.Type; -import haxe.macro.Expr; -#else -using cpp.NativeString; -using cpp.RawConstPointer; -using cpp.Char; - -#end - -#if macro -@:noPackageRestrict -#end class Lib { - #if !macro /** Load and return a Cpp primitive from a DLL library. **/ @@ -144,41 +129,9 @@ class Lib { untyped __global__.__hxcpp_println(v); } - #else - static function codeToType(code:String) : String - { - switch(code) - { - case "b" : return "Bool"; - case "i" : return "Int"; - case "d" : return "Float"; - case "f" : return "cpp.Float32"; - case "s" : return "String"; - case "o" : return "cpp.Object"; - case "v" : return "cpp.Void"; - case "c" : return "cpp.ConstCharStar"; - default: - throw "Unknown signature type :" + code; - } - } - #end - public static function setFloatFormat(inFormat:String):Void { untyped __global__.__hxcpp_set_float_format(inFormat); } - public static macro function loadPrime(inModule:String, inName:String, inSig:String,inAllowFail:Bool = false) - { - var parts = inSig.split(""); - if (parts.length<1) - throw "Invalid function signature " + inSig; - var typeString = parts.length==1 ? "Void" : codeToType(parts.shift()); - for(p in parts) - typeString += "->" + codeToType(p); - typeString = "cpp.Callable<" + typeString + ">"; - var expr = 'new $typeString(cpp.Lib._loadPrime("$inModule","$inName","$inSig",$inAllowFail))'; - return Context.parse( expr, Context.currentPos() ); - } - } diff --git a/std/cpp/Prime.hx b/std/cpp/Prime.hx new file mode 100644 index 00000000000..5f601907883 --- /dev/null +++ b/std/cpp/Prime.hx @@ -0,0 +1,123 @@ +/* + * Copyright (C)2005-2012 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package cpp; + +#if macro +import haxe.macro.Context; +import haxe.macro.Type; +import haxe.macro.Expr; +#end + +@:noPackageRestrict +class Prime { + + #if (!macro && cpp) + + @:analyzer(no_simplification) + public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic { + var factory:Callable< ConstCharStar -> Object > = + untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail); + if (factory!=null) + { + var func:Dynamic = factory.call(signature); + if (func==null && !quietFail) + throw '$prim does not have signature $signature'; + return func; + } + return null; + } + #end + + #if (macro) + static function codeToType(code:String,forCpp:Bool) : String + { + var isCpp = Context.defined("cpp"); + + switch(code) + { + case "b" : return "Bool"; + case "i" : return "Int"; + case "d" : return "Float"; + case "s" : return "String"; + case "f" : return forCpp ? "cpp.Float32" : "Float"; + case "o" : return forCpp ? "cpp.Object" : "Dynamic"; + case "v" : return forCpp ? "cpp.Void" : "Dynamic"; + case "c" : + if (forCpp) + return "cpp.ConstCharStar"; + throw "const char * type only supported in cpp mode"; + default: + throw "Unknown signature type :" + code; + } + } + #end + + public static function nekoInit(inModuleName:String) : Bool + { + #if neko + var init = neko.Lib.load(inModuleName, "neko_init", 5); + + if (init != null) + { + init( function(s) return new String(s), + function(len:Int) { var r = []; if (len > 0) r[len - 1] = null; return r; }, + null, + true, + false); + return true; + + } + #end + return false; + } + + + public static macro function load(inModule:String, inName:String, inSig:String,inAllowFail:Bool = false) + { + var parts = inSig.split(""); + if (parts.length<1) + throw "Invalid function signature " + inSig; + + var cppMode = Context.defined("cpp"); + + var typeString = parts.length==1 ? codeToType("v",cppMode) : codeToType(parts.shift(),cppMode); + for(p in parts) + typeString += "->" + codeToType(p,cppMode); + + if (cppMode) + { + typeString = "cpp.Callable<" + typeString + ">"; + var expr = 'new $typeString(cpp.Prime._loadPrime("$inModule","$inName","$inSig",$inAllowFail))'; + return Context.parse( expr, Context.currentPos() ); + } + else + { + var len = parts.length; + if (len>5) + len = -1; + var lazy = inAllowFail ? "loadLazy" : "load"; + var expr = 'new cpp.Callable<$typeString>(neko.Lib.$lazy("$inModule","$inName",$len))'; + return Context.parse( expr, Context.currentPos() ); + } + } + +} From 5e4b7f97930278513cf939a5ad83759a6282dcc5 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Thu, 26 Mar 2015 17:29:04 +0800 Subject: [PATCH 050/209] [test] sys test upgrade * Test PHP * Decoupled sys test from RunCi, particularly RunCi doesn't have to pass the test arguments. * Added test cases for Sys.command, sys.io.Process, and Sys.exitCode --- .travis.yml | 2 +- appveyor.yml | 2 +- tests/README.md | 13 ++++- tests/RunCi.hx | 26 ++++----- tests/RunCi.hxml | 3 ++ tests/sys/.gitignore | 2 + tests/sys/compile-cpp.hxml | 11 ++++ tests/sys/compile-cs.hxml | 11 ++++ tests/sys/compile-each.hxml | 3 +- tests/sys/compile-java.hxml | 11 ++++ tests/sys/compile-macro.hxml | 1 + tests/sys/compile-neko.hxml | 13 ++++- tests/sys/compile-php.hxml | 13 +++++ tests/sys/compile-python.hxml | 13 ++++- tests/sys/compile.hxml | 3 ++ tests/sys/run.hxml | 28 ++++++++++ tests/sys/src/ExitCode.hx | 37 +++++++++++++ tests/sys/src/Main.hx | 1 + tests/sys/src/TestArguments.hx | 63 ++++++++++++++++++++++ tests/sys/src/TestSys.hx | 90 +++++++++++++++++++++++++------ tests/sys/src/io/TestFileInput.hx | 6 ++- tests/sys/src/io/TestProcess.hx | 84 +++++++++++++++++++++++++++++ 22 files changed, 395 insertions(+), 41 deletions(-) create mode 100644 tests/RunCi.hxml create mode 100644 tests/sys/.gitignore create mode 100644 tests/sys/compile-php.hxml create mode 100644 tests/sys/run.hxml create mode 100644 tests/sys/src/ExitCode.hx create mode 100644 tests/sys/src/TestArguments.hx create mode 100644 tests/sys/src/io/TestProcess.hx diff --git a/.travis.yml b/.travis.yml index 3034a18e606..864cc94a092 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ script: - mkdir ~/haxelib && haxelib setup ~/haxelib - haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src - haxe -version - - haxe -neko RunCi.n -main RunCi -lib hx-yaml + - haxe RunCi.hxml - neko RunCi.n branches: diff --git a/appveyor.yml b/appveyor.yml index c65d735e1ec..6876ba463bf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -60,5 +60,5 @@ build_script: test_script: - cd %APPVEYOR_BUILD_FOLDER%/tests/ - haxe -version - - haxe -neko RunCi.n -main RunCi -lib hx-yaml + - haxe RunCi.hxml - neko RunCi.n diff --git a/tests/README.md b/tests/README.md index 186d86313d1..ab2c0f32cf7 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,8 +6,8 @@ We have a number of test suites, which are placed in their own folders in this d 1. Change to this directory. 2. Install lib used by the script: `haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src`. - 3. Compile the script: `haxe -neko RunCi.n -main RunCi -lib hx-yaml`. - 4. Define the test target by `export TEST=$TARGET`, where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). + 3. Compile the script: `haxe RunCi.hxml`. + 4. Define the test target by `export TEST=$TARGET` (or `set "TEST=$TARGET"` on Windows), where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). 5. Run it: `neko RunCi.n`. Note that the script will try to look for test dependencies and install them if they are not found. Look at the `getXXXDependencies` functions for the details. @@ -22,3 +22,12 @@ Assuming all test dependencies has been installed, we compile and run the unit t 2. Compile: `haxe compile.hxml`. 3. Start a dev server: `nekotools server`. 4. Open `http://localhost:2000/unit.html` in your browser. + +## Sys tests + +The "sys" folder contains tests for the system targets. It can also be run separately instead of using "RunCi.hx". + +Assuming all test dependencies has been installed, we compile and run the sys tests for all targets at once as follows: + + 1. Change to the "sys" directory. + 2. If you're on Windows, comment out the relevant lines in "run.hxml". `haxe run.hxml`. \ No newline at end of file diff --git a/tests/RunCi.hx b/tests/RunCi.hx index dd12567573c..927a25d3599 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -477,11 +477,6 @@ class RunCi { static function main():Void { Sys.putEnv("OCAMLRUNPARAM", "b"); - var args = [ - for (arg in new haxe.xml.Fast(Xml.parse(File.getContent('$sysDir/args.xml'))).node.args.nodes.arg) - arg.innerData - ]; - var tests:Array = switch (ci) { case null: [Sys.getEnv("TEST") == null ? Macro : Sys.getEnv("TEST")]; @@ -525,7 +520,7 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-macro.hxml"]); - runCommand("haxe", ["compile-each.hxml", "--run", "Main"].concat(args)); + runCommand("haxe", ["compile-each.hxml", "--run", "Main"]); //BYTECODE switch (ci) { @@ -549,12 +544,15 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-neko.hxml"]); - changeDirectory("bin/neko"); - runCommand("neko", ["sys.n"].concat(args)); + runCommand("neko", ["bin/neko/sys.n"]); case Php: getPhpDependencies(); runCommand("haxe", ["compile-php.hxml","-D","travis"]); runCommand("php", ["bin/php/index.php"]); + + changeDirectory(sysDir); + runCommand("haxe", ["compile-php.hxml"]); + runCommand("php", ["bin/php/Main/index.php"]); case Python: var pys = getPythonDependencies(); @@ -565,9 +563,8 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-python.hxml"]); - changeDirectory("bin/python"); for (py in pys) { - runCommand(py, ["sys.py"].concat(args)); + runCommand(py, ["bin/python/sys.py"]); } changeDirectory(miscDir + "pythonImport"); @@ -591,8 +588,7 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-cpp.hxml"]); - changeDirectory("bin/cpp"); - runCpp("Main-debug", args); + runCpp("bin/cpp/Main-debug", []); case Js: getJSDependencies(); @@ -636,8 +632,7 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-java.hxml"]); - changeDirectory("bin/java"); - runCommand("java", ["-jar", "Main-Debug.jar"].concat(args)); + runCommand("java", ["-jar", "bin/java/Main-Debug.jar"]); infoMsg("Testing java-lib extras"); changeDirectory('$unitDir/bin'); @@ -684,8 +679,7 @@ class RunCi { changeDirectory(sysDir); runCommand("haxe", ["compile-cs.hxml"]); - changeDirectory("bin/cs"); - runCs("bin/Main-Debug.exe", args); + runCs("bin/cs/bin/Main-Debug.exe", []); changeDirectory(miscDir + "csTwoLibs"); for (i in 1...5) diff --git a/tests/RunCi.hxml b/tests/RunCi.hxml new file mode 100644 index 00000000000..0a7429b5641 --- /dev/null +++ b/tests/RunCi.hxml @@ -0,0 +1,3 @@ +-neko RunCi.n +-main RunCi +-lib hx-yaml \ No newline at end of file diff --git a/tests/sys/.gitignore b/tests/sys/.gitignore new file mode 100644 index 00000000000..b9ee2b1e3cd --- /dev/null +++ b/tests/sys/.gitignore @@ -0,0 +1,2 @@ +TestArguments.txt +testcase-test-file.txt \ No newline at end of file diff --git a/tests/sys/compile-cpp.hxml b/tests/sys/compile-cpp.hxml index 3bdbc1ba553..ce4b037a68c 100644 --- a/tests/sys/compile-cpp.hxml +++ b/tests/sys/compile-cpp.hxml @@ -1,2 +1,13 @@ compile-each.hxml +-main Main +-cpp bin/cpp + +--next +compile-each.hxml +-main TestArguments +-cpp bin/cpp + +--next +compile-each.hxml +-main ExitCode -cpp bin/cpp \ No newline at end of file diff --git a/tests/sys/compile-cs.hxml b/tests/sys/compile-cs.hxml index 8992d333034..bfad66e6b56 100644 --- a/tests/sys/compile-cs.hxml +++ b/tests/sys/compile-cs.hxml @@ -1,2 +1,13 @@ compile-each.hxml +-main Main -cs bin/cs + +--next +compile-each.hxml +-main TestArguments +-cs bin/cs + +--next +compile-each.hxml +-main ExitCode +-cs bin/cs \ No newline at end of file diff --git a/tests/sys/compile-each.hxml b/tests/sys/compile-each.hxml index e12ee3ad561..4ad809bfac9 100644 --- a/tests/sys/compile-each.hxml +++ b/tests/sys/compile-each.hxml @@ -1,4 +1,3 @@ -debug -cp src --resource args.xml --main Main \ No newline at end of file +-resource args.xml \ No newline at end of file diff --git a/tests/sys/compile-java.hxml b/tests/sys/compile-java.hxml index 2ff29143a01..ae5a244db8a 100644 --- a/tests/sys/compile-java.hxml +++ b/tests/sys/compile-java.hxml @@ -1,2 +1,13 @@ compile-each.hxml +-main Main -java bin/java + +--next +compile-each.hxml +-main TestArguments +-java bin/java + +--next +compile-each.hxml +-main ExitCode +-java bin/java \ No newline at end of file diff --git a/tests/sys/compile-macro.hxml b/tests/sys/compile-macro.hxml index 4015d6dd48b..df74836607f 100644 --- a/tests/sys/compile-macro.hxml +++ b/tests/sys/compile-macro.hxml @@ -1,2 +1,3 @@ compile-each.hxml +-main Main --interp \ No newline at end of file diff --git a/tests/sys/compile-neko.hxml b/tests/sys/compile-neko.hxml index 06cd85be96d..7d2306e817b 100644 --- a/tests/sys/compile-neko.hxml +++ b/tests/sys/compile-neko.hxml @@ -1,2 +1,13 @@ compile-each.hxml --neko bin/neko/sys.n \ No newline at end of file +-main Main +-neko bin/neko/sys.n + +--next +compile-each.hxml +-main TestArguments +-neko bin/neko/TestArguments.n + +--next +compile-each.hxml +-main ExitCode +-neko bin/neko/ExitCode.n \ No newline at end of file diff --git a/tests/sys/compile-php.hxml b/tests/sys/compile-php.hxml new file mode 100644 index 00000000000..471789e7fde --- /dev/null +++ b/tests/sys/compile-php.hxml @@ -0,0 +1,13 @@ +compile-each.hxml +-main Main +-php bin/php/Main + +--next +compile-each.hxml +-main TestArguments +-php bin/php/TestArguments + +--next +compile-each.hxml +-main ExitCode +-php bin/php/ExitCode \ No newline at end of file diff --git a/tests/sys/compile-python.hxml b/tests/sys/compile-python.hxml index db38fadd336..01a8706aff2 100644 --- a/tests/sys/compile-python.hxml +++ b/tests/sys/compile-python.hxml @@ -1,2 +1,13 @@ compile-each.hxml --python bin/python/sys.py \ No newline at end of file +-main Main +-python bin/python/sys.py + +--next +compile-each.hxml +-main TestArguments +-python bin/python/TestArguments.py + +--next +compile-each.hxml +-main ExitCode +-python bin/python/ExitCode.py \ No newline at end of file diff --git a/tests/sys/compile.hxml b/tests/sys/compile.hxml index 87abac3c177..f413aa57782 100644 --- a/tests/sys/compile.hxml +++ b/tests/sys/compile.hxml @@ -1,3 +1,6 @@ +# This is not run by CIs, just for convenience when testing manually. +# Note that compile-macro.hxml is not included. + --next compile-neko.hxml --next compile-python.hxml --next compile-cpp.hxml diff --git a/tests/sys/run.hxml b/tests/sys/run.hxml new file mode 100644 index 00000000000..fb243816108 --- /dev/null +++ b/tests/sys/run.hxml @@ -0,0 +1,28 @@ +# This is not run by CIs, just for convenience when testing manually. + +# Compile everything first. +compile.hxml + +# Mac/Linux +--next +-cmd echo Neko && neko bin/neko/sys.n +-cmd echo Python && python3 bin/python/sys.py +-cmd echo Cpp && bin/cpp/Main-Debug +-cmd echo CS && mono bin/cs/bin/Main-Debug.exe +-cmd echo Java && java -jar bin/java/Main-Debug.jar +-cmd echo Php && php bin/php/Main/index.php + +# Windows +# --next +# -cmd echo Neko && neko bin\neko\sys.n +# -cmd echo Python && python3 bin\python\sys.py +# -cmd echo Cpp && bin\cpp\Main-Debug.exe +# -cmd echo CS && bin\cs\bin\Main-Debug.exe +# -cmd echo Java && java -jar bin\java\Main-Debug.jar +# -cmd echo Php && php bin\php\Main\index.php + +# Macro has to be placed at the end since it would exit the compilation process. +--next +-cmd echo Macro +--next +compile-macro.hxml \ No newline at end of file diff --git a/tests/sys/src/ExitCode.hx b/tests/sys/src/ExitCode.hx new file mode 100644 index 00000000000..6c01a37b63c --- /dev/null +++ b/tests/sys/src/ExitCode.hx @@ -0,0 +1,37 @@ +/** + This is intented to be used by TestSys and io.TestProcess. +*/ +class ExitCode { + static public var bin:String = + #if neko + "bin/neko/ExitCode.n"; + #elseif cpp + #if debug + "bin/cpp/ExitCode-debug"; + #else + "bin/cpp/ExitCode"; + #end + #elseif cs + #if debug + "bin/cs/bin/ExitCode-Debug.exe"; + #else + "bin/cs/bin/ExitCode.exe"; + #end + #elseif java + #if debug + "bin/java/ExitCode-Debug.jar"; + #else + "bin/java/ExitCode.jar"; + #end + #elseif python + "bin/python/ExitCode.py"; + #elseif php + "bin/php/ExitCode/index.php"; + #else + null; + #end + + static function main():Void { + Sys.exit(Std.parseInt(Sys.args()[0])); + } +} \ No newline at end of file diff --git a/tests/sys/src/Main.hx b/tests/sys/src/Main.hx index f7cc9aa49be..b4aa92243df 100644 --- a/tests/sys/src/Main.hx +++ b/tests/sys/src/Main.hx @@ -4,6 +4,7 @@ class Main { runner.add(new TestSys()); runner.add(new TestFileSystem()); runner.add(new io.TestFileInput()); + runner.add(new io.TestProcess()); var code = runner.run() ? 0 : 1; Sys.exit(code); } diff --git a/tests/sys/src/TestArguments.hx b/tests/sys/src/TestArguments.hx new file mode 100644 index 00000000000..a860476e203 --- /dev/null +++ b/tests/sys/src/TestArguments.hx @@ -0,0 +1,63 @@ +/** + This test is intented to be used by TestSys and io.TestProcess. +*/ +class TestArguments extends haxe.unit.TestCase { + static public var expectedArgs(get, null):Array; + static function get_expectedArgs() { + return expectedArgs != null ? expectedArgs : expectedArgs = [ + for (arg in new haxe.xml.Fast(Xml.parse(haxe.Resource.getString("args.xml"))).node.args.nodes.arg) + arg.innerData + ]; + } + + static public var bin:String = + #if neko + "bin/neko/TestArguments.n"; + #elseif cpp + #if debug + "bin/cpp/TestArguments-debug"; + #else + "bin/cpp/TestArguments"; + #end + #elseif cs + #if debug + "bin/cs/bin/TestArguments-Debug.exe"; + #else + "bin/cs/bin/TestArguments.exe"; + #end + #elseif java + #if debug + "bin/java/TestArguments-Debug.jar"; + #else + "bin/java/TestArguments.jar"; + #end + #elseif python + "bin/python/TestArguments.py"; + #elseif php + "bin/php/TestArguments/index.php"; + #else + null; + #end + + function testArgs() { + var args = Sys.args(); + // trace(args); + for (i in 0...expectedArgs.length) { + assertEquals(expectedArgs[i], args[i]); + } + assertEquals(expectedArgs.length, args.length); + } + + static function main():Void { + var log = sys.io.File.write("TestArguments.txt"); + haxe.unit.TestRunner.print = function(v){ + log.writeString(v); + }; + var runner = new haxe.unit.TestRunner(); + runner.add(new TestArguments()); + var code = runner.run() ? 0 : 1; + log.flush(); + log.close(); + Sys.exit(code); + } +} \ No newline at end of file diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 6f541024f17..b0090247b4a 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -1,28 +1,87 @@ class TestSys extends haxe.unit.TestCase { - // it receives the arguments passed to Haxe command line - #if !interp - function testArgs() { - var args = Sys.args(); - var expectedArgs = [ - for (arg in new haxe.xml.Fast(Xml.parse(haxe.Resource.getString("args.xml"))).node.args.nodes.arg) - arg.innerData - ]; - // trace(args); - assertEquals(expectedArgs.length, args.length); - for (i in 0...expectedArgs.length) { - assertEquals(expectedArgs[i], args[i]); + function testCommand() { + var bin = TestArguments.bin; + var args = TestArguments.expectedArgs; + + var exitCode = Sys.command("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); + assertEquals(0, exitCode); + + var exitCode = + #if (macro || interp) + Sys.command("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); + #elseif cpp + Sys.command(bin, args); + #elseif cs + switch (Sys.systemName()) { + case "Windows": + Sys.command(bin, args); + case _: + Sys.command("mono", [bin].concat(args)); + } + #elseif java + Sys.command("java", ["-jar", bin].concat(args)); + #elseif python + Sys.command("python3", [bin].concat(args)); + #elseif neko + Sys.command("neko", [bin].concat(args)); + #elseif php + Sys.command("php", [bin].concat(args)); + #else + -1; + #end + assertEquals(0, exitCode); + } + + function testExitCode() { + var bin = ExitCode.bin; + + // Just test only a few to save time. + // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html + var codes = [0, 1, 2, 126, 127, 128, 130, 255]; + + for (code in codes) { + var args = [Std.string(code)]; + var exitCode = Sys.command("haxe", ["compile-each.hxml", "--run", "ExitCode"].concat(args)); + assertEquals(code, exitCode); + } + + for (code in codes) { + var args = [Std.string(code)]; + var exitCode = + #if (macro || interp) + Sys.command("haxe", ["compile-each.hxml", "--run", "ExitCode"].concat(args)); + #elseif cpp + Sys.command(bin, args); + #elseif cs + switch (Sys.systemName()) { + case "Windows": + Sys.command(bin, args); + case _: + Sys.command("mono", [bin].concat(args)); + } + #elseif java + Sys.command("java", ["-jar", bin].concat(args)); + #elseif python + Sys.command("python3", [bin].concat(args)); + #elseif neko + Sys.command("neko", [bin].concat(args)); + #elseif php + Sys.command("php", [bin].concat(args)); + #else + -1; + #end + assertEquals(code, exitCode); } } - #end function testEnv() { - #if !java + #if !(java || php) Sys.putEnv("foo", "value"); assertEquals("value", Sys.getEnv("foo")); #end assertEquals(null, Sys.getEnv("doesn't exist")); - #if !java + #if !(java || php) var env = Sys.environment(); assertEquals("value", env.get("foo")); #end @@ -37,6 +96,7 @@ class TestSys extends haxe.unit.TestCase { return haxe.io.Path.addTrailingSlash(haxe.io.Path.normalize(path)); } assertEquals(normalize(newCwd), normalize(Sys.getCwd())); + Sys.setCwd(cur); } #end } diff --git a/tests/sys/src/io/TestFileInput.hx b/tests/sys/src/io/TestFileInput.hx index 20c5e85a34d..9206601e458 100644 --- a/tests/sys/src/io/TestFileInput.hx +++ b/tests/sys/src/io/TestFileInput.hx @@ -16,7 +16,7 @@ class TestFileInput extends haxe.unit.TestCase { public function new() { super(); - path = 'testcase-test-file'; + path = 'testcase-test-file.txt'; } override public function setup() { @@ -24,7 +24,7 @@ class TestFileInput extends haxe.unit.TestCase { } override public function tearDown() { - //FileSystem.deleteFile(path); + FileSystem.deleteFile(path); } public function testRead() { @@ -129,6 +129,7 @@ class TestFileInput extends haxe.unit.TestCase { file.close(); } + #if !php public function testSeekEofLast() { var file : FileInput = File.read(path); assertEquals(116, file.readByte()); @@ -213,6 +214,7 @@ class TestFileInput extends haxe.unit.TestCase { } file.close(); } + #end } diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx new file mode 100644 index 00000000000..fb7426a3be2 --- /dev/null +++ b/tests/sys/src/io/TestProcess.hx @@ -0,0 +1,84 @@ +package io; + +import sys.io.Process; + +class TestProcess extends haxe.unit.TestCase { + #if !(python || php) + function testArguments() { + var bin = TestArguments.bin; + var args = TestArguments.expectedArgs; + + var process = new Process("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); + assertEquals(0, process.exitCode()); + + var process = + #if (macro || interp) + new Process("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); + #elseif cpp + new Process(bin, args); + #elseif cs + switch (Sys.systemName()) { + case "Windows": + new Process(bin, args); + case _: + new Process("mono", [bin].concat(args)); + } + #elseif java + new Process("java", ["-jar", bin].concat(args)); + #elseif python + new Process("python3", [bin].concat(args)); + #elseif neko + new Process("neko", [bin].concat(args)); + #elseif php + new Process("php", [bin].concat(args)); + #else + null; + #end + assertEquals(0, process.exitCode()); + } + #end + + #if !python + function testExitCode() { + var bin = ExitCode.bin; + + // Just test only a few to save time. + // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html + var codes = [0, 1, 2, 126, 127, 128, 130, 255]; + + for (code in codes) { + var args = [Std.string(code)]; + var process = new Process("haxe", ["compile-each.hxml", "--run", "ExitCode"].concat(args)); + assertEquals(code, process.exitCode()); + } + + for (code in codes) { + var args = [Std.string(code)]; + var process = + #if (macro || interp) + new Process("haxe", ["compile-each.hxml", "--run", "ExitCode"].concat(args)); + #elseif cpp + new Process(bin, args); + #elseif cs + switch (Sys.systemName()) { + case "Windows": + new Process(bin, args); + case _: + new Process("mono", [bin].concat(args)); + } + #elseif java + new Process("java", ["-jar", bin].concat(args)); + #elseif python + new Process("python3", [bin].concat(args)); + #elseif neko + new Process("neko", [bin].concat(args)); + #elseif php + new Process("php", [bin].concat(args)); + #else + null; + #end + assertEquals(code, process.exitCode()); + } + } + #end +} \ No newline at end of file From 3135ba45df95ef1e1837ead245744554538fdcd2 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 26 Mar 2015 10:44:35 +0100 Subject: [PATCH 051/209] [php] check feof after reading (see #4082) --- std/php/_std/sys/io/FileInput.hx | 2 +- tests/sys/src/io/TestFileInput.hx | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/std/php/_std/sys/io/FileInput.hx b/std/php/_std/sys/io/FileInput.hx index 48c76aaecb3..e505c7d6dda 100644 --- a/std/php/_std/sys/io/FileInput.hx +++ b/std/php/_std/sys/io/FileInput.hx @@ -32,8 +32,8 @@ class FileInput extends haxe.io.Input { } public override function readByte() : Int { - if(untyped __call__('feof', __f)) return throw new haxe.io.Eof(); var r = untyped __call__('fread', __f, 1); + if(untyped __call__('feof', __f)) return throw new haxe.io.Eof(); if(untyped __physeq__(r, false)) return throw haxe.io.Error.Custom('An error occurred'); return untyped __call__('ord', r); } diff --git a/tests/sys/src/io/TestFileInput.hx b/tests/sys/src/io/TestFileInput.hx index 9206601e458..1c8ab7280ed 100644 --- a/tests/sys/src/io/TestFileInput.hx +++ b/tests/sys/src/io/TestFileInput.hx @@ -129,7 +129,6 @@ class TestFileInput extends haxe.unit.TestCase { file.close(); } - #if !php public function testSeekEofLast() { var file : FileInput = File.read(path); assertEquals(116, file.readByte()); @@ -214,7 +213,5 @@ class TestFileInput extends haxe.unit.TestCase { } file.close(); } - #end - } From c6830f0d236584df22768f5a2cda1c21576fe3fa Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 26 Mar 2015 11:13:33 +0100 Subject: [PATCH 052/209] support TargetBuild FD compilation for sys tests [skip ci] --- tests/sys/testsys.hxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/testsys.hxproj b/tests/sys/testsys.hxproj index 3208e3b1eec..4b471dd9172 100644 --- a/tests/sys/testsys.hxproj +++ b/tests/sys/testsys.hxproj @@ -39,7 +39,7 @@ - haxe compile.hxml + "$(CompilerPath)/haxe" compile$(TargetBuild).hxml From c189af425f9e867019a9625d442116c36d1a57fd Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 26 Mar 2015 11:43:38 +0100 Subject: [PATCH 053/209] [matcher] follow through static fields for value types (closes #4084) --- matcher.ml | 47 +++++++++++++++---------- tests/unit/src/unit/issues/Issue4084.hx | 17 +++++++++ 2 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4084.hx diff --git a/matcher.ml b/matcher.ml index c60f9831698..49397060eb8 100644 --- a/matcher.ml +++ b/matcher.ml @@ -326,6 +326,26 @@ let to_pattern ctx e t = tctx.pc_locals <- PMap.add s (v,p) tctx.pc_locals; v in + let check_texpr_pattern e t p = + let ec = match Optimizer.make_constant_expression ctx ~concat_strings:true e with Some e -> e | None -> e in + match ec.eexpr with + | TField (_,FEnum (en,ef)) -> + begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; + begin try + unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_params) ef t; + with Unify_error l -> + error (error_msg (Unify l)) p + end; + mk_con_pat (CEnum(en,ef)) [] t p + | TConst c | TCast({eexpr = TConst c},None) -> + begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; + unify ctx ec.etype t p; + mk_con_pat (CConst c) [] t p + | TTypeExpr mt -> + mk_type_pat ctx mt t p + | _ -> + raise Not_found + in let rec loop pctx e t = let p = pos e in match fst e with @@ -362,7 +382,13 @@ let to_pattern ctx e t = | TTypeExpr mt -> mk_type_pat ctx mt t p | TField(_, FStatic(_,cf)) when is_value_type cf.cf_type -> - mk_con_pat (CExpr e) [] cf.cf_type p + ignore (follow cf.cf_type); + begin match cf.cf_expr with + | Some e -> + (try check_texpr_pattern e t p with Not_found -> mk_con_pat (CExpr e) [] cf.cf_type p) + | None -> + mk_con_pat (CExpr e) [] cf.cf_type p + end | TField(_, FEnum(en,ef)) -> begin try unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_params) ef t @@ -449,24 +475,7 @@ let to_pattern ctx e t = ctx.untyped <- old; e in - let ec = match Optimizer.make_constant_expression ctx ~concat_strings:true ec with Some e -> e | None -> ec in - (match ec.eexpr with - | TField (_,FEnum (en,ef)) -> - begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; - begin try - unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_params) ef t; - with Unify_error l -> - error (error_msg (Unify l)) p - end; - mk_con_pat (CEnum(en,ef)) [] t p - | TConst c | TCast({eexpr = TConst c},None) -> - begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; - unify ctx ec.etype t p; - mk_con_pat (CConst c) [] t p - | TTypeExpr mt -> - mk_type_pat ctx mt t p - | _ -> - raise Not_found); + check_texpr_pattern ec t p with Not_found -> begin match get_tuple_params t with | Some tl -> diff --git a/tests/unit/src/unit/issues/Issue4084.hx b/tests/unit/src/unit/issues/Issue4084.hx new file mode 100644 index 00000000000..e3dbcba2daf --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4084.hx @@ -0,0 +1,17 @@ +package unit.issues; + +class Issue4084 extends Test { + function test() { + var x = Xml.parse("
Hello!
"); + var v = switch x.nodeType { + case Xml.ProcessingInstruction: 0; + case Xml.DocType: 1; + case Xml.Document: 2; + case Xml.CData: 3; + case Xml.PCData: 4; + case Xml.Element: 5; + case Xml.Comment: 6; + } + eq(2, v); + } +} \ No newline at end of file From a358eb35f7230daad18ecc17eda6f6c4ddc199d0 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Thu, 26 Mar 2015 19:07:11 +0800 Subject: [PATCH 054/209] [AppVeyor] run php test too --- tests/RunCi.hx | 8 +++++++- tests/sys/args.xml | 2 +- tests/sys/compile.hxml | 1 + tests/sys/src/TestSys.hx | 6 ++++-- tests/sys/src/io/TestProcess.hx | 4 ++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 927a25d3599..f9d5e647106 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -313,6 +313,12 @@ class RunCi { } case "Mac": //pass + case "Windows": + if (commandSucceed("php", ["-v"])) { + infoMsg('php has already been installed.'); + } else { + runCommand("cinst", ["php", "-y"], true); + } } runCommand("php", ["-v"]); } @@ -483,7 +489,7 @@ class RunCi { case TravisCI: [Sys.getEnv("TEST")]; case AppVeyor: - [Neko, Cs, Java, Cpp, Macro]; + [Neko, Cs, Java, Cpp, Php, Macro]; } Sys.println('Going to test: $tests'); diff --git a/tests/sys/args.xml b/tests/sys/args.xml index bf097d46b9b..2e11a4bc284 100644 --- a/tests/sys/args.xml +++ b/tests/sys/args.xml @@ -40,7 +40,7 @@ We may compare and update the test cases of other popular langs/libs: https://gi - + diff --git a/tests/sys/compile.hxml b/tests/sys/compile.hxml index f413aa57782..7c31ad4323f 100644 --- a/tests/sys/compile.hxml +++ b/tests/sys/compile.hxml @@ -6,3 +6,4 @@ --next compile-cpp.hxml --next compile-cs.hxml --next compile-java.hxml +--next compile-php.hxml diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index b0090247b4a..9acdaba80c8 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -1,6 +1,7 @@ class TestSys extends haxe.unit.TestCase { + #if !php //https://github.com/HaxeFoundation/haxe/issues/3603#issuecomment-86437474 function testCommand() { - var bin = TestArguments.bin; + var bin = sys.FileSystem.fullPath(TestArguments.bin); var args = TestArguments.expectedArgs; var exitCode = Sys.command("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); @@ -33,7 +34,7 @@ class TestSys extends haxe.unit.TestCase { } function testExitCode() { - var bin = ExitCode.bin; + var bin = sys.FileSystem.fullPath(ExitCode.bin); // Just test only a few to save time. // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html @@ -73,6 +74,7 @@ class TestSys extends haxe.unit.TestCase { assertEquals(code, exitCode); } } + #end function testEnv() { #if !(java || php) diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index fb7426a3be2..4c1df8eb57c 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -5,7 +5,7 @@ import sys.io.Process; class TestProcess extends haxe.unit.TestCase { #if !(python || php) function testArguments() { - var bin = TestArguments.bin; + var bin = sys.FileSystem.fullPath(TestArguments.bin); var args = TestArguments.expectedArgs; var process = new Process("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); @@ -40,7 +40,7 @@ class TestProcess extends haxe.unit.TestCase { #if !python function testExitCode() { - var bin = ExitCode.bin; + var bin = sys.FileSystem.fullPath(ExitCode.bin); // Just test only a few to save time. // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html From 22392b07303aafb0d48d49322f5e8cf771e00024 Mon Sep 17 00:00:00 2001 From: hughsando Date: Thu, 26 Mar 2015 19:37:57 +0800 Subject: [PATCH 055/209] [cpp] Add toString function to ConstCharStart --- std/cpp/ConstCharStar.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/cpp/ConstCharStar.hx b/std/cpp/ConstCharStar.hx index f22e5e371ce..5dd70b3df4f 100644 --- a/std/cpp/ConstCharStar.hx +++ b/std/cpp/ConstCharStar.hx @@ -7,6 +7,9 @@ abstract ConstCharStar( RawConstPointer ) to(RawConstPointer) @:from static public inline function fromString(s:String) return new ConstCharStar(s); + @:to + public inline function toString():String return new String(untyped this); + @:to @:extern public inline function toPointer() return this; } From 5f909d0c50a6d15141bb7fc43a45b2adf8999de5 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 26 Mar 2015 16:22:31 +0300 Subject: [PATCH 056/209] [js] set "message" to HaxeError so it's useful (not Std.string to avoid code explosion, but better than nothing) closes #4085 --- std/js/Boot.hx | 7 ++++--- tests/unit/src/unit/issues/Issue4085.hx | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4085.hx diff --git a/std/js/Boot.hx b/std/js/Boot.hx index 4096bb7a53c..0d8de65b2cf 100755 --- a/std/js/Boot.hx +++ b/std/js/Boot.hx @@ -25,10 +25,11 @@ private class HaxeError extends js.Error { var val:Dynamic; - public function new(val:Dynamic) { + public function new(val:Dynamic) untyped { super(); - this.val = untyped __define_feature__("js.Boot.HaxeError", val); - untyped if (js.Error.captureStackTrace) js.Error.captureStackTrace(this, HaxeError); + this.val = __define_feature__("js.Boot.HaxeError", val); + this.message = String(val); + if (js.Error.captureStackTrace) js.Error.captureStackTrace(this, HaxeError); } } diff --git a/tests/unit/src/unit/issues/Issue4085.hx b/tests/unit/src/unit/issues/Issue4085.hx new file mode 100644 index 00000000000..94af815c3d1 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4085.hx @@ -0,0 +1,12 @@ +package unit.issues; + +class Issue4085 extends Test { + #if js + function test() { + function throwError() throw "hello, world"; + var msg = null; + untyped __js__("try { throwError(); } catch (e) { msg = e.message; }"); + eq(msg, "hello, world"); + } + #end +} From da60c75213fbf1cc376190717c093a7421325d4e Mon Sep 17 00:00:00 2001 From: Andy Li Date: Thu, 26 Mar 2015 21:35:07 +0800 Subject: [PATCH 057/209] [test] use absolutePath instead of fullPath for now --- tests/sys/src/TestSys.hx | 4 ++-- tests/sys/src/io/TestProcess.hx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 9acdaba80c8..0db038233b6 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -1,7 +1,7 @@ class TestSys extends haxe.unit.TestCase { #if !php //https://github.com/HaxeFoundation/haxe/issues/3603#issuecomment-86437474 function testCommand() { - var bin = sys.FileSystem.fullPath(TestArguments.bin); + var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; var exitCode = Sys.command("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); @@ -34,7 +34,7 @@ class TestSys extends haxe.unit.TestCase { } function testExitCode() { - var bin = sys.FileSystem.fullPath(ExitCode.bin); + var bin = sys.FileSystem.absolutePath(ExitCode.bin); // Just test only a few to save time. // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index 4c1df8eb57c..df7f5996765 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -5,7 +5,7 @@ import sys.io.Process; class TestProcess extends haxe.unit.TestCase { #if !(python || php) function testArguments() { - var bin = sys.FileSystem.fullPath(TestArguments.bin); + var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; var process = new Process("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); @@ -40,7 +40,7 @@ class TestProcess extends haxe.unit.TestCase { #if !python function testExitCode() { - var bin = sys.FileSystem.fullPath(ExitCode.bin); + var bin = sys.FileSystem.absolutePath(ExitCode.bin); // Just test only a few to save time. // They have special meanings: http://tldp.org/LDP/abs/html/exitcodes.html From e4f83a650eac26fb394ab8e1cd500947e8eb9c25 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 26 Mar 2015 17:14:42 +0300 Subject: [PATCH 058/209] [python] wait for process exit in sys.io.Process.exitCode (see #4083) --- std/python/_std/sys/io/Process.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/python/_std/sys/io/Process.hx b/std/python/_std/sys/io/Process.hx index 35b8490da4a..07caba561f8 100644 --- a/std/python/_std/sys/io/Process.hx +++ b/std/python/_std/sys/io/Process.hx @@ -49,7 +49,7 @@ class Process { return p.pid; } public function exitCode() : Int { - return p.returncode; + return p.wait(); } public function close() : Void { p.terminate(); From 31e427e8e4e04b461afb4fc292a4400d2fd1d196 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Thu, 26 Mar 2015 22:36:29 +0800 Subject: [PATCH 059/209] [test] enable sys.io.Process test for python --- tests/sys/src/io/TestProcess.hx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index df7f5996765..f751abee0e8 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -3,7 +3,7 @@ package io; import sys.io.Process; class TestProcess extends haxe.unit.TestCase { - #if !(python || php) + #if !php function testArguments() { var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; @@ -38,7 +38,6 @@ class TestProcess extends haxe.unit.TestCase { } #end - #if !python function testExitCode() { var bin = sys.FileSystem.absolutePath(ExitCode.bin); @@ -80,5 +79,4 @@ class TestProcess extends haxe.unit.TestCase { assertEquals(code, process.exitCode()); } } - #end } \ No newline at end of file From e747fb65b92d92ef80d22c2bbc43af53f7647e08 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 26 Mar 2015 16:31:32 +0100 Subject: [PATCH 060/209] add back `@:privateAccess` to macro return (see #3714) --- typer.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer.ml b/typer.ml index 5c8312c04a5..7bbff8d67f4 100644 --- a/typer.ml +++ b/typer.ml @@ -3991,7 +3991,7 @@ and build_call ctx acc el (with_type:with_type) p = | None -> (fun() -> type_expr ctx (EConst (Ident "null"),p) Value) | Some (EMeta((Meta.MergeBlock,_,_),(EBlock el,_)),_) -> (fun () -> let e = type_block ctx el with_type p in mk (TMeta((Meta.MergeBlock,[],p), e)) e.etype e.epos) | Some (EVars vl,p) -> (fun() -> type_vars ctx vl p true) - | Some e -> (fun() -> type_expr ctx e with_type)) + | Some e -> (fun() -> type_expr ctx (EMeta((Meta.PrivateAccess,[],snd e),e),snd e) with_type)) | _ -> (* member-macro call : since we will make a static call, let's found the actual class and not its subclass *) (match follow ethis.etype with From 6d75afb19d0086f29bc07c5541c0234ed3324f4a Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 26 Mar 2015 16:55:26 +0100 Subject: [PATCH 061/209] lose hx-yaml dependency for now [skip ci] --- tests/README.md | 7 +++-- tests/RunCi.hx | 68 ++++++++++++++++++++++++------------------------ tests/RunCi.hxml | 3 +-- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/tests/README.md b/tests/README.md index ab2c0f32cf7..718d5aa4c13 100644 --- a/tests/README.md +++ b/tests/README.md @@ -5,10 +5,9 @@ We have a number of test suites, which are placed in their own folders in this d "RunCi.hx" is the script used by our CIs to run all the test suites. It is possible to run it in local machines too: 1. Change to this directory. - 2. Install lib used by the script: `haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src`. - 3. Compile the script: `haxe RunCi.hxml`. - 4. Define the test target by `export TEST=$TARGET` (or `set "TEST=$TARGET"` on Windows), where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). - 5. Run it: `neko RunCi.n`. + 2. Compile the script: `haxe RunCi.hxml`. + 3. Define the test target by `export TEST=$TARGET` (or `set "TEST=$TARGET"` on Windows), where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). + 4. Run it: `neko RunCi.n`. Note that the script will try to look for test dependencies and install them if they are not found. Look at the `getXXXDependencies` functions for the details. diff --git a/tests/RunCi.hx b/tests/RunCi.hx index f9d5e647106..b489a05db99 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -280,21 +280,21 @@ class RunCi { return args; } - static function parseTravisFile(path:String, ignoreBeforeInstall = false) { - var yaml:TravisConfig = yaml.Yaml.read(path, Parser.options().useObjects()); - if (!ignoreBeforeInstall) { - for (code in yaml.before_install) { - var args = parseCommand(code); - var cmd = args.shift(); - runCommand(cmd, args); - } - } - for (code in yaml.script) { - var args = parseCommand(code); - var cmd = args.shift(); - runCommand(cmd, args); - } - } + //static function parseTravisFile(path:String, ignoreBeforeInstall = false) { + //var yaml:TravisConfig = yaml.Yaml.read(path, Parser.options().useObjects()); + //if (!ignoreBeforeInstall) { + //for (code in yaml.before_install) { + //var args = parseCommand(code); + //var cmd = args.shift(); + //runCommand(cmd, args); + //} + //} + //for (code in yaml.script) { + //var args = parseCommand(code); + //var cmd = args.shift(); + //runCommand(cmd, args); + //} + //} static function commandSucceed(cmd:String, args:Array):Bool { return try { @@ -797,25 +797,25 @@ class RunCi { runCommand("sh", ["flambe/bin/run-travis"]); } - static function testOpenflSamples() { - infoMsg("Test OpenFL Samples:"); - - changeDirectory(unitDir); - - haxelibInstallGit("jgranick", "actuate"); - haxelibInstallGit("jgranick", "box2d"); - haxelibInstallGit("jgranick", "layout"); - haxelibInstallGit("openfl", "swf"); - haxelibInstallGit("openfl", "openfl-samples"); - - var path = getHaxelibPath("openfl-samples"); - var old = Sys.getEnv("pwd"); - Sys.putEnv("pwd", path); - parseTravisFile(haxe.io.Path.join([path, ".travis.yml"]), true); - if (old != null) { - Sys.putEnv("pwd", old); - } - } + //static function testOpenflSamples() { + //infoMsg("Test OpenFL Samples:"); +// + //changeDirectory(unitDir); +// + //haxelibInstallGit("jgranick", "actuate"); + //haxelibInstallGit("jgranick", "box2d"); + //haxelibInstallGit("jgranick", "layout"); + //haxelibInstallGit("openfl", "swf"); + //haxelibInstallGit("openfl", "openfl-samples"); +// + //var path = getHaxelibPath("openfl-samples"); + //var old = Sys.getEnv("pwd"); + //Sys.putEnv("pwd", path); + //parseTravisFile(haxe.io.Path.join([path, ".travis.yml"]), true); + //if (old != null) { + //Sys.putEnv("pwd", old); + //} + //} static function testFlixelDemos() { infoMsg("Test Flixel Demos:"); diff --git a/tests/RunCi.hxml b/tests/RunCi.hxml index 0a7429b5641..314a92d4952 100644 --- a/tests/RunCi.hxml +++ b/tests/RunCi.hxml @@ -1,3 +1,2 @@ -neko RunCi.n --main RunCi --lib hx-yaml \ No newline at end of file +-main RunCi \ No newline at end of file From f9ab409deb7419660a5a093bacc1f429fbb55398 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 26 Mar 2015 19:03:48 +0300 Subject: [PATCH 062/209] add @:noPrivateAccess to re-enable access control within @:privateAccess (closes #3714) --- ast.ml | 1 + common.ml | 1 + extra/CHANGES.txt | 4 ++++ tests/misc/projects/Issue3714/Main.hx | 13 +++++++++++++ tests/misc/projects/Issue3714/compile-fail.hxml | 1 + .../projects/Issue3714/compile-fail.hxml.stderr | 1 + tests/unit/src/unit/issues/Issue3714.hx | 15 +++++++++++++++ typer.ml | 3 +++ 8 files changed, 39 insertions(+) create mode 100644 tests/misc/projects/Issue3714/Main.hx create mode 100644 tests/misc/projects/Issue3714/compile-fail.hxml create mode 100644 tests/misc/projects/Issue3714/compile-fail.hxml.stderr create mode 100644 tests/unit/src/unit/issues/Issue3714.hx diff --git a/ast.ml b/ast.ml index ddca3339c4a..ad25c1222a1 100644 --- a/ast.ml +++ b/ast.ml @@ -123,6 +123,7 @@ module Meta = struct | NoExpr | NoImportGlobal | NoPackageRestrict + | NoPrivateAccess | NoStack | NotNull | NoUsing diff --git a/common.ml b/common.ml index 73d10da44c8..65dd192f868 100644 --- a/common.ml +++ b/common.ml @@ -445,6 +445,7 @@ module MetaInfo = struct | NoExpr -> ":noExpr",("Internally used to mark abstract fields which have no expression by design",[Internal]) | NoImportGlobal -> ":noImportGlobal",("Prevents a static field from being imported with import Class.*",[UsedOn TAnyField]) | NoPackageRestrict -> ":noPackageRestrict",("Allows a module to be accessed across all targets if found on its first type",[Internal]) + | NoPrivateAccess -> ":noPrivateAccess",("Disallow private access to anything for the annotated expression",[UsedOn TExpr]) | NoStack -> ":noStack",("",[Platform Cpp]) | NotNull -> ":notNull",("Declares an abstract type as not accepting null values",[UsedOn TAbstract]) | NoUsing -> ":noUsing",("Prevents a field from being used with 'using'",[UsedOn TClassField]) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 6c515d81b1e..fdaa806be3d 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -1,5 +1,9 @@ 2015-??-??: 3.2.0 + New features: + + all : added @:noPrivateAccess to re-enable access restrictions within @:privateAccess + Bugfixes: all : fixed detection of @:generic classes with constructor constraints diff --git a/tests/misc/projects/Issue3714/Main.hx b/tests/misc/projects/Issue3714/Main.hx new file mode 100644 index 00000000000..f3518b50029 --- /dev/null +++ b/tests/misc/projects/Issue3714/Main.hx @@ -0,0 +1,13 @@ +class Main { + static macro function m() { + return macro @:pos(haxe.macro.Context.currentPos()) @:noPrivateAccess A.a; + } + + static function main() { + m(); + } +} + +class A { + static var a:Int; +} diff --git a/tests/misc/projects/Issue3714/compile-fail.hxml b/tests/misc/projects/Issue3714/compile-fail.hxml new file mode 100644 index 00000000000..42409e72918 --- /dev/null +++ b/tests/misc/projects/Issue3714/compile-fail.hxml @@ -0,0 +1 @@ +-main Main diff --git a/tests/misc/projects/Issue3714/compile-fail.hxml.stderr b/tests/misc/projects/Issue3714/compile-fail.hxml.stderr new file mode 100644 index 00000000000..aace8ef0039 --- /dev/null +++ b/tests/misc/projects/Issue3714/compile-fail.hxml.stderr @@ -0,0 +1 @@ +Main.hx:7: characters 8-11 : Cannot access private field a \ No newline at end of file diff --git a/tests/unit/src/unit/issues/Issue3714.hx b/tests/unit/src/unit/issues/Issue3714.hx new file mode 100644 index 00000000000..b896b843bfc --- /dev/null +++ b/tests/unit/src/unit/issues/Issue3714.hx @@ -0,0 +1,15 @@ +package unit.issues; + +private class A { + static var a:Int; + static function f(a:Int) {} +} + +class Issue3714 extends Test { + function test() { + eq(unit.TestType.typeErrorText(A.f), "Cannot access private field f"); + eq(unit.TestType.typeErrorText(@:privateAccess A.f), null); + eq(unit.TestType.typeErrorText(@:privateAccess A.f(A.a)), null); + eq(unit.TestType.typeErrorText(@:privateAccess A.f(@:noPrivateAccess A.a)), "Cannot access private field a"); + } +} diff --git a/typer.ml b/typer.ml index 7bbff8d67f4..d382b85c9a3 100644 --- a/typer.ml +++ b/typer.ml @@ -3553,6 +3553,9 @@ and type_expr ctx (e,p) (with_type:with_type) = | (Meta.StoredTypedExpr,_,_) -> let id = match e1 with (EConst (Int s),_) -> int_of_string s | _ -> assert false in get_stored_typed_expr ctx.com id + | (Meta.NoPrivateAccess,_,_) -> + ctx.meta <- List.filter (fun(m,_,_) -> m <> Meta.PrivateAccess) ctx.meta; + e() | _ -> e() in ctx.meta <- old; From 444b8caf6cb6b476533d9346d4d6396910fd0b23 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 03:40:50 +0800 Subject: [PATCH 063/209] [AppVeyor] fixed cinst php --- tests/RunCi.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index b489a05db99..8c8a8931d98 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -317,7 +317,8 @@ class RunCi { if (commandSucceed("php", ["-v"])) { infoMsg('php has already been installed.'); } else { - runCommand("cinst", ["php", "-y"], true); + runCommand("cinst", ["php", "-version", "5.6.3", "-y"], true); + Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + "C:\\tools\\php"); } } runCommand("php", ["-v"]); From 825e21964433d3c7609e95fb4fb48d18bdab1439 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 01:27:48 +0800 Subject: [PATCH 064/209] [test] improved TestFileSystem (not completed yet) --- tests/sys/.gitignore | 2 - tests/sys/args.xml | 2 +- tests/sys/src/FileNames.hx | 15 +++++ tests/sys/src/TestArguments.hx | 6 +- tests/sys/src/TestFileSystem.hx | 101 +++++++++++++++++++++++++----- tests/sys/src/TestSys.hx | 4 ++ tests/sys/src/io/TestFileInput.hx | 7 +-- tests/sys/src/io/TestProcess.hx | 10 ++- tests/sys/temp/.gitignore | 2 + 9 files changed, 123 insertions(+), 26 deletions(-) delete mode 100644 tests/sys/.gitignore create mode 100644 tests/sys/src/FileNames.hx create mode 100644 tests/sys/temp/.gitignore diff --git a/tests/sys/.gitignore b/tests/sys/.gitignore deleted file mode 100644 index b9ee2b1e3cd..00000000000 --- a/tests/sys/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -TestArguments.txt -testcase-test-file.txt \ No newline at end of file diff --git a/tests/sys/args.xml b/tests/sys/args.xml index 2e11a4bc284..3fc42ee9bfd 100644 --- a/tests/sys/args.xml +++ b/tests/sys/args.xml @@ -1,5 +1,5 @@ diff --git a/tests/sys/src/FileNames.hx b/tests/sys/src/FileNames.hx new file mode 100644 index 00000000000..2b236ed5b4b --- /dev/null +++ b/tests/sys/src/FileNames.hx @@ -0,0 +1,15 @@ +class FileNames { + static public var names(default, never) = [ + "ok", + + // a space inside + "two words", + + // Chinese, Japanese + // "中文,にほんご", + + // "aaa...a" that has 255 characters + // 255 bytes is the max filename length according to http://en.wikipedia.org/wiki/Comparison_of_file_systems + // [for (i in 0...255) "a"].join("") + ]; +} \ No newline at end of file diff --git a/tests/sys/src/TestArguments.hx b/tests/sys/src/TestArguments.hx index a860476e203..f81aae7ce1f 100644 --- a/tests/sys/src/TestArguments.hx +++ b/tests/sys/src/TestArguments.hx @@ -1,5 +1,6 @@ /** This test is intented to be used by TestSys and io.TestProcess. + It will write the result to "temp/TestArguments.txt" (for debugging). */ class TestArguments extends haxe.unit.TestCase { static public var expectedArgs(get, null):Array; @@ -39,6 +40,8 @@ class TestArguments extends haxe.unit.TestCase { null; #end + static public var log = "temp/TestArguments.txt"; + function testArgs() { var args = Sys.args(); // trace(args); @@ -49,7 +52,8 @@ class TestArguments extends haxe.unit.TestCase { } static function main():Void { - var log = sys.io.File.write("TestArguments.txt"); + var log = sys.io.File.write(log); + log.writeString(haxe.Json.stringify(Sys.args()) + "\n"); haxe.unit.TestRunner.print = function(v){ log.writeString(v); }; diff --git a/tests/sys/src/TestFileSystem.hx b/tests/sys/src/TestFileSystem.hx index d06168c9043..d485326f9ef 100644 --- a/tests/sys/src/TestFileSystem.hx +++ b/tests/sys/src/TestFileSystem.hx @@ -1,21 +1,94 @@ import sys.FileSystem; class TestFileSystem extends haxe.unit.TestCase { - function testSimpleDir():Void { - assertFalse(FileSystem.exists("testCreateDirectory")); - FileSystem.createDirectory("testCreateDirectory"); - assertTrue(FileSystem.exists("testCreateDirectory")); - assertTrue(FileSystem.isDirectory("testCreateDirectory")); - FileSystem.deleteDirectory("testCreateDirectory"); - assertFalse(FileSystem.exists("testCreateDirectory")); + /** + Recursively remove a given directory. + */ + static function removeDir(dir:String):Void { + if (FileSystem.exists(dir)) { + for (item in FileSystem.readDirectory(dir)) { + item = haxe.io.Path.join([dir, item]); + if (FileSystem.isDirectory(item)) { + removeDir(item); + } else { + FileSystem.deleteFile(item); + } + } + FileSystem.deleteDirectory(dir); + } } - function testParentDir():Void { - assertFalse(FileSystem.exists("../testCreateDirectory")); - FileSystem.createDirectory("../testCreateDirectory"); - assertTrue(FileSystem.exists("../testCreateDirectory")); - assertTrue(FileSystem.isDirectory("../testCreateDirectory")); - FileSystem.deleteDirectory("../testCreateDirectory"); - assertFalse(FileSystem.exists("../testCreateDirectory")); + var dir = "temp/TestFileSystem/"; + var tailingSlashes = switch (Sys.systemName()) { + case "Windows": ["", "/", "\\"]; + case _: ["", "/"]; + } + + override public function setup() { + removeDir(dir); + FileSystem.createDirectory(dir); + } + + override public function tearDown() { + removeDir(dir); + } + + function testReadDirectory():Void { + for (tailingSlash in tailingSlashes) { + assertEquals(0, FileSystem.readDirectory(dir).length); + for (name in FileNames.names) { + var path = dir + name + tailingSlash; + FileSystem.createDirectory(path); + var files = FileSystem.readDirectory(path); + assertEquals(0, files.length); + } + var files = FileSystem.readDirectory(dir); + for (name in FileNames.names) { + assertTrue(files.indexOf(name) > -1); + } + assertEquals(FileNames.names.length, files.length); + for (name in FileNames.names) { + FileSystem.deleteDirectory(dir + name); + } + + //read current directory + assertTrue(FileSystem.readDirectory("." + tailingSlash).indexOf("compile.hxml") > -1); + //read parent directory + assertTrue(FileSystem.readDirectory(".." + tailingSlash).indexOf("sys") > -1); + //read directory with complex path + assertTrue(FileSystem.readDirectory("../sys/./.." + tailingSlash).indexOf("sys") > -1); + } + } + + function testCreateDirectory():Void { + for (tailingSlash in tailingSlashes) { + assertEquals(0, FileSystem.readDirectory(dir).length); + for (name in FileNames.names) { + FileSystem.createDirectory(dir + name + tailingSlash); + } + var files = FileSystem.readDirectory(dir); + for (name in FileNames.names) { + assertTrue(files.indexOf(name) > -1); + } + assertEquals(FileNames.names.length, files.length); + for (name in FileNames.names) { + FileSystem.deleteDirectory(dir + name); + } + + //create deep directory + var path = dir + "1/2/3" + tailingSlash; + FileSystem.createDirectory(path); + assertTrue(FileSystem.isDirectory(path)); + + //create directory in complex path + var path = dir + "1/../1/./../complex" + tailingSlash; + FileSystem.createDirectory(path); + assertTrue(FileSystem.readDirectory(dir).indexOf("complex") > -1); + + FileSystem.deleteDirectory(dir + "1/2/3"); + FileSystem.deleteDirectory(dir + "1/2"); + FileSystem.deleteDirectory(dir + "1"); + FileSystem.deleteDirectory(dir + "complex"); + } } } \ No newline at end of file diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 0db038233b6..afd290c3cb7 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -5,6 +5,8 @@ class TestSys extends haxe.unit.TestCase { var args = TestArguments.expectedArgs; var exitCode = Sys.command("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); + if (exitCode != 0) + trace(sys.io.File.getContent(TestArguments.log)); assertEquals(0, exitCode); var exitCode = @@ -30,6 +32,8 @@ class TestSys extends haxe.unit.TestCase { #else -1; #end + if (exitCode != 0) + trace(sys.io.File.getContent(TestArguments.log)); assertEquals(0, exitCode); } diff --git a/tests/sys/src/io/TestFileInput.hx b/tests/sys/src/io/TestFileInput.hx index 1c8ab7280ed..fb35e3be8dd 100644 --- a/tests/sys/src/io/TestFileInput.hx +++ b/tests/sys/src/io/TestFileInput.hx @@ -12,12 +12,7 @@ import sys.io.FileSeek; */ class TestFileInput extends haxe.unit.TestCase { - private var path : String; - - public function new() { - super(); - path = 'testcase-test-file.txt'; - } + private var path = 'temp/testcase-test-file.txt'; override public function setup() { File.saveContent(path, "test\n1234"); diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index f751abee0e8..dfad1033dce 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -9,7 +9,10 @@ class TestProcess extends haxe.unit.TestCase { var args = TestArguments.expectedArgs; var process = new Process("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); - assertEquals(0, process.exitCode()); + var exitCode = process.exitCode(); + if (exitCode != 0) + trace(sys.io.File.getContent(TestArguments.log)); + assertEquals(0, exitCode); var process = #if (macro || interp) @@ -34,7 +37,10 @@ class TestProcess extends haxe.unit.TestCase { #else null; #end - assertEquals(0, process.exitCode()); + var exitCode = process.exitCode(); + if (exitCode != 0) + trace(sys.io.File.getContent(TestArguments.log)); + assertEquals(0, exitCode); } #end diff --git a/tests/sys/temp/.gitignore b/tests/sys/temp/.gitignore new file mode 100644 index 00000000000..ac230515f67 --- /dev/null +++ b/tests/sys/temp/.gitignore @@ -0,0 +1,2 @@ +*.* +!.gitignore \ No newline at end of file From b1078affb56f0929830407a1e4b17b571a151b79 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 04:44:15 +0800 Subject: [PATCH 065/209] [ci] TEST=comma,separated,list,of,targets --- appveyor.yml | 16 ++++++---------- tests/RunCi.hx | 10 ++++------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6876ba463bf..d642a11f7c5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,16 +11,12 @@ environment: global: NEKO_ROOT: C:/projects/neko HAXELIB_ROOT: C:/projects/haxelib - matrix: - - CYG_ARCH: x86 - CYG_ROOT: C:/cygwin - CYG_SETUP: C:/cygwin/setup-x86.exe - WODI_ARCH: 32 - MINGW_ARCH: i686 - # - CYG_ARCH: x86_64 - # CYG_ROOT: C:/cygwin64 - # WODI_ARCH: 64 - # MINGW_ARCH: x86_64 + CYG_ARCH: x86 + CYG_ROOT: C:/cygwin + CYG_SETUP: C:/cygwin/setup-x86.exe + WODI_ARCH: 32 + MINGW_ARCH: i686 + TEST: "neko,cs,java,cpp,php,macro" skip_tags: true diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 8c8a8931d98..ce63d1ba7bb 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -484,13 +484,11 @@ class RunCi { static function main():Void { Sys.putEnv("OCAMLRUNPARAM", "b"); - var tests:Array = switch (ci) { + var tests:Array = switch (Sys.getEnv("TEST")) { case null: - [Sys.getEnv("TEST") == null ? Macro : Sys.getEnv("TEST")]; - case TravisCI: - [Sys.getEnv("TEST")]; - case AppVeyor: - [Neko, Cs, Java, Cpp, Php, Macro]; + [Macro]; + case env: + [for (v in env.split(",")) v.trim().toLowerCase()]; } Sys.println('Going to test: $tests'); From 3df54a856c4718dd16a435d109d60fc69f15bcf1 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 06:37:54 +0800 Subject: [PATCH 066/209] [AppVeyor] Add php to PATH. --- tests/RunCi.hx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index ce63d1ba7bb..93478245bf2 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -302,6 +302,15 @@ class RunCi { } catch(e:Dynamic) false; } + static function addToPATH(path:String):Void { + switch (systemName) { + case "Windows": + Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" + path); + case "Mac", "Linux": + Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + path); + } + } + static function getPhpDependencies() { switch (systemName) { case "Linux": @@ -318,7 +327,7 @@ class RunCi { infoMsg('php has already been installed.'); } else { runCommand("cinst", ["php", "-version", "5.6.3", "-y"], true); - Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + "C:\\tools\\php"); + addToPATH("C:\\tools\\php"); } } runCommand("php", ["-v"]); @@ -708,7 +717,7 @@ class RunCi { runCommand("wget", ['http://archive.apache.org/dist/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true); runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]); var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin'; - Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + flexsdkPath + "/bin"); + addToPATH(flexsdkPath + "/bin"); var playerglobalswcFolder = flexsdkPath + "/player"; FileSystem.createDirectory(playerglobalswcFolder + "/11.1"); runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true); From ad27da697e5ebd2a633b187d15b06e4a16334ebf Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 07:03:52 +0800 Subject: [PATCH 067/209] [ci] Added `-D travis` to compile-php.hxml when it is really using TravisCI. As discussed we will probably change it to `-D ci=TravisCI` in the future. This commit is just a temp fix. --- tests/RunCi.hx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 93478245bf2..73fe8cc9160 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -561,7 +561,13 @@ class RunCi { runCommand("neko", ["bin/neko/sys.n"]); case Php: getPhpDependencies(); - runCommand("haxe", ["compile-php.hxml","-D","travis"]); + var args = switch (ci) { + case TravisCI: + ["-D","travis"]; + case _: + []; + } + runCommand("haxe", ["compile-php.hxml"].concat(args)); runCommand("php", ["bin/php/index.php"]); changeDirectory(sysDir); From d622aa3f0492b59fd0a73cd7ce8bc5595f636476 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 09:40:09 +0800 Subject: [PATCH 068/209] [AppVeyor] Disable php for now. The chocolatey installed php is the standard php that doesn't have mbstring enabled, thus haxe.Utf8 tests failed. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d642a11f7c5..b394e8e5ab6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ environment: CYG_SETUP: C:/cygwin/setup-x86.exe WODI_ARCH: 32 MINGW_ARCH: i686 - TEST: "neko,cs,java,cpp,php,macro" + TEST: "neko,cs,java,cpp,macro" skip_tags: true From 4cbeb6c1b0e0434e2f52b1da66f62511d243ad7f Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Fri, 27 Mar 2015 12:28:45 -0400 Subject: [PATCH 069/209] Add DOMElement.innerText. Closes #4069. --- std/js/html/DOMElement.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/std/js/html/DOMElement.hx b/std/js/html/DOMElement.hx index d036e59843c..5208529c26b 100644 --- a/std/js/html/DOMElement.hx +++ b/std/js/html/DOMElement.hx @@ -57,6 +57,7 @@ extern class DOMElement extends Node var oncopy : haxe.Constraints.Function; var oncut : haxe.Constraints.Function; var onpaste : haxe.Constraints.Function; + var innerText : String; var offsetParent(default,null) : DOMElement; var offsetTop(default,null) : Int; var offsetLeft(default,null) : Int; From 8a5860367484d6a8f87d262b289468ba7c48be97 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 27 Mar 2015 22:27:55 +0800 Subject: [PATCH 070/209] [sys] test executing file with different names (see #3402) --- tests/sys/src/TestSys.hx | 59 +++++++++++++++++++++++++++++++ tests/sys/src/io/TestProcess.hx | 61 ++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index afd290c3cb7..2f657db0192 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -37,6 +37,65 @@ class TestSys extends haxe.unit.TestCase { assertEquals(0, exitCode); } + function testCommandName() { + // This is just a script that behaves like ExitCode.hx, + // which exits with the code same as the first given argument. + var scriptContent = switch (Sys.systemName()) { + case "Windows": + '@echo off\nexit /b %1'; + case "Mac", "Linux", _: + '#!/bin/sh\nexit $1'; + } + for (name in FileNames.names) { + //call without ext + var scriptExt = switch (Sys.systemName()) { + case "Windows": + ".bat"; + case "Mac", "Linux", _: + ""; + } + var path = "temp/" + name + scriptExt; + sys.io.File.saveContent(path, scriptContent); + + switch (Sys.systemName()) { + case "Mac", "Linux": + var exitCode = Sys.command("chmod", ["a+x", path]); + assertEquals(0, exitCode); + case "Windows": + //pass + } + + var random = Std.random(256); + var exitCode = Sys.command(path, [Std.string(random)]); + assertEquals(random, exitCode); + sys.FileSystem.deleteFile(path); + + + //call with ext + var scriptExt = switch (Sys.systemName()) { + case "Windows": + ".bat"; + case "Mac", "Linux", _: + ".sh"; + } + var path = "temp/" + name + scriptExt; + sys.io.File.saveContent(path, scriptContent); + + switch (Sys.systemName()) { + case "Mac", "Linux": + var exitCode = Sys.command("chmod", ["a+x", path]); + assertEquals(0, exitCode); + case "Windows": + //pass + } + + var random = Std.random(256); + var exitCode = Sys.command(path, [Std.string(random)]); + assertEquals(random, exitCode); + sys.FileSystem.deleteFile(path); + } + } + function testExitCode() { var bin = sys.FileSystem.absolutePath(ExitCode.bin); diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index dfad1033dce..49988c18438 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -3,7 +3,7 @@ package io; import sys.io.Process; class TestProcess extends haxe.unit.TestCase { - #if !php + #if !php //should be fixed function testArguments() { var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; @@ -42,6 +42,65 @@ class TestProcess extends haxe.unit.TestCase { trace(sys.io.File.getContent(TestArguments.log)); assertEquals(0, exitCode); } + + function testCommandName() { + // This is just a script that behaves like ExitCode.hx, + // which exits with the code same as the first given argument. + var scriptContent = switch (Sys.systemName()) { + case "Windows": + '@echo off\nexit /b %1'; + case "Mac", "Linux", _: + '#!/bin/sh\nexit $1'; + } + for (name in FileNames.names) { + //call without ext + var scriptExt = switch (Sys.systemName()) { + case "Windows": + ".bat"; + case "Mac", "Linux", _: + ""; + } + var path = "temp/" + name + scriptExt; + sys.io.File.saveContent(path, scriptContent); + + switch (Sys.systemName()) { + case "Mac", "Linux": + var exitCode = Sys.command("chmod", ["a+x", path]); + assertEquals(0, exitCode); + case "Windows": + //pass + } + + var random = Std.random(256); + var exitCode = new Process(path, [Std.string(random)]).exitCode(); + assertEquals(random, exitCode); + sys.FileSystem.deleteFile(path); + + + //call with ext + var scriptExt = switch (Sys.systemName()) { + case "Windows": + ".bat"; + case "Mac", "Linux", _: + ".sh"; + } + var path = "temp/" + name + scriptExt; + sys.io.File.saveContent(path, scriptContent); + + switch (Sys.systemName()) { + case "Mac", "Linux": + var exitCode = Sys.command("chmod", ["a+x", path]); + assertEquals(0, exitCode); + case "Windows": + //pass + } + + var random = Std.random(256); + var exitCode = new Process(path, [Std.string(random)]).exitCode(); + assertEquals(random, exitCode); + sys.FileSystem.deleteFile(path); + } + } #end function testExitCode() { From 00346ff7af76820feb1fee8788a8ab961884a6ef Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sat, 28 Mar 2015 01:19:55 +0800 Subject: [PATCH 071/209] [test] comment out tests that fail on Windows --- tests/sys/src/TestSys.hx | 21 ++++++++++++++------- tests/sys/src/io/TestProcess.hx | 24 ++++++++++++++++-------- tests/unit/src/unit/TestJson.hx | 9 +++++++++ tests/unit/src/unitstd/haxe/Utf8.unit.hx | 10 ++++++++++ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 2f657db0192..a860ee6875a 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -1,5 +1,5 @@ class TestSys extends haxe.unit.TestCase { - #if !php //https://github.com/HaxeFoundation/haxe/issues/3603#issuecomment-86437474 + #if !php //FIXME https://github.com/HaxeFoundation/haxe/issues/3603#issuecomment-86437474 function testCommand() { var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; @@ -37,6 +37,7 @@ class TestSys extends haxe.unit.TestCase { assertEquals(0, exitCode); } + #if !cs //FIXME function testCommandName() { // This is just a script that behaves like ExitCode.hx, // which exits with the code same as the first given argument. @@ -47,14 +48,14 @@ class TestSys extends haxe.unit.TestCase { '#!/bin/sh\nexit $1'; } for (name in FileNames.names) { - //call without ext + //call with ext var scriptExt = switch (Sys.systemName()) { case "Windows": ".bat"; case "Mac", "Linux", _: - ""; + ".sh"; } - var path = "temp/" + name + scriptExt; + var path = sys.FileSystem.absolutePath("temp/" + name + scriptExt); sys.io.File.saveContent(path, scriptContent); switch (Sys.systemName()) { @@ -67,18 +68,21 @@ class TestSys extends haxe.unit.TestCase { var random = Std.random(256); var exitCode = Sys.command(path, [Std.string(random)]); + if (exitCode != random) + trace(name); assertEquals(random, exitCode); sys.FileSystem.deleteFile(path); - //call with ext + + //call without ext var scriptExt = switch (Sys.systemName()) { case "Windows": ".bat"; case "Mac", "Linux", _: - ".sh"; + ""; } - var path = "temp/" + name + scriptExt; + var path = sys.FileSystem.absolutePath("temp/" + name + scriptExt); sys.io.File.saveContent(path, scriptContent); switch (Sys.systemName()) { @@ -91,10 +95,13 @@ class TestSys extends haxe.unit.TestCase { var random = Std.random(256); var exitCode = Sys.command(path, [Std.string(random)]); + if (exitCode != random) + trace(name); assertEquals(random, exitCode); sys.FileSystem.deleteFile(path); } } + #end //!cs function testExitCode() { var bin = sys.FileSystem.absolutePath(ExitCode.bin); diff --git a/tests/sys/src/io/TestProcess.hx b/tests/sys/src/io/TestProcess.hx index 49988c18438..3dc3a384053 100644 --- a/tests/sys/src/io/TestProcess.hx +++ b/tests/sys/src/io/TestProcess.hx @@ -3,7 +3,7 @@ package io; import sys.io.Process; class TestProcess extends haxe.unit.TestCase { - #if !php //should be fixed + #if !php //FIXME function testArguments() { var bin = sys.FileSystem.absolutePath(TestArguments.bin); var args = TestArguments.expectedArgs; @@ -43,6 +43,7 @@ class TestProcess extends haxe.unit.TestCase { assertEquals(0, exitCode); } + #if !(neko || cpp || cs) //FIXME function testCommandName() { // This is just a script that behaves like ExitCode.hx, // which exits with the code same as the first given argument. @@ -53,14 +54,14 @@ class TestProcess extends haxe.unit.TestCase { '#!/bin/sh\nexit $1'; } for (name in FileNames.names) { - //call without ext + //call with ext var scriptExt = switch (Sys.systemName()) { case "Windows": ".bat"; case "Mac", "Linux", _: - ""; + ".sh"; } - var path = "temp/" + name + scriptExt; + var path = sys.FileSystem.absolutePath("temp/" + name + scriptExt); sys.io.File.saveContent(path, scriptContent); switch (Sys.systemName()) { @@ -73,18 +74,21 @@ class TestProcess extends haxe.unit.TestCase { var random = Std.random(256); var exitCode = new Process(path, [Std.string(random)]).exitCode(); + if (exitCode != random) + trace(name); assertEquals(random, exitCode); sys.FileSystem.deleteFile(path); - //call with ext + + //call without ext var scriptExt = switch (Sys.systemName()) { case "Windows": ".bat"; case "Mac", "Linux", _: - ".sh"; + ""; } - var path = "temp/" + name + scriptExt; + var path = sys.FileSystem.absolutePath("temp/" + name + scriptExt); sys.io.File.saveContent(path, scriptContent); switch (Sys.systemName()) { @@ -97,11 +101,15 @@ class TestProcess extends haxe.unit.TestCase { var random = Std.random(256); var exitCode = new Process(path, [Std.string(random)]).exitCode(); + if (exitCode != random) + trace(name); assertEquals(random, exitCode); sys.FileSystem.deleteFile(path); } } - #end + #end //!neko + + #end //!php function testExitCode() { var bin = sys.FileSystem.absolutePath(ExitCode.bin); diff --git a/tests/unit/src/unit/TestJson.hx b/tests/unit/src/unit/TestJson.hx index f3b689af793..83ec3e529f0 100644 --- a/tests/unit/src/unit/TestJson.hx +++ b/tests/unit/src/unit/TestJson.hx @@ -48,6 +48,11 @@ class TestJson extends Test { // TODO: test pretty-printing (also with objects with skipped function fields!) function testHaxeJson() { + #if php + // php's haxe.Utf8 uses mbstring + if (untyped __call__("extension_loaded", "mbstring")) { + #end + var str = haxe.format.JsonPrinter.print( { x : -4500, y : 1.456, a : ["hello", "wor'\"\n\t\rd"], b : function() {} } ); str = str.substr(1, str.length - 2); // remove {} var parts = str.split(","); @@ -89,6 +94,10 @@ class TestJson extends Test { eq(haxe.format.JsonPrinter.print(Math.NaN), "null"); eq(haxe.format.JsonPrinter.print(function() {}), "\"\""); eq(haxe.format.JsonPrinter.print({a: function() {}, b: 1}), "{\"b\":1}"); + + #if php + } + #end } function test3690() { diff --git a/tests/unit/src/unitstd/haxe/Utf8.unit.hx b/tests/unit/src/unitstd/haxe/Utf8.unit.hx index 6f5355393e6..c5324eb68b5 100644 --- a/tests/unit/src/unitstd/haxe/Utf8.unit.hx +++ b/tests/unit/src/unitstd/haxe/Utf8.unit.hx @@ -1,3 +1,8 @@ +#if php +// php's haxe.Utf8 uses mbstring +if (untyped __call__("extension_loaded", "mbstring")) { +#end + #if false // disabled tests with outside BMP chars (will be reenabled when we support them) var str = "あ𠀀い"; @@ -38,3 +43,8 @@ haxe.Utf8.compare(haxe.Utf8.sub(str, 1, 0), "") == 0; // unspecify outside of range Utf8.sub // haxe.Utf8.compare(haxe.Utf8.sub(str, 9, 0), "") == 0; + + +#if php +} +#end \ No newline at end of file From 01cbe8d5c299ae04b5bd0a0f29b083ec20b47091 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sat, 28 Mar 2015 03:12:30 +0800 Subject: [PATCH 072/209] [AppVeyor] do not test BYTECODE=1 in order to save time... We have never shipped the bytecode version of the compiler anyway. --- tests/RunCi.hx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 73fe8cc9160..b6629900eba 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -547,10 +547,11 @@ class RunCi { changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); case AppVeyor: - changeDirectory(repoDir); - runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt BYTECODE=1']); - changeDirectory(unitDir); - runCommand("haxe", ["compile-macro.hxml"]); + // save time... + // changeDirectory(repoDir); + // runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt BYTECODE=1']); + // changeDirectory(unitDir); + // runCommand("haxe", ["compile-macro.hxml"]); } case Neko: runCommand("haxe", ["compile-neko.hxml"]); From c2d45eb8a4719cca6809ce2fc2ab82fcee0a0889 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 27 Mar 2015 20:27:54 +0100 Subject: [PATCH 073/209] always remove `@:generic` classes if they extend a type parameter (see #4092) also temp fix type parameter classes appearing in the output --- filters.ml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/filters.ml b/filters.ml index d5b27b7d399..2b59a77d48e 100644 --- a/filters.ml +++ b/filters.ml @@ -762,14 +762,23 @@ let save_class_state ctx t = match t with (* PASS 2 begin *) let is_removable_class c = - c.cl_kind = KGeneric && - (Meta.has Meta.Remove c.cl_meta || - List.exists (fun (_,t) -> match follow t with - | TInst(c,_) -> - Codegen.has_ctor_constraint c - | _ -> - false - ) c.cl_params) + match c.cl_kind with + | KGeneric -> + (Meta.has Meta.Remove c.cl_meta || + (match c.cl_super with + | Some ({cl_kind = KTypeParameter _},_) -> true + | _ -> false) || + List.exists (fun (_,t) -> match follow t with + | TInst(c,_) -> + Codegen.has_ctor_constraint c + | _ -> + false + ) c.cl_params) + | KTypeParameter _ -> + (* this shouldn't happen, have to investigate (see #4092) *) + true + | _ -> + false let remove_generic_base ctx t = match t with | TClassDecl c when is_removable_class c -> From 52e3e1c2c15d45905a1d2394dccd9018eaa6c337 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Fri, 27 Mar 2015 20:40:00 +0100 Subject: [PATCH 074/209] remove `@:generic` classes if they extend removable classes (see #4092) --- filters.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filters.ml b/filters.ml index 2b59a77d48e..3b531cff655 100644 --- a/filters.ml +++ b/filters.ml @@ -761,12 +761,12 @@ let save_class_state ctx t = match t with (* PASS 2 begin *) -let is_removable_class c = +let rec is_removable_class c = match c.cl_kind with | KGeneric -> (Meta.has Meta.Remove c.cl_meta || (match c.cl_super with - | Some ({cl_kind = KTypeParameter _},_) -> true + | Some (c,_) -> is_removable_class c | _ -> false) || List.exists (fun (_,t) -> match follow t with | TInst(c,_) -> From 30f1d1ee7f1103bd8bd82505b10fe763c78c5db3 Mon Sep 17 00:00:00 2001 From: Jason O'Neil Date: Sat, 28 Mar 2015 10:56:19 +0800 Subject: [PATCH 075/209] Improvements to new XML class' DOM manipulation functions. Summary of changes: - When doing insertChild() remove from old location/parent - When doing insertChild() update .parent - When doing removeChild() set child.parent to null - More precise documentation of behaviour in the comments - Unit tests to verify this behaviour Fixes #4094 --- std/Xml.hx | 19 +++++++++-- tests/unit/src/unit/issues/Issue4094.hx | 42 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4094.hx diff --git a/std/Xml.hx b/std/Xml.hx index 0e47bcf8d00..a11c15e2be1 100644 --- a/std/Xml.hx +++ b/std/Xml.hx @@ -265,7 +265,9 @@ class Xml { /** Adds a child node to the Document or Element. - One node can only be inside one given node which is indicated by the [parent] property. + A child node can only be inside one given parent node, which is indicated by the [parent] property. + If the child is already inside this Document or Element, there will be no effect. + If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function addChild( x : Xml ) : Void { ensureElementType(); @@ -284,15 +286,26 @@ class Xml { **/ public function removeChild( x : Xml ) : Bool { ensureElementType(); - return children.remove(x); + if (children.remove(x)) { + x.parent = null; + return true; + } + return false; } /** Inserts a child at the given position among the other childs. + A child node can only be inside one given parent node, which is indicated by the [parent] property. + If the child is already inside this Document or Element, it will be removed and added at the new position. + If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function insertChild( x : Xml, pos : Int ) : Void { ensureElementType(); + if (x.parent != null) { + x.parent.children.remove(x); + } children.insert(pos, x); + x.parent = this; } /** @@ -313,4 +326,4 @@ class Xml { throw 'Bad node type, expected Element or Document but found $nodeType'; } } -} \ No newline at end of file +} diff --git a/tests/unit/src/unit/issues/Issue4094.hx b/tests/unit/src/unit/issues/Issue4094.hx new file mode 100644 index 00000000000..5826f179d69 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4094.hx @@ -0,0 +1,42 @@ +package unit.issues; +import unit.Test; + +class Issue4094 extends Test { + function test() { + var div = Xml.parse("
").firstElement(); + var nodes = Xml.parse("Text1Span
Div
Text2"); + + // Test insertChild() moves the nodes correctly. + var text1 = nodes.firstChild(); + var span = nodes.firstElement(); + + div.insertChild( text1, 0 ); + div.insertChild( span, 1 ); + + eq( div.toString(), '
Text1Span
' ); + eq( nodes.toString(), '
Div
Text2' ); + eq( text1.parent, div ); + eq( span.parent, div ); + + // Test removeChild() removes the nodes correctly + var divText = nodes.firstElement().firstChild(); + + nodes.firstElement().removeChild( divText ); + eq( divText.parent, null ); + eq( nodes.toString(), '
Text2' ); + + // Test addChild() moves the nodes correctly. + var comment = nodes.firstChild(); + var innerDiv = nodes.firstElement(); + + div.addChild( comment ); + div.addChild( innerDiv ); + div.addChild( divText ); + + eq( div.toString(), '
Text1Span
Div
' ); + eq( nodes.toString(), 'Text2' ); + eq( comment.parent, div ); + eq( innerDiv.parent, div ); + eq( divText.parent, div ); + } +} From 4f36b96e5e3d63de76b7e9cbd8340d82f3da73d1 Mon Sep 17 00:00:00 2001 From: Jason O'Neil Date: Sat, 28 Mar 2015 11:19:40 +0800 Subject: [PATCH 076/209] Update Xml.addChild() to behave similarly to 3.1.3 If it's already present as a child, remove and re-add, rather than ignore. --- std/Xml.hx | 8 +++----- tests/unit/src/unit/issues/Issue4094.hx | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/std/Xml.hx b/std/Xml.hx index a11c15e2be1..0cd40d403bb 100644 --- a/std/Xml.hx +++ b/std/Xml.hx @@ -266,14 +266,12 @@ class Xml { /** Adds a child node to the Document or Element. A child node can only be inside one given parent node, which is indicated by the [parent] property. - If the child is already inside this Document or Element, there will be no effect. + If the child is already inside this Document or Element, it will be moved to the last position among the Document or Element's children. If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function addChild( x : Xml ) : Void { ensureElementType(); - if (x.parent == this) { - return; - } else if (x.parent != null) { + if (x.parent != null) { x.parent.removeChild(x); } children.push(x); @@ -296,7 +294,7 @@ class Xml { /** Inserts a child at the given position among the other childs. A child node can only be inside one given parent node, which is indicated by the [parent] property. - If the child is already inside this Document or Element, it will be removed and added at the new position. + If the child is already inside this Document or Element, it will be moved to the new position among the Document or Element's children. If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function insertChild( x : Xml, pos : Int ) : Void { diff --git a/tests/unit/src/unit/issues/Issue4094.hx b/tests/unit/src/unit/issues/Issue4094.hx index 5826f179d69..e106aa98fe3 100644 --- a/tests/unit/src/unit/issues/Issue4094.hx +++ b/tests/unit/src/unit/issues/Issue4094.hx @@ -38,5 +38,10 @@ class Issue4094 extends Test { eq( comment.parent, div ); eq( innerDiv.parent, div ); eq( divText.parent, div ); + + // Test addChild() moves a current child to the end. + + div.addChild( span ); + eq( div.toString(), '
Text1
DivSpan
' ); } } From 3937ecbfa7c5f3eb91d9c72a9c1e504fa335387b Mon Sep 17 00:00:00 2001 From: Hugh Date: Sat, 28 Mar 2015 13:38:15 +0800 Subject: [PATCH 077/209] Mark ConstCharStart.toString as extern too --- std/cpp/ConstCharStar.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cpp/ConstCharStar.hx b/std/cpp/ConstCharStar.hx index 5dd70b3df4f..10818f95525 100644 --- a/std/cpp/ConstCharStar.hx +++ b/std/cpp/ConstCharStar.hx @@ -7,7 +7,7 @@ abstract ConstCharStar( RawConstPointer ) to(RawConstPointer) @:from static public inline function fromString(s:String) return new ConstCharStar(s); - @:to + @:to @:extern public inline function toString():String return new String(untyped this); @:to @:extern From 163052da9f7bbd414795c75f5e0b4d9bb3ee5b87 Mon Sep 17 00:00:00 2001 From: Hugh Date: Sat, 28 Mar 2015 14:38:53 +0800 Subject: [PATCH 078/209] [cpp] Add cpp.Lib.unloadAllLibraries. Allow Sys.exit to exit after dlls have been unloaded --- std/cpp/Lib.hx | 8 ++++++++ std/cpp/_std/Sys.hx | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/std/cpp/Lib.hx b/std/cpp/Lib.hx index 425c3f5fa16..af6bcd0a479 100644 --- a/std/cpp/Lib.hx +++ b/std/cpp/Lib.hx @@ -35,6 +35,14 @@ class Lib { #end } + /** + Unloaded all dynamic libraries in reverse order of loading. + Returns the number of libraries unloaded. + **/ + public static function unloadAllLibraries() : Int { + return untyped __global__.__hxcpp_unload_all_libraries(); + } + @:analyzer(no_simplification) public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic { var factory:Callable< ConstCharStar -> Object > = diff --git a/std/cpp/_std/Sys.hx b/std/cpp/_std/Sys.hx index 165a02198e3..e5bd3f98bd0 100644 --- a/std/cpp/_std/Sys.hx +++ b/std/cpp/_std/Sys.hx @@ -106,7 +106,7 @@ } public static function exit( code : Int ) : Void { - sys_exit(code); + untyped __global__.__hxcpp_exit(code); } public static function time() : Float { @@ -140,7 +140,6 @@ private static var set_cwd = cpp.Lib.load("std","set_cwd",1); private static var sys_string = cpp.Lib.load("std","sys_string",0); private static var sys_command = cpp.Lib.load("std","sys_command",1); - private static var sys_exit = cpp.Lib.load("std","sys_exit",1); private static var sys_time = cpp.Lib.load("std","sys_time",0); private static var sys_cpu_time = cpp.Lib.load("std","sys_cpu_time",0); private static var sys_exe_path = cpp.Lib.load("std","sys_exe_path",0); @@ -151,4 +150,4 @@ private static var file_stderr = cpp.Lib.load("std","file_stderr",0); private static var getch = cpp.Lib.load("std","sys_getch",1); -} \ No newline at end of file +} From fb304ff907d2e4cb9165ba2c6274dfe39302f620 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sat, 28 Mar 2015 09:41:21 +0100 Subject: [PATCH 079/209] make sure the children count is in sync in XML parser (closes #4096) --- std/haxe/xml/Parser.hx | 24 ++++++++++++------------ tests/unit/src/unit/issues/Issue4096.hx | 11 +++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4096.hx diff --git a/std/haxe/xml/Parser.hx b/std/haxe/xml/Parser.hx index 8f0aba15f63..59f75c06162 100644 --- a/std/haxe/xml/Parser.hx +++ b/std/haxe/xml/Parser.hx @@ -82,6 +82,10 @@ class Parser // need extra state because next is in use var escapeNext = S.BEGIN; var attrValQuote = -1; + inline function addChild(xml:Xml) { + parent.addChild(xml); + nsubs++; + } while (!StringTools.isEof(c)) { switch(state) @@ -115,8 +119,7 @@ class Parser buf.addSub(str, start, p - start); var child = Xml.createPCData(buf.toString()); buf = new StringBuf(); - parent.addChild(child); - nsubs++; + addChild(child); state = S.IGNORE_SPACES; next = S.BEGIN_NODE; } else if (c == '&'.code) { @@ -129,8 +132,7 @@ class Parser if (c == ']'.code && str.fastCodeAt(p + 1) == ']'.code && str.fastCodeAt(p + 2) == '>'.code) { var child = Xml.createCData(str.substr(start, p - start)); - parent.addChild(child); - nsubs++; + addChild(child); p += 2; state = S.BEGIN; } @@ -183,7 +185,7 @@ class Parser if( p == start ) throw("Expected node name"); xml = Xml.createElement(str.substr(start, p - start)); - parent.addChild(xml); + addChild(xml); state = S.IGNORE_SPACES; next = S.BODY; continue; @@ -193,10 +195,8 @@ class Parser { case '/'.code: state = S.WAIT_END; - nsubs++; case '>'.code: state = S.CHILDS; - nsubs++; default: state = S.ATTRIB_NAME; start = p; @@ -293,7 +293,7 @@ class Parser case S.COMMENT: if (c == '-'.code && str.fastCodeAt(p +1) == '-'.code && str.fastCodeAt(p + 2) == '>'.code) { - parent.addChild(Xml.createComment(str.substr(start, p - start))); + addChild(Xml.createComment(str.substr(start, p - start))); p += 2; state = S.BEGIN; } @@ -304,7 +304,7 @@ class Parser nbrackets--; else if (c == '>'.code && nbrackets == 0) { - parent.addChild(Xml.createDocType(str.substr(start, p - start))); + addChild(Xml.createDocType(str.substr(start, p - start))); state = S.BEGIN; } case S.HEADER: @@ -312,7 +312,7 @@ class Parser { p++; var str = str.substr(start + 1, p - start - 2); - parent.addChild(Xml.createProcessingInstruction(str)); + addChild(Xml.createProcessingInstruction(str)); state = S.BEGIN; } case S.ESCAPE: @@ -375,7 +375,7 @@ class Parser { if (p != start || nsubs == 0) { buf.addSub(str, start, p-start); - parent.addChild(Xml.createPCData(buf.toString())); + addChild(Xml.createPCData(buf.toString())); } return p; } @@ -383,7 +383,7 @@ class Parser if( !strict && state == S.ESCAPE && escapeNext == S.PCDATA ) { buf.addChar("&".code); buf.addSub(str, start, p - start); - parent.addChild(Xml.createPCData(buf.toString())); + addChild(Xml.createPCData(buf.toString())); return p; } diff --git a/tests/unit/src/unit/issues/Issue4096.hx b/tests/unit/src/unit/issues/Issue4096.hx new file mode 100644 index 00000000000..fcee3a846db --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4096.hx @@ -0,0 +1,11 @@ +package unit.issues; + +using Lambda; + +class Issue4096 extends Test { + function test() { + eq(1, Xml.parse("").count()); + eq(1, Xml.parse("").count()); + eq(1, Xml.parse("").count()); + } +} \ No newline at end of file From 31f5d819cb15463b56b382e86ad60da09558d673 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sat, 28 Mar 2015 12:32:27 +0100 Subject: [PATCH 080/209] added neko 2.0+ support --- std/neko/vm/Module.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/std/neko/vm/Module.hx b/std/neko/vm/Module.hx index 6b0af3d1b7a..10a5bc6f608 100644 --- a/std/neko/vm/Module.hx +++ b/std/neko/vm/Module.hx @@ -193,6 +193,8 @@ class Module { a.push("FLOAT:"+i.readUntil(0)); case 5: a.push("DEBUG"); + case 6: + a.push("VERSION "+i.readByte()); default: throw "assert"; } From 96a5744e7434ec0584b4c529b1be2b2098f728ce Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sat, 28 Mar 2015 15:30:24 +0100 Subject: [PATCH 081/209] Revert "add back `@:privateAccess` to macro return (see #3714)" This reverts commit e747fb65b92d92ef80d22c2bbc43af53f7647e08. --- typer.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer.ml b/typer.ml index d382b85c9a3..c531a8a62e1 100644 --- a/typer.ml +++ b/typer.ml @@ -3994,7 +3994,7 @@ and build_call ctx acc el (with_type:with_type) p = | None -> (fun() -> type_expr ctx (EConst (Ident "null"),p) Value) | Some (EMeta((Meta.MergeBlock,_,_),(EBlock el,_)),_) -> (fun () -> let e = type_block ctx el with_type p in mk (TMeta((Meta.MergeBlock,[],p), e)) e.etype e.epos) | Some (EVars vl,p) -> (fun() -> type_vars ctx vl p true) - | Some e -> (fun() -> type_expr ctx (EMeta((Meta.PrivateAccess,[],snd e),e),snd e) with_type)) + | Some e -> (fun() -> type_expr ctx e with_type)) | _ -> (* member-macro call : since we will make a static call, let's found the actual class and not its subclass *) (match follow ethis.etype with From b8022bc2fa5ce91abf62865466298de3b6a32101 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Sat, 28 Mar 2015 19:26:38 +0300 Subject: [PATCH 082/209] sync ocamllibs --- libs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs b/libs index 8bba5315cab..7a83e902634 160000 --- a/libs +++ b/libs @@ -1 +1 @@ -Subproject commit 8bba5315cabf666f94031436653ee0c6115a1762 +Subproject commit 7a83e902634e1db204f6e3a48c2439f63d83c141 From 11ec6f3086f551f6db853b86f1d64bdff57255ac Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sat, 28 Mar 2015 20:01:57 +0100 Subject: [PATCH 083/209] prevent mixed newlines in CPP output (will confuse MSVC) --- gencpp.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index 5c475bb92e3..4f7e966e374 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -406,7 +406,7 @@ let get_code meta key = end else code in - if (code<>"") then code ^ "\n" else code + if (code<>"") then String.concat "\n" (ExtString.String.nsplit code "\r\n") ^ "\n" else code ;; let has_meta_key meta key = @@ -750,7 +750,7 @@ and cpp_function_signature_params params = match params with | TInst (klass,_) -> cpp_function_signature t (get_meta_string klass.cl_meta Meta.Abi) | _ -> print_endline (type_string abi); assert false ) - | _ -> + | _ -> print_endline ("Params:" ^ (String.concat "," (List.map type_string params) )); assert false; @@ -2599,13 +2599,13 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface output (" run(" ^ (gen_arg_list function_def.tf_args "__o_") ^ ")"); ctx.ctx_dump_src_pos <- dump_src; if (is_void) then begin - ctx.ctx_writer#begin_block; + ctx.ctx_writer#begin_block; generate_default_values ctx function_def.tf_args "__o_"; gen_expression ctx false function_def.tf_expr; output "return null();\n"; ctx.ctx_writer#end_block; end else if (has_default_values function_def.tf_args) then begin - ctx.ctx_writer#begin_block; + ctx.ctx_writer#begin_block; generate_default_values ctx function_def.tf_args "__o_"; gen_expression ctx false function_def.tf_expr; ctx.ctx_writer#end_block; @@ -5574,7 +5574,7 @@ let generate_source common_ctx = with Not_found -> "export_classes.info" in if (filename <> "") then begin - let escape s = + let escape s = let b = Buffer.create 0 in for i = 0 to String.length s - 1 do let c = String.unsafe_get s i in @@ -5599,7 +5599,7 @@ let generate_source common_ctx = | TAbstract ({ a_path = ([],"Int") },[]) -> "int" | TAbstract( { a_path = ([], "EnumValue") }, _ ) -> "Dynamic" | TEnum (enum,params) -> spath enum.e_path - | TInst (klass,params) -> + | TInst (klass,params) -> (match klass.cl_path, params with (* Array class *) (*| ([],"Array") when is_dynamic_array_param (List.hd params) -> "Dynamic" *) From a565eb2fb1493748a4c7909de5956fccb97e5ac8 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 29 Mar 2015 17:25:24 +0200 Subject: [PATCH 084/209] added DELETE as reserved identifier --- gencpp.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/gencpp.ml b/gencpp.ml index 4f7e966e374..a0cc42e9101 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -321,6 +321,7 @@ let keyword_remap name = | "_Complex" | "INFINITY" | "NAN" | "INT_MIN" | "INT_MAX" | "INT8_MIN" | "INT8_MAX" | "UINT8_MAX" | "INT16_MIN" | "INT16_MAX" | "UINT16_MAX" | "INT32_MIN" | "INT32_MAX" | "UINT32_MAX" + | "DELETE" | "struct" -> "_" ^ name | "asm" -> "_asm_" | x -> x From c27d546a47c79a189644f96a3f34e65114bc6b85 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 29 Mar 2015 17:53:17 +0200 Subject: [PATCH 085/209] fix for OSX --- std/js/_std/haxe/io/Bytes.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/std/js/_std/haxe/io/Bytes.hx b/std/js/_std/haxe/io/Bytes.hx index b2543869089..d2eea72f8b7 100644 --- a/std/js/_std/haxe/io/Bytes.hx +++ b/std/js/_std/haxe/io/Bytes.hx @@ -34,6 +34,7 @@ class Bytes { this.length = data.byteLength; this.b = new js.html.Uint8Array(data); untyped { + b.bufferValue = data; // some impl does not return the same instance in .buffer data.hxBytes = this; data.bytes = this.b; } @@ -183,7 +184,7 @@ class Bytes { } public inline function getData() : BytesData { - return b.buffer; + return untyped b.bufferValue; } public static function alloc( length : Int ) : Bytes { From c72b274a47be71e857e38c7a20c5838303f8ccb4 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 29 Mar 2015 18:02:13 +0200 Subject: [PATCH 086/209] if we detect Float32Array but not Float64Array, set it to "notsupported" --- std/js/html/compat/Float64Array.hx | 2 +- tests/unit/src/unitstd/haxe/io/Float64Array.unit.hx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index ca3c3387b5d..f44a5c8c6b7 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -110,7 +110,7 @@ class Float64Array { } static function __init__() untyped { - var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new; + var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || __js__('typeof(window) != "undefined" && window.Float32Array && "notsupported"') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new; } } \ No newline at end of file diff --git a/tests/unit/src/unitstd/haxe/io/Float64Array.unit.hx b/tests/unit/src/unitstd/haxe/io/Float64Array.unit.hx index 62808aad462..be618d2c5b7 100644 --- a/tests/unit/src/unitstd/haxe/io/Float64Array.unit.hx +++ b/tests/unit/src/unitstd/haxe/io/Float64Array.unit.hx @@ -1,6 +1,10 @@ var emulated = haxe.io.ArrayBufferView.EMULATED; +#if js +if( untyped js.html.Float64Array == "notsupported" ) return; +#end + var b = new haxe.io.Float64Array(5); b[0] == 0; b[4] == 0; From 29591471e0b5b4444dbe819b0b29bbdebffa789d Mon Sep 17 00:00:00 2001 From: Juraj Kirchheim Date: Sun, 29 Mar 2015 22:52:47 +0200 Subject: [PATCH 087/209] Use flash.Vector.ofArray only for flash10. As it is, it causes a compiler error for flash9 --- std/haxe/ds/Vector.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/haxe/ds/Vector.hx b/std/haxe/ds/Vector.hx index a33649bfec1..175d686da59 100644 --- a/std/haxe/ds/Vector.hx +++ b/std/haxe/ds/Vector.hx @@ -205,7 +205,7 @@ abstract Vector(VectorData) { static public inline function fromArrayCopy(array:Array):Vector { #if python return cast array.copy(); - #elseif flash + #elseif flash10 return fromData(flash.Vector.ofArray(array)); #elseif java return fromData(java.Lib.nativeArray(array,false)); From 3ccfca5bdd142fa67f2c5a11151cb921a1608617 Mon Sep 17 00:00:00 2001 From: Hugh Date: Mon, 30 Mar 2015 13:22:27 +0800 Subject: [PATCH 088/209] [cpp] Expose some ArrayBase functions via the cpp.NativeArray and cpp.ArrayBase classes --- std/cpp/ArrayBase.hx | 11 +++++++++++ std/cpp/NativeArray.hx | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 std/cpp/ArrayBase.hx diff --git a/std/cpp/ArrayBase.hx b/std/cpp/ArrayBase.hx new file mode 100644 index 00000000000..06e26eab204 --- /dev/null +++ b/std/cpp/ArrayBase.hx @@ -0,0 +1,11 @@ +package cpp; + +extern class ArrayBase +{ + // Length is number of elements + public var length(default,null):Int; + public function getElementSize():Int; + public function getByteCount():Int; + public function getBase():RawPointer; +} + diff --git a/std/cpp/NativeArray.hx b/std/cpp/NativeArray.hx index 1aa5746ead4..7322831c2d3 100644 --- a/std/cpp/NativeArray.hx +++ b/std/cpp/NativeArray.hx @@ -8,6 +8,10 @@ extern class NativeArray { untyped ioDestArray.blit(inDestElement, inSourceArray, inSourceElement, inElementCount); }; + public static inline function getBase( inArray:Array ) : ArrayBase { + return untyped inArray; + } + public static inline function zero( ioDestArray:Array, ?inFirst:Int, ?inElements:Int ) : Void { untyped ioDestArray.zero(inFirst, inElements); }; From 094db4e554c8c49edd44b5c8e2564ce182271687 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 30 Mar 2015 10:44:02 +0200 Subject: [PATCH 089/209] use `cast_or_unify` for map literals (closes #4100) --- tests/unit/src/unit/issues/Issue4100.hx | 40 +++++++++++++++++++++++++ typer.ml | 10 +++---- 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4100.hx diff --git a/tests/unit/src/unit/issues/Issue4100.hx b/tests/unit/src/unit/issues/Issue4100.hx new file mode 100644 index 00000000000..c594e0b7830 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4100.hx @@ -0,0 +1,40 @@ +package unit.issues; + +private enum ValueEnum { + VString(v : String); + VInt(v : Int); +} + +private abstract ValueAbs(ValueEnum) { + public inline function new(v : ValueEnum) { + this = v; + } + + @:from + public static function fromString(v : String) : ValueAbs { + return new ValueAbs(VString(v)); + } + + @:from + public static function fromInt(v : Int) { + return new ValueAbs(VInt(v)); + } + + public function getString() { + return switch (this) { + case VString(s): s; + case VInt(i): "" + i; + } + } +} + +class Issue4100 extends Test { + function test() { + var myMap2 : Map = [ + "one" => "some other string", + "two" => 12 + ]; + eq("some other string", myMap2["one"].getString()); + eq("12", myMap2["two"].getString()); + } +} \ No newline at end of file diff --git a/typer.ml b/typer.ml index c531a8a62e1..2ddf7ed6f0f 100644 --- a/typer.ml +++ b/typer.ml @@ -3010,9 +3010,9 @@ and type_expr ctx (e,p) (with_type:with_type) = | WithTypeResume t -> get_map_params t,true | _ -> (mk_mono(),mk_mono()),false in - let unify_with_resume ctx a b p = - if resume then try unify_raise ctx a b p with Error (Unify l,p) -> raise (WithTypeError(l,p)) - else unify ctx a b p + let unify_with_resume ctx e t p = + if resume then try Codegen.AbstractCast.cast_or_unify_raise ctx t e p with Error (Unify l,p) -> raise (WithTypeError(l,p)) + else Codegen.AbstractCast.cast_or_unify ctx t e p in let type_arrow e1 e2 = let e1 = type_expr ctx e1 (WithType tkey) in @@ -3022,9 +3022,9 @@ and type_expr ctx (e,p) (with_type:with_type) = error "Previously defined here" p with Not_found -> Hashtbl.add keys e1.eexpr e1.epos; - unify_with_resume ctx e1.etype tkey e1.epos; + let e1 = unify_with_resume ctx e1 tkey e1.epos in let e2 = type_expr ctx e2 (WithType tval) in - unify_with_resume ctx e2.etype tval e2.epos; + let e2 = unify_with_resume ctx e2 tval e2.epos in e1,e2 in let m = Typeload.load_module ctx ([],"Map") null_pos in From a285600aa16ef552745288900fff2de0856b4974 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 30 Mar 2015 21:56:59 +0800 Subject: [PATCH 090/209] Speedup array unsafe_get and unsafe_set for object types. Closes https://github.com/HaxeFoundation/hxcpp/issues/145 --- gencpp.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index a0cc42e9101..2a3b6655df4 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -2080,7 +2080,7 @@ and gen_expression ctx retval expression = match func.eexpr with | TField(obj,field) when is_array obj.etype -> (match field_name field with - | "pop" | "shift" -> check_array_element_cast obj.etype ".StaticCast" "()" + | "pop" | "shift" | "__unsafe_get" | "__unsafe_set" -> check_array_element_cast obj.etype ".StaticCast" "()" | "map" -> check_array_cast expression.etype | _ -> () ) From ff6f33e0fe837661d506026db2b73ee03b816c5f Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 30 Mar 2015 22:08:35 +0200 Subject: [PATCH 091/209] fix `@:enum` abstract removal in no-dce mode (see #4103) --- filters.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filters.ml b/filters.ml index 3b531cff655..a8d557e4f7a 100644 --- a/filters.ml +++ b/filters.ml @@ -1188,7 +1188,7 @@ let run com tctx main = not (Meta.has Meta.Enum cf.cf_meta) in (* also filter abstract implementation classes that have only @:enum fields (issue #2858) *) - if not (Meta.has Meta.Used c.cl_meta || Common.defined com Define.As3) || not (List.exists is_runtime_field c.cl_ordered_statics) then + if not (List.exists is_runtime_field c.cl_ordered_statics) then c.cl_extern <- true | _ -> () ) com.types; From e6ea0c6c2b986641b08a5d8cbb3a23ff910a1c81 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 31 Mar 2015 14:45:52 +0200 Subject: [PATCH 092/209] dodge java.lang.Double issue (see #4113) --- std/java/lang/Double.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/std/java/lang/Double.hx b/std/java/lang/Double.hx index f3c3c11fccf..88f3b465808 100644 --- a/std/java/lang/Double.hx +++ b/std/java/lang/Double.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // workaround for #4113 @:forward abstract Double(DoubleClass) from DoubleClass to DoubleClass { @:to @:extern inline public function toFloat():Float From cca982ae2b9271efe6a6f7daa58c8661d08c2e43 Mon Sep 17 00:00:00 2001 From: Hugh Date: Tue, 31 Mar 2015 21:47:50 +0800 Subject: [PATCH 093/209] [cpp] Add explicit cast to CastCharStar --- std/cpp/CastCharStar.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cpp/CastCharStar.hx b/std/cpp/CastCharStar.hx index fd780ed3fe4..0d6d2957ee5 100644 --- a/std/cpp/CastCharStar.hx +++ b/std/cpp/CastCharStar.hx @@ -2,7 +2,7 @@ package cpp; abstract CastCharStar( RawPointer ) to(RawPointer) { - inline function new(s:String) this = untyped s.__s; + inline function new(s:String) this = cast untyped s.__s; @:from static public inline function fromString(s:String) return new CastCharStar(s); From 6265f7943642b7aa1f24bd1c628df188c4ffbb1f Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Tue, 31 Mar 2015 13:02:03 -0400 Subject: [PATCH 094/209] Add js.html.Console.clear(). --- std/js/html/Console.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/std/js/html/Console.hx b/std/js/html/Console.hx index aca4d1fcd08..a623ed61d2b 100644 --- a/std/js/html/Console.hx +++ b/std/js/html/Console.hx @@ -45,4 +45,5 @@ extern class Console function profileEnd( data : haxe.extern.Rest ) : Void; function assert( condition : Bool, data : haxe.extern.Rest ) : Void; function count( data : haxe.extern.Rest ) : Void; + function clear() : Void; } \ No newline at end of file From 85e5dd763f0a5c136828a2f16faacbcfcc4934e6 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 31 Mar 2015 22:23:58 +0800 Subject: [PATCH 095/209] [CI] hx-yaml is not needed --- .travis.yml | 1 - appveyor.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 864cc94a092..c272edadba0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,6 @@ script: - sudo make install -s - cd tests/ - mkdir ~/haxelib && haxelib setup ~/haxelib - - haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src - haxe -version - haxe RunCi.hxml - neko RunCi.n diff --git a/appveyor.yml b/appveyor.yml index b394e8e5ab6..d3e45fc2191 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -51,7 +51,6 @@ build_script: - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" - haxelib setup "%HAXELIB_ROOT%" - - haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src test_script: - cd %APPVEYOR_BUILD_FOLDER%/tests/ From 181922fa6783a403ecbd8da4420368395be2a511 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 31 Mar 2015 22:27:48 +0800 Subject: [PATCH 096/209] [AppVeyor] Rebuild hxcpp for m32 only. --- tests/RunCi.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index b6629900eba..9056102f1ff 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -356,7 +356,12 @@ class RunCi { changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/"); runCommand("haxe", ["compile.hxml"]); changeDirectory(getHaxelibPath("hxcpp") + "project/"); - runCommand("neko", ["build.n"]); + switch (ci) { + case AppVeyor: + runCommand("neko", ["build.n", "windows-m32"]); + case _: + runCommand("neko", ["build.n"]); + } changeDirectory(oldDir); } From 7d0df2b39f5967bfb7da3f0fa159e344752733d2 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Tue, 31 Mar 2015 21:24:10 +0200 Subject: [PATCH 097/209] DELETE is properly handled by undef.h --- gencpp.ml | 1 - 1 file changed, 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index 2a3b6655df4..3cfeaa87dfd 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -321,7 +321,6 @@ let keyword_remap name = | "_Complex" | "INFINITY" | "NAN" | "INT_MIN" | "INT_MAX" | "INT8_MIN" | "INT8_MAX" | "UINT8_MAX" | "INT16_MIN" | "INT16_MAX" | "UINT16_MAX" | "INT32_MIN" | "INT32_MAX" | "UINT32_MAX" - | "DELETE" | "struct" -> "_" ^ name | "asm" -> "_asm_" | x -> x From 24d5894ac72e6c428eb74b2b3f34873d60835130 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Tue, 31 Mar 2015 21:55:37 +0200 Subject: [PATCH 098/209] fixed __cpp__ for different newline endings --- gencpp.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index 3cfeaa87dfd..839e5123256 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -396,6 +396,9 @@ match field_access with | _ -> "" ;; +let format_code code = + String.concat "\n" (ExtString.String.nsplit code "\r\n") + let get_code meta key = let code = get_meta_string meta key in let magic_var = "${GENCPP_SOURCE_DIRECTORY}" in @@ -406,7 +409,7 @@ let get_code meta key = end else code in - if (code<>"") then String.concat "\n" (ExtString.String.nsplit code "\r\n") ^ "\n" else code + if (code<>"") then format_code code ^ "\n" else code ;; let has_meta_key meta key = @@ -1964,9 +1967,9 @@ and gen_expression ctx retval expression = | TLocal { v_name = "__cpp__" } -> true | _ -> false) -> ( match arg_list with - | [{ eexpr = TConst (TString code) }] -> output code; + | [{ eexpr = TConst (TString code) }] -> output (format_code code); | ({ eexpr = TConst (TString code) } as ecode) :: tl -> - Codegen.interpolate_code ctx.ctx_common code tl output (gen_expression ctx true) ecode.epos + Codegen.interpolate_code ctx.ctx_common (format_code code) tl output (gen_expression ctx true) ecode.epos | _ -> error "__cpp__'s first argument must be a string" func.epos; ) | TCall (func, arg_list) when tcall_expand_args-> From f5b43f52a9a1c96ccd48b865557971e925ebcdf1 Mon Sep 17 00:00:00 2001 From: Hugh Date: Wed, 1 Apr 2015 13:27:45 +0800 Subject: [PATCH 099/209] [cpp] Make sure there is a space after '<' when casting cpp.Functions --- gencpp.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index 839e5123256..fea108048db 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -2003,7 +2003,7 @@ and gen_expression ctx retval expression = let signature = cpp_function_signature field.cf_type "" in let name = keyword_remap field.cf_name in let void_cast = has_meta_key field.cf_meta Meta.Void in - output ("::cpp::Function<" ^ signature ^">("); + output ("::cpp::Function< " ^ signature ^">("); if (void_cast) then output "hx::AnyCast("; output ("&::" ^(join_class_path klass.cl_path "::")^ "_obj::" ^ name ); if (void_cast) then output ")"; From cdc36ba431dd470f6e420a73009425adee5743e8 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 1 Apr 2015 20:56:55 +0300 Subject: [PATCH 100/209] [gencommon] don't print warning about using @:readOnly with non-never setter for @:coreApi classes (because they won't allow us to change property modifiers) --- gencommon.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gencommon.ml b/gencommon.ml index 7993e3423ac..efd9974be19 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -2113,7 +2113,7 @@ struct let init = List.fold_left (fun acc cf -> match cf.cf_kind, should_handle_dynamic_functions with | (Var v, _) when Meta.has Meta.ReadOnly cf.cf_meta && readonly_support -> - if v.v_write <> AccNever then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; + if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; (match cf.cf_expr with | None -> gen.gcon.warning "Uninitialized readonly variable" cf.cf_pos; acc | Some e -> ensure_simple_expr gen e; acc) @@ -2154,7 +2154,7 @@ struct let vars, funs = List.fold_left (fun (acc_vars,acc_funs) cf -> match cf.cf_kind with | Var v when Meta.has Meta.ReadOnly cf.cf_meta && readonly_support -> - if v.v_write <> AccNever then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; + if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; (match cf.cf_expr with | None -> (acc_vars,acc_funs) | Some e -> ensure_simple_expr gen e; (acc_vars,acc_funs)) From 5da8881c53c504392686ac70e6a5ebe1c2690900 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 1 Apr 2015 20:58:05 +0300 Subject: [PATCH 101/209] [cs] use @:readOnly static vars for Math constants instead of __init__ method, so they're not generated if not used. --- std/cs/_std/Math.hx | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/std/cs/_std/Math.hx b/std/cs/_std/Math.hx index ababdd79b48..99b11b9d2db 100644 --- a/std/cs/_std/Math.hx +++ b/std/cs/_std/Math.hx @@ -19,25 +19,19 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -package; -import cs.system.Random; - @:coreApi @:nativeGen class Math { - public static inline function __init__():Void - { - PI = cs.system.Math.PI; - NaN = cs.system.Double.NaN; - NEGATIVE_INFINITY = cs.system.Double.NegativeInfinity; - POSITIVE_INFINITY = cs.system.Double.PositiveInfinity; - rand = new Random(); - } - - private static var rand:Random; - public static var PI(default, null) : Float; - public static var NaN(default,null) : Float; - public static var NEGATIVE_INFINITY(default,null) : Float; - public static var POSITIVE_INFINITY(default,null) : Float; + @:readOnly + private static var rand = new cs.system.Random(); + + @:readOnly + public static var PI(default,null) = cs.system.Math.PI; + @:readOnly + public static var NaN(default,null) = cs.system.Double.NaN; + @:readOnly + public static var NEGATIVE_INFINITY(default,null) = cs.system.Double.NegativeInfinity; + @:readOnly + public static var POSITIVE_INFINITY(default,null) = cs.system.Double.PositiveInfinity; public static inline function abs(v:Float):Float { From 4bdfca3acd756b61ad040aa49545ec80c95fd6f1 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 1 Apr 2015 20:58:46 +0300 Subject: [PATCH 102/209] [cs] use c# original double.PositiveInfinity instead of Math.POSITIVE_INFINITY, so Math.cs is not even generated for a hello world --- std/cs/internal/Runtime.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cs/internal/Runtime.hx b/std/cs/internal/Runtime.hx index 4cd587f0919..b4be8bcb907 100644 --- a/std/cs/internal/Runtime.hx +++ b/std/cs/internal/Runtime.hx @@ -487,7 +487,7 @@ import cs.system.Object; if (methodLength == 0) throw "Invalid calling parameters for method " + methods[0].Name; - var best = Math.POSITIVE_INFINITY; + var best = cs.system.Double.PositiveInfinity; var bestMethod = 0; for(i in 0...methodLength) { From b78ba4ad7208d29bb38db3a3b7ad2918a6e28deb Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 1 Apr 2015 21:06:31 +0300 Subject: [PATCH 103/209] [cs] lose unneeded @:keep from StringTools --- std/StringTools.hx | 3 --- 1 file changed, 3 deletions(-) diff --git a/std/StringTools.hx b/std/StringTools.hx index 32c8e139d90..16aad21413f 100644 --- a/std/StringTools.hx +++ b/std/StringTools.hx @@ -29,9 +29,6 @@ #if cpp using cpp.NativeString; #end -#if cs -@:keep -#end class StringTools { /** Encode an URL by using the standard format. From bd55c7005019aa0d6ea32672ead96b489d516a10 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 2 Apr 2015 01:49:16 +0300 Subject: [PATCH 104/209] [cs] move generation of GenericInterface attribute to gencs where proper escaping is available (closes #4116) --- gencommon.ml | 13 ++++++------- gencs.ml | 16 ++++++++++++++++ tests/misc/projects/Issue4116/.gitignore | 1 + tests/misc/projects/Issue4116/base/A.hx | 3 +++ tests/misc/projects/Issue4116/compile.hxml | 2 ++ 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 tests/misc/projects/Issue4116/.gitignore create mode 100644 tests/misc/projects/Issue4116/base/A.hx create mode 100644 tests/misc/projects/Issue4116/compile.hxml diff --git a/gencommon.ml b/gencommon.ml index efd9974be19..49b4390f256 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -4815,13 +4815,12 @@ struct let iface = mk_class cl.cl_module cl.cl_path cl.cl_pos in iface.cl_array_access <- Option.map (apply_params (cl.cl_params) (List.map (fun _ -> t_dynamic) cl.cl_params)) cl.cl_array_access; iface.cl_module <- cl.cl_module; - iface.cl_meta <- (Meta.HxGen, [], cl.cl_pos) :: iface.cl_meta; - if gen.gcon.platform = Cs then begin - let tparams = List.map (fun _ -> "object") cl.cl_params in - iface.cl_meta <- (Meta.Meta, [ - EConst( String("haxe.lang.GenericInterface(typeof(" ^ path_s cl.cl_path ^ "<" ^ String.concat ", " tparams ^">))") ), cl.cl_pos - ], cl.cl_pos) :: iface.cl_meta - end; + iface.cl_meta <- + (Meta.HxGen, [], cl.cl_pos) + :: + (Meta.Custom "generic_iface", [(EConst(Int(string_of_int(List.length cl.cl_params))), cl.cl_pos)], cl.cl_pos) + :: + iface.cl_meta; Hashtbl.add ifaces cl.cl_path iface; iface.cl_implements <- (base_generic, []) :: iface.cl_implements; diff --git a/gencs.ml b/gencs.ml index c25e9339386..4d51e792d6b 100644 --- a/gencs.ml +++ b/gencs.ml @@ -2362,6 +2362,22 @@ let configure gen = begin_block w; true in + + (try + let _,m,_ = Meta.get (Meta.Custom "generic_iface") cl.cl_meta in + let rec loop i acc = + if i == 0 then + acc + else + "object" :: (loop (pred i) acc) + in + let tparams = loop (match m with [(EConst(Int s),_)] -> int_of_string s | _ -> assert false) [] in + cl.cl_meta <- (Meta.Meta, [ + EConst(String("global::haxe.lang.GenericInterface(typeof(global::" ^ module_s (TClassDecl cl) ^ "<" ^ String.concat ", " tparams ^ ">))") ), cl.cl_pos + ], cl.cl_pos) :: cl.cl_meta + with Not_found -> + ()); + gen_attributes w cl.cl_meta; let is_main = diff --git a/tests/misc/projects/Issue4116/.gitignore b/tests/misc/projects/Issue4116/.gitignore new file mode 100644 index 00000000000..4b24efc1112 --- /dev/null +++ b/tests/misc/projects/Issue4116/.gitignore @@ -0,0 +1 @@ +/cs diff --git a/tests/misc/projects/Issue4116/base/A.hx b/tests/misc/projects/Issue4116/base/A.hx new file mode 100644 index 00000000000..5d16aa95a66 --- /dev/null +++ b/tests/misc/projects/Issue4116/base/A.hx @@ -0,0 +1,3 @@ +package base; + +class A {} \ No newline at end of file diff --git a/tests/misc/projects/Issue4116/compile.hxml b/tests/misc/projects/Issue4116/compile.hxml new file mode 100644 index 00000000000..5549dd9fd2f --- /dev/null +++ b/tests/misc/projects/Issue4116/compile.hxml @@ -0,0 +1,2 @@ +-cs cs +base.A From 52ef124b5aed5ffdfefe72651117ff9e3f810bcd Mon Sep 17 00:00:00 2001 From: Andy Li Date: Thu, 2 Apr 2015 18:26:53 +0800 Subject: [PATCH 105/209] [CI] misc/projects/Issue4116 is targeting C# --- tests/RunCi.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 9056102f1ff..73d69bccfc7 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -514,6 +514,7 @@ class RunCi { runCommand("haxe", ["compile-macro.hxml"]); changeDirectory(miscDir); + getCsDependencies(); runCommand("haxe", ["compile.hxml"]); switch (ci) { From 230cba0717bd3188a7c6a167e8cb0e5ddf0f87c5 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 2 Apr 2015 15:01:48 +0300 Subject: [PATCH 106/209] Link to RC2 binaries instead of RC1 --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e6631b43aec..51bf386e446 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,14 @@ For the complete Haxe licenses, please see http://haxe.org/foundation/open-sourc ## Installing Haxe -The latest stable release is [Haxe 3.2.0-rc1](http://haxe.org/download). Pre-built binaries are available for your platform: - - * **[Windows installer](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-win.exe)** - * **[Windows binaries](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-win.zip)** - * **[OSX installer](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-osx-installer.pkg)** - * **[OSX binaries](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-osx.tar.gz)** - * **[Linux 32-bit binaries](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-linux32.tar.gz)** - * **[Linux 64-bit binaries](http://haxe.org/download/file/3.2.0-rc.1/haxe-3.2.0-rc1-linux64.tar.gz)** +The latest stable release is [Haxe 3.2.0-rc2](http://haxe.org/download/version/3.2.0-rc.2/). Pre-built binaries are available for your platform: + + * **[Windows installer](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-win.exe)** + * **[Windows binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-win.zip)** + * **[OSX installer](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-osx-installer.pkg)** + * **[OSX binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-osx.tar.gz)** + * **[Linux 32-bit binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-linux32.tar.gz)** + * **[Linux 64-bit binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-linux64.tar.gz)** Automated development builds are available from [build.haxe.org](http://build.haxe.org). From 4ea7785243522f10f13d1362014c9bc93fda3d12 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Thu, 2 Apr 2015 20:49:42 +0300 Subject: [PATCH 107/209] [macro] fix decoding of FClosure (closes #4124) --- interp.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interp.ml b/interp.ml index 4702b2a3db0..f966d36ce0a 100644 --- a/interp.ml +++ b/interp.ml @@ -4775,7 +4775,9 @@ let decode_field_access v = | 1, [c;cf] -> FStatic(decode_ref c,decode_ref cf) | 2, [cf] -> FAnon(decode_ref cf) | 3, [s] -> FDynamic(dec_string s) - | 4, [co;cf] -> FClosure(opt decode_ref co,decode_ref cf) + | 4, [co;cf] -> + let co = opt decode_ref co in + FClosure(Option.map (fun c -> c, List.map snd c.cl_params) co, decode_ref cf) (* TODO: breaking change? *) | 5, [e;ef] -> FEnum(decode_ref e,decode_efield ef) | _ -> raise Invalid_expr From 3e12f6fb8befc0b3a94e908e110eb13d4670221f Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 00:45:56 +0200 Subject: [PATCH 108/209] Update link haxe.Template to new manual page --- std/haxe/Template.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/haxe/Template.hx b/std/haxe/Template.hx index 6fe0b21ace4..1855f7fd6b7 100644 --- a/std/haxe/Template.hx +++ b/std/haxe/Template.hx @@ -47,7 +47,7 @@ private typedef ExprToken = { String, and to have some basic logic. A complete documentation of the supported syntax is available at: - http://haxe.org/doc/cross/template + http://haxe.org/manual/std-template.html **/ class Template { From 31125cf59d0cbb41b44248f89ed0fe59eb1fd6fe Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 00:59:39 +0200 Subject: [PATCH 109/209] Update Sha224.hx --- std/haxe/crypto/Sha224.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/haxe/crypto/Sha224.hx b/std/haxe/crypto/Sha224.hx index 9eae10b91ce..a3cd5aadfab 100644 --- a/std/haxe/crypto/Sha224.hx +++ b/std/haxe/crypto/Sha224.hx @@ -21,6 +21,9 @@ */ package haxe.crypto; +/** + Creates a Sha224 of a String. +*/ class Sha224 { public static function encode( s:String ) : String { From 3e9ce1c01bd21e082fcb5e967ca5d65c9759bafb Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 01:02:01 +0200 Subject: [PATCH 110/209] Update Sha1.hx --- std/haxe/crypto/Sha1.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/haxe/crypto/Sha1.hx b/std/haxe/crypto/Sha1.hx index a604afae3c6..9eb038ee2f9 100644 --- a/std/haxe/crypto/Sha1.hx +++ b/std/haxe/crypto/Sha1.hx @@ -21,6 +21,9 @@ */ package haxe.crypto; +/** + Creates a Sha1 of a String. +*/ class Sha1 { public static function encode( s:String ) : String { From 9cec290da39a6f2803c942689d7a5a8c0eefe80e Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 01:02:33 +0200 Subject: [PATCH 111/209] Update Sha256.hx --- std/haxe/crypto/Sha256.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/haxe/crypto/Sha256.hx b/std/haxe/crypto/Sha256.hx index 6cdc2307052..2a08b38646a 100644 --- a/std/haxe/crypto/Sha256.hx +++ b/std/haxe/crypto/Sha256.hx @@ -21,6 +21,9 @@ */ package haxe.crypto; +/** + Creates a Sha256 of a String. +*/ class Sha256 { public static function encode( s:String ) : String { From 0312a94a64f07a0e2bc4d1e17a552f31b78927c6 Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 01:05:38 +0200 Subject: [PATCH 112/209] Update Crc32.hx --- std/haxe/crypto/Crc32.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/std/haxe/crypto/Crc32.hx b/std/haxe/crypto/Crc32.hx index d6c0c08ca30..bb4f1176378 100644 --- a/std/haxe/crypto/Crc32.hx +++ b/std/haxe/crypto/Crc32.hx @@ -21,6 +21,9 @@ */ package haxe.crypto; +/** + Calculates the Crc32 of the given Bytes. +*/ class Crc32 { var crc : Int; @@ -78,4 +81,4 @@ class Crc32 { return crc ^ init; } -} \ No newline at end of file +} From 5d66ed352a5d81d585adfe2c2aeb755f272cb358 Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 01:06:54 +0200 Subject: [PATCH 113/209] Update Adler32.hx --- std/haxe/crypto/Adler32.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/haxe/crypto/Adler32.hx b/std/haxe/crypto/Adler32.hx index 0c77bf2a2bf..4ce234ab633 100644 --- a/std/haxe/crypto/Adler32.hx +++ b/std/haxe/crypto/Adler32.hx @@ -21,6 +21,9 @@ */ package haxe.crypto; +/** + Calculates the Adler32 of the given Bytes. +*/ class Adler32 { var a1 : Int; From 2bbfa056458c0d5cbd7e03007125c4fc5e124001 Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Fri, 3 Apr 2015 01:11:20 +0200 Subject: [PATCH 114/209] Update Hmac.hx --- std/haxe/crypto/Hmac.hx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/std/haxe/crypto/Hmac.hx b/std/haxe/crypto/Hmac.hx index 7ece8bea517..229c454422c 100644 --- a/std/haxe/crypto/Hmac.hx +++ b/std/haxe/crypto/Hmac.hx @@ -21,12 +21,18 @@ */ package haxe.crypto; +/** + Hash methods for Hmac calculation. +*/ enum HashMethod { MD5; SHA1; SHA256; } +/** + Calculates a Hmac of the given Bytes using a HasMethod. +*/ class Hmac { var method : HashMethod; @@ -82,4 +88,4 @@ class Hmac { return doHash(Ko.getBytes()); } -} \ No newline at end of file +} From a66fb549a42f6b587800d955a885a00da9908809 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 3 Apr 2015 15:38:23 +0300 Subject: [PATCH 115/209] [cs] fix parsing of sign after E in Std.parseFloat (see #4051) --- std/cs/_std/Std.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/std/cs/_std/Std.hx b/std/cs/_std/Std.hx index 0f33ece304f..86ac5301879 100644 --- a/std/cs/_std/Std.hx +++ b/std/cs/_std/Std.hx @@ -134,7 +134,7 @@ import cs.internal.Exceptions; public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); - var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasENeg = false; + var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasESign = false; var i = -1; inline function getch(i:Int):Int return cast ((untyped x : cs.system.String)[i]); @@ -163,8 +163,8 @@ import cs.internal.Exceptions; hasDot = true; case '-'.code if (!found && !hasNeg): hasNeg = true; - case '-'.code if (found && !hasENeg && hasE): - hasENeg = true; + case '-'.code | '+'.code if (found && !hasESign && hasE): + hasESign = true; case _: break; } From 8a0460bde2ab2bf17256c52e7a55dde13a39a942 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 3 Apr 2015 15:39:07 +0300 Subject: [PATCH 116/209] add a couple of tests for Std.parseFloat regarding scientific float notation (see #4051) --- tests/unit/src/unitstd/Std.unit.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/src/unitstd/Std.unit.hx b/tests/unit/src/unitstd/Std.unit.hx index 3a24849ff0f..07a1a68b61d 100644 --- a/tests/unit/src/unitstd/Std.unit.hx +++ b/tests/unit/src/unitstd/Std.unit.hx @@ -84,6 +84,10 @@ Math.isNaN(Std.parseFloat(null)) == true; Std.parseFloat("5.3 ") == 5.3; Std.parseFloat("0.0") == 0.; Std.parseFloat("5.3 1") == 5.3; +Std.parseFloat("2.426670815e+12") == 2.426670815e+12; +Std.parseFloat("2.426670815E+12") == 2.426670815e+12; +Std.parseFloat("2.426670815e-12") == 2.426670815e-12; +Std.parseFloat("2.426670815E-12") == 2.426670815e-12; // random var x = Std.random(2); From 616ac8fc53582aec724d6c84f6e886a0157e1f58 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 3 Apr 2015 15:57:20 +0300 Subject: [PATCH 117/209] [java] fix parsing of sign after E in Std.parseFloat (see #4051) --- std/java/_std/Std.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/std/java/_std/Std.hx b/std/java/_std/Std.hx index 028f3a1dc8b..bec42699bb0 100644 --- a/std/java/_std/Std.hx +++ b/std/java/_std/Std.hx @@ -138,7 +138,7 @@ import java.internal.Exceptions; public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); - var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasENeg = false; + var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasESign = false; var i = -1; inline function getch(i:Int):Int return cast (untyped x._charAt(i) : java.StdTypes.Char16); @@ -167,8 +167,8 @@ import java.internal.Exceptions; hasDot = true; case '-'.code if (!found && !hasNeg): hasNeg = true; - case '-'.code if (found && !hasENeg && hasE): - hasENeg = true; + case '-'.code | '+'.code if (found && !hasESign && hasE): + hasESign = true; case _: break; } From 2743ba1c3d7b78f07b24d0e6e65e0caa225e8c07 Mon Sep 17 00:00:00 2001 From: hughsando Date: Sat, 4 Apr 2015 16:24:21 +0800 Subject: [PATCH 118/209] [cpp] Add the cpp static link code to the haxe ditro. Use static linking and no threads for emscripten --- std/cpp/link/StaticMysql.hx | 17 +++++++++++++++++ std/cpp/link/StaticRegexp.hx | 16 ++++++++++++++++ std/cpp/link/StaticSqlite.hx | 17 +++++++++++++++++ std/cpp/link/StaticStd.hx | 17 +++++++++++++++++ std/cpp/link/StaticZlib.hx | 16 ++++++++++++++++ tests/unit/src/unit/Test.hx | 7 +++++++ tests/unit/src/unit/issues/Issue3767.hx | 2 +- 7 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 std/cpp/link/StaticMysql.hx create mode 100644 std/cpp/link/StaticRegexp.hx create mode 100644 std/cpp/link/StaticSqlite.hx create mode 100644 std/cpp/link/StaticStd.hx create mode 100644 std/cpp/link/StaticZlib.hx diff --git a/std/cpp/link/StaticMysql.hx b/std/cpp/link/StaticMysql.hx new file mode 100644 index 00000000000..75d5e4480e9 --- /dev/null +++ b/std/cpp/link/StaticMysql.hx @@ -0,0 +1,17 @@ +package cpp.link; + +@:cppFileCode( 'extern "C" int mysql_register_prims();') +@:buildXml(" + + + + +") +@:keep class StaticMysql +{ + static function __init__() + { + untyped __cpp__("mysql_register_prims();"); + } +} + diff --git a/std/cpp/link/StaticRegexp.hx b/std/cpp/link/StaticRegexp.hx new file mode 100644 index 00000000000..74a8cdfb986 --- /dev/null +++ b/std/cpp/link/StaticRegexp.hx @@ -0,0 +1,16 @@ +package cpp.link; + +@:cppFileCode( 'extern "C" int regexp_register_prims();') +@:buildXml(" + + + +") +@:keep class StaticRegexp +{ + static function __init__() + { + untyped __cpp__("regexp_register_prims();"); + } +} + diff --git a/std/cpp/link/StaticSqlite.hx b/std/cpp/link/StaticSqlite.hx new file mode 100644 index 00000000000..1e382f139d2 --- /dev/null +++ b/std/cpp/link/StaticSqlite.hx @@ -0,0 +1,17 @@ +package cpp.link; + +@:cppFileCode( 'extern "C" int sqlite_register_prims();') +@:buildXml(" + + + + +") +@:keep class StaticSqlite +{ + static function __init__() + { + untyped __cpp__("sqlite_register_prims();"); + } +} + diff --git a/std/cpp/link/StaticStd.hx b/std/cpp/link/StaticStd.hx new file mode 100644 index 00000000000..a58166d89ca --- /dev/null +++ b/std/cpp/link/StaticStd.hx @@ -0,0 +1,17 @@ +package cpp.link; + +@:cppFileCode( 'extern "C" int std_register_prims();') +@:buildXml(" + + + + +") +@:keep class StaticStd +{ + static function __init__() + { + untyped __cpp__("std_register_prims();"); + } +} + diff --git a/std/cpp/link/StaticZlib.hx b/std/cpp/link/StaticZlib.hx new file mode 100644 index 00000000000..471000a05ae --- /dev/null +++ b/std/cpp/link/StaticZlib.hx @@ -0,0 +1,16 @@ +package cpp.link; + +@:cppFileCode( 'extern "C" int zlib_register_prims();') +@:buildXml(" + + + +") +@:keep class StaticZlib +{ + static function __init__() + { + untyped __cpp__("zlib_register_prims();"); + } +} + diff --git a/tests/unit/src/unit/Test.hx b/tests/unit/src/unit/Test.hx index 348861a7906..fe85a059837 100644 --- a/tests/unit/src/unit/Test.hx +++ b/tests/unit/src/unit/Test.hx @@ -1,5 +1,12 @@ package unit; +#if (!macro && emscripten) +import cpp.link.StaticStd; +import cpp.link.StaticRegexp; +import cpp.link.StaticSqlite; +import cpp.link.StaticZlib; +#end + @:expose("unit.Test") @:keepSub #if as3 diff --git a/tests/unit/src/unit/issues/Issue3767.hx b/tests/unit/src/unit/issues/Issue3767.hx index dd1299f1c4e..5f9d55478f6 100644 --- a/tests/unit/src/unit/issues/Issue3767.hx +++ b/tests/unit/src/unit/issues/Issue3767.hx @@ -10,7 +10,7 @@ import cpp.vm.*; class Issue3767 extends Test { -#if (java || (neko && !interp && !macro) || cpp) +#if (java || (neko && !interp && !macro) || (cpp && !emscripten)) function testBasicLock() { var lock = new Lock(); From 649d16aa9c9e8eb66c79339b358c49e71a11dbd5 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sat, 4 Apr 2015 10:30:49 +0200 Subject: [PATCH 119/209] mention that types in Types.hx might change [skip-ci] --- std/haxe/macro/Type.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/std/haxe/macro/Type.hx b/std/haxe/macro/Type.hx index 69810adef6e..22cbed9735d 100644 --- a/std/haxe/macro/Type.hx +++ b/std/haxe/macro/Type.hx @@ -21,6 +21,10 @@ */ package haxe.macro; +/* + Warning: Some of these types correspond to compiler-internal data structures + and might change in minor Haxe releases in order to adapt to internal changes. +*/ typedef Ref = { public function get() : T; public function toString() : String; From b620c8d7f9ef32a00c17ff75c25d6a0a5c4ff5ca Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Sun, 5 Apr 2015 13:38:08 +0200 Subject: [PATCH 120/209] [java] reverse `must_wrap_catches` (see #4134) --- gencommon.ml | 2 ++ tests/unit/src/unit/issues/Issue4134.hx | 26 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/unit/src/unit/issues/Issue4134.hx diff --git a/gencommon.ml b/gencommon.ml index 49b4390f256..4eae69a6fb4 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -2805,6 +2805,8 @@ struct ( (v,catch_map v (run catch)) :: nowrap_catches, must_wrap_catches, catchall ) ) ([], [], None) catches in + (* temp (?) fix for https://github.com/HaxeFoundation/haxe/issues/4134 *) + let must_wrap_catches = List.rev must_wrap_catches in (* 1st catch all nowrap "the easy way" 2nd see if there are any must_wrap or catchall. If there is, diff --git a/tests/unit/src/unit/issues/Issue4134.hx b/tests/unit/src/unit/issues/Issue4134.hx new file mode 100644 index 00000000000..19a46fc8dd1 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4134.hx @@ -0,0 +1,26 @@ +package unit.issues; + +private class A { + public function new() { } +} + +private class B extends A { } + +class Issue4134 extends Test { + function test() { + eq("first", throwSomething(new B())); + eq("second", throwSomething(new A())); + } + + function throwSomething(a:A) { + try { + throw a; + } + catch(b:B) { + return "first"; + } + catch(a:A) { + return "second"; + } + } +} \ No newline at end of file From 89914ed36554603b84722550f080d14e20653e34 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Sun, 5 Apr 2015 14:43:13 +0300 Subject: [PATCH 121/209] [cpp] minor indenting fix --- gencpp.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index fea108048db..9d64d79cbf8 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -4151,15 +4151,15 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_h ("\t\t//~" ^ class_name ^ "();\n\n"); output_h ("\t\tHX_DO_RTTI_ALL;\n"); if (has_get_member_field class_def) then - output_h ("Dynamic __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n"); + output_h ("\t\tDynamic __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n"); if (has_get_static_field class_def) then - output_h ("static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n"); + output_h ("\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n"); if (has_set_member_field class_def) then - output_h ("Dynamic __SetField(const ::String &inString,const Dynamic &inValue, hx::PropertyAccess inCallProp);\n"); + output_h ("\t\tDynamic __SetField(const ::String &inString,const Dynamic &inValue, hx::PropertyAccess inCallProp);\n"); if (has_set_static_field class_def) then - output_h ("static bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n"); + output_h ("\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n"); if (has_get_fields class_def) then - output_h ("void __GetFields(Array< ::String> &outFields);\n"); + output_h ("\t\tvoid __GetFields(Array< ::String> &outFields);\n"); if (field_integer_dynamic) then output_h "\t\tDynamic __IField(int inFieldID);\n"; if (field_integer_numeric) then output_h "\t\tdouble __INumField(int inFieldID);\n"; From c8b3cc1067490f86ca517392c4b24025c49ec07b Mon Sep 17 00:00:00 2001 From: hughsando Date: Sun, 5 Apr 2015 22:27:36 +0800 Subject: [PATCH 122/209] [cpp] Add Map specializations for Int64 and Pointer values. Closes #4130 --- std/cpp/_std/haxe/ds/IntMap.hx | 5 ++ std/cpp/_std/haxe/ds/ObjectMap.hx | 7 +++ std/cpp/_std/haxe/ds/StringMap.hx | 5 ++ std/cpp/_std/haxe/ds/WeakMap.hx | 5 ++ tests/unit/src/unit/issues/Issue4130.hx | 71 +++++++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 tests/unit/src/unit/issues/Issue4130.hx diff --git a/std/cpp/_std/haxe/ds/IntMap.hx b/std/cpp/_std/haxe/ds/IntMap.hx index e9ebcd9717d..fee281e1a9d 100644 --- a/std/cpp/_std/haxe/ds/IntMap.hx +++ b/std/cpp/_std/haxe/ds/IntMap.hx @@ -35,6 +35,11 @@ package haxe.ds; inline void set(int key, double value) { __int_hash_set_float(h,key,value); } inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); } + template + inline void set(int key, const ::cpp::Struct &value) {__int_hash_set(h,key,value); } + template + inline void set(int key, const ::cpp::Pointer &value) {__int_hash_set(h,key,(Dynamic)value ); } + template inline Void set(Dynamic &key, const VALUE &value) { set( (int)key, value ); return null(); } ") diff --git a/std/cpp/_std/haxe/ds/ObjectMap.hx b/std/cpp/_std/haxe/ds/ObjectMap.hx index df4b2f64356..81772a18fdb 100644 --- a/std/cpp/_std/haxe/ds/ObjectMap.hx +++ b/std/cpp/_std/haxe/ds/ObjectMap.hx @@ -34,6 +34,13 @@ package haxe.ds; inline void set(Dynamic key, float value) { __object_hash_set_float(h,key,value); } inline void set(Dynamic key, double value) { __object_hash_set_float(h,key,value); } inline void set(Dynamic key, ::String value) { __object_hash_set_string(h,key,value); } + + + template + inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value); } + template + inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value ); } + ") @:coreApi class ObjectMap implements haxe.Constraints.IMap { diff --git a/std/cpp/_std/haxe/ds/StringMap.hx b/std/cpp/_std/haxe/ds/StringMap.hx index a80650c677a..43539ec129c 100644 --- a/std/cpp/_std/haxe/ds/StringMap.hx +++ b/std/cpp/_std/haxe/ds/StringMap.hx @@ -35,6 +35,11 @@ package haxe.ds; inline void set(String key, double value) { __string_hash_set_float(h,key,value); } inline void set(String key, ::String value) { __string_hash_set_string(h,key,value); } + template + inline void set(String key, const ::cpp::Struct &value) {__string_hash_set(h,key,value); } + template + inline void set(String key, const ::cpp::Pointer &value) {__string_hash_set(h,key,(Dynamic)value ); } + template inline Void set(Dynamic &key, const VALUE &value) { set( (String)key, value ); return null(); } ") diff --git a/std/cpp/_std/haxe/ds/WeakMap.hx b/std/cpp/_std/haxe/ds/WeakMap.hx index ba9af9815f4..9ddaff54603 100644 --- a/std/cpp/_std/haxe/ds/WeakMap.hx +++ b/std/cpp/_std/haxe/ds/WeakMap.hx @@ -34,6 +34,11 @@ package haxe.ds; inline void set(Dynamic key, float value) { __object_hash_set_float(h,key,value,true); } inline void set(Dynamic key, double value) { __object_hash_set_float(h,key,value,true); } inline void set(Dynamic key, ::String value) { __object_hash_set_string(h,key,value,true); } + + template + inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value,true); } + template + inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value,true ); } ") @:coreApi class WeakMap implements haxe.Constraints.IMap { diff --git a/tests/unit/src/unit/issues/Issue4130.hx b/tests/unit/src/unit/issues/Issue4130.hx new file mode 100644 index 00000000000..013b1be7f26 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4130.hx @@ -0,0 +1,71 @@ +package unit.issues; + +import haxe.Int64; + +private class TestKey +{ + public function new() { } +} + +class Issue4130 extends Test +{ + #if cpp + public function test() + { + var a = [1]; + + var val64 = Int64.make(42,24); + var valPtr = cpp.Pointer.arrayElem(a,0); + + var int2Int64 = new haxe.ds.IntMap(); + int2Int64.set( 42, val64); + var key:Dynamic = 43; + int2Int64.set( key, val64); + eq(int2Int64.get(42),val64); + eq(int2Int64.get(43),val64); + + + var int2Ptr = new haxe.ds.IntMap< cpp.Pointer >(); + int2Ptr.set( 42, valPtr ); + int2Ptr.set( key, valPtr ); + eq( int2Ptr.get(42), valPtr); + eq( int2Ptr.get(key), valPtr); + + + var string2Int64 = new haxe.ds.StringMap(); + string2Int64.set( "42", val64 ); + var key:Dynamic = "43"; + string2Int64.set( "43", val64 ); + eq( string2Int64.get("42"), val64 ); + eq( string2Int64.get(key), val64 ); + + var string2Ptr = new haxe.ds.StringMap< cpp.Pointer >(); + string2Ptr.set( "42", valPtr ); + string2Ptr.set( key, valPtr ); + eq( string2Ptr.get("42"), valPtr ); + eq( string2Ptr.get(key), valPtr ); + + + var key = new TestKey(); + var obj2Int64 = new haxe.ds.ObjectMap(); + obj2Int64.set( key, val64); + eq( obj2Int64.get(key), val64 ); + + var obj2Ptr = new haxe.ds.ObjectMap >(); + obj2Ptr.set( key, valPtr ); + eq( obj2Ptr.get(key), valPtr ); + + + var weak2Int64 = new haxe.ds.WeakMap(); + weak2Int64.set( key, val64); + eq( weak2Int64.get(key),val64 ); + + var weak2Ptr = new haxe.ds.WeakMap >(); + weak2Ptr.set( key, valPtr ); + eq( weak2Ptr.get(key), valPtr ); + + } + #end +} + + From cb8852dfe9816f044d2249debac61292a438df23 Mon Sep 17 00:00:00 2001 From: hughsando Date: Sun, 5 Apr 2015 23:57:34 +0800 Subject: [PATCH 123/209] [cpp] Don't do pointer tests on cppia. --- tests/unit/src/unit/issues/Issue4130.hx | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/unit/src/unit/issues/Issue4130.hx b/tests/unit/src/unit/issues/Issue4130.hx index 013b1be7f26..e0871747b24 100644 --- a/tests/unit/src/unit/issues/Issue4130.hx +++ b/tests/unit/src/unit/issues/Issue4130.hx @@ -12,10 +12,7 @@ class Issue4130 extends Test #if cpp public function test() { - var a = [1]; - var val64 = Int64.make(42,24); - var valPtr = cpp.Pointer.arrayElem(a,0); var int2Int64 = new haxe.ds.IntMap(); int2Int64.set( 42, val64); @@ -25,13 +22,6 @@ class Issue4130 extends Test eq(int2Int64.get(43),val64); - var int2Ptr = new haxe.ds.IntMap< cpp.Pointer >(); - int2Ptr.set( 42, valPtr ); - int2Ptr.set( key, valPtr ); - eq( int2Ptr.get(42), valPtr); - eq( int2Ptr.get(key), valPtr); - - var string2Int64 = new haxe.ds.StringMap(); string2Int64.set( "42", val64 ); var key:Dynamic = "43"; @@ -39,31 +29,40 @@ class Issue4130 extends Test eq( string2Int64.get("42"), val64 ); eq( string2Int64.get(key), val64 ); - var string2Ptr = new haxe.ds.StringMap< cpp.Pointer >(); - string2Ptr.set( "42", valPtr ); - string2Ptr.set( key, valPtr ); - eq( string2Ptr.get("42"), valPtr ); - eq( string2Ptr.get(key), valPtr ); - var key = new TestKey(); var obj2Int64 = new haxe.ds.ObjectMap(); obj2Int64.set( key, val64); eq( obj2Int64.get(key), val64 ); - var obj2Ptr = new haxe.ds.ObjectMap >(); - obj2Ptr.set( key, valPtr ); - eq( obj2Ptr.get(key), valPtr ); - - var weak2Int64 = new haxe.ds.WeakMap(); weak2Int64.set( key, val64); eq( weak2Int64.get(key),val64 ); + #if !cppia + var a = [1]; + var valPtr = cpp.Pointer.arrayElem(a,0); + + var int2Ptr = new haxe.ds.IntMap< cpp.Pointer >(); + int2Ptr.set( 42, valPtr ); + int2Ptr.set( key, valPtr ); + eq( int2Ptr.get(42), valPtr); + eq( int2Ptr.get(key), valPtr); + + var string2Ptr = new haxe.ds.StringMap< cpp.Pointer >(); + string2Ptr.set( "42", valPtr ); + string2Ptr.set( key, valPtr ); + eq( string2Ptr.get("42"), valPtr ); + eq( string2Ptr.get(key), valPtr ); + + var obj2Ptr = new haxe.ds.ObjectMap >(); + obj2Ptr.set( key, valPtr ); + eq( obj2Ptr.get(key), valPtr ); + var weak2Ptr = new haxe.ds.WeakMap >(); weak2Ptr.set( key, valPtr ); eq( weak2Ptr.get(key), valPtr ); - + #end } #end } From a193f1fc8cf702a87565603aa7684c66325edf85 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 6 Apr 2015 01:03:24 +0800 Subject: [PATCH 124/209] Fix test --- tests/unit/src/unit/issues/Issue4130.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/src/unit/issues/Issue4130.hx b/tests/unit/src/unit/issues/Issue4130.hx index e0871747b24..9c3b4f99f22 100644 --- a/tests/unit/src/unit/issues/Issue4130.hx +++ b/tests/unit/src/unit/issues/Issue4130.hx @@ -45,16 +45,19 @@ class Issue4130 extends Test var int2Ptr = new haxe.ds.IntMap< cpp.Pointer >(); int2Ptr.set( 42, valPtr ); + var key:Dynamic = 42; int2Ptr.set( key, valPtr ); eq( int2Ptr.get(42), valPtr); eq( int2Ptr.get(key), valPtr); var string2Ptr = new haxe.ds.StringMap< cpp.Pointer >(); string2Ptr.set( "42", valPtr ); + var key:Dynamic = "42"; string2Ptr.set( key, valPtr ); eq( string2Ptr.get("42"), valPtr ); eq( string2Ptr.get(key), valPtr ); + var key = new TestKey(); var obj2Ptr = new haxe.ds.ObjectMap >(); obj2Ptr.set( key, valPtr ); eq( obj2Ptr.get(key), valPtr ); From 84850fd6ab0fbd81d8c50816714e0d572c4f51cb Mon Sep 17 00:00:00 2001 From: Hugh Date: Mon, 6 Apr 2015 14:45:28 +0800 Subject: [PATCH 125/209] [cpp] Add special cases for cpp.Functions as Map values --- std/cpp/_std/haxe/ds/IntMap.hx | 2 ++ std/cpp/_std/haxe/ds/ObjectMap.hx | 2 ++ std/cpp/_std/haxe/ds/StringMap.hx | 2 ++ std/cpp/_std/haxe/ds/WeakMap.hx | 2 ++ tests/unit/src/unit/issues/Issue4130.hx | 29 +++++++++++++++++++++++++ 5 files changed, 37 insertions(+) diff --git a/std/cpp/_std/haxe/ds/IntMap.hx b/std/cpp/_std/haxe/ds/IntMap.hx index fee281e1a9d..b2b2a9893a7 100644 --- a/std/cpp/_std/haxe/ds/IntMap.hx +++ b/std/cpp/_std/haxe/ds/IntMap.hx @@ -37,6 +37,8 @@ package haxe.ds; template inline void set(int key, const ::cpp::Struct &value) {__int_hash_set(h,key,value); } + template + inline void set(int key, const ::cpp::Function &value) {__int_hash_set(h,key,value); } template inline void set(int key, const ::cpp::Pointer &value) {__int_hash_set(h,key,(Dynamic)value ); } diff --git a/std/cpp/_std/haxe/ds/ObjectMap.hx b/std/cpp/_std/haxe/ds/ObjectMap.hx index 81772a18fdb..6a454ce6136 100644 --- a/std/cpp/_std/haxe/ds/ObjectMap.hx +++ b/std/cpp/_std/haxe/ds/ObjectMap.hx @@ -39,6 +39,8 @@ package haxe.ds; template inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value); } template + inline void set(Dynamic key, const ::cpp::Function &value) {__object_hash_set(h,key,(Dynamic)value ); } + template inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value ); } ") diff --git a/std/cpp/_std/haxe/ds/StringMap.hx b/std/cpp/_std/haxe/ds/StringMap.hx index 43539ec129c..37d01b41947 100644 --- a/std/cpp/_std/haxe/ds/StringMap.hx +++ b/std/cpp/_std/haxe/ds/StringMap.hx @@ -38,6 +38,8 @@ package haxe.ds; template inline void set(String key, const ::cpp::Struct &value) {__string_hash_set(h,key,value); } template + inline void set(String key, const ::cpp::Function &value) {__string_hash_set(h,key,(Dynamic)value ); } + template inline void set(String key, const ::cpp::Pointer &value) {__string_hash_set(h,key,(Dynamic)value ); } template diff --git a/std/cpp/_std/haxe/ds/WeakMap.hx b/std/cpp/_std/haxe/ds/WeakMap.hx index 9ddaff54603..ac0df37e8fb 100644 --- a/std/cpp/_std/haxe/ds/WeakMap.hx +++ b/std/cpp/_std/haxe/ds/WeakMap.hx @@ -39,6 +39,8 @@ package haxe.ds; inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value,true); } template inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value,true ); } + template + inline void set(Dynamic key, const ::cpp::Function &value) {__object_hash_set(h,key,(Dynamic)value,true ); } ") @:coreApi class WeakMap implements haxe.Constraints.IMap { diff --git a/tests/unit/src/unit/issues/Issue4130.hx b/tests/unit/src/unit/issues/Issue4130.hx index 9c3b4f99f22..baa24fc4196 100644 --- a/tests/unit/src/unit/issues/Issue4130.hx +++ b/tests/unit/src/unit/issues/Issue4130.hx @@ -65,8 +65,37 @@ class Issue4130 extends Test var weak2Ptr = new haxe.ds.WeakMap >(); weak2Ptr.set( key, valPtr ); eq( weak2Ptr.get(key), valPtr ); + + // Functions + var valFunc = cpp.Callable.fromStaticFunction( someFunc ); + + var int2Func = new haxe.ds.IntMap< cpp.CallableInt> >(); + int2Func.set( 42, valFunc ); + var key:Dynamic = 42; + int2Func.set( key, valFunc ); + eq( int2Func.get(42), valFunc); + eq( int2Func.get(key), valFunc); + + var string2Func = new haxe.ds.StringMap< cpp.CallableInt> >(); + string2Func.set( "42", valFunc ); + var key:Dynamic = "42"; + string2Func.set( key, valFunc ); + eq( string2Func.get("42"), valFunc ); + eq( string2Func.get(key), valFunc ); + + var key = new TestKey(); + var obj2Func = new haxe.ds.ObjectMapInt> >(); + obj2Func.set( key, valFunc ); + eq( obj2Func.get(key), valFunc ); + + var weak2Func = new haxe.ds.WeakMapInt> >(); + weak2Func.set( key, valFunc ); + eq( weak2Func.get(key), valFunc ); + #end } + + static function someFunc(a:Int) : Int return a; #end } From 9a2cb4b13a7067dfe7e28416e728c09340f14012 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 6 Apr 2015 17:00:43 +0200 Subject: [PATCH 126/209] fix start position for invalid xml entities (closes #4139) --- std/haxe/xml/Parser.hx | 2 +- tests/unit/src/unit/TestXML.hx | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/std/haxe/xml/Parser.hx b/std/haxe/xml/Parser.hx index 59f75c06162..94607477a18 100644 --- a/std/haxe/xml/Parser.hx +++ b/std/haxe/xml/Parser.hx @@ -358,7 +358,7 @@ class Parser buf.addChar("&".code); buf.addSub(str, start, p - start); p--; - start = p; + start = p + 1; state = escapeNext; } } diff --git a/tests/unit/src/unit/TestXML.hx b/tests/unit/src/unit/TestXML.hx index 079f692a0e9..7a277a54458 100644 --- a/tests/unit/src/unit/TestXML.hx +++ b/tests/unit/src/unit/TestXML.hx @@ -216,4 +216,18 @@ class TestXML extends Test { var c = a.firstChild(); eq('event=Hit.Eject\r\n"onHit', c.get("e")); } + + function testIssue4139() { + function doXml(data:String) + { + var xml = Xml.parse(data); + var first = xml.firstElement(); + var thing = first.firstChild(); + return "blah = " + thing.get("blah"); + } + var fancyData = ''; + eq("blah = abc&def", doXml(fancyData)); + var plainData = ''; + eq("blah = abc&def", doXml(plainData)); + } } From 3640a5b631de33d26da7a56e7038840c37f99db0 Mon Sep 17 00:00:00 2001 From: Hugh Date: Tue, 7 Apr 2015 15:27:22 +0800 Subject: [PATCH 127/209] [cpp] Add accessors for manipulating NativeArray data. --- std/cpp/ConstPointer.hx | 3 ++- std/cpp/NativeArray.hx | 12 ++++++++++++ std/cpp/Pointer.hx | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/std/cpp/ConstPointer.hx b/std/cpp/ConstPointer.hx index f161d603591..45c9fd1ca62 100644 --- a/std/cpp/ConstPointer.hx +++ b/std/cpp/ConstPointer.hx @@ -20,11 +20,12 @@ extern class ConstPointer public function gt(inOther:Pointer):Bool; public function geq(inOther:Pointer):Bool; - + public static function fromRaw(ptr:RawConstPointer) : ConstPointer; public static function fromPointer(inNativePointer:Dynamic) : ConstPointer; public function reinterpret():Pointer; + public function rawCast():RawPointer; @:analyzer(no_simplification) public function at(inIndex:Int):T; diff --git a/std/cpp/NativeArray.hx b/std/cpp/NativeArray.hx index 7322831c2d3..901d9e36125 100644 --- a/std/cpp/NativeArray.hx +++ b/std/cpp/NativeArray.hx @@ -12,6 +12,18 @@ extern class NativeArray { return untyped inArray; } + public static inline function address( inArray:Array,inIndex:Int ) : Pointer { + return Pointer.arrayElem(inArray,inIndex); + } + + public static inline function setData( inArray:Array,inData:Pointer,inElementCount:Int ) : Void { + untyped inArray.setData(inData.raw,inElementCount); + } + public static inline function setUnmanagedData( inArray:Array,inData:Pointer,inElementCount:Int ) : Void { + untyped inArray.setUnmanagedData(inData.raw,inElementCount); + } + + public static inline function zero( ioDestArray:Array, ?inFirst:Int, ?inElements:Int ) : Void { untyped ioDestArray.zero(inFirst, inElements); }; diff --git a/std/cpp/Pointer.hx b/std/cpp/Pointer.hx index 3e59aca7525..de4aa7f48d3 100644 --- a/std/cpp/Pointer.hx +++ b/std/cpp/Pointer.hx @@ -13,6 +13,8 @@ extern class Pointer extends ConstPointer implements ArrayAccess public function set_ref(t:T) : T; + public static function fromRaw(ptr:RawPointer) : Pointer; + public static function fromHandle(inHandle:Dynamic,?inKind:String) : Pointer; public static function fromPointer(inNativePointer:Dynamic) : Pointer; From 900ce4569971fc448a72760a4950cb555ba15a40 Mon Sep 17 00:00:00 2001 From: hughsando Date: Tue, 7 Apr 2015 23:29:08 +0800 Subject: [PATCH 128/209] Expose pointer.ptr --- std/cpp/ConstPointer.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cpp/ConstPointer.hx b/std/cpp/ConstPointer.hx index 45c9fd1ca62..27dd222c0a5 100644 --- a/std/cpp/ConstPointer.hx +++ b/std/cpp/ConstPointer.hx @@ -6,7 +6,7 @@ extern class ConstPointer { // ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers // Use value or ref to get dereferenced value - private var ptr:T; + public var ptr:T; @:analyzer(no_simplification) public var value(get,never):T; From 903eb0badd00440ec618981392350fa2ee29ac39 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 8 Apr 2015 08:34:39 +0800 Subject: [PATCH 129/209] Let `haxe -version` output version_extra too. --- Makefile | 2 +- main.ml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7e7bdfcb686..d6545ef2365 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ else endif ifneq ($(ADD_REVISION),0) - VERSION_EXTRA="let version_extra = Some \" (git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always)) \"" + VERSION_EXTRA="let version_extra = Some \"(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always))\"" else VERSION_EXTRA="let version_extra = None" endif diff --git a/main.ml b/main.ml index b43ea8e627c..e87babe1e47 100644 --- a/main.ml +++ b/main.ml @@ -96,7 +96,7 @@ let is_debug_run() = try Sys.getenv "HAXEDEBUG" = "1" with _ -> false let s_version = - Printf.sprintf "%d.%d.%d" version_major version_minor version_revision + Printf.sprintf "%d.%d.%d%s" version_major version_minor version_revision (match Version.version_extra with None -> "" | Some v -> " " ^ v) let format msg p = if p = Ast.null_pos then @@ -978,8 +978,8 @@ and do_connect host port args = and init ctx = let usage = Printf.sprintf - "Haxe Compiler %s %s- (C)2005-2015 Haxe Foundation\n Usage : haxe%s -main [-swf|-js|-neko|-php|-cpp|-as3] [options]\n Options :" - s_version (match Version.version_extra with None -> "" | Some v -> v) (if Sys.os_type = "Win32" then ".exe" else "") + "Haxe Compiler %s - (C)2005-2015 Haxe Foundation\n Usage : haxe%s -main [-swf|-js|-neko|-php|-cpp|-as3] [options]\n Options :" + s_version (if Sys.os_type = "Win32" then ".exe" else "") in let com = ctx.com in let classes = ref [([],"Std")] in From b9f05ecdeab2aad7e93a5c61d859a97c76b8cd00 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 8 Apr 2015 09:04:38 +0800 Subject: [PATCH 130/209] [CI] make with ADD_REVISION=1 --- .travis.yml | 2 +- appveyor.yml | 2 +- tests/RunCi.hx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c272edadba0..8a6322a0797 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ install: - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew install neko --HEAD; fi script: - - make OCAMLOPT=ocamlopt.opt -s + - make OCAMLOPT=ocamlopt.opt ADD_REVISION=1 -s - make tools -s - sudo make install -s - cd tests/ diff --git a/appveyor.yml b/appveyor.yml index d3e45fc2191..7db4bbb95c0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -46,7 +46,7 @@ install: build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt ADD_REVISION=1"' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 73d69bccfc7..53a40a38751 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -548,14 +548,14 @@ class RunCi { //pass case TravisCI: changeDirectory(repoDir); - runCommand("make", ["BYTECODE=1", "OCAMLOPT=ocamlopt.opt", "-s"]); + runCommand("make", ["BYTECODE=1", "OCAMLOPT=ocamlopt.opt", "ADD_REVISION=1", "-s"]); runCommand("sudo", ["make", "install", "-s"]); changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); case AppVeyor: // save time... // changeDirectory(repoDir); - // runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt BYTECODE=1']); + // runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt ADD_REVISION=1 BYTECODE=1']); // changeDirectory(unitDir); // runCommand("haxe", ["compile-macro.hxml"]); } From 0a005296ff8f5ec1b994b6dbfc64f4c269fa1851 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 8 Apr 2015 09:11:44 +0800 Subject: [PATCH 131/209] [CI] Explicitly compile cpp test for m32 and m64. We were not actually testing m32 build on TravisCI since hxcpp builds m64 for 64bit Linux... --- tests/RunCi.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RunCi.hx b/tests/RunCi.hx index 53a40a38751..ae7c7a3a5b1 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -601,7 +601,7 @@ class RunCi { } case Cpp: getCppDependencies(); - runCommand("haxe", ["compile-cpp.hxml"]); + runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M32"]); runCpp("bin/cpp/Test-debug", []); switch (ci) { From 4d67266fb6e94fc29644f314091c1520b8d95278 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 8 Apr 2015 11:14:43 +0800 Subject: [PATCH 132/209] Use `git rev-parse --short HEAD` to get commit sha. On windows using cygwin, `git describe --always` gives me `v3.1.0-2983-g903eb0b`. According to the man page, "git-describe - Show the most recent tag that is reachable from a commit". I'm not sure why `git describe` is able to show commit sha on mac and linux... --- Makefile | 2 +- Makefile.win | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d6545ef2365..8a789d9273e 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ else endif ifneq ($(ADD_REVISION),0) - VERSION_EXTRA="let version_extra = Some \"(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always))\"" + VERSION_EXTRA="let version_extra = Some \"(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git rev-parse --short HEAD))\"" else VERSION_EXTRA="let version_extra = None" endif diff --git a/Makefile.win b/Makefile.win index 76ab47a1b61..49cd6481320 100644 --- a/Makefile.win +++ b/Makefile.win @@ -5,12 +5,6 @@ EXTENSION=.exe OCAMLOPT=ocamlopt.opt -ifneq ($(ADD_REVISION),0) - VERSION_EXTRA=let version_extra = Some " (git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always)) " -else - VERSION_EXTRA=let version_extra = None -endif - kill: -@taskkill /F /IM haxe.exe From fb11e54e3e85062c08e9fd8c7aa286781497f12b Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 8 Apr 2015 11:19:03 +0800 Subject: [PATCH 133/209] Don't use ADD_REVISION=1 for AppVeyor for now. See https://github.com/andyli/haxe/commit/4d67266fb6e94fc29644f314091c1520b8d95278 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7db4bbb95c0..d3e45fc2191 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -46,7 +46,7 @@ install: build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt ADD_REVISION=1"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" From 4f8f6a99ddf810ea045492cdd6d40c55abc03e15 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Wed, 8 Apr 2015 10:46:56 +0200 Subject: [PATCH 134/209] revert Makefile.win changes (cannot compile locally anymore) --- Makefile.win | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.win b/Makefile.win index 49cd6481320..76ab47a1b61 100644 --- a/Makefile.win +++ b/Makefile.win @@ -5,6 +5,12 @@ EXTENSION=.exe OCAMLOPT=ocamlopt.opt +ifneq ($(ADD_REVISION),0) + VERSION_EXTRA=let version_extra = Some " (git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always)) " +else + VERSION_EXTRA=let version_extra = None +endif + kill: -@taskkill /F /IM haxe.exe From 3194502a0009605502f4f63573bd5297a17b97fb Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Wed, 8 Apr 2015 14:02:52 +0200 Subject: [PATCH 135/209] keep __compare (close #4141) --- std/neko/vm/Thread.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/neko/vm/Thread.hx b/std/neko/vm/Thread.hx index e63ce6f8010..a877c85a3c3 100644 --- a/std/neko/vm/Thread.hx +++ b/std/neko/vm/Thread.hx @@ -63,7 +63,7 @@ class Thread { return thread_read_message(block); } - function __compare(t) { + @:keep function __compare(t) { return untyped __dollar__compare(handle,t.handle); } From 4a9dd2cda41f3f917d1464286a691d814230f1f9 Mon Sep 17 00:00:00 2001 From: hughsando Date: Wed, 8 Apr 2015 22:06:06 +0800 Subject: [PATCH 136/209] [cpp] Use ArrayBase instead of Dynamic where possible --- gencpp.ml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index 9d64d79cbf8..4a0350b18b1 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -612,7 +612,8 @@ let rec class_string klass suffix params remap = let join_class_path_remap = if remap then join_class_path_remap else join_class_path in (match klass.cl_path with (* Array class *) - | ([],"Array") when is_dynamic_array_param (List.hd params) -> "Dynamic" + | ([],"Array") when is_dynamic_array_param (List.hd params) -> + "cpp::ArrayBase" ^ suffix (* "Dynamic" *) | ([],"Array") -> (snd klass.cl_path) ^ suffix ^ "< " ^ (String.concat "," (List.map array_element_type params) ) ^ " >" (* FastIterator class *) @@ -1883,7 +1884,7 @@ and gen_expression ctx retval expression = | x when is_interface_type x -> () | TInst (klass,[element]) -> let name = type_string element in - if ( is_object name ) then + if ( is_object name && not (is_interface_type element) ) then gen_array_cast ".StaticCast" "Array" "()" else gen_array_cast ".StaticCast" (type_string array_type) "()" @@ -1936,6 +1937,13 @@ and gen_expression ctx retval expression = output ( "." ^ remap_name ) else begin cast_if_required ctx field_object (type_string field_object.etype); + let remap_name = if (type_string field_object.etype)="cpp::ArrayBase" then + match remap_name with + | "length" -> remap_name + | _ -> "__" ^ remap_name + else + remap_name + in output ( "->" ^ remap_name ); if (calling && (is_array field_object.etype) && remap_name="iterator" ) then check_array_element_cast field_object.etype "Fast" ""; @@ -2027,7 +2035,7 @@ and gen_expression ctx retval expression = let cpp_type = member_type ctx obj field.cf_name in (not (is_scalar cpp_type)) && ( let fixed = (cpp_type<>"?") && (expr_type<>"Dynamic") && (cpp_type<>"Dynamic") && - (cpp_type<>expr_type) && (expr_type<>"Void") in + (cpp_type<>expr_type) && (expr_type<>"Void") && (cpp_type<>"cpp::ArrayBase") in if (fixed && (ctx.ctx_debug_level>1) ) then begin output ("/* " ^ (cpp_type) ^ " != " ^ expr_type ^ " -> cast */"); end; @@ -2075,7 +2083,7 @@ and gen_expression ctx retval expression = end; if (cast_result) then output (")"); if ( (is_variable func) && (not (is_cpp_function_member func) ) && - (expr_type<>"Dynamic") && (not is_super) && (not is_block_call)) then + (expr_type<>"Dynamic" && expr_type<>"cpp::ArrayBase" ) && (not is_super) && (not is_block_call)) then ctx.ctx_output (".Cast< " ^ expr_type ^ " >()" ); let rec cast_array_output func = @@ -2157,7 +2165,7 @@ and gen_expression ctx retval expression = | TLocal v -> output (keyword_remap v.v_name); | TArray (array_expr,_) when (is_null array_expr) -> output "Dynamic()" | TArray (array_expr,index) -> - let dynamic = is_dynamic_in_cpp ctx array_expr in + let dynamic = is_dynamic_in_cpp ctx array_expr || (type_string array_expr.etype) = "cpp::ArrayBase" in if ( assigning && (not dynamic) ) then begin if (is_array_implementer array_expr.etype) then begin output "hx::__ArrayImplRef("; From 0a903c6791706148751a074da7fa6ae2184dea1f Mon Sep 17 00:00:00 2001 From: hughsando Date: Wed, 8 Apr 2015 22:13:25 +0800 Subject: [PATCH 137/209] [cpp] keep Thread.__compare. Closes 4141 --- std/cpp/vm/Thread.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/cpp/vm/Thread.hx b/std/cpp/vm/Thread.hx index 348c57cefba..db7fec68e32 100644 --- a/std/cpp/vm/Thread.hx +++ b/std/cpp/vm/Thread.hx @@ -62,7 +62,7 @@ class Thread { return untyped __global__.__hxcpp_thread_read_message(block); } - function __compare(t) : Int { + @:keep function __compare(t) : Int { return handle == t.handle ? 0 : 1; } From c829fa1bcbc9e2a582004f78f0f4720a7c5cd49a Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Wed, 8 Apr 2015 21:57:57 +0200 Subject: [PATCH 138/209] added test for #4142 --- tests/unit/src/unitstd/haxe/io/UInt8Array.unit.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/src/unitstd/haxe/io/UInt8Array.unit.hx b/tests/unit/src/unitstd/haxe/io/UInt8Array.unit.hx index a179f48bf21..2a5cf560db7 100644 --- a/tests/unit/src/unitstd/haxe/io/UInt8Array.unit.hx +++ b/tests/unit/src/unitstd/haxe/io/UInt8Array.unit.hx @@ -79,3 +79,9 @@ for( i in 0...3 ) b3[0] = b3[0] + 1; if( !emulated ) b3[0] == b[2]; +var bytes = haxe.io.Bytes.alloc(50); +var b4 = haxe.io.UInt8Array.fromBytes(bytes); +b4.length == 50; +b4.set(0,55); +b4.get(0) == 55; +if( !emulated ) bytes.get(0) == 55; From 4c1e83c64fc6798d54a84f9f8e41d5829c4c55e3 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Thu, 9 Apr 2015 08:43:00 +0200 Subject: [PATCH 139/209] typed arrays fixes for nodeJS (does not respect spec wrt optional length) close #4142 --- std/js/_std/haxe/io/Float32Array.hx | 1 + std/js/_std/haxe/io/Float64Array.hx | 1 + std/js/_std/haxe/io/Int32Array.hx | 1 + std/js/_std/haxe/io/UInt16Array.hx | 1 + std/js/_std/haxe/io/UInt32Array.hx | 1 + std/js/_std/haxe/io/UInt8Array.hx | 1 + 6 files changed, 6 insertions(+) diff --git a/std/js/_std/haxe/io/Float32Array.hx b/std/js/_std/haxe/io/Float32Array.hx index faa4e01cd11..aaf256bb87c 100644 --- a/std/js/_std/haxe/io/Float32Array.hx +++ b/std/js/_std/haxe/io/Float32Array.hx @@ -80,6 +80,7 @@ abstract Float32Array(Float32ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Float32Array { + if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new Float32ArrayData(bytes.getData(), bytePos, length)); } } diff --git a/std/js/_std/haxe/io/Float64Array.hx b/std/js/_std/haxe/io/Float64Array.hx index 2e5fa912e08..a4a8c1a0c24 100644 --- a/std/js/_std/haxe/io/Float64Array.hx +++ b/std/js/_std/haxe/io/Float64Array.hx @@ -80,6 +80,7 @@ abstract Float64Array(Float64ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Float64Array { + if( length == null ) length = (bytes.length - bytePos) >> 3; return fromData(new Float64ArrayData(bytes.getData(), bytePos, length)); } } diff --git a/std/js/_std/haxe/io/Int32Array.hx b/std/js/_std/haxe/io/Int32Array.hx index 8a77d64675b..a705bdd8429 100644 --- a/std/js/_std/haxe/io/Int32Array.hx +++ b/std/js/_std/haxe/io/Int32Array.hx @@ -78,6 +78,7 @@ abstract Int32Array(Int32ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Int32Array { + if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new Int32ArrayData(bytes.getData(), bytePos, length)); } diff --git a/std/js/_std/haxe/io/UInt16Array.hx b/std/js/_std/haxe/io/UInt16Array.hx index 3ef08865431..a85c44e4984 100644 --- a/std/js/_std/haxe/io/UInt16Array.hx +++ b/std/js/_std/haxe/io/UInt16Array.hx @@ -78,6 +78,7 @@ abstract UInt16Array(UInt16ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt16Array { + if( length == null ) length = (bytes.length - bytePos) >> 1; return fromData(new UInt16ArrayData(bytes.getData(), bytePos, length)); } diff --git a/std/js/_std/haxe/io/UInt32Array.hx b/std/js/_std/haxe/io/UInt32Array.hx index e3e729a6bb3..70099a58058 100644 --- a/std/js/_std/haxe/io/UInt32Array.hx +++ b/std/js/_std/haxe/io/UInt32Array.hx @@ -78,6 +78,7 @@ abstract UInt32Array(UInt32ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt32Array { + if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new UInt32ArrayData(bytes.getData(), bytePos, length)); } diff --git a/std/js/_std/haxe/io/UInt8Array.hx b/std/js/_std/haxe/io/UInt8Array.hx index 393e648884a..93df4a360cb 100644 --- a/std/js/_std/haxe/io/UInt8Array.hx +++ b/std/js/_std/haxe/io/UInt8Array.hx @@ -78,6 +78,7 @@ abstract UInt8Array(UInt8ArrayData) { } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt8Array { + if( length == null ) length = bytes.length - bytePos; return fromData(new UInt8ArrayData(bytes.getData(), bytePos, length)); } From c4f1b4a7f045c8ab37d8e8ccf822a93e232e69b5 Mon Sep 17 00:00:00 2001 From: hughsando Date: Thu, 9 Apr 2015 23:50:25 +0800 Subject: [PATCH 140/209] treat cpp::ArrayBase as Dynamic as far as cppia is concerned --- gencpp.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index 4a0350b18b1..195b7e095ec 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -1287,7 +1287,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_ let rec is_dynamic_in_cpp ctx expr = let expr_type = type_string ( match follow expr.etype with TFun (args,ret) -> ret | _ -> expr.etype) in ctx.ctx_dbgout ( "/* idic: " ^ expr_type ^ " */" ); - if ( expr_type="Dynamic" ) then + if ( expr_type="Dynamic" || expr_type="cpp::ArrayBase") then true else begin let result = ( @@ -1365,18 +1365,18 @@ and is_dynamic_member_return_in_cpp ctx field_object field = | TTypeExpr t -> let full_name = "::" ^ (join_class_path (t_path t) "::" ) ^ "." ^ member in ctx.ctx_dbgout ("/*static:"^ full_name^"*/"); - ( try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic" ) + ( try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" ) with Not_found -> true ) | _ -> let tstr = type_string field_object.etype in (match tstr with (* Internal classes have no dynamic members *) | "::String" | "Null" | "::hx::Class" | "::Enum" | "::Math" | "::ArrayAccess" -> false - | "Dynamic" -> ctx.ctx_dbgout "/*D*/"; true + | "Dynamic" | "cpp::ArrayBase" -> ctx.ctx_dbgout "/*D*/"; true | name -> let full_name = name ^ "." ^ member in ctx.ctx_dbgout ("/*R:"^full_name^"*/"); - try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic" ) + try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" ) with Not_found -> true ) ;; @@ -4989,7 +4989,7 @@ class script_writer common_ctx ctx filename asciiOut = | "::String" -> ArrayData "String" | "int" | "Float" | "bool" | "String" | "unsigned char" -> ArrayData typeName - | "Dynamic" -> ArrayAny + | "cpp::ArrayBase" | "Dynamic" -> ArrayAny | _ when is_interface_type param -> ArrayInterface (this#typeId (script_type_string param)) | _ -> ArrayObject ) From 77c11b69fa338713870ec7120a2f707a40d9d382 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Fri, 10 Apr 2015 18:30:56 +0800 Subject: [PATCH 141/209] Fixed `make ADD_REVISION=1` across Win (cygwin / command prompt) and Unix bash. --- Makefile | 8 +------- Makefile.version_extra | 11 +++++++++++ Makefile.win | 6 ------ 3 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 Makefile.version_extra diff --git a/Makefile b/Makefile index 8a789d9273e..1503f098480 100644 --- a/Makefile +++ b/Makefile @@ -60,12 +60,6 @@ else export HAXE_STD_PATH=$(CURDIR)/std endif -ifneq ($(ADD_REVISION),0) - VERSION_EXTRA="let version_extra = Some \"(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git rev-parse --short HEAD))\"" -else - VERSION_EXTRA="let version_extra = None" -endif - all: libs haxe libs: @@ -176,7 +170,7 @@ lexer.$(MODULE_EXT): ast.$(MODULE_EXT) ast.$(MODULE_EXT): version.$(MODULE_EXT): - echo $(VERSION_EXTRA) > version.ml + $(MAKE) -f Makefile.version_extra -s ADD_REVISION=$(ADD_REVISION) > version.ml $(COMPILER) $(CFLAGS) -c version.ml # Clean diff --git a/Makefile.version_extra b/Makefile.version_extra new file mode 100644 index 00000000000..52185f04c21 --- /dev/null +++ b/Makefile.version_extra @@ -0,0 +1,11 @@ +# A hack to print the content of version.ml consistently across Windows (cygwin / command prompt) and Unix. +# The hack: http://stackoverflow.com/a/7284135/267998 +# The issue: https://github.com/HaxeFoundation/haxe/commit/4f8f6a99ddf810ea045492cdd6d40c55abc03e15#commitcomment-10660400 + +all: ; + +ifneq ($(ADD_REVISION),0) + $(info let version_extra = Some "(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git rev-parse --short HEAD))") +else + $(info let version_extra = None) +endif \ No newline at end of file diff --git a/Makefile.win b/Makefile.win index 76ab47a1b61..49cd6481320 100644 --- a/Makefile.win +++ b/Makefile.win @@ -5,12 +5,6 @@ EXTENSION=.exe OCAMLOPT=ocamlopt.opt -ifneq ($(ADD_REVISION),0) - VERSION_EXTRA=let version_extra = Some " (git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git describe --always)) " -else - VERSION_EXTRA=let version_extra = None -endif - kill: -@taskkill /F /IM haxe.exe From bb168f66a783f7060ad9bf57374c3cb7f49c6bbe Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sat, 11 Apr 2015 02:55:36 +0800 Subject: [PATCH 142/209] [AppVeyor] make ADD_REVISION=1 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d3e45fc2191..7db4bbb95c0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -46,7 +46,7 @@ install: build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt ADD_REVISION=1"' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" From ec4456534e941504b09f68a8c7d050362be75822 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sat, 11 Apr 2015 15:30:04 +0800 Subject: [PATCH 143/209] Added package_bin rule to Makefile. Save package as an artifacts on AppVeyor. --- .gitignore | 1 + Makefile | 26 ++++++++++++++++++++++++-- Makefile.version_extra | 2 +- Makefile.win | 15 +++++++++++++++ appveyor.yml | 22 ++++++++++++++-------- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 4e62178bf31..392577554e7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.a *.exe .*.swp +/out /extra/hxclasses /extra/*.swf diff --git a/Makefile b/Makefile index 1503f098480..19349ee1b2f 100644 --- a/Makefile +++ b/Makefile @@ -169,10 +169,32 @@ lexer.$(MODULE_EXT): ast.$(MODULE_EXT) ast.$(MODULE_EXT): -version.$(MODULE_EXT): - $(MAKE) -f Makefile.version_extra -s ADD_REVISION=$(ADD_REVISION) > version.ml +version_info: + $(if $(APPVEYOR),\ + $(eval BRANCH:=$(APPVEYOR_REPO_BRANCH)),\ + $(if $(TRAVIS),\ + $(eval BRANCH:=$(TRAVIS_BRANCH)),\ + $(eval BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)))) + $(eval COMMIT_SHA:=$(shell git rev-parse --short HEAD)) + $(eval COMMIT_DATE:=$(shell git show -s --format=%ci HEAD | grep -oh ....-..-..)) + $(eval PACKAGE_FILE_NAME:=haxe_$(COMMIT_DATE)_$(BRANCH)_$(COMMIT_SHA)) + +version.$(MODULE_EXT): version_info + $(MAKE) -f Makefile.version_extra -s ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > version.ml $(COMPILER) $(CFLAGS) -c version.ml +# Package + +package_bin: version_info + mkdir -p out + rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).tar.gz + # Copy the package contents to $(PACKAGE_FILE_NAME) + mkdir -p $(PACKAGE_FILE_NAME) + cp -r $(OUTPUT) haxelib$(EXTENSION) std extra/LICENSE.txt extra/CONTRIB.txt extra/CHANGES.txt $(PACKAGE_FILE_NAME) + # archive + tar -zcf out/$(PACKAGE_FILE_NAME).tar.gz $(PACKAGE_FILE_NAME) + rm -r $(PACKAGE_FILE_NAME) + # Clean clean: clean_libs clean_haxe clean_tools diff --git a/Makefile.version_extra b/Makefile.version_extra index 52185f04c21..991233b6d56 100644 --- a/Makefile.version_extra +++ b/Makefile.version_extra @@ -5,7 +5,7 @@ all: ; ifneq ($(ADD_REVISION),0) - $(info let version_extra = Some "(git build $(shell git rev-parse --abbrev-ref HEAD) @ $(shell git rev-parse --short HEAD))") + $(info let version_extra = Some "(git build $(BRANCH) @ $(COMMIT_SHA))") else $(info let version_extra = None) endif \ No newline at end of file diff --git a/Makefile.win b/Makefile.win index 49cd6481320..fe75d499c7b 100644 --- a/Makefile.win +++ b/Makefile.win @@ -33,3 +33,18 @@ ifdef FILTER CC_CMD=($(OCAMLOPT) $(CFLAGS) -c $< 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1) CC_PARSER_CMD=($(OCAMLOPT) -pp camlp4o $(CFLAGS) -c parser.ml 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1) endif + +package_bin: version_info + mkdir -p out + rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).zip temp.zip + # Copy the package contents to $(PACKAGE_FILE_NAME) + # Using poor man's cp (zip then unzip), because cp in cygwin is quite broken + mkdir -p $(PACKAGE_FILE_NAME) + 7za a -y -tzip -mx0 temp.zip $(OUTPUT) haxelib$(EXTENSION) std > log.txt || type log.txt + cd extra && 7za a -y -tzip -mx0 ../temp.zip LICENSE.txt CONTRIB.txt CHANGES.txt > log.txt || type log.txt + 7za x -y temp.zip -o$(PACKAGE_FILE_NAME) > log.txt || type log.txt + rm temp.zip + # archive + 7za a -r -tzip out/$(PACKAGE_FILE_NAME).zip $(PACKAGE_FILE_NAME) > log.txt || type log.txt + rm -r $(PACKAGE_FILE_NAME) + rm log.txt extra/log.txt \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 7db4bbb95c0..1f254fc4c5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ os: unstable #http://help.appveyor.com/discussions/suggestions/427-pre-install-c platform: - Win32 -clone_folder: C:/projects/haxe - environment: global: NEKO_ROOT: C:/projects/neko @@ -14,22 +12,25 @@ environment: CYG_ARCH: x86 CYG_ROOT: C:/cygwin CYG_SETUP: C:/cygwin/setup-x86.exe - WODI_ARCH: 32 MINGW_ARCH: i686 + WODI: wodi32 + ADD_REVISION: 1 + OCAMLOPT: ocamlopt.opt TEST: "neko,cs,java,cpp,macro" skip_tags: true install: - 'git submodule update --init --recursive' + - cinst 7zip.commandline -y # Install ocaml using wodi - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin" > log.txt || type log.txt' - - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/wodi%WODI_ARCH%.tar.xz -O /tmp/wodi%WODI_ARCH%.tar.xz" > log.txt || type log.txt' - - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf wodi%WODI_ARCH% && tar -xf wodi%WODI_ARCH%.tar.xz && bash wodi%WODI_ARCH%/install.sh" > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/%WODI%.tar.xz -O /tmp/%WODI%.tar.xz" > log.txt || type log.txt' + - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf %WODI% && tar -xf %WODI%.tar.xz && bash %WODI%/install.sh" > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip" > log.txt || type log.txt' - - 'set PATH=%PATH%;%CYG_ROOT%/opt/wodi%WODI_ARCH%/bin' + - 'set PATH=%PATH%;%CYG_ROOT%/opt/%WODI%/bin' # Install neko - cinst make -y - 'git clone --recursive https://github.com/HaxeFoundation/neko.git %NEKO_ROOT%' @@ -46,8 +47,10 @@ install: build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt ADD_REVISION=1"' - - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win tools"' + - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win package_bin"' + - dir %APPVEYOR_BUILD_FOLDER%\out - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" - haxelib setup "%HAXELIB_ROOT%" @@ -57,3 +60,6 @@ test_script: - haxe -version - haxe RunCi.hxml - neko RunCi.n + +artifacts: + - path: out/haxe_*.zip From 2debb503974f6eaabadeebadeef95aeea61ab9c8 Mon Sep 17 00:00:00 2001 From: Gama11 Date: Sat, 11 Apr 2015 23:08:04 +0200 Subject: [PATCH 144/209] Fix two minor typos --- std/IntIterator.hx | 2 +- std/cs/internal/FieldLookup.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/std/IntIterator.hx b/std/IntIterator.hx index c0e60abfe83..a97c4297c16 100644 --- a/std/IntIterator.hx +++ b/std/IntIterator.hx @@ -23,7 +23,7 @@ /** IntIterator is used for implementing interval iterations. - It is usually not used explicitly, but through it's special syntax: + It is usually not used explicitly, but through its special syntax: `min...max` While it is possible to assign an instance of IntIterator to a variable or diff --git a/std/cs/internal/FieldLookup.hx b/std/cs/internal/FieldLookup.hx index 6c3502d6ff1..9ca1580dd9f 100644 --- a/std/cs/internal/FieldLookup.hx +++ b/std/cs/internal/FieldLookup.hx @@ -132,7 +132,7 @@ package cs.internal; return fields[mid]; } } - //if not found, it's definately an error + //if not found, it's definitely an error throw "Field not found for hash " + key; } From f925d426d00bf1db17f85c5d3fa254093ebacb0c Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sun, 12 Apr 2015 14:57:44 +0800 Subject: [PATCH 145/209] [TravisCI] improve config readability --- .travis.yml | 38 +++++++++++++++++++++++++++++++------- tests/RunCi.hx | 4 ++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a6322a0797..81f58f53282 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,10 @@ os: env: global: + # make variables + - OCAMLC=ocamlc.opt + - OCAMLOPT=ocamlopt.opt + - ADD_REVISION=1 # SAUCE_USERNAME - secure: SjyKefmjUEXi0IKHGGpcbLAajU0mLHONg8aA8LoY7Q9nAkSN6Aql+fzS38Boq7w1jWn+2FOpr+4jy0l6wVd/bftsF+huFfYpFJmdh8BlKmE0K71zZAral0H1c7YxkuQpPiJCIFGXqtkvev7SWTy0z31u7kuuQeEyW27boXe5cDA= # SAUCE_ACCESS_KEY @@ -27,17 +31,37 @@ matrix: # fast_finish: true #https://github.com/travis-ci/travis-ci/issues/1696 before_script: - - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then mysql -u root -e "CREATE DATABASE haxe_test;"; fi + - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then + mysql -u root -e "CREATE DATABASE haxe_test;"; + fi install: - - if [ -z "${TRAVIS_OS_NAME}" ]; then export TRAVIS_OS_NAME=linux; fi; # for our forks that do not have mult-os enabled. - - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry sudo apt-get update -qq; travis_retry sudo apt-get install ocaml-native-compilers zlib1g-dev libgc-dev -qq; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew update; travis_retry brew install caskroom/cask/brew-cask; travis_retry brew install ocaml camlp4; fi - - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry git clone https://github.com/HaxeFoundation/neko.git ~/neko && cd ~/neko && make os=${TRAVIS_OS_NAME} -s && sudo make install -s && cd $TRAVIS_BUILD_DIR; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew install neko --HEAD; fi + # For our forks that do not have mult-os enabled... + - if [ -z "${TRAVIS_OS_NAME}" ]; then + export TRAVIS_OS_NAME=linux; + fi + # Install haxe and neko dependencies + - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then + travis_retry sudo apt-get update -qq; + travis_retry sudo apt-get install ocaml-native-compilers zlib1g-dev libgc-dev -qq; + fi + - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then + travis_retry brew update; + travis_retry brew install caskroom/cask/brew-cask; + travis_retry brew install ocaml camlp4; + fi + # Install neko + - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then + travis_retry git clone https://github.com/HaxeFoundation/neko.git ~/neko; + cd ~/neko && make os=${TRAVIS_OS_NAME} -s && sudo make install -s; + cd $TRAVIS_BUILD_DIR; + fi + - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then + travis_retry brew install neko --HEAD; + fi script: - - make OCAMLOPT=ocamlopt.opt ADD_REVISION=1 -s + - make -s - make tools -s - sudo make install -s - cd tests/ diff --git a/tests/RunCi.hx b/tests/RunCi.hx index ae7c7a3a5b1..32f866455ab 100644 --- a/tests/RunCi.hx +++ b/tests/RunCi.hx @@ -548,14 +548,14 @@ class RunCi { //pass case TravisCI: changeDirectory(repoDir); - runCommand("make", ["BYTECODE=1", "OCAMLOPT=ocamlopt.opt", "ADD_REVISION=1", "-s"]); + runCommand("make", ["BYTECODE=1", "-s"]); runCommand("sudo", ["make", "install", "-s"]); changeDirectory(unitDir); runCommand("haxe", ["compile-macro.hxml"]); case AppVeyor: // save time... // changeDirectory(repoDir); - // runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} OCAMLC=ocamlc.opt ADD_REVISION=1 BYTECODE=1']); + // runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -s -f Makefile.win BYTECODE=1']); // changeDirectory(unitDir); // runCommand("haxe", ["compile-macro.hxml"]); } From 7c35df7d9ee394a12584740d815fae444e5999e0 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Sun, 12 Apr 2015 16:08:04 +0300 Subject: [PATCH 146/209] [php] always newline before expression inside a block, because we're generating empty blocks as well since 534fd95 (closes #4149) --- genphp.ml | 4 +--- tests/unit/src/unit/issues/Issue4149.hx | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4149.hx diff --git a/genphp.ml b/genphp.ml index ab75c54d6d9..7f7e3404dbb 100644 --- a/genphp.ml +++ b/genphp.ml @@ -1309,9 +1309,7 @@ and gen_expr ctx e = end) in let remaining = ref (List.length el) in let build e = - (match e.eexpr with - | TBlock [] -> () - | _ -> newline ctx); + newline ctx; if (in_block && !remaining = 1) then begin (match e.eexpr with | TIf _ diff --git a/tests/unit/src/unit/issues/Issue4149.hx b/tests/unit/src/unit/issues/Issue4149.hx new file mode 100644 index 00000000000..983508577de --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4149.hx @@ -0,0 +1,8 @@ +package unit.issues; + +class Issue4149 extends Test { + function test() { + var a = "a"; + {}; + } +} From 0ecf280c414553c40f86abe6a16cc707a492115a Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 13 Apr 2015 10:21:06 +0200 Subject: [PATCH 147/209] adjust Compiler.keep documentation (closes #4111) --- extra/CHANGES.txt | 1 + std/haxe/macro/Compiler.hx | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index fdaa806be3d..205746b193e 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -13,6 +13,7 @@ General improvements and optimizations: + all : --macro keep no longer causes types to be included for compilation php : support interpolation in __php__ code 2015-03-15: 3.2.0-RC1 diff --git a/std/haxe/macro/Compiler.hx b/std/haxe/macro/Compiler.hx index ff054905f94..b6be64944e7 100644 --- a/std/haxe/macro/Compiler.hx +++ b/std/haxe/macro/Compiler.hx @@ -102,7 +102,7 @@ class Compiler { In order to include single modules, their paths can be listed directly on command line: `haxe ... ModuleName pack.ModuleName`. - + By default `Compiler.include` will search for modules in the directories defined with `-cp`. If you want to specify a different set of paths to search for modules, you can use the optional argument `classPath`. @@ -110,7 +110,7 @@ class Compiler { @param rec If true, recursively adds all sub-packages. @param ignore Array of module names to ignore for inclusion. @param classPaths An alternative array of paths (directory names) to use to search for modules to include. - Note that if you pass this argument, only the specified paths will be used for inclusion. + Note that if you pass this argument, only the specified paths will be used for inclusion. **/ public static function include( pack : String, ?rec = true, ?ignore : Array, ?classPaths : Array ) { var skip = if( ignore == null ) { @@ -269,8 +269,7 @@ class Compiler { } /** - Marks types or packages to be kept by DCE and includes them for - compilation. + Marks types or packages to be kept by DCE. This also extends to the sub-types of resolved modules. From df3917f2ee323cb73f846e5ac03877fb1361ee25 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 13 Apr 2015 10:59:06 +0200 Subject: [PATCH 148/209] fix printing of FClosure --- type.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type.ml b/type.ml index cb3e059b134..541c976843c 100644 --- a/type.ml +++ b/type.ml @@ -1115,7 +1115,7 @@ let rec s_expr_ast print_var_ids tabs s_type e = let sfa = match fa with | FInstance(c,tl,cf) -> tag "FInstance" ~extra_tabs:"\t" [s_type (TInst(c,tl)); cf.cf_name] | FStatic(c,cf) -> tag "FStatic" ~extra_tabs:"\t" [s_type_path c.cl_path; cf.cf_name] - | FClosure(co,cf) -> tag "FClosure" ~extra_tabs:"\t" [(match co with None -> "None" | Some (c,_) -> s_type_path c.cl_path); cf.cf_name] + | FClosure(co,cf) -> tag "FClosure" ~extra_tabs:"\t" [(match co with None -> "None" | Some (c,tl) -> s_type (TInst(c,tl))); cf.cf_name] | FAnon cf -> tag "FAnon" ~extra_tabs:"\t" [cf.cf_name] | FDynamic s -> tag "FDynamic" ~extra_tabs:"\t" [s] | FEnum(en,ef) -> tag "FEnum" ~extra_tabs:"\t" [s_type_path en.e_path; ef.ef_name] From 8044213a9d746bf0d6021995be1663f1275f78da Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 13 Apr 2015 10:59:46 +0200 Subject: [PATCH 149/209] fix FInstance/FClosure encoding (closes #4126) --- interp.ml | 21 ++++++++---- std/haxe/macro/Type.hx | 4 +-- tests/unit/src/unit/issues/Issue4126.hx | 44 +++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4126.hx diff --git a/interp.ml b/interp.ml index f966d36ce0a..492b909bce8 100644 --- a/interp.ml +++ b/interp.ml @@ -4628,12 +4628,18 @@ and encode_tfunc func = ] and encode_field_access fa = + let encode_instance c tl = + enc_obj [ + "c",encode_clref c; + "params",encode_tparams tl + ] + in let tag,pl = match fa with - | FInstance(c,_,cf) -> 0,[encode_clref c;encode_cfref cf] (* TODO: breaking change, kind of *) + | FInstance(c,tl,cf) -> 0,[encode_clref c;encode_tparams tl;encode_cfref cf] | FStatic(c,cf) -> 1,[encode_clref c;encode_cfref cf] | FAnon(cf) -> 2,[encode_cfref cf] | FDynamic(s) -> 3,[enc_string s] - | FClosure(co,cf) -> 4,[(match co with Some (c,_) -> encode_clref c | None -> VNull);encode_cfref cf] (* TODO: breaking change, kind of, too *) + | FClosure(co,cf) -> 4,[(match co with Some (c,tl) -> encode_instance c tl | None -> VNull);encode_cfref cf] | FEnum(en,ef) -> 5,[encode_enref en;encode_efield ef] in enc_enum IFieldAccess tag pl @@ -4769,15 +4775,18 @@ let decode_efield v = let decode_field_access v = match decode_enum v with - | 0, [c;cf] -> + | 0, [c;tl;cf] -> let c = decode_ref c in - FInstance(c,List.map snd c.cl_params,decode_ref cf) (* TODO: breaking change? *) + FInstance(c,List.map decode_type (dec_array tl),decode_ref cf) | 1, [c;cf] -> FStatic(decode_ref c,decode_ref cf) | 2, [cf] -> FAnon(decode_ref cf) | 3, [s] -> FDynamic(dec_string s) | 4, [co;cf] -> - let co = opt decode_ref co in - FClosure(Option.map (fun c -> c, List.map snd c.cl_params) co, decode_ref cf) (* TODO: breaking change? *) + let co = match co with + | VNull -> None + | _ -> Some (decode_ref (field co "c"),List.map decode_type (dec_array (field co "params"))) + in + FClosure(co,decode_ref cf) | 5, [e;ef] -> FEnum(decode_ref e,decode_efield ef) | _ -> raise Invalid_expr diff --git a/std/haxe/macro/Type.hx b/std/haxe/macro/Type.hx index 22cbed9735d..366fafd0268 100644 --- a/std/haxe/macro/Type.hx +++ b/std/haxe/macro/Type.hx @@ -304,11 +304,11 @@ typedef TFunc = { } enum FieldAccess { - FInstance(c:Ref, cf:Ref); + FInstance(c:Ref, params:Array, cf:Ref); FStatic(c:Ref, cf:Ref); FAnon(cf:Ref); FDynamic(s:String); - FClosure(c:Null>, cf:Ref); + FClosure(c:Null<{c:Ref, params:Array}>, cf:Ref); FEnum(e:Ref, ef:EnumField); } diff --git a/tests/unit/src/unit/issues/Issue4126.hx b/tests/unit/src/unit/issues/Issue4126.hx new file mode 100644 index 00000000000..4b72f538827 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4126.hx @@ -0,0 +1,44 @@ +package unit.issues; + +private class A { + public var v:Int; + public function new() { } + public function f() { } +} + +private typedef T = { + function f():Void; +} + +class Issue4126 extends Test { + function test() { + var a = new A(); + eq("A", getFieldAccessString(a.v)); + eq("A", getFieldAccessString(a.f)); + eq("String", getFieldAccessString("foo".length)); + eq("String", getFieldAccessString("foo".charAt)); + var t:T = null; + eq("null", getFieldAccessString(t.f)); + } + + macro static function getFieldAccessString(e) { + var et = haxe.macro.Context.typeExpr(e); + inline function shortPrint(c, tl) { + var a = haxe.macro.TypeTools.toString(TInst(c, tl)).split("."); + return a.pop(); + } + var s = switch (et.expr) { + case TField(_, FClosure(co, _)): + if (co == null) { + "null"; + } else { + shortPrint(co.c, co.params); + } + case TField(_, FInstance(c, tl, _)): + shortPrint(c, tl); + case _: + "invalid: " + haxe.macro.TypedExprTools.toString(et); + } + return macro $v{s}; + } +} \ No newline at end of file From 2bd1c23620e2bafeb8c7b115b1ddb7ba8bc66097 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 13 Apr 2015 11:46:27 +0200 Subject: [PATCH 150/209] dodge issues --- tests/optimization/src/TestBaseMacro.hx | 4 ++-- tests/unit/src/unit/issues/Issue4126.hx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/optimization/src/TestBaseMacro.hx b/tests/optimization/src/TestBaseMacro.hx index a2118a76635..68e26184885 100644 --- a/tests/optimization/src/TestBaseMacro.hx +++ b/tests/optimization/src/TestBaseMacro.hx @@ -41,7 +41,7 @@ class TestBaseMacro { static function checkExpr(e:TypedExpr) { switch (e.expr) { - case TCall({ expr: TField(_, FInstance(_, _.get() => {name: "assertEqualsConst"}))}, el): + case TCall({ expr: TField(_, FInstance(_, _, _.get() => {name: "assertEqualsConst"}))}, el): switch [el[0].expr, el[1].expr] { case [TConst(tc1), TConst(tc2)]: if (!constEquals(tc1, tc2)) { @@ -50,7 +50,7 @@ class TestBaseMacro { case [e1, e2]: Context.warning('$e2 should be $e1', e.pos); } - case TCall({ expr: TField(_, FInstance(_, _.get() => {name: "assertEquals"}))}, el): + case TCall({ expr: TField(_, FInstance(_, _, _.get() => {name: "assertEquals"}))}, el): for (e in el) { checkExpr(e); } diff --git a/tests/unit/src/unit/issues/Issue4126.hx b/tests/unit/src/unit/issues/Issue4126.hx index 4b72f538827..f2eb7fa01b9 100644 --- a/tests/unit/src/unit/issues/Issue4126.hx +++ b/tests/unit/src/unit/issues/Issue4126.hx @@ -16,7 +16,9 @@ class Issue4126 extends Test { eq("A", getFieldAccessString(a.v)); eq("A", getFieldAccessString(a.f)); eq("String", getFieldAccessString("foo".length)); + #if !python eq("String", getFieldAccessString("foo".charAt)); + #end var t:T = null; eq("null", getFieldAccessString(t.f)); } From ac89c25c9c1b6c5b3cc383a825e7fcac6542646c Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 13 Apr 2015 11:54:47 +0200 Subject: [PATCH 151/209] try something related to --run --- main.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.ml b/main.ml index e87babe1e47..5b11bc5f225 100644 --- a/main.ml +++ b/main.ml @@ -660,7 +660,7 @@ let rec process_params create pl = (* already connected : skip *) loop acc l) | "--run" :: cl :: args -> - let acc = (cl ^ ".main()") :: "--macro" :: acc in + let acc = cl :: "-main" :: "--interp" :: acc in let ctx = create (!each_params @ (List.rev acc)) in ctx.com.sys_args <- args; init ctx; From 38ead57d5f47449724836bc0303caaa4cb012e7c Mon Sep 17 00:00:00 2001 From: Andy Li Date: Mon, 13 Apr 2015 18:48:14 +0800 Subject: [PATCH 152/209] Makefile improvements. * Allow OCAMLC/OCAMLOPT/ADD_REVISION to be defined as env vars * Use TRAVIS_BRANCH only if TRAVIS_REPO_SLUG ends with /haxe, similar for Appveyor. --- Makefile | 25 ++++++++++--------------- Makefile.win | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 19349ee1b2f..e912e15a7a8 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,8 @@ INSTALL_LIB_DIR=$(INSTALL_DIR)/lib/haxe OUTPUT=haxe EXTENSION= -OCAMLOPT=ocamlopt -OCAMLC=ocamlc +OCAMLOPT?=ocamlopt +OCAMLC?=ocamlc LFLAGS= CFLAGS= -g -I libs/extlib -I libs/extc -I libs/neko -I libs/javalib -I libs/ziplib -I libs/swflib -I libs/xml-light -I libs/ttflib -I libs/ilib -I libs/objsize @@ -51,7 +51,12 @@ MODULES=ast type lexer common genxml parser typecore optimizer typeload \ codegen gencommon genas3 gencpp genjs genneko genphp \ genswf9 genswf genjava gencs genpy interp dce analyzer filters typer matcher version main -ADD_REVISION=0 +ADD_REVISION?=0 + +BRANCH=$(shell echo $$APPVEYOR_REPO_NAME | grep -q /haxe && echo $$APPVEYOR_REPO_BRANCH || echo $$TRAVIS_REPO_SLUG | grep -q /haxe && echo $$TRAVIS_BRANCH || git rev-parse --abbrev-ref HEAD) +COMMIT_SHA=$(shell git rev-parse --short HEAD) +COMMIT_DATE=$(shell git show -s --format=%ci HEAD | grep -oh ....-..-..) +PACKAGE_FILE_NAME=haxe_$(COMMIT_DATE)_$(BRANCH)_$(COMMIT_SHA) # using $(CURDIR) on Windows will not work since it might be a Cygwin path ifdef SYSTEMROOT @@ -169,23 +174,13 @@ lexer.$(MODULE_EXT): ast.$(MODULE_EXT) ast.$(MODULE_EXT): -version_info: - $(if $(APPVEYOR),\ - $(eval BRANCH:=$(APPVEYOR_REPO_BRANCH)),\ - $(if $(TRAVIS),\ - $(eval BRANCH:=$(TRAVIS_BRANCH)),\ - $(eval BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)))) - $(eval COMMIT_SHA:=$(shell git rev-parse --short HEAD)) - $(eval COMMIT_DATE:=$(shell git show -s --format=%ci HEAD | grep -oh ....-..-..)) - $(eval PACKAGE_FILE_NAME:=haxe_$(COMMIT_DATE)_$(BRANCH)_$(COMMIT_SHA)) - -version.$(MODULE_EXT): version_info +version.$(MODULE_EXT): $(MAKE) -f Makefile.version_extra -s ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > version.ml $(COMPILER) $(CFLAGS) -c version.ml # Package -package_bin: version_info +package_bin: mkdir -p out rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).tar.gz # Copy the package contents to $(PACKAGE_FILE_NAME) diff --git a/Makefile.win b/Makefile.win index fe75d499c7b..d00c42c4c88 100644 --- a/Makefile.win +++ b/Makefile.win @@ -11,6 +11,7 @@ kill: # allow Ocaml/Mingw as well NATIVE_LIBS += -I "c:/program files/mingw/lib/" +# use make WODI=wodi32 -f Makefile.win to build using WODI 32bit ifdef WODI NATIVE_LIBS += -I "/opt/${WODI}/lib" endif @@ -34,7 +35,7 @@ CC_CMD=($(OCAMLOPT) $(CFLAGS) -c $< 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exi CC_PARSER_CMD=($(OCAMLOPT) -pp camlp4o $(CFLAGS) -c parser.ml 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1) endif -package_bin: version_info +package_bin: mkdir -p out rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).zip temp.zip # Copy the package contents to $(PACKAGE_FILE_NAME) From 85ac5555655285fcacb1a146a1ab49a69e8aca90 Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Tue, 14 Apr 2015 14:27:29 +0200 Subject: [PATCH 153/209] Type in Hmac description --- std/haxe/crypto/Hmac.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/haxe/crypto/Hmac.hx b/std/haxe/crypto/Hmac.hx index 229c454422c..da60d1917d3 100644 --- a/std/haxe/crypto/Hmac.hx +++ b/std/haxe/crypto/Hmac.hx @@ -31,7 +31,7 @@ enum HashMethod { } /** - Calculates a Hmac of the given Bytes using a HasMethod. + Calculates a Hmac of the given Bytes using a HashMethod. */ class Hmac { From 7bc43d853678e8fbd8af385b1cfe148b70cba2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Tue, 14 Apr 2015 15:15:23 -0300 Subject: [PATCH 154/209] [spod] Fixed ID types equivalence (SInt -> SId); * Fixed declaration of relations in same module * Fixed invalid relation type error message * Closes #3828 --- std/sys/db/RecordInfos.hx | 1 + std/sys/db/RecordMacros.hx | 28 +++++++++++++++++++++++++--- tests/unit/src/unit/MySpodClass.hx | 11 +++++++++++ tests/unit/src/unit/TestSpod.hx | 20 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/std/sys/db/RecordInfos.hx b/std/sys/db/RecordInfos.hx index 024fa1b2a1f..002f509970d 100644 --- a/std/sys/db/RecordInfos.hx +++ b/std/sys/db/RecordInfos.hx @@ -69,6 +69,7 @@ typedef RecordRelation = { var prop : String; var key : String; var type : String; + var module : String; var cascade : Bool; var lock : Bool; var isNull : Bool; diff --git a/std/sys/db/RecordMacros.hx b/std/sys/db/RecordMacros.hx index 2f600f048a6..b8571aae926 100644 --- a/std/sys/db/RecordMacros.hx +++ b/std/sys/db/RecordMacros.hx @@ -122,8 +122,18 @@ class RecordMacros { #end } - public dynamic function resolveType( name : String ) : haxe.macro.Type { + public dynamic function resolveType( name : String, ?module : String ) : haxe.macro.Type { #if macro + if (module != null) + { + var m = Context.getModule(module); + for (t in m) + { + if (t.toString() == name) + return t; + } + } + return Context.getType(name); #else throw "not implemented"; @@ -317,10 +327,12 @@ class RecordMacros { isNull = false; var t = makeRecord(f.type); if( t == null ) error("Relation type should be a sys.db.Object", f.pos); + var mod = t.get().module; var r = { prop : f.name, key : params.shift().i, type : t.toString(), + module : mod, cascade : false, lock : false, isNull : isNull, @@ -354,6 +366,16 @@ class RecordMacros { default: fi.name == "id"; } if( isId ) { + switch(fi.t) + { + case DInt: + fi.t = DId; + case DUInt: + fi.t = DUId; + case DBigInt: + fi.t = DBigId; + case _: + } if( i.key == null ) i.key = [fi.name] else error("Multiple table id declaration", f.pos); } i.fields.push(fi); @@ -363,7 +385,7 @@ class RecordMacros { for( r in i.relations ) { var field = fields.find(function(f) return f.name == r.prop); var f = i.hfields.get(r.key); - var relatedInf = getRecordInfos(makeRecord(resolveType(r.type))); + var relatedInf = getRecordInfos(makeRecord(resolveType(r.type, r.module))); if (relatedInf.key.length > 1) error('The relation ${r.prop} is invalid: Type ${r.type} has multiple keys, which is not supported',field.pos); var relatedKey = relatedInf.key[0]; @@ -373,7 +395,7 @@ class RecordMacros { case DUId: DUInt; case DBigId: DBigInt; case t = DString(_): t; - case t: error("Unexpected id type $t for the relation. Use either SId, SInt, SUId, SUInt, SBigID, SBigInt or SString", field.pos); + case t: error('Unexpected id type $t for the relation. Use either SId, SInt, SUId, SUInt, SBigID, SBigInt or SString', field.pos); } if( f == null ) { diff --git a/tests/unit/src/unit/MySpodClass.hx b/tests/unit/src/unit/MySpodClass.hx index c1ed9e1a521..0654a2f16ba 100644 --- a/tests/unit/src/unit/MySpodClass.hx +++ b/tests/unit/src/unit/MySpodClass.hx @@ -82,3 +82,14 @@ abstract AbstractSpodTest(A) from A public var id:SId; @:relation(ref_id) public var ref:ClassWithStringId; } + + +//issue #3828 +@:keep @:skip class BaseIssueC3828 extends sys.db.Object { + public var id : SInt; + @:relation(ruid) + public var refUser : SNull; +} + +@:keep class IssueC3828 extends BaseIssueC3828 { +} diff --git a/tests/unit/src/unit/TestSpod.hx b/tests/unit/src/unit/TestSpod.hx index 45d20fa8b35..d507aae9ec2 100644 --- a/tests/unit/src/unit/TestSpod.hx +++ b/tests/unit/src/unit/TestSpod.hx @@ -24,11 +24,13 @@ class TestSpod extends Test try cnx.request('DROP TABLE NullableSpodClass') catch(e:Dynamic) {} try cnx.request('DROP TABLE ClassWithStringId') catch(e:Dynamic) {} try cnx.request('DROP TABLE ClassWithStringIdRef') catch(e:Dynamic) {} + try cnx.request('DROP TABLE IssueC3828') catch(e:Dynamic) {} TableCreate.create(MySpodClass.manager); TableCreate.create(OtherSpodClass.manager); TableCreate.create(NullableSpodClass.manager); TableCreate.create(ClassWithStringId.manager); TableCreate.create(ClassWithStringIdRef.manager); + TableCreate.create(IssueC3828.manager); } private function setManager() @@ -60,6 +62,24 @@ class TestSpod extends Test return scls; } + public function testIssue3828() + { + setManager(); + var u1 = new IssueC3828(); + u1.insert(); + var u2 = new IssueC3828(); + u2.refUser = u1; + u2.insert(); + var u1id = u1.id, u2id = u2.id; + u1 = null; u2 = null; + Manager.cleanup(); + + var u1 = IssueC3828.manager.get(u1id); + var u2 = IssueC3828.manager.search($refUser == u1).first(); + eq(u1.id, u1id); + eq(u2.id, u2id); + } + public function testStringIdRel() { setManager(); From 972cc5dfce5f76782a256b7552b07093b6a53988 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Thu, 16 Apr 2015 09:10:43 +0200 Subject: [PATCH 155/209] make some TypedExprTools methods available in non-macro context --- std/haxe/macro/TypedExprTools.hx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/std/haxe/macro/TypedExprTools.hx b/std/haxe/macro/TypedExprTools.hx index 309273667e8..0a0177c2f28 100644 --- a/std/haxe/macro/TypedExprTools.hx +++ b/std/haxe/macro/TypedExprTools.hx @@ -22,12 +22,9 @@ package haxe.macro; -import haxe.macro.Context; import haxe.macro.Type; class TypedExprTools { - #if macro - static function with(e:TypedExpr, ?edef:TypedExprDef, ?t:Type) { return { expr: edef == null ? e.expr : edef, @@ -152,8 +149,9 @@ class TypedExprTools { } } + #if macro static public function toString(t:TypedExpr, ?pretty = false):String { - return new String(Context.load("s_expr", 2)(t, pretty)); + return new String(haxe.macro.Context.load("s_expr", 2)(t, pretty)); } #end } From 407e28d00478ce38cc26948a8d91a492b2819e0c Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sun, 19 Apr 2015 20:47:25 +0800 Subject: [PATCH 156/209] update haxelib submodule to haxelib 3.2.0-rc3 --- extra/haxelib_src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/haxelib_src b/extra/haxelib_src index 0dfb33242a2..68f25d97dc9 160000 --- a/extra/haxelib_src +++ b/extra/haxelib_src @@ -1 +1 @@ -Subproject commit 0dfb33242a28d5a89178c1e48968174646e0fefe +Subproject commit 68f25d97dc991516c02a2665081ba5cc0d2ae23e From 035305cb969bddecf0342eda520fdaa107f8a715 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 20 Apr 2015 10:34:38 +0200 Subject: [PATCH 157/209] fix class path if `HAXE_STD_PATH` is set (see #4163) --- main.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.ml b/main.ml index 5b11bc5f225..3c7c1a72f2e 100644 --- a/main.ml +++ b/main.ml @@ -1017,8 +1017,8 @@ try | l -> l in - let parts = "" :: Str.split_delim (Str.regexp "[;:]") p in - com.class_path <- List.map normalize_path (loop parts) + let parts = Str.split_delim (Str.regexp "[;:]") p in + com.class_path <- "" :: List.map normalize_path (loop parts) with Not_found -> if Sys.os_type = "Unix" then From 5acd015c8999c3187ce21b0691084513985f1024 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Mon, 20 Apr 2015 11:22:36 -0400 Subject: [PATCH 158/209] Force Element and Document references to HTMLElement and HTMLDocument. Fixes #4081. --- std/js/html/Animation.hx | 2 +- std/js/html/Attr.hx | 2 +- std/js/html/CanvasRenderingContext2D.hx | 4 +-- std/js/html/CharacterData.hx | 4 +-- std/js/html/DOMElement.hx | 20 ++++++------- std/js/html/DOMImplementation.hx | 4 +-- std/js/html/DOMParser.hx | 2 +- std/js/html/DataTransfer.hx | 4 +-- std/js/html/Document.hx | 34 +++++++++++------------ std/js/html/DocumentFragment.hx | 8 +++--- std/js/html/EmbedElement.hx | 2 +- std/js/html/FrameElement.hx | 2 +- std/js/html/HTMLCollection.hx | 6 ++-- std/js/html/HTMLDocument.hx | 2 +- std/js/html/HitRegionOptions.hx | 2 +- std/js/html/IFrameElement.hx | 4 +-- std/js/html/LinkElement.hx | 2 +- std/js/html/Node.hx | 4 +-- std/js/html/ObjectElement.hx | 4 +-- std/js/html/SelectElement.hx | 4 +-- std/js/html/ShadowRoot.hx | 2 +- std/js/html/SpeechRecognitionEvent.hx | 2 +- std/js/html/SpeechRecognitionEventInit.hx | 2 +- std/js/html/Text.hx | 6 ++-- std/js/html/Window.hx | 8 +++--- std/js/html/XMLHttpRequest.hx | 4 +-- std/js/html/XSLTProcessor.hx | 4 +-- std/js/html/svg/IFrameElement.hx | 2 +- std/js/html/svg/SVGElement.hx | 2 +- 29 files changed, 74 insertions(+), 74 deletions(-) diff --git a/std/js/html/Animation.hx b/std/js/html/Animation.hx index b21d06f5c0e..bb4d871986f 100644 --- a/std/js/html/Animation.hx +++ b/std/js/html/Animation.hx @@ -28,6 +28,6 @@ package js.html; extern class Animation { var effect(default,null) : AnimationEffect; - var target(default,null) : DOMElement; + var target(default,null) : Element; } \ No newline at end of file diff --git a/std/js/html/Attr.hx b/std/js/html/Attr.hx index d7eeeb7d87b..1fe07a1c95d 100644 --- a/std/js/html/Attr.hx +++ b/std/js/html/Attr.hx @@ -30,6 +30,6 @@ extern class Attr extends Node var value : String; var name(default,null) : String; var specified(default,null) : Bool; - var ownerElement(default,null) : DOMElement; + var ownerElement(default,null) : Element; } \ No newline at end of file diff --git a/std/js/html/CanvasRenderingContext2D.hx b/std/js/html/CanvasRenderingContext2D.hx index 816452ece7d..fbfc6ebc521 100644 --- a/std/js/html/CanvasRenderingContext2D.hx +++ b/std/js/html/CanvasRenderingContext2D.hx @@ -74,8 +74,8 @@ extern class CanvasRenderingContext2D function fill( path : Path2D, ?winding : CanvasWindingRule = "nonzero" ) : Void; @:overload( function() : Void {} ) function stroke( path : Path2D ) : Void; - function drawFocusIfNeeded( element : DOMElement ) : Void; - function drawCustomFocusRing( element : DOMElement ) : Bool; + function drawFocusIfNeeded( element : Element ) : Void; + function drawCustomFocusRing( element : Element ) : Bool; @:overload( function( ?winding : CanvasWindingRule = "nonzero" ) : Void {} ) function clip( path : Path2D, ?winding : CanvasWindingRule = "nonzero" ) : Void; @:overload( function( x : Float, y : Float, ?winding : CanvasWindingRule = "nonzero" ) : Bool {} ) diff --git a/std/js/html/CharacterData.hx b/std/js/html/CharacterData.hx index cf367bb30bc..65f6df8543e 100644 --- a/std/js/html/CharacterData.hx +++ b/std/js/html/CharacterData.hx @@ -29,8 +29,8 @@ extern class CharacterData extends Node { var data : String; var length(default,null) : Int; - var previousElementSibling(default,null) : DOMElement; - var nextElementSibling(default,null) : DOMElement; + var previousElementSibling(default,null) : Element; + var nextElementSibling(default,null) : Element; /** @throws DOMError */ function substringData( offset : Int, count : Int ) : String; diff --git a/std/js/html/DOMElement.hx b/std/js/html/DOMElement.hx index 5208529c26b..bee3892a2c0 100644 --- a/std/js/html/DOMElement.hx +++ b/std/js/html/DOMElement.hx @@ -58,7 +58,7 @@ extern class DOMElement extends Node var oncut : haxe.Constraints.Function; var onpaste : haxe.Constraints.Function; var innerText : String; - var offsetParent(default,null) : DOMElement; + var offsetParent(default,null) : Element; var offsetTop(default,null) : Int; var offsetLeft(default,null) : Int; var offsetWidth(default,null) : Int; @@ -140,12 +140,12 @@ extern class DOMElement extends Node var onlostpointercapture : haxe.Constraints.Function; var onpointerlockchange : haxe.Constraints.Function; var onpointerlockerror : haxe.Constraints.Function; - var previousElementSibling(default,null) : DOMElement; - var nextElementSibling(default,null) : DOMElement; + var previousElementSibling(default,null) : Element; + var nextElementSibling(default,null) : Element; var onerror : haxe.Constraints.Function; var children(default,null) : HTMLCollection; - var firstElementChild(default,null) : DOMElement; - var lastElementChild(default,null) : DOMElement; + var firstElementChild(default,null) : Element; + var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; var ontouchstart : haxe.Constraints.Function; var ontouchend : haxe.Constraints.Function; @@ -166,7 +166,7 @@ extern class DOMElement extends Node function hasAttributeNS( namespace_ : String, localName : String ) : Bool; function hasAttributes() : Bool; /** @throws DOMError */ - function closest( selector : String ) : DOMElement; + function closest( selector : String ) : Element; /** @throws DOMError */ function matches( selector : String ) : Bool; function getElementsByTagName( localName : String ) : HTMLCollection; @@ -207,7 +207,7 @@ extern class DOMElement extends Node /** @throws DOMError */ function insertAdjacentHTML( position : String, text : String ) : Void; /** @throws DOMError */ - function querySelector( selectors : String ) : DOMElement; + function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; /** @throws DOMError */ @@ -216,9 +216,9 @@ extern class DOMElement extends Node function getAnimationPlayers() : Array; function remove() : Void; /** @throws DOMError */ - function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; + function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; } \ No newline at end of file diff --git a/std/js/html/DOMImplementation.hx b/std/js/html/DOMImplementation.hx index 5bfa11b11ff..45e98ee5107 100644 --- a/std/js/html/DOMImplementation.hx +++ b/std/js/html/DOMImplementation.hx @@ -31,7 +31,7 @@ extern class DOMImplementation /** @throws DOMError */ function createDocumentType( qualifiedName : String, publicId : String, systemId : String ) : DocumentType; /** @throws DOMError */ - function createDocument( namespace_ : String, qualifiedName : String, ?doctype : DocumentType ) : Document; + function createDocument( namespace_ : String, qualifiedName : String, ?doctype : DocumentType ) : HTMLDocument; /** @throws DOMError */ - function createHTMLDocument( ?title : String ) : Document; + function createHTMLDocument( ?title : String ) : HTMLDocument; } \ No newline at end of file diff --git a/std/js/html/DOMParser.hx b/std/js/html/DOMParser.hx index 27a08b7db15..56a81d113ee 100644 --- a/std/js/html/DOMParser.hx +++ b/std/js/html/DOMParser.hx @@ -31,5 +31,5 @@ extern class DOMParser @:overload( function() : Void {} ) function new( prin : Dynamic/*MISSING Principal*/, ?documentURI : Dynamic/*MISSING URI*/, ?baseURI : Dynamic/*MISSING URI*/ ) : Void; /** @throws DOMError */ - function parseFromString( str : String, type : SupportedType ) : Document; + function parseFromString( str : String, type : SupportedType ) : HTMLDocument; } \ No newline at end of file diff --git a/std/js/html/DataTransfer.hx b/std/js/html/DataTransfer.hx index 8eb21a6b12b..addf094c562 100644 --- a/std/js/html/DataTransfer.hx +++ b/std/js/html/DataTransfer.hx @@ -35,7 +35,7 @@ extern class DataTransfer /** @throws DOMError */ function new( eventType : String, isExternal : Bool ) : Void; /** @throws DOMError */ - function setDragImage( image : DOMElement, x : Int, y : Int ) : Void; + function setDragImage( image : Element, x : Int, y : Int ) : Void; /** @throws DOMError */ function getData( format : String ) : String; /** @throws DOMError */ @@ -43,5 +43,5 @@ extern class DataTransfer /** @throws DOMError */ function clearData( ?format : String ) : Void; /** @throws DOMError */ - function addElement( element : DOMElement ) : Void; + function addElement( element : Element ) : Void; } \ No newline at end of file diff --git a/std/js/html/Document.hx b/std/js/html/Document.hx index 1c188c2db6c..2d8af38253c 100644 --- a/std/js/html/Document.hx +++ b/std/js/html/Document.hx @@ -34,10 +34,10 @@ extern class Document extends Node var characterSet(default,null) : String; var contentType(default,null) : String; var doctype(default,null) : DocumentType; - var documentElement(default,null) : DOMElement; + var documentElement(default,null) : Element; var inputEncoding(default,null) : String; var fullscreenEnabled(default,null) : Bool; - var fullscreenElement(default,null) : DOMElement; + var fullscreenElement(default,null) : Element; var onfullscreenchange : haxe.Constraints.Function; var onfullscreenerror : haxe.Constraints.Function; var location(default,null) : Location; @@ -47,7 +47,7 @@ extern class Document extends Node var title : String; var dir : String; var defaultView(default,null) : Window; - var activeElement(default,null) : DOMElement; + var activeElement(default,null) : Element; var onreadystatechange : haxe.Constraints.Function; var onwheel : haxe.Constraints.Function; var oncopy : haxe.Constraints.Function; @@ -55,8 +55,8 @@ extern class Document extends Node var onpaste : haxe.Constraints.Function; var onbeforescriptexecute : haxe.Constraints.Function; var onafterscriptexecute : haxe.Constraints.Function; - var currentScript(default,null) : DOMElement; - var pointerLockElement(default,null) : DOMElement; + var currentScript(default,null) : Element; + var pointerLockElement(default,null) : Element; var hidden(default,null) : Bool; var visibilityState(default,null) : VisibilityState; var styleSheets(default,null) : StyleSheetList; @@ -132,8 +132,8 @@ extern class Document extends Node var onpointerlockerror : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; var children(default,null) : HTMLCollection; - var firstElementChild(default,null) : DOMElement; - var lastElementChild(default,null) : DOMElement; + var firstElementChild(default,null) : Element; + var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; var ontouchstart : haxe.Constraints.Function; var ontouchend : haxe.Constraints.Function; @@ -146,13 +146,13 @@ extern class Document extends Node /** @throws DOMError */ function getElementsByTagNameNS( namespace_ : String, localName : String ) : HTMLCollection; function getElementsByClassName( classNames : String ) : HTMLCollection; - function getElementById( elementId : String ) : DOMElement; + function getElementById( elementId : String ) : Element; /** @throws DOMError */ - @:overload( function( localName : String ) : DOMElement {} ) - function createElement( localName : String, typeExtension : String ) : DOMElement; + @:overload( function( localName : String ) : Element {} ) + function createElement( localName : String, typeExtension : String ) : Element; /** @throws DOMError */ - @:overload( function( namespace_ : String, qualifiedName : String ) : DOMElement {} ) - function createElementNS( namespace_ : String, qualifiedName : String, typeExtension : String ) : DOMElement; + @:overload( function( namespace_ : String, qualifiedName : String ) : Element {} ) + function createElementNS( namespace_ : String, qualifiedName : String, typeExtension : String ) : Element; function createDocumentFragment() : DocumentFragment; function createTextNode( data : String ) : Text; function createComment( data : String ) : Comment; @@ -184,10 +184,10 @@ extern class Document extends Node /** @throws DOMError */ function registerElement( name : String, ?options : ElementRegistrationOptions ) : Dynamic; function enableStyleSheetsForSet( name : String ) : Void; - function elementFromPoint( x : Float, y : Float ) : DOMElement; + function elementFromPoint( x : Float, y : Float ) : Element; function caretPositionFromPoint( x : Float, y : Float ) : CaretPosition; /** @throws DOMError */ - function querySelector( selectors : String ) : DOMElement; + function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; function createTouch( ?view : Window, ?target : EventTarget, ?identifier : Int = 0, ?pageX : Int = 0, ?pageY : Int = 0, ?screenX : Int = 0, ?screenY : Int = 0, ?clientX : Int = 0, ?clientY : Int = 0, ?radiusX : Int = 0, ?radiusY : Int = 0, ?rotationAngle : Float = 0.0, ?force : Float = 0.0 ) : Touch; @@ -195,11 +195,11 @@ extern class Document extends Node @:overload( function() : TouchList {} ) function createTouchList( touches : Array ) : TouchList; /** @throws DOMError */ - function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; + function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; /** @throws DOMError */ function createExpression( expression : String, resolver : XPathNSResolver ) : XPathExpression; function createNSResolver( nodeResolver : Node ) : Node; diff --git a/std/js/html/DocumentFragment.hx b/std/js/html/DocumentFragment.hx index fca40912653..82aad0da76c 100644 --- a/std/js/html/DocumentFragment.hx +++ b/std/js/html/DocumentFragment.hx @@ -28,15 +28,15 @@ package js.html; extern class DocumentFragment extends Node { var children(default,null) : HTMLCollection; - var firstElementChild(default,null) : DOMElement; - var lastElementChild(default,null) : DOMElement; + var firstElementChild(default,null) : Element; + var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; /** @throws DOMError */ function new() : Void; - function getElementById( elementId : String ) : DOMElement; + function getElementById( elementId : String ) : Element; /** @throws DOMError */ - function querySelector( selectors : String ) : DOMElement; + function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; } \ No newline at end of file diff --git a/std/js/html/EmbedElement.hx b/std/js/html/EmbedElement.hx index 0f93b240dae..74c871bbc70 100644 --- a/std/js/html/EmbedElement.hx +++ b/std/js/html/EmbedElement.hx @@ -34,5 +34,5 @@ extern class EmbedElement extends Element var align : String; var name : String; - function getSVGDocument() : Document; + function getSVGDocument() : HTMLDocument; } \ No newline at end of file diff --git a/std/js/html/FrameElement.hx b/std/js/html/FrameElement.hx index c579f0dd271..c4a06e8d333 100644 --- a/std/js/html/FrameElement.hx +++ b/std/js/html/FrameElement.hx @@ -33,7 +33,7 @@ extern class FrameElement extends Element var frameBorder : String; var longDesc : String; var noResize : Bool; - var contentDocument(default,null) : Document; + var contentDocument(default,null) : HTMLDocument; var contentWindow(default,null) : Window; var marginHeight : String; var marginWidth : String; diff --git a/std/js/html/HTMLCollection.hx b/std/js/html/HTMLCollection.hx index c827f2e37ca..8f5057bcdb0 100644 --- a/std/js/html/HTMLCollection.hx +++ b/std/js/html/HTMLCollection.hx @@ -25,10 +25,10 @@ package js.html; @:native("HTMLCollection") -extern class HTMLCollection implements ArrayAccess +extern class HTMLCollection implements ArrayAccess { var length(default,null) : Int; - function item( index : Int ) : DOMElement; - function namedItem( name : String ) : DOMElement; + function item( index : Int ) : Element; + function namedItem( name : String ) : Element; } \ No newline at end of file diff --git a/std/js/html/HTMLDocument.hx b/std/js/html/HTMLDocument.hx index 56c5590a05a..50ae5e931d6 100644 --- a/std/js/html/HTMLDocument.hx +++ b/std/js/html/HTMLDocument.hx @@ -50,7 +50,7 @@ extern class HTMLDocument extends Document function getElementsByName( elementName : String ) : NodeList; function getItems( ?typeNames : String = "" ) : NodeList; /** @throws DOMError */ - @:overload( function( ?type : String = "text/html", ?replace : String = "" ) : Document {} ) + @:overload( function( ?type : String = "text/html", ?replace : String = "" ) : HTMLDocument {} ) function open( url : String, name : String, features : String, ?replace : Bool = false ) : Window; /** @throws DOMError */ function close() : Void; diff --git a/std/js/html/HitRegionOptions.hx b/std/js/html/HitRegionOptions.hx index 01faa89754a..99452c5b3d8 100644 --- a/std/js/html/HitRegionOptions.hx +++ b/std/js/html/HitRegionOptions.hx @@ -26,6 +26,6 @@ package js.html; typedef HitRegionOptions = { - @:optional var control : DOMElement; + @:optional var control : Element; @:optional var id : String; } \ No newline at end of file diff --git a/std/js/html/IFrameElement.hx b/std/js/html/IFrameElement.hx index e35efc0a542..fae23d544a3 100644 --- a/std/js/html/IFrameElement.hx +++ b/std/js/html/IFrameElement.hx @@ -34,7 +34,7 @@ extern class IFrameElement extends Element var allowFullscreen : Bool; var width : String; var height : String; - var contentDocument(default,null) : Document; + var contentDocument(default,null) : HTMLDocument; var contentWindow(default,null) : Window; var align : String; var scrolling : String; @@ -43,5 +43,5 @@ extern class IFrameElement extends Element var marginHeight : String; var marginWidth : String; - function getSVGDocument() : Document; + function getSVGDocument() : HTMLDocument; } \ No newline at end of file diff --git a/std/js/html/LinkElement.hx b/std/js/html/LinkElement.hx index 7b54d72aced..dcd64e2c549 100644 --- a/std/js/html/LinkElement.hx +++ b/std/js/html/LinkElement.hx @@ -40,7 +40,7 @@ extern class LinkElement extends Element var rev : String; var target : String; @:native("import") - var import_(default,null) : Document; + var import_(default,null) : HTMLDocument; var sheet(default,null) : StyleSheet; } \ No newline at end of file diff --git a/std/js/html/Node.hx b/std/js/html/Node.hx index decc3234716..b2ca7725466 100644 --- a/std/js/html/Node.hx +++ b/std/js/html/Node.hx @@ -49,9 +49,9 @@ extern class Node extends EventTarget var nodeType(default,null) : Int; var nodeName(default,null) : String; var baseURI(default,null) : String; - var ownerDocument(default,null) : Document; + var ownerDocument(default,null) : HTMLDocument; var parentNode(default,null) : Node; - var parentElement(default,null) : DOMElement; + var parentElement(default,null) : Element; var childNodes(default,null) : NodeList; var firstChild(default,null) : Node; var lastChild(default,null) : Node; diff --git a/std/js/html/ObjectElement.hx b/std/js/html/ObjectElement.hx index 6160e62a132..33774f71a85 100644 --- a/std/js/html/ObjectElement.hx +++ b/std/js/html/ObjectElement.hx @@ -35,7 +35,7 @@ extern class ObjectElement extends Element var form(default,null) : FormElement; var width : String; var height : String; - var contentDocument(default,null) : Document; + var contentDocument(default,null) : HTMLDocument; var contentWindow(default,null) : Window; var willValidate(default,null) : Bool; var validity(default,null) : ValidityState; @@ -53,5 +53,5 @@ extern class ObjectElement extends Element function checkValidity() : Bool; function setCustomValidity( error : String ) : Void; - function getSVGDocument() : Document; + function getSVGDocument() : HTMLDocument; } \ No newline at end of file diff --git a/std/js/html/SelectElement.hx b/std/js/html/SelectElement.hx index 56c494b4961..72cc373a90c 100644 --- a/std/js/html/SelectElement.hx +++ b/std/js/html/SelectElement.hx @@ -25,7 +25,7 @@ package js.html; @:native("HTMLSelectElement") -extern class SelectElement extends Element implements ArrayAccess +extern class SelectElement extends Element implements ArrayAccess { var autofocus : Bool; var disabled : Bool; @@ -44,7 +44,7 @@ extern class SelectElement extends Element implements ArrayAccess var validity(default,null) : ValidityState; var validationMessage(default,null) : String; - function item( index : Int ) : DOMElement; + function item( index : Int ) : Element; function namedItem( name : String ) : OptionElement; /** @throws DOMError */ function add( element : haxe.extern.EitherType, ?before : haxe.extern.EitherType ) : Void; diff --git a/std/js/html/ShadowRoot.hx b/std/js/html/ShadowRoot.hx index b4a0442191e..eb24668d081 100644 --- a/std/js/html/ShadowRoot.hx +++ b/std/js/html/ShadowRoot.hx @@ -28,7 +28,7 @@ package js.html; extern class ShadowRoot extends DocumentFragment { var innerHTML : String; - var host(default,null) : DOMElement; + var host(default,null) : Element; var olderShadowRoot(default,null) : ShadowRoot; var applyAuthorStyles : Bool; var styleSheets(default,null) : StyleSheetList; diff --git a/std/js/html/SpeechRecognitionEvent.hx b/std/js/html/SpeechRecognitionEvent.hx index b1f693a2aa0..96caae50c39 100644 --- a/std/js/html/SpeechRecognitionEvent.hx +++ b/std/js/html/SpeechRecognitionEvent.hx @@ -30,7 +30,7 @@ extern class SpeechRecognitionEvent extends Event var resultIndex(default,null) : Int; var results(default,null) : Dynamic/*MISSING nsISupports*/; var interpretation(default,null) : String; - var emma(default,null) : Document; + var emma(default,null) : HTMLDocument; /** @throws DOMError */ function new( type : String, ?eventInitDict : SpeechRecognitionEventInit ) : Void; diff --git a/std/js/html/SpeechRecognitionEventInit.hx b/std/js/html/SpeechRecognitionEventInit.hx index 50ce7af8077..70c62550f21 100644 --- a/std/js/html/SpeechRecognitionEventInit.hx +++ b/std/js/html/SpeechRecognitionEventInit.hx @@ -27,7 +27,7 @@ package js.html; typedef SpeechRecognitionEventInit = { > EventInit, - @:optional var emma : Document; + @:optional var emma : HTMLDocument; @:optional var interpretation : String; @:optional var resultIndex : Int; @:optional var results : Dynamic/*MISSING nsISupports*/; diff --git a/std/js/html/Text.hx b/std/js/html/Text.hx index 6fc51c2e86c..21fa1dec002 100644 --- a/std/js/html/Text.hx +++ b/std/js/html/Text.hx @@ -34,9 +34,9 @@ extern class Text extends CharacterData /** @throws DOMError */ function splitText( offset : Int ) : Text; /** @throws DOMError */ - function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; + function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ - function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; + function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; } \ No newline at end of file diff --git a/std/js/html/Window.hx b/std/js/html/Window.hx index 01c3c419cca..a3724d42ca0 100644 --- a/std/js/html/Window.hx +++ b/std/js/html/Window.hx @@ -29,7 +29,7 @@ extern class Window extends EventTarget { var window(default,null) : Window; var self(default,null) : Window; - var document(default,null) : Document; + var document(default,null) : HTMLDocument; var name : String; var location(default,null) : Location; var history(default,null) : History; @@ -46,7 +46,7 @@ extern class Window extends EventTarget var top(default,null) : Window; var opener : Dynamic; var parent(default,null) : Window; - var frameElement(default,null) : DOMElement; + var frameElement(default,null) : Element; var navigator(default,null) : Navigator; var applicationCache(default,null) : ApplicationCache; var orientation(default,null) : Int; @@ -189,7 +189,7 @@ extern class Window extends EventTarget /** @throws DOMError */ function getSelection() : Selection; /** @throws DOMError */ - function getComputedStyle( elt : DOMElement, ?pseudoElt : String = "" ) : CSSStyleDeclaration; + function getComputedStyle( elt : Element, ?pseudoElt : String = "" ) : CSSStyleDeclaration; /** @throws DOMError */ function matchMedia( query : String ) : MediaQueryList; /** @throws DOMError */ @@ -211,7 +211,7 @@ extern class Window extends EventTarget /** @throws DOMError */ function cancelAnimationFrame( handle : Int ) : Void; /** @throws DOMError */ - function getDefaultComputedStyle( elt : DOMElement, ?pseudoElt : String = "" ) : CSSStyleDeclaration; + function getDefaultComputedStyle( elt : Element, ?pseudoElt : String = "" ) : CSSStyleDeclaration; function scrollByLines( numLines : Int, ?options : ScrollOptions ) : Void; function scrollByPages( numPages : Int, ?options : ScrollOptions ) : Void; /** @throws DOMError */ diff --git a/std/js/html/XMLHttpRequest.hx b/std/js/html/XMLHttpRequest.hx index 9680bc760fd..826b2d02fa9 100644 --- a/std/js/html/XMLHttpRequest.hx +++ b/std/js/html/XMLHttpRequest.hx @@ -44,7 +44,7 @@ extern class XMLHttpRequest extends XMLHttpRequestEventTarget var responseType : XMLHttpRequestResponseType; var response(default,null) : Dynamic; var responseText(default,null) : String; - var responseXML(default,null) : Document; + var responseXML(default,null) : HTMLDocument; /** @throws DOMError */ @:overload( function( ?params : Dynamic/*MISSING MozXMLHttpRequestParameters*/ ) : Void {} ) @@ -59,7 +59,7 @@ extern class XMLHttpRequest extends XMLHttpRequestEventTarget @:overload( function( data : ArrayBuffer ) : Void {} ) @:overload( function( data : ArrayBufferView ) : Void {} ) @:overload( function( data : Blob ) : Void {} ) - @:overload( function( data : Document ) : Void {} ) + @:overload( function( data : HTMLDocument ) : Void {} ) @:overload( function( data : String ) : Void {} ) @:overload( function( data : FormData ) : Void {} ) function send( data : Dynamic/*MISSING InputStream*/ ) : Void; diff --git a/std/js/html/XSLTProcessor.hx b/std/js/html/XSLTProcessor.hx index 198b2ee2164..e4fc9c0c0c1 100644 --- a/std/js/html/XSLTProcessor.hx +++ b/std/js/html/XSLTProcessor.hx @@ -32,9 +32,9 @@ extern class XSLTProcessor /** @throws DOMError */ function importStylesheet( style : Node ) : Void; /** @throws DOMError */ - function transformToFragment( source : Node, output : Document ) : DocumentFragment; + function transformToFragment( source : Node, output : HTMLDocument ) : DocumentFragment; /** @throws DOMError */ - function transformToDocument( source : Node ) : Document; + function transformToDocument( source : Node ) : HTMLDocument; /** @throws DOMError */ function setParameter( namespaceURI : String, localName : String, value : Dynamic ) : Void; /** @throws DOMError */ diff --git a/std/js/html/svg/IFrameElement.hx b/std/js/html/svg/IFrameElement.hx index e25be78c864..fb72ee6b0d6 100644 --- a/std/js/html/svg/IFrameElement.hx +++ b/std/js/html/svg/IFrameElement.hx @@ -36,7 +36,7 @@ extern class IFrameElement extends GraphicsElement var src(default,null) : String; var srcdoc(default,null) : String; var sandbox(default,null) : js.html.DOMSettableTokenList; - var contentDocument(default,null) : js.html.Document; + var contentDocument(default,null) : js.html.HTMLDocument; var contentWindow(default,null) : Window; } \ No newline at end of file diff --git a/std/js/html/svg/SVGElement.hx b/std/js/html/svg/SVGElement.hx index beb80745b7d..a9e9a21c41c 100644 --- a/std/js/html/svg/SVGElement.hx +++ b/std/js/html/svg/SVGElement.hx @@ -65,5 +65,5 @@ extern class SVGElement extends GraphicsElement function createSVGRect() : Rect; function createSVGTransform() : Transform; function createSVGTransformFromMatrix( matrix : Matrix ) : Transform; - function getElementById( elementId : String ) : js.html.DOMElement; + function getElementById( elementId : String ) : js.html.Element; } \ No newline at end of file From 9ca3649f2f28545dd23af2140e52e2a4491b7292 Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Wed, 22 Apr 2015 11:22:14 +0200 Subject: [PATCH 159/209] Small Std documentation fixes Added ` on several places since that causes italic texts because of markdown. --- std/Std.hx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/std/Std.hx b/std/Std.hx index 57564eb22a5..70e64b96f09 100644 --- a/std/Std.hx +++ b/std/Std.hx @@ -29,7 +29,7 @@ extern class Std { /** - Tells if a value v is of the type t. Returns false if v or t are null. + Tells if a value `v` is of the type `t`. Returns `false` if `v` or `t` are null. **/ public static function is( v : Dynamic, t : Dynamic ) : Bool; @@ -44,7 +44,7 @@ extern class Std { returned. Otherwise null is returned. This method is not guaranteed to work with interfaces or core types such - as String, Array and Date. + as `String`, `Array` and `Date`. If `value` is null, the result is null. If `c` is null, the result is unspecified. @@ -74,7 +74,7 @@ extern class Std { /** Converts a `Float` to an `Int`, rounded towards 0. - If `x` is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified. + If `x` is outside of the signed Int32 range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ public static function int( x : Float ) : Int; @@ -96,7 +96,7 @@ extern class Std { Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal notation is not supported. - If the input cannot be recognized, the result is null. + If the input cannot be recognized, the result is `null`. **/ public static function parseInt( x : String ) : Null; @@ -104,7 +104,7 @@ extern class Std { Converts a `String` to a `Float`. The parsing rules for `parseInt` apply here as well, with the exception of invalid input - resulting in a NaN value instead of null. + resulting in a `NaN` value instead of null. Additionally, decimal notation may contain a single `.` to denote the start of the fractions. **/ From ae655b22713085d6c94079dbc40b97d8ce39237c Mon Sep 17 00:00:00 2001 From: Mark Knol Date: Wed, 22 Apr 2015 11:34:21 +0200 Subject: [PATCH 160/209] Small Math documentation fixes Added ` on several places since that causes italic texts because of markdown. --- std/Math.hx | 116 ++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/std/Math.hx b/std/Math.hx index 6baf7e3844e..6f6d87a954f 100644 --- a/std/Math.hx +++ b/std/Math.hx @@ -32,47 +32,47 @@ extern class Math static var PI(default,null) : Float; /** - A special Float constant which denotes negative infinity. + A special `Float` constant which denotes negative infinity. For example, this is the result of -1.0 / 0.0. - Operations with NEGATIVE_INFINITY as an operand may result in - NEGATIVE_INFINITY, POSITIVE_INFINITY or NaN. + Operations with `NEGATIVE_INFINITY` as an operand may result in + `NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`. - If this constant is converted to an Int, e.g. through Std.int(), the + If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. **/ static var NEGATIVE_INFINITY(default, null) : Float; /** - A special Float constant which denotes negative infinity. + A special `Float` constant which denotes negative infinity. For example, this is the result of 1.0 / 0.0. - Operations with POSITIVE_INFINITY as an operand may result in - NEGATIVE_INFINITY, POSITIVE_INFINITY or NaN. + Operations with `POSITIVE_INFINITY` as an operand may result in + `NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`. - If this constant is converted to an Int, e.g. through Std.int(), the + If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. **/ static var POSITIVE_INFINITY(default,null) : Float; /** - A special Float constant which denotes an invalid number. + A special `Float` constant which denotes an invalid number. NaN stands for "Not a Number". It occurs when a mathematically incorrect operation is executed, such as taking the square root of a negative number: Math.sqrt(-1). - All further operations with NaN as an operand will result in NaN. + All further operations with `NaN` as an operand will result in `NaN`. - If this constant is converted to an Int, e.g. through Std.int(), the + If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. - In order to test if a value is NaN, you should use Math.isNaN() function. + In order to test if a value is `NaN`, you should use `Math.isNaN()` function. @php In PHP versions prior to 5.3.1 VC 9 there may be unexpected - results when performing arithmetic operations with NaN on Windows, + results when performing arithmetic operations with `NaN` on Windows, see [https://bugs.php.net/bug.php?id=42143] **/ static var NaN(default, null) : Float; @@ -83,56 +83,56 @@ extern class Math If `v` is positive or 0, the result is unchanged. Otherwise the result is -`v`. - If `v` is NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is - POSITIVE_INFINITY. + If `v` is `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is + `POSITIVE_INFINITY`. - If `v` is NaN, the result is NaN. + If `v` is `NaN`, the result is `NaN`. **/ static function abs(v:Float):Float; /** Returns the smaller of values `a` and `b`. - If `a` or `b` are NaN, the result is NaN. - If `a` or `b` are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY. - If `a` and `b` are POSITIVE_INFINITY, the result is POSITIVE_INFINITY. + If `a` or `b` are `NaN`, the result is `NaN`. + If `a` or `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`. + If `a` and `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. **/ static function min(a:Float, b:Float):Float; /** Returns the greater of values `a` and `b`. - If `a` or `b` are NaN, the result is NaN. - If `a` or `b` are POSITIVE_INFINITY, the result is POSITIVE_INFINITY. - If `a` and `b` are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY. + If `a` or `b` are `NaN`, the result is `NaN`. + If `a` or `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. + If `a` and `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`. **/ static function max(a:Float, b:Float):Float; /** Returns the trigonometric sine of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function sin(v:Float):Float; /** Returns the trigonometric cosine of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function cos(v:Float):Float; /** Returns the trigonometric tangent of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function tan(v:Float):Float; /** Returns the trigonometric arc of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function asin(v:Float):Float; @@ -140,7 +140,7 @@ extern class Math Returns the trigonometric arc cosine of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function acos(v:Float):Float; @@ -148,7 +148,7 @@ extern class Math Returns the trigonometric arc tangent of the specified angle `v`, in radians. - If `v` is NaN or infinite, the result is NaN. + If `v` is `NaN` or infinite, the result is `NaN`. **/ static function atan(v:Float):Float; @@ -156,8 +156,8 @@ extern class Math Returns the trigonometric arc tangent whose tangent is the quotient of two specified numbers, in radians. - If parameter `x` or `y` is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, - the result is NaN. + If parameter `x` or `y` is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, + the result is `NaN`. **/ static function atan2(y:Float, x:Float):Float; @@ -166,9 +166,9 @@ extern class Math exp(1.0) is approximately 2.718281828459. - If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY. - If `v` is NEGATIVE_INFINITY, the result is 0.0. - If `v` is NaN, the result is NaN. + If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. + If `v` is `NEGATIVE_INFINITY`, the result is `0.0`. + If `v` is `NaN`, the result is `NaN`. **/ static function exp(v:Float):Float; @@ -178,10 +178,10 @@ extern class Math This is the mathematical inverse operation of exp, i.e. `log(exp(v)) == v` always holds. - If `v` is negative (including NEGATIVE_INFINITY) or NaN, the result - is NaN. - If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY. - If `v` is 0.0, the result is NEGATIVE_INFINITY. + If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result + is `NaN`. + If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. + If `v` is `0.0`, the result is `NEGATIVE_INFINITY`. **/ static function log(v:Float):Float; @@ -193,34 +193,34 @@ extern class Math /** Returns the square root of `v`. - If `v` is negative (including NEGATIVE_INFINITY) or NaN, the result - is NaN. - If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY. - If `v` is 0.0, the result is 0.0. - **/ + If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result + is `NaN`. + If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. + If `v` is `0.0`, the result is `0.0`. + **/tr static function sqrt(v:Float):Float; /** Rounds `v` to the nearest integer value. - If `v` is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY - or POSITIVE_INFINITY, the result is unspecified. + If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` + or `POSITIVE_INFINITY`, the result is unspecified. **/ static function round(v:Float):Int; /** Returns the largest integer value that is not greater than `v`. - If `v` is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY - or POSITIVE_INFINITY, the result is unspecified. + If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` + or `POSITIVE_INFINITY`, the result is unspecified. **/ static function floor(v:Float):Int; /** Returns the smallest integer value that is not less than `v`. - If `v` is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY - or POSITIVE_INFINITY, the result is unspecified. + If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` + or `POSITIVE_INFINITY`, the result is unspecified. **/ static function ceil(v:Float):Int; @@ -232,17 +232,17 @@ extern class Math #if ((flash && !as3) || cpp) /** - Returns the largest integer value that is not greater than `v`, as a Float. + Returns the largest integer value that is not greater than `v`, as a `Float`. - If `v` is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, + If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function ffloor( v : Float ) : Float; /** - Returns the smallest integer value that is not less than `v`, as a Float. + Returns the smallest integer value that is not less than `v`, as a `Float`. - If `v` is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, + If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function fceil( v : Float ) : Float; @@ -250,7 +250,7 @@ extern class Math /** Rounds `v` to the nearest integer value, as a Float. - If `v` is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, + If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function fround( v : Float ) : Float; @@ -275,17 +275,17 @@ extern class Math /** Tells if `f` is a finite number. - If `f` is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN, the result - is false, otherwise the result is true. + If `f` is `POSITIVE_INFINITY`, `NEGATIVE_INFINITY` or `NaN`, the result + is `false`, otherwise the result is `true`. **/ static function isFinite( f : Float ) : Bool; /** Tells if `f` is not a valid number. - If `f` is NaN, the result is true, otherwise the result is false. - In particular, both POSITIVE_INFINITY and NEGATIVE_INFINITY are - not considered NaN. + If `f` is `NaN`, the result is `true`, otherwise the result is `false`. + In particular, both `POSITIVE_INFINITY` and `NEGATIVE_INFINITY` are + not considered `NaN`. **/ static function isNaN( f : Float ) : Bool; From 7ee34f4e2d4f7d29f1931924bf95016b961e7e89 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 22 Apr 2015 17:55:03 +0800 Subject: [PATCH 161/209] Removed garbage. --- std/Math.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/Math.hx b/std/Math.hx index 6f6d87a954f..4d246f8aaaa 100644 --- a/std/Math.hx +++ b/std/Math.hx @@ -197,7 +197,7 @@ extern class Math is `NaN`. If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `v` is `0.0`, the result is `0.0`. - **/tr + **/ static function sqrt(v:Float):Float; /** From 6c40616fc751cef1587cecbb8b87cb0330372f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 22 Apr 2015 16:01:42 -0300 Subject: [PATCH 162/209] [cs] Take off useless abstract-to-struct cast. See #4045 --- gencommon.ml | 18 +++++++++++ tests/unit/src/unit/issues/Issue4045.hx | 43 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/unit/src/unit/issues/Issue4045.hx diff --git a/gencommon.ml b/gencommon.ml index 4eae69a6fb4..608c231fe07 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -6569,6 +6569,20 @@ struct | _ -> e in + let get_abstract_impl t = match t with + | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> + Abstract.get_underlying_type a pl + | t -> t + in + + let rec is_abstract_to_struct t = match t with + | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> + is_abstract_to_struct (Abstract.get_underlying_type a pl) + | TInst(c,_) when Meta.has Meta.Struct c.cl_meta -> + true + | _ -> false + in + let rec run ?(just_type = false) e = let handle = if not just_type then handle else fun e t1 t2 -> { e with etype = gen.greal_type t2 } in let was_in_value = !in_value in @@ -6748,12 +6762,15 @@ struct | TParenthesis e | TMeta(_,e) -> get_null e | _ -> None in + (match get_null expr with | Some enull -> if gen.gcon.platform = Cs then { enull with etype = gen.greal_type e.etype } else mk_cast (gen.greal_type e.etype) enull + | _ when is_abstract_to_struct expr.etype && type_iseq gen e.etype (get_abstract_impl expr.etype) -> + run { expr with etype = expr.etype } | _ -> let last_unsafe = gen.gon_unsafe_cast in gen.gon_unsafe_cast <- (fun t t2 pos -> ()); @@ -6769,6 +6786,7 @@ struct | TFunction f -> in_value := false; Type.map_expr run e + | _ -> Type.map_expr run e in run diff --git a/tests/unit/src/unit/issues/Issue4045.hx b/tests/unit/src/unit/issues/Issue4045.hx new file mode 100644 index 00000000000..f4c4fc8e973 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4045.hx @@ -0,0 +1,43 @@ +package unit.issues; + +#if cs +class Issue4045 extends Test +{ + public function test() + { + var t = new TestS(); + t.a = 10; + eq(10, t.a); + } +} + +private abstract TestS(TestClass) +{ + inline public function new() + { + this = new TestClass(0); + } + + public var a(get,set):Int; + + inline private function get_a() + { + return this.a; + } + + inline private function set_a(v:Int) + { + return this.a = v; + } +} + +@:nativeGen @:struct private class TestClass +{ + public var a:Int; + + public function new(av) + { + this.a = av; + } +} +#end From 6767c40ac9de3a110dc8bcdc9fdb7200fe7156b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 22 Apr 2015 16:30:51 -0300 Subject: [PATCH 163/209] [cs] minor - avoid class not found errors on other platforms --- tests/unit/src/unit/issues/Issue4045.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/src/unit/issues/Issue4045.hx b/tests/unit/src/unit/issues/Issue4045.hx index f4c4fc8e973..c2c7cee7537 100644 --- a/tests/unit/src/unit/issues/Issue4045.hx +++ b/tests/unit/src/unit/issues/Issue4045.hx @@ -1,16 +1,18 @@ package unit.issues; -#if cs class Issue4045 extends Test { +#if cs public function test() { var t = new TestS(); t.a = 10; eq(10, t.a); } +#end } +#if cs private abstract TestS(TestClass) { inline public function new() From 18972f25c24ddab7abdc19780f3945e067aad1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Fri, 24 Apr 2015 15:17:12 -0300 Subject: [PATCH 164/209] [cs] More fixes from bugs introduced by abstracts casts --- gencommon.ml | 20 ++++++++++++-------- std/cs/Pointer.hx | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gencommon.ml b/gencommon.ml index 608c231fe07..889a50af37d 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -6579,7 +6579,7 @@ struct | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> is_abstract_to_struct (Abstract.get_underlying_type a pl) | TInst(c,_) when Meta.has Meta.Struct c.cl_meta -> - true + true | _ -> false in @@ -6772,13 +6772,17 @@ struct | _ when is_abstract_to_struct expr.etype && type_iseq gen e.etype (get_abstract_impl expr.etype) -> run { expr with etype = expr.etype } | _ -> - let last_unsafe = gen.gon_unsafe_cast in - gen.gon_unsafe_cast <- (fun t t2 pos -> ()); - let ret = handle (run expr) e.etype expr.etype in - gen.gon_unsafe_cast <- last_unsafe; - match ret.eexpr with - | TCast _ -> ret - | _ -> { e with eexpr = TCast(ret,md); etype = gen.greal_type e.etype } + match gen.greal_type e.etype, gen.greal_type expr.etype with + | (TInst(c,tl) as tinst1), TAbstract({ a_path = ["cs"],"Pointer" }, [tinst2]) when type_iseq gen tinst1 (gen.greal_type tinst2) -> + run expr + | _ -> + let last_unsafe = gen.gon_unsafe_cast in + gen.gon_unsafe_cast <- (fun t t2 pos -> ()); + let ret = handle (run expr) e.etype expr.etype in + gen.gon_unsafe_cast <- last_unsafe; + match ret.eexpr with + | TCast _ -> { ret with etype = gen.greal_type e.etype } + | _ -> { e with eexpr = TCast(ret,md); etype = gen.greal_type e.etype } ) (*| TCast _ -> (* if there is already a cast, we should skip this cast check *) diff --git a/std/cs/Pointer.hx b/std/cs/Pointer.hx index 057e0553089..16dc0474c7b 100644 --- a/std/cs/Pointer.hx +++ b/std/cs/Pointer.hx @@ -43,7 +43,7 @@ import cs.StdTypes.Int64; #if !unsafe #error "You need to define 'unsafe' to be able to use unsafe code in hxcs" #else -@:runtimeValue @:coreType abstract Pointer from Int64 +@:runtimeValue @:coreType abstract Pointer from Int64 from PointerAccess to PointerAccess { @:op(A+B) public static function addIp(lhs:Pointer, rhs:Int):Pointer; @:op(A+B) public static function addp(lhs:Pointer, rhs:Int64):Pointer; From bddfbc22fad9764795fedb54d613d4b07946b79f Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Mon, 27 Apr 2015 15:25:27 +0300 Subject: [PATCH 165/209] [cs] fix Math.fround, add tests for it (closes #4177) --- std/cs/_std/Math.hx | 2 +- tests/unit/src/unitstd/Math.unit.hx | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/std/cs/_std/Math.hx b/std/cs/_std/Math.hx index 99b11b9d2db..b06b4d11bc3 100644 --- a/std/cs/_std/Math.hx +++ b/std/cs/_std/Math.hx @@ -85,7 +85,7 @@ public static inline function fround(v:Float):Float { - return cs.system.Math.Round(v); + return cs.system.Math.Floor(v + 0.5); } public static inline function ffloor(v:Float):Float diff --git a/tests/unit/src/unitstd/Math.unit.hx b/tests/unit/src/unitstd/Math.unit.hx index e26566f2d9d..c9f4e50c380 100644 --- a/tests/unit/src/unitstd/Math.unit.hx +++ b/tests/unit/src/unitstd/Math.unit.hx @@ -170,6 +170,21 @@ Math.round( -1.50001) == -2; Math.fround(Math.POSITIVE_INFINITY) == Math.POSITIVE_INFINITY; Math.fround(Math.NEGATIVE_INFINITY) == Math.NEGATIVE_INFINITY; Math.isNaN(Math.fround(Math.NaN)) == true; +Math.fround(0.0) == 0.0; +Math.fround(0.1) == 0.0; +Math.fround(0.4999) == 0.0; +Math.fround(0.5) == 1.0; +Math.fround(1.0) == 1.0; +Math.fround(1.499) == 1.0; +Math.fround(1.5) == 2.0; +Math.fround(-0.1) == -0.0; +Math.fround(-0.4999) == -0.0; +Math.fround(-0.5) == -0.0; +Math.fround(-0.50001) == -1.0; +Math.fround(-1.0) == -1.0; +Math.fround(-1.499) == -1.0; +Math.fround(-1.5) == -1.0; +Math.fround( -1.50001) == -2.0; // floor Math.floor(0.0) == 0; From d5e6ec4431a760bf4bf65e159930cf0d907c76e4 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Mon, 27 Apr 2015 15:49:09 +0300 Subject: [PATCH 166/209] [java] fix #4177 for java as well --- genjava.ml | 2 -- std/java/_std/Math.hx | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/genjava.ml b/genjava.ml index ad53c8f9424..78f2ae98847 100644 --- a/genjava.ml +++ b/genjava.ml @@ -205,8 +205,6 @@ struct | TCall( ({ eexpr = TField( (_ as ef), FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = ("ffloor" as f) }) ) } as fe), p) | TCall( ({ eexpr = TField( (_ as ef), FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = ("fceil" as f) }) ) } as fe), p) -> Type.map_expr run { e with eexpr = TCall({ fe with eexpr = TField(ef, FDynamic (String.sub f 1 (String.length f - 1))) }, p) } - | TCall( ({ eexpr = TField( (_ as ef), FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = ("fround") }) ) } as fe), p) -> - Type.map_expr run { e with eexpr = TCall({ fe with eexpr = TField(ef, FDynamic "rint") }, p) } | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "floor" }) ) }, _) | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "round" }) ) }, _) | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "ceil" }) ) }, _) -> diff --git a/std/java/_std/Math.hx b/std/java/_std/Math.hx index a4820718648..6f159c06ee3 100644 --- a/std/java/_std/Math.hx +++ b/std/java/_std/Math.hx @@ -42,7 +42,9 @@ static function floor(v:Float):Int; static function ceil(v:Float):Int; static function atan(v:Float):Float; - static function fround(v:Float):Float; + inline static function fround(v:Float):Float { + return ffloor(v + 0.5); + } static function ffloor(v:Float):Float; static function fceil(v:Float):Float; static function asin(v:Float):Float; From df27b1b5f4c6956c03a0656b00525e173d910314 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 27 Apr 2015 21:41:15 +0800 Subject: [PATCH 167/209] [cpp] Fix optional Int64 in interfaces. Closes https://github.com/HaxeFoundation/hxcpp/issues/225 --- extra/haxelib_src | 2 +- gencpp.ml | 5 ++++- tests/unit/src/unit/hxcpp_issues/Issue225.hx | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/unit/src/unit/hxcpp_issues/Issue225.hx diff --git a/extra/haxelib_src b/extra/haxelib_src index 68f25d97dc9..0dfb33242a2 160000 --- a/extra/haxelib_src +++ b/extra/haxelib_src @@ -1 +1 @@ -Subproject commit 68f25d97dc991516c02a2665081ba5cc0d2ae23e +Subproject commit 0dfb33242a28d5a89178c1e48968174646e0fefe diff --git a/gencpp.ml b/gencpp.ml index 195b7e095ec..1bb6d77bb04 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -760,10 +760,13 @@ and cpp_function_signature_params params = match params with and gen_interface_arg_type_name name opt typ = let type_str = (type_string typ) in - (if (opt && (cant_be_null typ) ) then + (* type_str may have already converted Null to Dynamic because of NotNull tag ... *) + (if (opt && (cant_be_null typ) && type_str<>"Dynamic" ) then "hx::Null< " ^ type_str ^ " > " else type_str ) + + ^ " " ^ (keyword_remap name) and gen_tfun_interface_arg_list args = String.concat "," (List.map (fun (name,opt,typ) -> gen_interface_arg_type_name name opt typ) args) diff --git a/tests/unit/src/unit/hxcpp_issues/Issue225.hx b/tests/unit/src/unit/hxcpp_issues/Issue225.hx new file mode 100644 index 00000000000..e92963ce0f4 --- /dev/null +++ b/tests/unit/src/unit/hxcpp_issues/Issue225.hx @@ -0,0 +1,19 @@ +package unit.hxcpp_issues; + +import haxe.Int64; +using haxe.Int64; + +interface InterfaceWithDefaultI64 { + public function optionalI64(?i:Int64) : Int; +} + +class Issue225 extends Test implements InterfaceWithDefaultI64 { + function test() { + var i:InterfaceWithDefaultI64 = new Issue225(); + eq(i.optionalI64(), -1); + eq(i.optionalI64(Int64.make(0,1)), 1); + } + public function optionalI64(?i:Int64) + return i==null ? -1 : i.toInt(); +} + From a7209a6b77ecb17101ef44d847ceb0ba6e1d17a4 Mon Sep 17 00:00:00 2001 From: Hugh Date: Tue, 28 Apr 2015 00:45:47 +0800 Subject: [PATCH 168/209] Reset commit id --- extra/haxelib_src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/haxelib_src b/extra/haxelib_src index 0dfb33242a2..68f25d97dc9 160000 --- a/extra/haxelib_src +++ b/extra/haxelib_src @@ -1 +1 @@ -Subproject commit 0dfb33242a28d5a89178c1e48968174646e0fefe +Subproject commit 68f25d97dc991516c02a2665081ba5cc0d2ae23e From 10792944cd0170d05d22e02e36986e637435ab68 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 28 Apr 2015 18:07:42 +0800 Subject: [PATCH 169/209] Added info on how to config CIs for forks. --- tests/README.md | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index 718d5aa4c13..aa55fe995e2 100644 --- a/tests/README.md +++ b/tests/README.md @@ -2,11 +2,51 @@ We have a number of test suites, which are placed in their own folders in this directory. -"RunCi.hx" is the script used by our CIs to run all the test suites. It is possible to run it in local machines too: +"RunCi.hx" is the script used by our CIs to run all the test suites. It is possible to configure CIs for your own fork of Haxe on Github using the instructions as follows. + +### TravisCI + +TravisCI provides Linux and Mac builds. However, for forks, it only provides Linux builds unless [requested manually](http://docs.travis-ci.com/user/multi-os/). + +To set up TravisCI: + + 1. Head to TravisCI, go to the [profile page](https://travis-ci.org/profile). + 2. Turn on the switch of your fork. If you couldn't find the repo, try the *Sync* button on the top to refresh the list. + 3. If you want to enable browser testing for the JS target, follow the instructions in the SauceLabs section. If not, go to the next step. + 4. Push to the repo to trigger a new build. The build result should be available at `https://travis-ci.org//haxe`. + +### AppVeyor + +AppVeyor provides Windows builds. + +To set up AppVeyor: + + 1. Head to AppVeyor, [add a new project](https://ci.appveyor.com/projects/new). + 2. Select the forked repo under your account. + 3. The build worker provided by the AppVeyor free plan is very slow. In order to avoid reaching the 40 min build time limit for each build, it is recommanded to test only the targets you're interested. Go the *settings* page of the new project, select *Environment*. Click *Add variable* under *Environment variables*. Enter `TEST` in the *name* field, and a comma-seperated list of targets (e.g. `neko,macro`) in the *value* field. + 4. Push to the repo to trigger a new build. The build result should be available at `https://ci.appveyor.com/project//haxe`. + +### SauceLabs + +SauceLabs provides browser testings. We use TravisCI to drive the test, so you should have TravisCI configured. + +To set up SauceLabs: + + 1. Head to the project page of your fork at `https://travis-ci.org//haxe` + 2. Select *Settings* -> *Settings*. + 3. Select the *Environment Variables* tab. + 4. Select *Add a new variable* for the following pairs, keeping the switch off for *Display value in build logs*. + * name: `SAUCE_USERNAME`, value: your SauceLabs account name + * name: `SAUCE_ACCESS_KEY`, value: your SauceLabs access key, which can be found at https://saucelabs.com/account + 5. Push to the repo to trigger a new TravisCI build. SauceLabs test results should be available in the JS build log. + +### Local testing + +It is possible to run it in local machines too: 1. Change to this directory. 2. Compile the script: `haxe RunCi.hxml`. - 3. Define the test target by `export TEST=$TARGET` (or `set "TEST=$TARGET"` on Windows), where `$TARGET` should be one of `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, or `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). + 3. Define the test target by `export TEST=$TARGET` (or `set "TEST=$TARGET"` on Windows), where `$TARGET` should be a comma-seperated list of targets, e.g. `neko,macro`. Possible targets are `macro`, `neko`, `js`, `php`, `cpp`, `flash9`, `as3`, `java`, `cs`, `python`, and `third-party`. However, `flash9`, `as3`, and `third-party` are not likely to work on local machines (TODO). 4. Run it: `neko RunCi.n`. Note that the script will try to look for test dependencies and install them if they are not found. Look at the `getXXXDependencies` functions for the details. @@ -29,4 +69,4 @@ The "sys" folder contains tests for the system targets. It can also be run separ Assuming all test dependencies has been installed, we compile and run the sys tests for all targets at once as follows: 1. Change to the "sys" directory. - 2. If you're on Windows, comment out the relevant lines in "run.hxml". `haxe run.hxml`. \ No newline at end of file + 2. If you're on Windows, comment out the relevant lines in "run.hxml". `haxe run.hxml`. From 0dc150045ed849946b03dc961d34b0b019cd7ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 29 Apr 2015 15:02:40 -0300 Subject: [PATCH 170/209] [java] Make sure no 'Unexpected module type' happens on the abstract java.lang types. Closes #4113 --- std/java/lang/Boolean.hx | 1 + std/java/lang/Byte.hx | 1 + std/java/lang/Character.hx | 1 + std/java/lang/Double.hx | 2 +- std/java/lang/Float.hx | 1 + std/java/lang/Integer.hx | 1 + std/java/lang/Long.hx | 1 + std/java/lang/Short.hx | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/std/java/lang/Boolean.hx b/std/java/lang/Boolean.hx index efcd19c2111..e0645cd9275 100644 --- a/std/java/lang/Boolean.hx +++ b/std/java/lang/Boolean.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Boolean(BooleanClass) from BooleanClass to BooleanClass { @:to @:extern inline public function toBool():Bool diff --git a/std/java/lang/Byte.hx b/std/java/lang/Byte.hx index 2ba1226e61d..b9557e941b2 100644 --- a/std/java/lang/Byte.hx +++ b/std/java/lang/Byte.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Byte(ByteClass) from ByteClass to ByteClass { @:to @:extern inline public function toByte():java.types.Int8 diff --git a/std/java/lang/Character.hx b/std/java/lang/Character.hx index 8c05fc9e2a5..a409fdb0f2d 100644 --- a/std/java/lang/Character.hx +++ b/std/java/lang/Character.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Character(CharacterClass) from CharacterClass to CharacterClass { @:to @:extern inline public function toCharacter():java.types.Char16 diff --git a/std/java/lang/Double.hx b/std/java/lang/Double.hx index 88f3b465808..ef8e41da73a 100644 --- a/std/java/lang/Double.hx +++ b/std/java/lang/Double.hx @@ -1,6 +1,6 @@ package java.lang; -@:native("") // workaround for #4113 +@:native("") // make sure the generator won't see this @:forward abstract Double(DoubleClass) from DoubleClass to DoubleClass { @:to @:extern inline public function toFloat():Float diff --git a/std/java/lang/Float.hx b/std/java/lang/Float.hx index c32e4136ba7..89df8a44167 100644 --- a/std/java/lang/Float.hx +++ b/std/java/lang/Float.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Float(FloatClass) from FloatClass to FloatClass { @:to @:extern inline public function toFloat():std.StdTypes.Float diff --git a/std/java/lang/Integer.hx b/std/java/lang/Integer.hx index 160decb6ec4..b4eddcaa0c4 100644 --- a/std/java/lang/Integer.hx +++ b/std/java/lang/Integer.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Integer(IntegerClass) from IntegerClass to IntegerClass { @:to @:extern inline public function toInt():Int diff --git a/std/java/lang/Long.hx b/std/java/lang/Long.hx index 7e6e3308dac..ebf1bf1bd2c 100644 --- a/std/java/lang/Long.hx +++ b/std/java/lang/Long.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Long(LongClass) from LongClass to LongClass { @:to @:extern inline public function toLong():haxe.Int64 diff --git a/std/java/lang/Short.hx b/std/java/lang/Short.hx index dfc593937fa..7affef47c2b 100644 --- a/std/java/lang/Short.hx +++ b/std/java/lang/Short.hx @@ -1,5 +1,6 @@ package java.lang; +@:native("") // make sure the generator won't see this @:forward abstract Short(ShortClass) from ShortClass to ShortClass { @:to @:extern inline public function toShort():java.types.Int16 From 13fe6a596ba7839262d58866597673146fe9cd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 29 Apr 2015 15:17:26 -0300 Subject: [PATCH 171/209] [java/cs] Add some parseInt tests from #4132 and fix them on java/cs Related to #4051 --- std/cs/_std/Std.hx | 2 +- std/java/_std/Std.hx | 2 +- tests/unit/src/unitstd/Std.unit.hx | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/std/cs/_std/Std.hx b/std/cs/_std/Std.hx index 86ac5301879..d8be7b62d69 100644 --- a/std/cs/_std/Std.hx +++ b/std/cs/_std/Std.hx @@ -81,7 +81,7 @@ import cs.internal.Exceptions; } } - var foundAny = false; + var foundAny = i != -1; var isNeg = false; while (++i < len) { diff --git a/std/java/_std/Std.hx b/std/java/_std/Std.hx index bec42699bb0..6624d01f98f 100644 --- a/std/java/_std/Std.hx +++ b/std/java/_std/Std.hx @@ -79,7 +79,7 @@ import java.internal.Exceptions; } } - boolean foundAny = false; + boolean foundAny = i != 0; boolean isNeg = false; for (; i < len; i++) { diff --git a/tests/unit/src/unitstd/Std.unit.hx b/tests/unit/src/unitstd/Std.unit.hx index 07a1a68b61d..386d9cd1527 100644 --- a/tests/unit/src/unitstd/Std.unit.hx +++ b/tests/unit/src/unitstd/Std.unit.hx @@ -88,6 +88,8 @@ Std.parseFloat("2.426670815e+12") == 2.426670815e+12; Std.parseFloat("2.426670815E+12") == 2.426670815e+12; Std.parseFloat("2.426670815e-12") == 2.426670815e-12; Std.parseFloat("2.426670815E-12") == 2.426670815e-12; +Std.parseInt("0x C") == 0; +Std.parseInt("0x+A") == 0; // random var x = Std.random(2); From f19ddc667145ed8c31552b881cdd7df03393f3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 29 Apr 2015 16:05:00 -0300 Subject: [PATCH 172/209] [java/cs] Fix parseFloat tests from #4132 and on java/cs See #4051 --- std/cs/_std/Std.hx | 27 +++++++++++++-------------- std/java/_std/Std.hx | 28 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/std/cs/_std/Std.hx b/std/cs/_std/Std.hx index d8be7b62d69..d67b0f806f9 100644 --- a/std/cs/_std/Std.hx +++ b/std/cs/_std/Std.hx @@ -134,7 +134,8 @@ import cs.internal.Exceptions; public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); - var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasESign = false; + var found = false, hasDot = false, hasSign = false, + hasE = false, hasESign = false, hasEData = false; var i = -1; inline function getch(i:Int):Int return cast ((untyped x : cs.system.String)[i]); @@ -143,32 +144,30 @@ import cs.internal.Exceptions; var chr = getch(i); if (chr >= '0'.code && chr <= '9'.code) { - if ( !found && chr == '0'.code && (i+1) < x.length ) + if (hasE) { - var next = getch(i+1); - if (next == 'x'.code || next == 'X'.code) - { - isHex = true; - i++; - } + hasEData = true; } found = true; } else switch (chr) { - case 'a'.code | 'b'.code | 'c'.code | 'd'.code | 'e'.code | 'f'.code - | 'A'.code | 'B'.code | 'C'.code | 'D'.code | 'E'.code | 'F'.code if (isHex): - //do nothing - it's alright case 'e'.code | 'E'.code if(!hasE): hasE = true; case '.'.code if (!hasDot): hasDot = true; - case '-'.code if (!found && !hasNeg): - hasNeg = true; - case '-'.code | '+'.code if (found && !hasESign && hasE): + case '-'.code, '+'.code if (!found && !hasSign): + hasSign = true; + case '-'.code | '+'.code if (found && !hasESign && hasE && !hasEData): hasESign = true; case _: break; } } + if (hasE && !hasEData) + { + i--; + if (hasESign) + i--; + } if (i != x.length) { x = x.substr(0,i); diff --git a/std/java/_std/Std.hx b/std/java/_std/Std.hx index 6624d01f98f..b1fff425162 100644 --- a/std/java/_std/Std.hx +++ b/std/java/_std/Std.hx @@ -138,7 +138,8 @@ import java.internal.Exceptions; public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); - var found = false, isHex = false, hasDot = false, hasE = false, hasNeg = false, hasESign = false; + var found = false, hasDot = false, hasSign = false, + hasE = false, hasESign = false, hasEData = false; var i = -1; inline function getch(i:Int):Int return cast (untyped x._charAt(i) : java.StdTypes.Char16); @@ -147,32 +148,31 @@ import java.internal.Exceptions; var chr = getch(i); if (chr >= '0'.code && chr <= '9'.code) { - if ( !found && chr == '0'.code && (i+1) < x.length ) + if (hasE) { - var next = getch(i+1); - if (next == 'x'.code || next == 'X'.code) - { - isHex = true; - i++; - } + hasEData = true; } found = true; } else switch (chr) { - case 'a'.code | 'b'.code | 'c'.code | 'd'.code | 'e'.code | 'f'.code - | 'A'.code | 'B'.code | 'C'.code | 'D'.code | 'E'.code | 'F'.code if (isHex): - //do nothing - it's alright case 'e'.code | 'E'.code if(!hasE): hasE = true; case '.'.code if (!hasDot): hasDot = true; - case '-'.code if (!found && !hasNeg): - hasNeg = true; - case '-'.code | '+'.code if (found && !hasESign && hasE): + case '-'.code, '+'.code if (!found && !hasSign): + hasSign = true; + case '-'.code | '+'.code if (found && !hasESign && hasE && !hasEData): hasESign = true; case _: break; } } + if (hasE && !hasEData) + { + i--; + if (hasESign) + i--; + } + if (i != x.length) { x = x.substr(0,i); From 0fd2ca423d97eb5492de37cd1f1aecd9266744d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Wed, 29 Apr 2015 16:19:26 -0300 Subject: [PATCH 173/209] [tests] Disable #4132 tests for now --- tests/unit/src/unitstd/Std.unit.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/src/unitstd/Std.unit.hx b/tests/unit/src/unitstd/Std.unit.hx index 386d9cd1527..985ffcfb3fa 100644 --- a/tests/unit/src/unitstd/Std.unit.hx +++ b/tests/unit/src/unitstd/Std.unit.hx @@ -88,8 +88,8 @@ Std.parseFloat("2.426670815e+12") == 2.426670815e+12; Std.parseFloat("2.426670815E+12") == 2.426670815e+12; Std.parseFloat("2.426670815e-12") == 2.426670815e-12; Std.parseFloat("2.426670815E-12") == 2.426670815e-12; -Std.parseInt("0x C") == 0; -Std.parseInt("0x+A") == 0; +// Std.parseInt("0x C") == 0; +// Std.parseInt("0x+A") == 0; // random var x = Std.random(2); From ca94d7891e8e4d583dbf7c90527155db4a8239d9 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Thu, 30 Apr 2015 11:26:27 -0400 Subject: [PATCH 174/209] Add missing ArrayAccess to some js.html types. Fixes #4168. --- std/js/html/ApplicationCache.hx | 2 +- std/js/html/AudioTrackList.hx | 2 +- std/js/html/FontFaceSet.hx | 2 +- std/js/html/FormElement.hx | 2 +- std/js/html/HTMLAllCollection.hx | 2 +- std/js/html/SourceBufferList.hx | 2 +- std/js/html/TextTrackCueList.hx | 2 +- std/js/html/TextTrackList.hx | 2 +- std/js/html/VideoTrackList.hx | 2 +- std/js/html/svg/StringList.hx | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/std/js/html/ApplicationCache.hx b/std/js/html/ApplicationCache.hx index a7ddda8c0cb..716bda8854c 100644 --- a/std/js/html/ApplicationCache.hx +++ b/std/js/html/ApplicationCache.hx @@ -25,7 +25,7 @@ package js.html; @:native("ApplicationCache") -extern class ApplicationCache extends EventTarget +extern class ApplicationCache extends EventTarget implements ArrayAccess { static inline var UNCACHED : Int = 0; static inline var IDLE : Int = 1; diff --git a/std/js/html/AudioTrackList.hx b/std/js/html/AudioTrackList.hx index d018cf5b645..8e8baa1ae33 100644 --- a/std/js/html/AudioTrackList.hx +++ b/std/js/html/AudioTrackList.hx @@ -25,7 +25,7 @@ package js.html; @:native("AudioTrackList") -extern class AudioTrackList extends EventTarget +extern class AudioTrackList extends EventTarget implements ArrayAccess { var length(default,null) : Int; var onchange : haxe.Constraints.Function; diff --git a/std/js/html/FontFaceSet.hx b/std/js/html/FontFaceSet.hx index 53301331bed..087b1967e40 100644 --- a/std/js/html/FontFaceSet.hx +++ b/std/js/html/FontFaceSet.hx @@ -25,7 +25,7 @@ package js.html; @:native("FontFaceSet") -extern class FontFaceSet extends EventTarget +extern class FontFaceSet extends EventTarget implements ArrayAccess { var onloading : haxe.Constraints.Function; var onloadingdone : haxe.Constraints.Function; diff --git a/std/js/html/FormElement.hx b/std/js/html/FormElement.hx index 1b0e7c724c1..68002c2e2e4 100644 --- a/std/js/html/FormElement.hx +++ b/std/js/html/FormElement.hx @@ -25,7 +25,7 @@ package js.html; @:native("HTMLFormElement") -extern class FormElement extends Element +extern class FormElement extends Element implements ArrayAccess { var acceptCharset : String; var action : String; diff --git a/std/js/html/HTMLAllCollection.hx b/std/js/html/HTMLAllCollection.hx index eb1671d6143..2990f2804cf 100644 --- a/std/js/html/HTMLAllCollection.hx +++ b/std/js/html/HTMLAllCollection.hx @@ -25,7 +25,7 @@ package js.html; @:native("HTMLAllCollection") -extern class HTMLAllCollection +extern class HTMLAllCollection implements ArrayAccess { var length(default,null) : Int; diff --git a/std/js/html/SourceBufferList.hx b/std/js/html/SourceBufferList.hx index e9b33b2280e..cce04cbb09f 100644 --- a/std/js/html/SourceBufferList.hx +++ b/std/js/html/SourceBufferList.hx @@ -25,7 +25,7 @@ package js.html; @:native("SourceBufferList") -extern class SourceBufferList extends EventTarget +extern class SourceBufferList extends EventTarget implements ArrayAccess { var length(default,null) : Int; diff --git a/std/js/html/TextTrackCueList.hx b/std/js/html/TextTrackCueList.hx index 000e70ffe6a..e26669f836b 100644 --- a/std/js/html/TextTrackCueList.hx +++ b/std/js/html/TextTrackCueList.hx @@ -25,7 +25,7 @@ package js.html; @:native("TextTrackCueList") -extern class TextTrackCueList +extern class TextTrackCueList implements ArrayAccess { var length(default,null) : Int; diff --git a/std/js/html/TextTrackList.hx b/std/js/html/TextTrackList.hx index 17b38fbbbf3..641380edebf 100644 --- a/std/js/html/TextTrackList.hx +++ b/std/js/html/TextTrackList.hx @@ -25,7 +25,7 @@ package js.html; @:native("TextTrackList") -extern class TextTrackList extends EventTarget +extern class TextTrackList extends EventTarget implements ArrayAccess { var length(default,null) : Int; var onchange : haxe.Constraints.Function; diff --git a/std/js/html/VideoTrackList.hx b/std/js/html/VideoTrackList.hx index 1adf8ebe549..6f98780f32f 100644 --- a/std/js/html/VideoTrackList.hx +++ b/std/js/html/VideoTrackList.hx @@ -25,7 +25,7 @@ package js.html; @:native("VideoTrackList") -extern class VideoTrackList extends EventTarget +extern class VideoTrackList extends EventTarget implements ArrayAccess { var length(default,null) : Int; var selectedIndex(default,null) : Int; diff --git a/std/js/html/svg/StringList.hx b/std/js/html/svg/StringList.hx index e1d0919f6cb..43ce3b09682 100644 --- a/std/js/html/svg/StringList.hx +++ b/std/js/html/svg/StringList.hx @@ -25,7 +25,7 @@ package js.html.svg; @:native("SVGStringList") -extern class StringList +extern class StringList implements ArrayAccess { var length(default,null) : Int; var numberOfItems(default,null) : Int; From 86e940912fe93e5278bae8241d7e8a2960025cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Thu, 30 Apr 2015 13:17:44 -0300 Subject: [PATCH 175/209] [cs] Fix is_hxgen/generic test for abstracts that have an implementation Closes #3711 --- gencommon.ml | 6 +++++- tests/unit/src/unit/issues/Issue3711.hx | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/unit/src/unit/issues/Issue3711.hx diff --git a/gencommon.ml b/gencommon.ml index 889a50af37d..413d35e5fd9 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -1606,8 +1606,10 @@ struct | TAbstractDecl a -> (match follow a.a_this with | TInst _ | TEnum _ | TAbstract _ -> default_hxgen_func (t_to_md (follow a.a_this)) + | TDynamic _ | TFun _ -> + true | _ -> - Meta.has Meta.NativeGen a.a_meta) + not (Meta.has Meta.NativeGen a.a_meta)) | TTypeDecl t -> (* TODO see when would we use this *) false @@ -4235,6 +4237,7 @@ struct | TEnum(e,_) -> follow_all_md (TEnumDecl e) | TAbstract(a,_) -> follow_all_md (TAbstractDecl a) | TType(t,_) -> follow_all_md (TTypeDecl t) + | TDynamic _ -> Some (TClassDecl (null_class)) | _ -> None) | TTypeDecl t -> ( match follow (apply_params t.t_params (List.map snd t.t_params) t.t_type) with @@ -4242,6 +4245,7 @@ struct | TEnum(e,_) -> follow_all_md (TEnumDecl e) | TAbstract(a,_) -> follow_all_md (TAbstractDecl a) | TType(t,_) -> follow_all_md (TTypeDecl t) + | TDynamic _ -> Some (TClassDecl (null_class)) | _ -> None) | md -> Some md diff --git a/tests/unit/src/unit/issues/Issue3711.hx b/tests/unit/src/unit/issues/Issue3711.hx new file mode 100644 index 00000000000..f280e731550 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue3711.hx @@ -0,0 +1,15 @@ +package unit.issues; + +private abstract A(haxe.DynamicAccess) { + public function f():Array return []; +} + +class Issue3711 extends Test { + public function test() + { + var a:A = null; + var k = a.f(); + eq(k[0],null); + eq(k.length,0); + } +} From 0755698455a1ee0f4441efbeece3a0739546e683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Thu, 30 Apr 2015 14:37:37 -0300 Subject: [PATCH 176/209] [cs] Make sure abstracts are followed correctly on is_hxgeneric. Fixes how some abstracts to Dynamic were being treated as hxgeneric. See #3711 and 86e940912fe93e5278bae8241d7e8a2960025cf8 --- gencommon.ml | 58 +++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/gencommon.ml b/gencommon.ml index 413d35e5fd9..0e663a21679 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -1606,8 +1606,6 @@ struct | TAbstractDecl a -> (match follow a.a_this with | TInst _ | TEnum _ | TAbstract _ -> default_hxgen_func (t_to_md (follow a.a_this)) - | TDynamic _ | TFun _ -> - true | _ -> not (Meta.has Meta.NativeGen a.a_meta)) | TTypeDecl t -> (* TODO see when would we use this *) @@ -4226,28 +4224,19 @@ struct | _ -> false let rec follow_all_md md = - match md with - | TClassDecl { cl_kind = KAbstractImpl a } -> - follow_all_md (TAbstractDecl a) - | TAbstractDecl a -> if Meta.has Meta.CoreType a.a_meta then - None - else ( - match follow (apply_params a.a_params (List.map snd a.a_params) a.a_this) with - | TInst(c,_) -> follow_all_md (TClassDecl c) - | TEnum(e,_) -> follow_all_md (TEnumDecl e) - | TAbstract(a,_) -> follow_all_md (TAbstractDecl a) - | TType(t,_) -> follow_all_md (TTypeDecl t) - | TDynamic _ -> Some (TClassDecl (null_class)) - | _ -> None) - | TTypeDecl t -> ( - match follow (apply_params t.t_params (List.map snd t.t_params) t.t_type) with - | TInst(c,_) -> follow_all_md (TClassDecl c) - | TEnum(e,_) -> follow_all_md (TEnumDecl e) - | TAbstract(a,_) -> follow_all_md (TAbstractDecl a) - | TType(t,_) -> follow_all_md (TTypeDecl t) - | TDynamic _ -> Some (TClassDecl (null_class)) - | _ -> None) - | md -> Some md + let t = match md with + | TClassDecl { cl_kind = KAbstractImpl a } -> + TAbstract(a, List.map snd a.a_params) + | TClassDecl c -> + TInst(c, List.map snd c.cl_params) + | TEnumDecl e -> + TEnum(e, List.map snd e.e_params) + | TTypeDecl t -> + TType(t, List.map snd t.t_params) + | TAbstractDecl a -> + TAbstract(a, List.map snd a.a_params) + in + Abstract.follow_with_abstracts t let rec is_hxgeneric md = match md with @@ -4257,9 +4246,13 @@ struct not (Meta.has Meta.NativeGeneric cl.cl_meta) | TEnumDecl(e) -> not (Meta.has Meta.NativeGeneric e.e_meta) + | TAbstractDecl(a) when Meta.has Meta.NativeGeneric a.a_meta -> + not (Meta.has Meta.NativeGeneric a.a_meta) | md -> match follow_all_md md with - | Some md -> is_hxgeneric md - | None -> true + | TInst(cl,_) -> is_hxgeneric (TClassDecl cl) + | TEnum(e,_) -> is_hxgeneric (TEnumDecl e) + | TAbstract(a,_) -> not (Meta.has Meta.NativeGeneric a.a_meta) + | _ -> true let rec set_hxgeneric gen mds isfirst md = let path = t_path md in @@ -4395,11 +4388,16 @@ struct let set_hxgeneric gen md = let ret = match md with | TClassDecl { cl_kind = KAbstractImpl a } -> (match follow_all_md md with - | Some md -> + | (TInst _ | TEnum _ as t) -> ( + let md = match t with + | TInst(cl,_) -> TClassDecl cl + | TEnum(e,_) -> TEnumDecl e + | _ -> assert false + in let ret = set_hxgeneric gen [] true md in - if ret = None then get (set_hxgeneric gen [] false md) else get ret - | None -> - true) + if ret = None then get (set_hxgeneric gen [] false md) else get ret) + | TAbstract(a,_) -> true + | _ -> true) | _ -> match set_hxgeneric gen [] true md with | None -> get (set_hxgeneric gen [] false md) From d99b6521f8d8c65ca5a41be297d4372abdf4f24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Thu, 30 Apr 2015 15:08:04 -0300 Subject: [PATCH 177/209] [cs] Make arrayAlloc inline. See #3946 --- std/cs/Lib.hx | 2 +- tests/unit/src/unit/issues/Issue3946.hx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/std/cs/Lib.hx b/std/cs/Lib.hx index b7f7f87f1ab..b884dfe2b3a 100644 --- a/std/cs/Lib.hx +++ b/std/cs/Lib.hx @@ -166,7 +166,7 @@ class Lib /** Allocates a new Haxe Array with a predetermined size **/ - public static function arrayAlloc(size:Int):Array + inline public static function arrayAlloc(size:Int):Array { return @:privateAccess Array.alloc(size); } diff --git a/tests/unit/src/unit/issues/Issue3946.hx b/tests/unit/src/unit/issues/Issue3946.hx index 17d902f9e28..3af912957d8 100644 --- a/tests/unit/src/unit/issues/Issue3946.hx +++ b/tests/unit/src/unit/issues/Issue3946.hx @@ -5,6 +5,8 @@ class Issue3946 extends Test { function test() { var arr = cs.Lib.arrayAlloc(10); eq(arr.length, 10); + arr[0] = 5; + eq(arr[0],5); } #end } From 8b72f276e470dc18e49251706cfa16a47dae5591 Mon Sep 17 00:00:00 2001 From: Hugh Date: Fri, 1 May 2015 13:55:18 +0800 Subject: [PATCH 178/209] [cpp] Some work on @:nativeGen. Fix unreflective in some cases. Add @:nonVirtual meta. --- ast.ml | 1 + common.ml | 1 + gencpp.ml | 148 +++++++++++++++++++++++++++++++++++------------------- 3 files changed, 99 insertions(+), 51 deletions(-) diff --git a/ast.ml b/ast.ml index ad25c1222a1..bcd6b95ec7e 100644 --- a/ast.ml +++ b/ast.ml @@ -122,6 +122,7 @@ module Meta = struct | NoDoc | NoExpr | NoImportGlobal + | NonVirtual | NoPackageRestrict | NoPrivateAccess | NoStack diff --git a/common.ml b/common.ml index 65dd192f868..b98dd2b1fdd 100644 --- a/common.ml +++ b/common.ml @@ -444,6 +444,7 @@ module MetaInfo = struct | NoDoc -> ":noDoc",("Prevents a type from being included in documentation generation",[]) | NoExpr -> ":noExpr",("Internally used to mark abstract fields which have no expression by design",[Internal]) | NoImportGlobal -> ":noImportGlobal",("Prevents a static field from being imported with import Class.*",[UsedOn TAnyField]) + | NonVirtual -> ":nonVirtual",("Declares function to be non-virtual in cpp",[Platform Cpp]) | NoPackageRestrict -> ":noPackageRestrict",("Allows a module to be accessed across all targets if found on its first type",[Internal]) | NoPrivateAccess -> ":noPrivateAccess",("Disallow private access to anything for the annotated expression",[UsedOn TExpr]) | NoStack -> ":noStack",("",[Platform Cpp]) diff --git a/gencpp.ml b/gencpp.ml index 1bb6d77bb04..1cd08d2afd6 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -883,6 +883,15 @@ let is_extern_class class_def = | _ -> false ); ;; + +let is_native_gen_class class_def = + (has_meta_key class_def.cl_meta Meta.NativeGen) || + (match class_def.cl_kind with + | KAbstractImpl abstract_def -> (has_meta_key abstract_def.a_meta Meta.NativeGen) + | _ -> false ); +;; + + let is_extern_class_instance obj = match follow obj.etype with | TInst (klass,params) -> klass.cl_extern @@ -2519,6 +2528,18 @@ let rec all_virtual_functions clazz = | _ -> [] ) ;; +let reflective class_def field = not ( + (Meta.has Meta.NativeGen class_def.cl_meta) || + (Meta.has Meta.Unreflective class_def.cl_meta) || + (Meta.has Meta.Unreflective field.cf_meta) || + (match field.cf_type with + | TInst (klass,_) -> Meta.has Meta.Unreflective klass.cl_meta + | _ -> false + ) +) +;; + + @@ -2538,6 +2559,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface let remap_name = keyword_remap field.cf_name in let decl = get_meta_string field.cf_meta Meta.Decl in let has_decl = decl <> "" in + let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in if (is_interface) then begin (* Just the dynamic glue - not even that ... *) () @@ -2550,7 +2572,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface let ret = if is_void then "(void)" else "return " in let output_i = ctx.ctx_writer#write_i in let orig_debug = ctx.ctx_debug_level in - let dump_src = if ((Meta.has Meta.NoStack field.cf_meta)||(Meta.has Meta.NoDebug field.cf_meta) || orig_debug<1) then begin + let dump_src = if ((Meta.has Meta.NoStack field.cf_meta)||(Meta.has Meta.NoDebug field.cf_meta) || orig_debug<1 || nativeGen) then begin ctx.ctx_debug_level <- 0; (fun()->()) end else begin @@ -2597,8 +2619,10 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface end; output "\n\n"; + let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in + let doDynamic = (nonVirtual || not (is_override class_def field.cf_name ) ) && (reflective class_def field ) in (* generate dynamic version too ... *) - if ( not (is_override class_def field.cf_name ) ) then begin + if ( doDynamic ) then begin if (is_static) then output "STATIC_"; output ("HX_DEFINE_DYNAMIC_FUNC" ^ nargs ^ "(" ^ class_name ^ "," ^ remap_name ^ "," ^ ret ^ ")\n\n"); @@ -2694,6 +2718,7 @@ let has_field_init field = let gen_member_def ctx class_def is_static is_interface field = let output = ctx.ctx_output in let remap_name = keyword_remap field.cf_name in + let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in if (is_interface) then begin match follow field.cf_type, field.cf_kind with @@ -2703,8 +2728,10 @@ let gen_member_def ctx class_def is_static is_interface field = output (" " ^ remap_name ^ "( " ); output (gen_tfun_interface_arg_list args); output (if (not is_static) then ")=0;\n" else ");\n"); - output (if is_static then "\t\tstatic " else "\t\t"); - output ("virtual Dynamic " ^ remap_name ^ "_dyn()=0;\n" ); + if not nativeGen then begin + output (if is_static then "\t\tstatic " else "\t\t"); + output ("virtual Dynamic " ^ remap_name ^ "_dyn()=0;\n" ); + end | _ -> ( ) end else begin let decl = get_meta_string field.cf_meta Meta.Decl in @@ -2714,8 +2741,10 @@ let gen_member_def ctx class_def is_static is_interface field = output (if is_static then "\t\tstatic " else "\t\t"); (match field.cf_expr with | Some { eexpr = TFunction function_def } -> + let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in + let doDynamic = (nonVirtual || not (is_override class_def field.cf_name ) ) && (reflective class_def field ) in if ( is_dynamic_haxe_method field ) then begin - if ( not (is_override class_def field.cf_name ) ) then begin + if ( doDynamic ) then begin output ("Dynamic " ^ remap_name ^ ";\n"); output (if is_static then "\t\tstatic " else "\t\t"); output ("inline Dynamic &" ^ remap_name ^ "_dyn() " ^ "{return " ^ remap_name^ "; }\n") @@ -2723,13 +2752,13 @@ let gen_member_def ctx class_def is_static is_interface field = end else begin let return_type = (type_string function_def.tf_type) in - if (not is_static) then output "virtual "; + if ( not is_static && not nonVirtual ) then output "virtual "; output (if return_type="Void" && (has_meta_key field.cf_meta Meta.Void) then "void" else return_type ); output (" " ^ remap_name ^ "( " ); output (gen_arg_list function_def.tf_args "" ); output ");\n"; - if ( not (is_override class_def field.cf_name ) ) then begin + if ( doDynamic ) then begin output (if is_static then "\t\tstatic " else "\t\t"); output ("Dynamic " ^ remap_name ^ "_dyn();\n" ) end; @@ -2745,6 +2774,7 @@ let gen_member_def ctx class_def is_static is_interface field = (* Add a "dyn" function for variable to unify variable/function access *) (match follow field.cf_type with + | _ when nativeGen -> () | TFun (_,_) -> output (if is_static then "\t\tstatic " else "\t\t"); gen_type ctx field.cf_type; @@ -2791,6 +2821,15 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de else if (not for_depends) && (has_meta_key klass.cl_meta Meta.Include) then add_type klass.cl_path in + let add_native_gen_class klass = + let include_file = get_meta_string_path klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in + if (include_file<>"") then + add_type ( path_of_string include_file ) + else if for_depends then + add_type klass.cl_path + else + add_type ( path_of_string ( (join_class_path klass.cl_path "/") ^ ".h") ) + in let visited = ref [] in let rec visit_type in_type = if not (List.exists (fun t2 -> Type.fast_eq in_type t2) !visited) then begin @@ -2805,6 +2844,7 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de | ([],"Array") | ([],"Class") | (["cpp"],"FastIterator") | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") | (["cpp"],"Function") | (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer") -> List.iter visit_type params + | _ when is_native_gen_class klass -> add_native_gen_class klass | _ when is_extern_class klass -> add_extern_class klass | _ -> (match klass.cl_kind with KTypeParameter _ -> () | _ -> add_type klass.cl_path); ) @@ -2821,6 +2861,7 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de (* Expand out TTypeExpr (ie, the name of a class, as used for static access etc ... *) (match expression.eexpr with | TTypeExpr type_def -> ( match type_def with + | TClassDecl class_def when is_native_gen_class class_def -> add_native_gen_class class_def | TClassDecl class_def when is_extern_class class_def -> add_extern_class class_def | _ -> add_type (t_path type_def) ) @@ -2883,7 +2924,10 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de List.iter visit_field (List.map (fun (a,_,_) -> a ) (all_virtual_functions class_def )); (* Add super & interfaces *) - add_type class_def.cl_path; + if is_native_gen_class class_def then + add_native_gen_class class_def + else + add_type class_def.cl_path; in let visit_enum enum_def = add_type enum_def.e_path; @@ -3361,15 +3405,6 @@ let is_writable class_def field = | _ -> true) ;; -let reflective class_def field = not ( - (Meta.has Meta.Unreflective class_def.cl_meta) || - (Meta.has Meta.Unreflective field.cf_meta) || - (match field.cf_type with - | TInst (klass,_) -> Meta.has Meta.Unreflective klass.cl_meta - | _ -> false - ) -) -;; let statics_except_meta class_def = (List.filter (fun static -> static.cf_name <> "__meta__" && static.cf_name <> "__rtti") class_def.cl_ordered_statics);; @@ -3436,7 +3471,8 @@ let access_str a = match a with let generate_class_files common_ctx member_types super_deps constructor_deps class_def file_info inScriptable = let class_path = class_def.cl_path in - let class_name = (snd class_path) ^ "_obj" in + let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in + let class_name = (snd class_path) ^ (if nativeGen then "" else "_obj") in let dot_name = join_class_path class_path "." in let smart_class_name = (snd class_path) in (*let cpp_file = new_cpp_file common_ctx.file class_path in*) @@ -3446,6 +3482,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla then 0 else 1 in let scriptable = inScriptable && not class_def.cl_private in let ctx = new_context common_ctx cpp_file debug file_info in + + ctx.ctx_class_name <- "::" ^ (join_class_path class_def.cl_path "::"); ctx.ctx_class_super_name <- (match class_def.cl_super with | Some (klass, params) -> class_string klass "_obj" params true @@ -3516,7 +3554,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_cpp ( get_class_code class_def Meta.CppNamespaceCode ); - if (not class_def.cl_interface) then begin + if (not class_def.cl_interface) && not nativeGen then begin output_cpp ("Void " ^ class_name ^ "::__construct(" ^ constructor_type_args ^ ")\n{\n"); (match class_def.cl_constructor with | Some definition -> @@ -3599,10 +3637,10 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla (gen_field ctx class_def class_name smart_class_name dot_name true class_def.cl_interface) statics_except_meta; output_cpp "\n"; - let override_iteration = has_new_gc_references class_def in + let override_iteration = (not nativeGen) && (has_new_gc_references class_def) in (* Initialise non-static variables *) - if (not class_def.cl_interface) then begin + if ( (not class_def.cl_interface) && (not nativeGen) ) then begin output_cpp (class_name ^ "::" ^ class_name ^ "()\n{\n"); if (implement_dynamic) then output_cpp "\tHX_INIT_IMPLEMENT_DYNAMIC;\n"; @@ -3878,25 +3916,27 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla "0 /* sMemberFields */"; in - (* Mark static variables as used *) - output_cpp "static void sMarkStatics(HX_MARK_PARAMS) {\n"; - output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); - List.iter (fun field -> - if (is_data_member field) then - output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) - implemented_fields; - output_cpp "};\n\n"; - - (* Visit static variables *) - output_cpp "#ifdef HXCPP_VISIT_ALLOCS\n"; - output_cpp "static void sVisitStatics(HX_VISIT_PARAMS) {\n"; - output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); - List.iter (fun field -> - if (is_data_member field) then - output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) - implemented_fields; - output_cpp "};\n\n"; - output_cpp "#endif\n\n"; + if (not nativeGen) then begin + (* Mark static variables as used *) + output_cpp "static void sMarkStatics(HX_MARK_PARAMS) {\n"; + output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); + List.iter (fun field -> + if (is_data_member field) then + output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) + implemented_fields; + output_cpp "};\n\n"; + + (* Visit static variables *) + output_cpp "#ifdef HXCPP_VISIT_ALLOCS\n"; + output_cpp "static void sVisitStatics(HX_VISIT_PARAMS) {\n"; + output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); + List.iter (fun field -> + if (is_data_member field) then + output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) + implemented_fields; + output_cpp "};\n\n"; + output_cpp "#endif\n\n"; + end; let script_type t optional = if optional then "Object" else match type_string t with @@ -3945,7 +3985,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla in - if (scriptable ) then begin + if (scriptable && not nativeGen) then begin let dump_script_field idx (field,f_args,return_t) = let args = if (class_def.cl_interface) then gen_tfun_interface_arg_list f_args @@ -4026,7 +4066,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla let class_name_text = join_class_path class_path "." in (* Initialise static in boot function ... *) - if (not class_def.cl_interface) then begin + if (not class_def.cl_interface && not nativeGen) then begin (* Remap the specialised "extern" classes back to the generic names *) output_cpp ("hx::Class " ^ class_name ^ "::__mClass;\n\n"); if (scriptable) then begin @@ -4071,7 +4111,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_cpp (" HX_SCRIPTABLE_REGISTER_CLASS(\""^class_name_text^"\"," ^ class_name ^ ");\n"); output_cpp ("}\n\n"); - end else begin + end else if not nativeGen then begin output_cpp ("hx::Class " ^ class_name ^ "::__mClass;\n\n"); output_cpp ("void " ^ class_name ^ "::__register()\n{\n"); @@ -4105,6 +4145,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla let h_file = new_header_file common_ctx common_ctx.file class_path in let super = match class_def.cl_super with | Some (klass,params) -> (class_string klass "_obj" params true) + | _ when nativeGen -> "" | _ -> if (class_def.cl_interface) then "hx::Interface" else "hx::Object" in let output_h = (h_file#write) in @@ -4141,12 +4182,17 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla let extern_class = Common.defined common_ctx Define.DllExport in let attribs = "HXCPP_" ^ (if extern_class then "EXTERN_" else "") ^ "CLASS_ATTRIBUTES " in - output_h ("class " ^ attribs ^ " " ^ class_name ^ " : public " ^ super ); - output_h "{\n\tpublic:\n"; - output_h ("\t\ttypedef " ^ super ^ " super;\n"); - output_h ("\t\ttypedef " ^ class_name ^ " OBJ_;\n"); + if (super="") then begin + output_h ("class " ^ attribs ^ " " ^ class_name); + output_h "{\n\tpublic:\n"; + end else begin + output_h ("class " ^ attribs ^ " " ^ class_name ^ " : public " ^ super ); + output_h "{\n\tpublic:\n"; + output_h ("\t\ttypedef " ^ super ^ " super;\n"); + output_h ("\t\ttypedef " ^ class_name ^ " OBJ_;\n"); + end; - if (not class_def.cl_interface) then begin + if (not class_def.cl_interface && not nativeGen) then begin output_h ("\t\t" ^ class_name ^ "();\n"); output_h ("\t\tVoid __construct(" ^ constructor_type_args ^ ");\n"); output_h "\n\tpublic:\n"; @@ -4193,7 +4239,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla if (has_init_field class_def) then output_h "\t\tstatic void __init__();\n\n"; output_h ("\t\t::String __ToString() const { return " ^ (str smart_class_name) ^ "; }\n\n"); - end else begin + end else if not nativeGen then begin output_h ("\t\tHX_DO_INTERFACE_RTTI;\n"); end; if (has_boot_field class_def) then @@ -4212,7 +4258,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla output_h ( get_class_code class_def Meta.HeaderClassCode ); output_h "};\n\n"; - if (class_def.cl_interface) then begin + if (class_def.cl_interface && not nativeGen) then begin output_h ("#define DELEGATE_" ^ (join_class_path class_path "_" ) ^ " \\\n"); List.iter (fun field -> match follow field.cf_type, field.cf_kind with @@ -5538,7 +5584,7 @@ let generate_source common_ctx = init_classes := class_def.cl_path :: !init_classes; if (has_boot_field class_def) then boot_classes := class_def.cl_path :: !boot_classes - else + else if not (has_meta_key class_def.cl_meta Meta.NativeGen) then nonboot_classes := class_def.cl_path :: !nonboot_classes; let deps = generate_class_files common_ctx member_types super_deps constructor_deps class_def file_info scriptable in From b381a8a3348a68320d587cbc38e76b8757968105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Fri, 1 May 2015 19:37:07 -0300 Subject: [PATCH 179/209] [java/cs] Sort captured variables so their generation is deterministic Closes #3659 --- gencommon.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gencommon.ml b/gencommon.ml index 0e663a21679..c36141a157c 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -3241,6 +3241,11 @@ struct (* get all captured variables it uses *) let captured_ht, tparams = get_captured fexpr in let captured = Hashtbl.fold (fun _ e acc -> e :: acc) captured_ht [] in + let captured = List.sort (fun e1 e2 -> match e1, e2 with + | { eexpr = TLocal v1 }, { eexpr = TLocal v2 } -> + compare v1.v_name v2.v_name + | _ -> assert false) captured + in (*let cltypes = List.map (fun cl -> (snd cl.cl_path, TInst(map_param cl, []) )) tparams in*) let cltypes = List.map (fun cl -> (snd cl.cl_path, TInst(cl, []) )) tparams in From 6b5fba8b94aa1455e8a5b41cb784f2617c62e1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Fri, 1 May 2015 20:16:23 -0300 Subject: [PATCH 180/209] [java] Forward static definitions to the underlying class. Closes #3987 --- std/java/lang/Boolean.hx | 15 +++ std/java/lang/Byte.hx | 15 +++ std/java/lang/Character.hx | 182 +++++++++++++++++++++++++++++++++++++ std/java/lang/Double.hx | 32 +++++++ std/java/lang/Float.hx | 32 +++++++ std/java/lang/Integer.hx | 29 ++++++ std/java/lang/Long.hx | 29 ++++++ std/java/lang/Short.hx | 16 ++++ 8 files changed, 350 insertions(+) diff --git a/std/java/lang/Boolean.hx b/std/java/lang/Boolean.hx index e0645cd9275..48448b50c1a 100644 --- a/std/java/lang/Boolean.hx +++ b/std/java/lang/Boolean.hx @@ -7,6 +7,21 @@ package java.lang; return this.booleanValue(); @:from @:extern inline public static function fromBool(b:Bool):Boolean return BooleanClass.valueOf(b); + + public static var FALSE(get,set):Boolean; + @:extern static inline function get_FALSE():Boolean return BooleanClass.FALSE; + @:extern static inline function set_FALSE(val:Boolean):Boolean return BooleanClass.FALSE = val; + public static var TRUE(get,set):Boolean; + @:extern static inline function get_TRUE():Boolean return BooleanClass.TRUE; + @:extern static inline function set_TRUE(val:Boolean):Boolean return BooleanClass.TRUE = val; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return BooleanClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return BooleanClass.TYPE = val; + @:extern @:overload inline public static function compare(param1:Bool, param2:Bool):Int return BooleanClass.compare(param1, param2); + @:extern @:overload inline public static function getBoolean(param1:String):Bool return BooleanClass.getBoolean(param1); + @:extern @:overload inline public static function parseBoolean(param1:String):Bool return BooleanClass.parseBoolean(param1); + @:extern @:overload inline public static function _toString(param1:Bool):String return BooleanClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:Bool):Boolean return BooleanClass.valueOf(param1); } @:native("java.lang.Boolean") extern class BooleanClass extends Number implements Comparable diff --git a/std/java/lang/Byte.hx b/std/java/lang/Byte.hx index b9557e941b2..6e130d5018f 100644 --- a/std/java/lang/Byte.hx +++ b/std/java/lang/Byte.hx @@ -7,6 +7,21 @@ package java.lang; return this.byteValue(); @:from @:extern inline public static function fromByte(b:java.types.Int8):Byte return ByteClass.valueOf(b); + + public static var MAX_VALUE(get,never):java.types.Int8; + @:extern static inline function get_MAX_VALUE():java.types.Int8 return ByteClass.MAX_VALUE; + public static var MIN_VALUE(get,never):java.types.Int8; + @:extern static inline function get_MIN_VALUE():java.types.Int8 return ByteClass.MIN_VALUE; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return ByteClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return ByteClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return ByteClass.TYPE = val; + @:extern @:overload inline public static function compare(param1:java.types.Int8, param2:java.types.Int8):Int return ByteClass.compare(param1, param2); + @:extern @:overload inline public static function decode(param1:String):Byte return ByteClass.decode(param1); + @:extern @:overload inline public static function parseByte(param1:String, param2:Int):java.types.Int8 return ByteClass.parseByte(param1, param2); + @:extern @:overload inline public static function _toString(param1:java.types.Int8):String return ByteClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:java.types.Int8):Byte return ByteClass.valueOf(param1); } @:native("java.lang.Byte") extern class ByteClass extends Number implements Comparable diff --git a/std/java/lang/Character.hx b/std/java/lang/Character.hx index a409fdb0f2d..adea71b7ab2 100644 --- a/std/java/lang/Character.hx +++ b/std/java/lang/Character.hx @@ -7,6 +7,188 @@ package java.lang; return this.charValue(); @:from @:extern inline public static function fromCharacter(b:java.types.Char16):Character return CharacterClass.valueOf(b); + + public static var COMBINING_SPACING_MARK(get,never):java.types.Char16; + @:extern static inline function get_COMBINING_SPACING_MARK():java.types.Char16 return CharacterClass.COMBINING_SPACING_MARK; + public static var CONNECTOR_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_CONNECTOR_PUNCTUATION():java.types.Char16 return CharacterClass.CONNECTOR_PUNCTUATION; + public static var CONTROL(get,never):java.types.Char16; + @:extern static inline function get_CONTROL():java.types.Char16 return CharacterClass.CONTROL; + public static var CURRENCY_SYMBOL(get,never):java.types.Char16; + @:extern static inline function get_CURRENCY_SYMBOL():java.types.Char16 return CharacterClass.CURRENCY_SYMBOL; + public static var DASH_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_DASH_PUNCTUATION():java.types.Char16 return CharacterClass.DASH_PUNCTUATION; + public static var DECIMAL_DIGIT_NUMBER(get,never):java.types.Char16; + @:extern static inline function get_DECIMAL_DIGIT_NUMBER():java.types.Char16 return CharacterClass.DECIMAL_DIGIT_NUMBER; + public static var DIRECTIONALITY_ARABIC_NUMBER(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_ARABIC_NUMBER():java.types.Char16 return CharacterClass.DIRECTIONALITY_ARABIC_NUMBER; + public static var DIRECTIONALITY_BOUNDARY_NEUTRAL(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_BOUNDARY_NEUTRAL():java.types.Char16 return CharacterClass.DIRECTIONALITY_BOUNDARY_NEUTRAL; + public static var DIRECTIONALITY_COMMON_NUMBER_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_COMMON_NUMBER_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR; + public static var DIRECTIONALITY_EUROPEAN_NUMBER(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER; + public static var DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR; + public static var DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR; + public static var DIRECTIONALITY_LEFT_TO_RIGHT(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT; + public static var DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING; + public static var DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE; + public static var DIRECTIONALITY_NONSPACING_MARK(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_NONSPACING_MARK():java.types.Char16 return CharacterClass.DIRECTIONALITY_NONSPACING_MARK; + public static var DIRECTIONALITY_OTHER_NEUTRALS(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_OTHER_NEUTRALS():java.types.Char16 return CharacterClass.DIRECTIONALITY_OTHER_NEUTRALS; + public static var DIRECTIONALITY_PARAGRAPH_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_PARAGRAPH_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_PARAGRAPH_SEPARATOR; + public static var DIRECTIONALITY_POP_DIRECTIONAL_FORMAT(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_POP_DIRECTIONAL_FORMAT():java.types.Char16 return CharacterClass.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT; + public static var DIRECTIONALITY_RIGHT_TO_LEFT(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT; + public static var DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; + public static var DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING; + public static var DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE; + public static var DIRECTIONALITY_SEGMENT_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_SEGMENT_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_SEGMENT_SEPARATOR; + public static var DIRECTIONALITY_UNDEFINED(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_UNDEFINED():java.types.Char16 return CharacterClass.DIRECTIONALITY_UNDEFINED; + public static var DIRECTIONALITY_WHITESPACE(get,never):java.types.Char16; + @:extern static inline function get_DIRECTIONALITY_WHITESPACE():java.types.Char16 return CharacterClass.DIRECTIONALITY_WHITESPACE; + public static var ENCLOSING_MARK(get,never):java.types.Char16; + @:extern static inline function get_ENCLOSING_MARK():java.types.Char16 return CharacterClass.ENCLOSING_MARK; + public static var END_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_END_PUNCTUATION():java.types.Char16 return CharacterClass.END_PUNCTUATION; + public static var FINAL_QUOTE_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_FINAL_QUOTE_PUNCTUATION():java.types.Char16 return CharacterClass.FINAL_QUOTE_PUNCTUATION; + public static var FORMAT(get,never):java.types.Char16; + @:extern static inline function get_FORMAT():java.types.Char16 return CharacterClass.FORMAT; + public static var INITIAL_QUOTE_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_INITIAL_QUOTE_PUNCTUATION():java.types.Char16 return CharacterClass.INITIAL_QUOTE_PUNCTUATION; + public static var LETTER_NUMBER(get,never):java.types.Char16; + @:extern static inline function get_LETTER_NUMBER():java.types.Char16 return CharacterClass.LETTER_NUMBER; + public static var LINE_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_LINE_SEPARATOR():java.types.Char16 return CharacterClass.LINE_SEPARATOR; + public static var LOWERCASE_LETTER(get,never):java.types.Char16; + @:extern static inline function get_LOWERCASE_LETTER():java.types.Char16 return CharacterClass.LOWERCASE_LETTER; + public static var MATH_SYMBOL(get,never):java.types.Char16; + @:extern static inline function get_MATH_SYMBOL():java.types.Char16 return CharacterClass.MATH_SYMBOL; + public static var MAX_CODE_POINT(get,never):Int; + @:extern static inline function get_MAX_CODE_POINT():Int return CharacterClass.MAX_CODE_POINT; + public static var MAX_HIGH_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MAX_HIGH_SURROGATE():java.types.Char16 return CharacterClass.MAX_HIGH_SURROGATE; + public static var MAX_LOW_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MAX_LOW_SURROGATE():java.types.Char16 return CharacterClass.MAX_LOW_SURROGATE; + public static var MAX_RADIX(get,never):Int; + @:extern static inline function get_MAX_RADIX():Int return CharacterClass.MAX_RADIX; + public static var MAX_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MAX_SURROGATE():java.types.Char16 return CharacterClass.MAX_SURROGATE; + public static var MAX_VALUE(get,never):java.types.Char16; + @:extern static inline function get_MAX_VALUE():java.types.Char16 return CharacterClass.MAX_VALUE; + public static var MIN_CODE_POINT(get,never):Int; + @:extern static inline function get_MIN_CODE_POINT():Int return CharacterClass.MIN_CODE_POINT; + public static var MIN_HIGH_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MIN_HIGH_SURROGATE():java.types.Char16 return CharacterClass.MIN_HIGH_SURROGATE; + public static var MIN_LOW_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MIN_LOW_SURROGATE():java.types.Char16 return CharacterClass.MIN_LOW_SURROGATE; + public static var MIN_RADIX(get,never):Int; + @:extern static inline function get_MIN_RADIX():Int return CharacterClass.MIN_RADIX; + public static var MIN_SUPPLEMENTARY_CODE_POINT(get,never):Int; + @:extern static inline function get_MIN_SUPPLEMENTARY_CODE_POINT():Int return CharacterClass.MIN_SUPPLEMENTARY_CODE_POINT; + public static var MIN_SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_MIN_SURROGATE():java.types.Char16 return CharacterClass.MIN_SURROGATE; + public static var MIN_VALUE(get,never):java.types.Char16; + @:extern static inline function get_MIN_VALUE():java.types.Char16 return CharacterClass.MIN_VALUE; + public static var MODIFIER_LETTER(get,never):java.types.Char16; + @:extern static inline function get_MODIFIER_LETTER():java.types.Char16 return CharacterClass.MODIFIER_LETTER; + public static var MODIFIER_SYMBOL(get,never):java.types.Char16; + @:extern static inline function get_MODIFIER_SYMBOL():java.types.Char16 return CharacterClass.MODIFIER_SYMBOL; + public static var NON_SPACING_MARK(get,never):java.types.Char16; + @:extern static inline function get_NON_SPACING_MARK():java.types.Char16 return CharacterClass.NON_SPACING_MARK; + public static var OTHER_LETTER(get,never):java.types.Char16; + @:extern static inline function get_OTHER_LETTER():java.types.Char16 return CharacterClass.OTHER_LETTER; + public static var OTHER_NUMBER(get,never):java.types.Char16; + @:extern static inline function get_OTHER_NUMBER():java.types.Char16 return CharacterClass.OTHER_NUMBER; + public static var OTHER_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_OTHER_PUNCTUATION():java.types.Char16 return CharacterClass.OTHER_PUNCTUATION; + public static var OTHER_SYMBOL(get,never):java.types.Char16; + @:extern static inline function get_OTHER_SYMBOL():java.types.Char16 return CharacterClass.OTHER_SYMBOL; + public static var PARAGRAPH_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_PARAGRAPH_SEPARATOR():java.types.Char16 return CharacterClass.PARAGRAPH_SEPARATOR; + public static var PRIVATE_USE(get,never):java.types.Char16; + @:extern static inline function get_PRIVATE_USE():java.types.Char16 return CharacterClass.PRIVATE_USE; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return CharacterClass.SIZE; + public static var SPACE_SEPARATOR(get,never):java.types.Char16; + @:extern static inline function get_SPACE_SEPARATOR():java.types.Char16 return CharacterClass.SPACE_SEPARATOR; + public static var START_PUNCTUATION(get,never):java.types.Char16; + @:extern static inline function get_START_PUNCTUATION():java.types.Char16 return CharacterClass.START_PUNCTUATION; + public static var SURROGATE(get,never):java.types.Char16; + @:extern static inline function get_SURROGATE():java.types.Char16 return CharacterClass.SURROGATE; + public static var TITLECASE_LETTER(get,never):java.types.Char16; + @:extern static inline function get_TITLECASE_LETTER():java.types.Char16 return CharacterClass.TITLECASE_LETTER; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return CharacterClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return CharacterClass.TYPE = val; + public static var UNASSIGNED(get,never):java.types.Char16; + @:extern static inline function get_UNASSIGNED():java.types.Char16 return CharacterClass.UNASSIGNED; + public static var UPPERCASE_LETTER(get,never):java.types.Char16; + @:extern static inline function get_UPPERCASE_LETTER():java.types.Char16 return CharacterClass.UPPERCASE_LETTER; + @:extern @:overload inline public static function charCount(param1:Int):Int return CharacterClass.charCount(param1); + @:extern @:overload inline public static function codePointAt(param1:CharSequence, param2:Int):Int return CharacterClass.codePointAt(param1, param2); + @:extern @:overload inline public static function codePointBefore(param1:CharSequence, param2:Int):Int return CharacterClass.codePointBefore(param1, param2); + @:extern @:overload inline public static function codePointCount(param1:CharSequence, param2:Int, param3:Int):Int return CharacterClass.codePointCount(param1, param2, param3); + @:extern @:overload inline public static function compare(param1:java.types.Char16, param2:java.types.Char16):Int return CharacterClass.compare(param1, param2); + @:extern @:overload inline public static function digit(param1:java.types.Char16, param2:Int):Int return CharacterClass.digit(param1, param2); + @:extern @:overload inline public static function forDigit(param1:Int, param2:Int):java.types.Char16 return CharacterClass.forDigit(param1, param2); + @:extern @:overload inline public static function getDirectionality(param1:java.types.Char16):java.types.Char16 return CharacterClass.getDirectionality(param1); + @:extern @:overload inline public static function getName(param1:Int):String return CharacterClass.getName(param1); + @:extern @:overload inline public static function getNumericValue(param1:java.types.Char16):Int return CharacterClass.getNumericValue(param1); + @:extern @:overload inline public static function getType(param1:java.types.Char16):Int return CharacterClass.getType(param1); + @:extern @:overload inline public static function highSurrogate(param1:Int):java.types.Char16 return CharacterClass.highSurrogate(param1); + @:extern @:overload inline public static function isAlphabetic(param1:Int):Bool return CharacterClass.isAlphabetic(param1); + @:extern @:overload inline public static function isBmpCodePoint(param1:Int):Bool return CharacterClass.isBmpCodePoint(param1); + @:extern @:overload inline public static function isDefined(param1:java.types.Char16):Bool return CharacterClass.isDefined(param1); + @:extern @:overload inline public static function isDigit(param1:java.types.Char16):Bool return CharacterClass.isDigit(param1); + @:extern @:overload inline public static function isHighSurrogate(param1:java.types.Char16):Bool return CharacterClass.isHighSurrogate(param1); + @:extern @:overload inline public static function isISOControl(param1:java.types.Char16):Bool return CharacterClass.isISOControl(param1); + @:extern @:overload inline public static function isIdentifierIgnorable(param1:java.types.Char16):Bool return CharacterClass.isIdentifierIgnorable(param1); + @:extern @:overload inline public static function isIdeographic(param1:Int):Bool return CharacterClass.isIdeographic(param1); + @:extern @:overload inline public static function isJavaIdentifierPart(param1:java.types.Char16):Bool return CharacterClass.isJavaIdentifierPart(param1); + @:extern @:overload inline public static function isJavaIdentifierStart(param1:java.types.Char16):Bool return CharacterClass.isJavaIdentifierStart(param1); + + + @:extern @:overload inline public static function isLetter(param1:java.types.Char16):Bool return CharacterClass.isLetter(param1); + @:extern @:overload inline public static function isLetterOrDigit(param1:java.types.Char16):Bool return CharacterClass.isLetterOrDigit(param1); + @:extern @:overload inline public static function isLowSurrogate(param1:java.types.Char16):Bool return CharacterClass.isLowSurrogate(param1); + @:extern @:overload inline public static function isLowerCase(param1:java.types.Char16):Bool return CharacterClass.isLowerCase(param1); + @:extern @:overload inline public static function isMirrored(param1:java.types.Char16):Bool return CharacterClass.isMirrored(param1); + + @:extern @:overload inline public static function isSpaceChar(param1:java.types.Char16):Bool return CharacterClass.isSpaceChar(param1); + @:extern @:overload inline public static function isSupplementaryCodePoint(param1:Int):Bool return CharacterClass.isSupplementaryCodePoint(param1); + @:extern @:overload inline public static function isSurrogate(param1:java.types.Char16):Bool return CharacterClass.isSurrogate(param1); + @:extern @:overload inline public static function isSurrogatePair(param1:java.types.Char16, param2:java.types.Char16):Bool return CharacterClass.isSurrogatePair(param1, param2); + @:extern @:overload inline public static function isTitleCase(param1:java.types.Char16):Bool return CharacterClass.isTitleCase(param1); + @:extern @:overload inline public static function isUnicodeIdentifierPart(param1:java.types.Char16):Bool return CharacterClass.isUnicodeIdentifierPart(param1); + @:extern @:overload inline public static function isUnicodeIdentifierStart(param1:java.types.Char16):Bool return CharacterClass.isUnicodeIdentifierStart(param1); + @:extern @:overload inline public static function isUpperCase(param1:java.types.Char16):Bool return CharacterClass.isUpperCase(param1); + @:extern @:overload inline public static function isValidCodePoint(param1:Int):Bool return CharacterClass.isValidCodePoint(param1); + @:extern @:overload inline public static function isWhitespace(param1:java.types.Char16):Bool return CharacterClass.isWhitespace(param1); + @:extern @:overload inline public static function lowSurrogate(param1:Int):java.types.Char16 return CharacterClass.lowSurrogate(param1); + @:extern @:overload inline public static function offsetByCodePoints(param1:CharSequence, param2:Int, param3:Int):Int return CharacterClass.offsetByCodePoints(param1, param2, param3); + @:extern @:overload inline public static function reverseBytes(param1:java.types.Char16):java.types.Char16 return CharacterClass.reverseBytes(param1); + @:extern @:overload inline public static function toChars(param1:Int, param2:java.NativeArray, param3:Int):Int return CharacterClass.toChars(param1, param2, param3); + @:extern @:overload inline public static function toCodePoint(param1:java.types.Char16, param2:java.types.Char16):Int return CharacterClass.toCodePoint(param1, param2); + @:extern @:overload inline public static function toLowerCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toLowerCase(param1); + @:extern @:overload inline public static function _toString(param1:java.types.Char16):String return CharacterClass._toString(param1); + @:extern @:overload inline public static function toTitleCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toTitleCase(param1); + @:extern @:overload inline public static function toUpperCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toUpperCase(param1); + @:extern @:overload inline public static function valueOf(param1:java.types.Char16):Character return CharacterClass.valueOf(param1); } @:native("java.lang.Character") extern class CharacterClass implements Comparable diff --git a/std/java/lang/Double.hx b/std/java/lang/Double.hx index ef8e41da73a..0ba3bc1e985 100644 --- a/std/java/lang/Double.hx +++ b/std/java/lang/Double.hx @@ -7,6 +7,38 @@ package java.lang; return this.doubleValue(); @:from @:extern inline public static function fromFloat(b:Float):Double return DoubleClass.valueOf(b); + + public static var MAX_EXPONENT(get,never):Int; + @:extern static inline function get_MAX_EXPONENT():Int return DoubleClass.MAX_EXPONENT; + public static var MAX_VALUE(get,never):Float; + @:extern static inline function get_MAX_VALUE():Float return DoubleClass.MAX_VALUE; + public static var MIN_EXPONENT(get,never):Int; + @:extern static inline function get_MIN_EXPONENT():Int return DoubleClass.MIN_EXPONENT; + public static var MIN_NORMAL(get,never):Float; + @:extern static inline function get_MIN_NORMAL():Float return DoubleClass.MIN_NORMAL; + public static var MIN_VALUE(get,never):Float; + @:extern static inline function get_MIN_VALUE():Float return DoubleClass.MIN_VALUE; + public static var NEGATIVE_INFINITY(get,never):Float; + @:extern static inline function get_NEGATIVE_INFINITY():Float return DoubleClass.NEGATIVE_INFINITY; + public static var NaN(get,never):Float; + @:extern static inline function get_NaN():Float return DoubleClass.NaN; + public static var POSITIVE_INFINITY(get,never):Float; + @:extern static inline function get_POSITIVE_INFINITY():Float return DoubleClass.POSITIVE_INFINITY; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return DoubleClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return DoubleClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return DoubleClass.TYPE = val; + @:extern @:overload inline public static function compare(param1:Float, param2:Float):Int return DoubleClass.compare(param1, param2); + @:extern @:overload inline public static function doubleToLongBits(param1:Float):haxe.Int64 return DoubleClass.doubleToLongBits(param1); + @:extern @:overload inline public static function doubleToRawLongBits(param1:Float):haxe.Int64 return DoubleClass.doubleToRawLongBits(param1); + @:extern @:overload inline public static function _isInfinite(param1:Float):Bool return DoubleClass._isInfinite(param1); + @:extern @:overload inline public static function _isNaN(param1:Float):Bool return DoubleClass._isNaN(param1); + @:extern @:overload inline public static function longBitsToDouble(param1:haxe.Int64):Float return DoubleClass.longBitsToDouble(param1); + @:extern @:overload inline public static function parseDouble(param1:String):Float return DoubleClass.parseDouble(param1); + @:extern @:overload inline public static function toHexString(param1:Float):String return DoubleClass.toHexString(param1); + @:extern @:overload inline public static function _toString(param1:Float):String return DoubleClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:String):Double return DoubleClass.valueOf(param1); } @:native("java.lang.Double") extern class DoubleClass extends Number implements Comparable diff --git a/std/java/lang/Float.hx b/std/java/lang/Float.hx index 89df8a44167..c3e62b6178a 100644 --- a/std/java/lang/Float.hx +++ b/std/java/lang/Float.hx @@ -7,6 +7,38 @@ package java.lang; return this.floatValue(); @:from @:extern inline public static function fromFloat(b:std.StdTypes.Single):Float return FloatClass.valueOf(b); + + public static var MAX_EXPONENT(get,never):Int; + @:extern static inline function get_MAX_EXPONENT():Int return FloatClass.MAX_EXPONENT; + public static var MAX_VALUE(get,never):Single; + @:extern static inline function get_MAX_VALUE():Single return FloatClass.MAX_VALUE; + public static var MIN_EXPONENT(get,never):Int; + @:extern static inline function get_MIN_EXPONENT():Int return FloatClass.MIN_EXPONENT; + public static var MIN_NORMAL(get,never):Single; + @:extern static inline function get_MIN_NORMAL():Single return FloatClass.MIN_NORMAL; + public static var MIN_VALUE(get,never):Single; + @:extern static inline function get_MIN_VALUE():Single return FloatClass.MIN_VALUE; + public static var NEGATIVE_INFINITY(get,never):Single; + @:extern static inline function get_NEGATIVE_INFINITY():Single return FloatClass.NEGATIVE_INFINITY; + public static var NaN(get,never):Single; + @:extern static inline function get_NaN():Single return FloatClass.NaN; + public static var POSITIVE_INFINITY(get,never):Single; + @:extern static inline function get_POSITIVE_INFINITY():Single return FloatClass.POSITIVE_INFINITY; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return FloatClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return FloatClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return FloatClass.TYPE = val; + @:extern @:overload inline public static function compare(param1:Single, param2:Single):Int return FloatClass.compare(param1, param2); + @:extern @:overload inline public static function floatToIntBits(param1:Single):Int return FloatClass.floatToIntBits(param1); + @:extern @:overload inline public static function floatToRawIntBits(param1:Single):Int return FloatClass.floatToRawIntBits(param1); + @:extern @:overload inline public static function intBitsToFloat(param1:Int):Single return FloatClass.intBitsToFloat(param1); + @:extern @:overload inline public static function _isInfinite(param1:Single):Bool return FloatClass._isInfinite(param1); + @:extern @:overload inline public static function _isNaN(param1:Single):Bool return FloatClass._isNaN(param1); + @:extern @:overload inline public static function parseFloat(param1:String):Single return FloatClass.parseFloat(param1); + @:extern @:overload inline public static function toHexString(param1:Single):String return FloatClass.toHexString(param1); + @:extern @:overload inline public static function _toString(param1:Single):String return FloatClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:String):Float return FloatClass.valueOf(param1); } @:native("java.lang.Float") extern class FloatClass extends Number implements Comparable diff --git a/std/java/lang/Integer.hx b/std/java/lang/Integer.hx index b4eddcaa0c4..b4576c24632 100644 --- a/std/java/lang/Integer.hx +++ b/std/java/lang/Integer.hx @@ -7,6 +7,35 @@ package java.lang; return this.intValue(); @:from @:extern inline public static function fromInt(b:Int):Integer return IntegerClass.valueOf(b); + + public static var MAX_VALUE(get,never):Int; + @:extern static inline function get_MAX_VALUE():Int return IntegerClass.MAX_VALUE; + public static var MIN_VALUE(get,never):Int; + @:extern static inline function get_MIN_VALUE():Int return IntegerClass.MIN_VALUE; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return IntegerClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return IntegerClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return IntegerClass.TYPE = val; + @:extern @:overload inline public static function bitCount(param1:Int):Int return IntegerClass.bitCount(param1); + @:extern @:overload inline public static function compare(param1:Int, param2:Int):Int return IntegerClass.compare(param1, param2); + @:extern @:overload inline public static function decode(param1:String):Integer return IntegerClass.decode(param1); + @:extern @:overload inline public static function getInteger(param1:String):Integer return IntegerClass.getInteger(param1); + @:extern @:overload inline public static function highestOneBit(param1:Int):Int return IntegerClass.highestOneBit(param1); + @:extern @:overload inline public static function lowestOneBit(param1:Int):Int return IntegerClass.lowestOneBit(param1); + @:extern @:overload inline public static function numberOfLeadingZeros(param1:Int):Int return IntegerClass.numberOfLeadingZeros(param1); + @:extern @:overload inline public static function numberOfTrailingZeros(param1:Int):Int return IntegerClass.numberOfTrailingZeros(param1); + @:extern @:overload inline public static function parseInt(param1:String, param2:Int):Int return IntegerClass.parseInt(param1, param2); + @:extern @:overload inline public static function reverse(param1:Int):Int return IntegerClass.reverse(param1); + @:extern @:overload inline public static function reverseBytes(param1:Int):Int return IntegerClass.reverseBytes(param1); + @:extern @:overload inline public static function rotateLeft(param1:Int, param2:Int):Int return IntegerClass.rotateLeft(param1, param2); + @:extern @:overload inline public static function rotateRight(param1:Int, param2:Int):Int return IntegerClass.rotateRight(param1, param2); + @:extern @:overload inline public static function signum(param1:Int):Int return IntegerClass.signum(param1); + @:extern @:overload inline public static function toBinaryString(param1:Int):String return IntegerClass.toBinaryString(param1); + @:extern @:overload inline public static function toHexString(param1:Int):String return IntegerClass.toHexString(param1); + @:extern @:overload inline public static function toOctalString(param1:Int):String return IntegerClass.toOctalString(param1); + @:extern @:overload inline public static function _toString(param1:Int, param2:Int):String return IntegerClass._toString(param1, param2); + @:extern @:overload inline public static function valueOf(param1:String, param2:Int):Integer return IntegerClass.valueOf(param1, param2); } @:native("java.lang.Integer") extern class IntegerClass extends Number implements Comparable diff --git a/std/java/lang/Long.hx b/std/java/lang/Long.hx index ebf1bf1bd2c..a14c098d04a 100644 --- a/std/java/lang/Long.hx +++ b/std/java/lang/Long.hx @@ -7,6 +7,35 @@ package java.lang; return this.longValue(); @:from @:extern inline public static function fromLong(b:haxe.Int64):Long return LongClass.valueOf(b); + + public static var MAX_VALUE(get,never):haxe.Int64; + @:extern static inline function get_MAX_VALUE():haxe.Int64 return LongClass.MAX_VALUE; + public static var MIN_VALUE(get,never):haxe.Int64; + @:extern static inline function get_MIN_VALUE():haxe.Int64 return LongClass.MIN_VALUE; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return LongClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return LongClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return LongClass.TYPE = val; + @:extern @:overload inline public static function bitCount(param1:haxe.Int64):Int return LongClass.bitCount(param1); + @:extern @:overload inline public static function compare(param1:haxe.Int64, param2:haxe.Int64):Int return LongClass.compare(param1, param2); + @:extern @:overload inline public static function decode(param1:String):Long return LongClass.decode(param1); + @:extern @:overload inline public static function getLong(param1:String, param2:Long):Long return LongClass.getLong(param1, param2); + @:extern @:overload inline public static function highestOneBit(param1:haxe.Int64):haxe.Int64 return LongClass.highestOneBit(param1); + @:extern @:overload inline public static function lowestOneBit(param1:haxe.Int64):haxe.Int64 return LongClass.lowestOneBit(param1); + @:extern @:overload inline public static function numberOfLeadingZeros(param1:haxe.Int64):Int return LongClass.numberOfLeadingZeros(param1); + @:extern @:overload inline public static function numberOfTrailingZeros(param1:haxe.Int64):Int return LongClass.numberOfTrailingZeros(param1); + @:extern @:overload inline public static function parseLong(param1:String):haxe.Int64 return LongClass.parseLong(param1); + @:extern @:overload inline public static function reverse(param1:haxe.Int64):haxe.Int64 return LongClass.reverse(param1); + @:extern @:overload inline public static function reverseBytes(param1:haxe.Int64):haxe.Int64 return LongClass.reverseBytes(param1); + @:extern @:overload inline public static function rotateLeft(param1:haxe.Int64, param2:Int):haxe.Int64 return LongClass.rotateLeft(param1, param2); + @:extern @:overload inline public static function rotateRight(param1:haxe.Int64, param2:Int):haxe.Int64 return LongClass.rotateRight(param1, param2); + @:extern @:overload inline public static function signum(param1:haxe.Int64):Int return LongClass.signum(param1); + @:extern @:overload inline public static function toBinaryString(param1:haxe.Int64):String return LongClass.toBinaryString(param1); + @:extern @:overload inline public static function toHexString(param1:haxe.Int64):String return LongClass.toHexString(param1); + @:extern @:overload inline public static function toOctalString(param1:haxe.Int64):String return LongClass.toOctalString(param1); + @:extern @:overload inline public static function _toString(param1:haxe.Int64):String return LongClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:haxe.Int64):Long return LongClass.valueOf(param1); } @:native("java.lang.Long") extern class LongClass extends Number implements Comparable diff --git a/std/java/lang/Short.hx b/std/java/lang/Short.hx index 7affef47c2b..9719cfd2b0a 100644 --- a/std/java/lang/Short.hx +++ b/std/java/lang/Short.hx @@ -7,6 +7,22 @@ package java.lang; return this.shortValue(); @:from @:extern inline public static function fromShort(b:java.types.Int16):Short return ShortClass.valueOf(b); + + public static var MAX_VALUE(get,never):java.types.Int16; + @:extern static inline function get_MAX_VALUE():java.types.Int16 return ShortClass.MAX_VALUE; + public static var MIN_VALUE(get,never):java.types.Int16; + @:extern static inline function get_MIN_VALUE():java.types.Int16 return ShortClass.MIN_VALUE; + public static var SIZE(get,never):Int; + @:extern static inline function get_SIZE():Int return ShortClass.SIZE; + public static var TYPE(get,set):Class; + @:extern static inline function get_TYPE():Class return ShortClass.TYPE; + @:extern static inline function set_TYPE(val:Class):Class return ShortClass.TYPE = val; + @:extern @:overload inline public static function compare(param1:java.types.Int16, param2:java.types.Int16):Int return ShortClass.compare(param1, param2); + @:extern @:overload inline public static function decode(param1:String):Short return ShortClass.decode(param1); + @:extern @:overload inline public static function parseShort(param1:String, param2:Int):java.types.Int16 return ShortClass.parseShort(param1, param2); + @:extern @:overload inline public static function reverseBytes(param1:java.types.Int16):java.types.Int16 return ShortClass.reverseBytes(param1); + @:extern @:overload inline public static function _toString(param1:java.types.Int16):String return ShortClass._toString(param1); + @:extern @:overload inline public static function valueOf(param1:String, param2:Int):Short return ShortClass.valueOf(param1, param2); } @:native("java.lang.Short") extern class ShortClass extends Number implements Comparable From 34d5816d2a49f8fa7120f7bb86b0e925eef7b184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Waneck?= Date: Fri, 1 May 2015 20:30:14 -0300 Subject: [PATCH 181/209] [java/cs] Do a deep follow on infer_params, and take off all unneeded abstracts Closes #3850 --- gencommon.ml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gencommon.ml b/gencommon.ml index c36141a157c..cd039e59d8a 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -4145,6 +4145,19 @@ struct let priority = max_dep -. 20. + let rec deep_follow gen t = match run_follow gen t with + | TInst(c,tl) -> + TInst(c,List.map (deep_follow gen) tl) + | TEnum(e,tl) -> + TEnum(e,List.map (deep_follow gen) tl) + | TAbstract(a,tl) -> + TAbstract(a,List.map (deep_follow gen) tl) + | TType(t,tl) -> + TType(t,List.map (deep_follow gen) tl) + | TFun(args,ret) -> + TFun(List.map (fun (n,o,t) -> n,o,deep_follow gen t) args, deep_follow gen ret) + | t -> t + (* this function will receive the original function argument, the applied function argument and the original function parameters. *) (* from this info, it will infer the applied tparams for the function *) (* this function is used by CastDetection module *) @@ -4160,8 +4173,8 @@ struct (try List.iter2 (fun a o -> - let o = run_follow gen o in - let a = run_follow gen a in + let o = deep_follow gen o in + let a = deep_follow gen a in unify a o (* type_eq EqStrict a o *) ) applied original From bf1fef4deb4ce67f1846e9e741c3c9dd6372a3ad Mon Sep 17 00:00:00 2001 From: hughsando Date: Sat, 2 May 2015 19:39:12 +0800 Subject: [PATCH 182/209] Disable most nativeGen tests for cpp --- tests/unit/src/unit/issues/Issue2304.hx | 2 +- tests/unit/src/unit/issues/Issue2380.hx | 2 +- tests/unit/src/unit/issues/Issue2570.hx | 2 +- tests/unit/src/unit/issues/Issue3217.hx | 10 ++++++++++ tests/unit/src/unit/issues/Issue3248.hx | 2 +- tests/unit/src/unit/issues/Issue3575.hx | 2 +- tests/unit/src/unit/issues/Issue4000.hx | 2 +- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/unit/src/unit/issues/Issue2304.hx b/tests/unit/src/unit/issues/Issue2304.hx index c396e31fad1..ffe940dd9b4 100644 --- a/tests/unit/src/unit/issues/Issue2304.hx +++ b/tests/unit/src/unit/issues/Issue2304.hx @@ -24,7 +24,7 @@ private class TestImpl extends BaseTest implements ITest } } -@:nativeGen +#if !cpp @:nativeGen #end private class BaseTest { public function new() diff --git a/tests/unit/src/unit/issues/Issue2380.hx b/tests/unit/src/unit/issues/Issue2380.hx index 855b05266f3..305fd43e4e8 100644 --- a/tests/unit/src/unit/issues/Issue2380.hx +++ b/tests/unit/src/unit/issues/Issue2380.hx @@ -9,7 +9,7 @@ class Issue2380 extends unit.Test } } -@:nativeGen private class SomeCls +#if !cpp @:nativeGen #end private class SomeCls { public function new():Void {} @:keep public function test(v) return v == null; diff --git a/tests/unit/src/unit/issues/Issue2570.hx b/tests/unit/src/unit/issues/Issue2570.hx index 8d6add9f7aa..5db0d2fa037 100644 --- a/tests/unit/src/unit/issues/Issue2570.hx +++ b/tests/unit/src/unit/issues/Issue2570.hx @@ -9,7 +9,7 @@ class Issue2570 extends unit.Test } } -@:nativeGen private class A +#if !cpp @:nativeGen #end private class A { public function new() { diff --git a/tests/unit/src/unit/issues/Issue3217.hx b/tests/unit/src/unit/issues/Issue3217.hx index 7fd3799d4a2..bf46343b847 100644 --- a/tests/unit/src/unit/issues/Issue3217.hx +++ b/tests/unit/src/unit/issues/Issue3217.hx @@ -4,12 +4,22 @@ class Issue3217 extends Test { public function test() { + #if (cpp && !cppia) + var t:NativeClassStruct = null; + #else var t:{ test:Int } = new NativeClass(); + #end t.test = 10; eq(t.test,10); } } +#if (cpp && !cppia) +@:native("cpp::Struct< ::unit::issues::_Issue3217::NativeClass>") +@:include("unit/issues/_Issue3217/NativeClass.h") +private extern class NativeClassStruct extends NativeClass { } +#end + @:nativeGen private class NativeClass { diff --git a/tests/unit/src/unit/issues/Issue3248.hx b/tests/unit/src/unit/issues/Issue3248.hx index 5e0017f5451..37e0ce59050 100644 --- a/tests/unit/src/unit/issues/Issue3248.hx +++ b/tests/unit/src/unit/issues/Issue3248.hx @@ -11,7 +11,7 @@ class Issue3248 extends Test { private class Foo {} -@:nativeGen private class Bar +#if !cpp @:nativeGen #end private class Bar { public var arr:Vector; public function new(arr) diff --git a/tests/unit/src/unit/issues/Issue3575.hx b/tests/unit/src/unit/issues/Issue3575.hx index eaa9d331b7c..bc7e6391167 100644 --- a/tests/unit/src/unit/issues/Issue3575.hx +++ b/tests/unit/src/unit/issues/Issue3575.hx @@ -8,7 +8,7 @@ class Issue3575 extends Test { } -@:nativeGen private class Base +#if !cpp @:nativeGen #end private class Base { #if (cs || java) @:overload #end public function getName() diff --git a/tests/unit/src/unit/issues/Issue4000.hx b/tests/unit/src/unit/issues/Issue4000.hx index 877e50257d0..1045f550128 100644 --- a/tests/unit/src/unit/issues/Issue4000.hx +++ b/tests/unit/src/unit/issues/Issue4000.hx @@ -21,7 +21,7 @@ class Issue4000 extends Test } } -@:nativeGen private class NativeGen +#if !cpp @:nativeGen #end private class NativeGen { public function new() { From 145066f5501115a7ac8c50195d33ded22f924c42 Mon Sep 17 00:00:00 2001 From: hughsando Date: Sat, 2 May 2015 23:12:57 +0800 Subject: [PATCH 183/209] [cpp] MethInine is considered a real function too --- gencpp.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index 1cd08d2afd6..f5638c54ef8 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -5211,7 +5211,7 @@ class script_writer common_ctx ctx filename asciiOut = let argN = (string_of_int (List.length arg_list)) ^ " " in let is_real_function field = match field.cf_kind with - | Method MethNormal -> true + | Method MethNormal | Method MethInline-> true | _ -> false; in let gen_call () = From b762cf956e77918200aff23b5cf7f4d33e304ed7 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Sun, 3 May 2015 23:28:56 +0800 Subject: [PATCH 184/209] temp fix to ocaml wodi installation until we switch to something else --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1f254fc4c5c..5933785f354 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,7 +27,8 @@ install: - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin" > log.txt || type log.txt' - - '%CYG_ROOT%/bin/bash -lc "wget -q http://ml.ignorelist.com/wodi/8/%WODI%.tar.xz -O /tmp/%WODI%.tar.xz" > log.txt || type log.txt' + # The archive is a dropbox hosted version of https://github.com/fdopen/godi-repo/issues/7#issuecomment-98480339 + - '%CYG_ROOT%/bin/bash -lc "wget -q https://dl.dropboxusercontent.com/u/2661116/wodi/%WODI%.tar.xz -O /tmp/%WODI%.tar.xz" > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf %WODI% && tar -xf %WODI%.tar.xz && bash %WODI%/install.sh" > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip" > log.txt || type log.txt' - 'set PATH=%PATH%;%CYG_ROOT%/opt/%WODI%/bin' From f1647e9b45426c0002ce460a6500ae8000353310 Mon Sep 17 00:00:00 2001 From: "A. Hauptmann" Date: Mon, 4 May 2015 19:35:50 +0000 Subject: [PATCH 185/209] Update appveyor.yml The most recent version of the mingw64* is incompatible with the pre-installed version of cygwin. You must either update cygwin or download an old version of mingw64*. 'godi_add godi-zip' should work as intended. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5933785f354..600f3320068 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ install: - cinst 7zip.commandline -y # Install ocaml using wodi - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - - '%CYG_ROOT%/setup.exe -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' + - '%CYG_ROOT%/setup.exe -g -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin" > log.txt || type log.txt' # The archive is a dropbox hosted version of https://github.com/fdopen/godi-repo/issues/7#issuecomment-98480339 - '%CYG_ROOT%/bin/bash -lc "wget -q https://dl.dropboxusercontent.com/u/2661116/wodi/%WODI%.tar.xz -O /tmp/%WODI%.tar.xz" > log.txt || type log.txt' From 4bb3b0fa78ffd77836ceae8aa7c8bbe8ccc959ad Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 6 May 2015 15:25:00 +0300 Subject: [PATCH 186/209] [cs] make StringTools.urlEncode consistent with other targets (as well as StringTools.urlDecode) --- std/StringTools.hx | 2 +- tests/unit/src/unit/TestMisc.hx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/std/StringTools.hx b/std/StringTools.hx index 16aad21413f..725c8e596a6 100644 --- a/std/StringTools.hx +++ b/std/StringTools.hx @@ -47,7 +47,7 @@ class StringTools { return untyped __java__("java.net.URLEncoder.encode(s, \"UTF-8\")") catch (e:Dynamic) throw e; #elseif cs - return untyped cs.system.Uri.EscapeUriString(s); + return untyped cs.system.Uri.EscapeDataString(s); #elseif python return python.lib.urllib.Parse.quote(s); #else diff --git a/tests/unit/src/unit/TestMisc.hx b/tests/unit/src/unit/TestMisc.hx index fc8045e1ad2..c5a81a73b98 100644 --- a/tests/unit/src/unit/TestMisc.hx +++ b/tests/unit/src/unit/TestMisc.hx @@ -323,6 +323,9 @@ class TestMisc extends Test { function testUrlEncode() { eq( StringTools.urlEncode("é"), "%C3%A9" ); eq( StringTools.urlDecode("%C3%A9"), "é" ); + + eq( StringTools.urlEncode("a/b+c"), "a%2Fb%2Bc"); + eq( StringTools.urlDecode("a%2Fb%2Bc"), "a/b+c"); } function opt1( ?x : Int, ?y : String ) { From f2129439ae7ffc623ebe3535ea1b060f23a372d3 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 6 May 2015 15:46:16 +0300 Subject: [PATCH 187/209] [python] fix StringTools.urlEncode to escape "/" symbol to be consistent with other targets --- std/StringTools.hx | 2 +- std/python/lib/urllib/Parse.hx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/std/StringTools.hx b/std/StringTools.hx index 725c8e596a6..23fb84d7db1 100644 --- a/std/StringTools.hx +++ b/std/StringTools.hx @@ -49,7 +49,7 @@ class StringTools { #elseif cs return untyped cs.system.Uri.EscapeDataString(s); #elseif python - return python.lib.urllib.Parse.quote(s); + return python.lib.urllib.Parse.quote(s, ""); #else return null; #end diff --git a/std/python/lib/urllib/Parse.hx b/std/python/lib/urllib/Parse.hx index 2070d2d5896..0fc6bfcb16e 100644 --- a/std/python/lib/urllib/Parse.hx +++ b/std/python/lib/urllib/Parse.hx @@ -23,6 +23,6 @@ package python.lib.urllib; @:pythonImport("urllib.parse") extern class Parse { - public static function quote (s:String):String; - public static function unquote (s:String):String; + static function quote(s:String, ?safe:String):String; + static function unquote(s:String):String; } \ No newline at end of file From 00be0ee039a0f36601e3dc4a2f62552f7c7b465e Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Wed, 6 May 2015 17:51:37 +0300 Subject: [PATCH 188/209] minor [skip ci] --- gencpp.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index f5638c54ef8..ce138b6665e 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -1,4 +1,4 @@ -(* gencommon.$(MODULE_EXT) +(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a From b464f40c18ef334bb3a2e1774690acdb4b12a8d9 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 6 May 2015 22:47:56 +0800 Subject: [PATCH 189/209] [AppVeyor] test cpp in separated build to avoid timeout Taking longer is better then timeout... --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 600f3320068..53b1b519339 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,9 @@ environment: WODI: wodi32 ADD_REVISION: 1 OCAMLOPT: ocamlopt.opt - TEST: "neko,cs,java,cpp,macro" + matrix: + - TEST: "neko,cs,java,macro" + - TEST: "cpp" skip_tags: true From 99f3d9a93f52006ff30d2c7be1ca65b4e45f9250 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Wed, 6 May 2015 23:13:48 +0800 Subject: [PATCH 190/209] update ci info --- tests/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index aa55fe995e2..660b68d6d9c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -23,8 +23,7 @@ To set up AppVeyor: 1. Head to AppVeyor, [add a new project](https://ci.appveyor.com/projects/new). 2. Select the forked repo under your account. - 3. The build worker provided by the AppVeyor free plan is very slow. In order to avoid reaching the 40 min build time limit for each build, it is recommanded to test only the targets you're interested. Go the *settings* page of the new project, select *Environment*. Click *Add variable* under *Environment variables*. Enter `TEST` in the *name* field, and a comma-seperated list of targets (e.g. `neko,macro`) in the *value* field. - 4. Push to the repo to trigger a new build. The build result should be available at `https://ci.appveyor.com/project//haxe`. + 3. Push to the repo to trigger a new build. The build result should be available at `https://ci.appveyor.com/project//haxe`. ### SauceLabs From f15de91f37fba893905b0056f313c4e1cdb01530 Mon Sep 17 00:00:00 2001 From: Hugh Date: Sat, 9 May 2015 17:24:28 +0800 Subject: [PATCH 191/209] [cpp] Fix dependencies for __boot__ class --- gencpp.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gencpp.ml b/gencpp.ml index ce138b6665e..e31e0aaf1b2 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -4354,7 +4354,7 @@ let write_resources common_ctx = -let write_build_data common_ctx filename classes main_deps build_extra extern_src exe_name = +let write_build_data common_ctx filename classes main_deps boot_deps build_extra extern_src exe_name = let buildfile = open_out filename in let include_prefix = get_include_prefix common_ctx true in let add_class_to_buildfile class_path deps = @@ -4376,7 +4376,7 @@ let write_build_data common_ctx filename classes main_deps build_extra extern_sr output_string buildfile "\n"; output_string buildfile "\n"; List.iter add_classdef_to_buildfile classes; - add_class_to_buildfile ( [] , "__boot__") []; + add_class_to_buildfile ( [] , "__boot__") boot_deps; add_class_to_buildfile ( [] , "__files__") []; add_class_to_buildfile ( [] , "__resources__") []; output_string buildfile "\n"; @@ -5754,7 +5754,7 @@ let generate_source common_ctx = | Some path -> (snd path) | _ -> "output" in - write_build_data common_ctx (common_ctx.file ^ "/Build.xml") !exe_classes !main_deps !build_xml !extern_src output_name; + write_build_data common_ctx (common_ctx.file ^ "/Build.xml") !exe_classes !main_deps (!boot_enums@ !boot_classes) !build_xml !extern_src output_name; let cmd_defines = ref "" in PMap.iter ( fun name value -> match name with | "true" | "sys" | "dce" | "cpp" | "debug" -> () From 88800484e14a13a5d9c824a9d98a6b763023b4a5 Mon Sep 17 00:00:00 2001 From: hughsando Date: Sat, 9 May 2015 21:15:11 +0800 Subject: [PATCH 192/209] [cpp] Do not store array values in temp variables in case this causes a copy operation. --- analyzer.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/analyzer.ml b/analyzer.ml index ced3a5f9455..e5933e37734 100644 --- a/analyzer.ml +++ b/analyzer.ml @@ -236,6 +236,7 @@ module Simplifier = struct with Exit -> begin match follow e.etype with | TAbstract({a_path = [],"Void"},_) -> true + | TInst ({ cl_path = [],"Array" }, _) when com.platform = Cpp -> true | _ -> false end in From 10e25d13d69140ac9934354fbacb1ae09325db39 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 10 May 2015 12:26:04 +0200 Subject: [PATCH 193/209] use Function code instead of global/window (close #4138) --- std/js/html/compat/ArrayBuffer.hx | 2 +- std/js/html/compat/DataView.hx | 2 +- std/js/html/compat/Float32Array.hx | 2 +- std/js/html/compat/Float64Array.hx | 2 +- std/js/html/compat/Uint8Array.hx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/std/js/html/compat/ArrayBuffer.hx b/std/js/html/compat/ArrayBuffer.hx index a38775d34a5..01f9c7d93b7 100644 --- a/std/js/html/compat/ArrayBuffer.hx +++ b/std/js/html/compat/ArrayBuffer.hx @@ -53,7 +53,7 @@ class ArrayBuffer { } static function __init__() untyped { - var ArrayBuffer = __js__('typeof(window) != "undefined" && window.ArrayBuffer') || __js__('typeof(global) != "undefined" && global.ArrayBuffer') || ArrayBuffer; + var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")"); if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10 } } \ No newline at end of file diff --git a/std/js/html/compat/DataView.hx b/std/js/html/compat/DataView.hx index bef1f6e54ff..da2a235d76a 100644 --- a/std/js/html/compat/DataView.hx +++ b/std/js/html/compat/DataView.hx @@ -138,7 +138,7 @@ class DataView { } static function __init__() untyped { - var DataView = __js__('typeof(window) != "undefined" && window.DataView') || (__js__('typeof(global) != "undefined" && global.DataView')) || DataView; + var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")"); } } \ No newline at end of file diff --git a/std/js/html/compat/Float32Array.hx b/std/js/html/compat/Float32Array.hx index 0e3cb3464c6..0b096f19977 100644 --- a/std/js/html/compat/Float32Array.hx +++ b/std/js/html/compat/Float32Array.hx @@ -103,7 +103,7 @@ class Float32Array { } static function __init__() untyped { - var Float32Array = __js__('typeof(window) != "undefined" && window.Float32Array') || (__js__('typeof(global) != "undefined" && global.Float32Array')) || _new; + var Float32Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? Float32Array : null\")") || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index f44a5c8c6b7..631f85e6803 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -110,7 +110,7 @@ class Float64Array { } static function __init__() untyped { - var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || __js__('typeof(window) != "undefined" && window.Float32Array && "notsupported"') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new; + var Float64Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? (typeof Float64Array != 'undefined' ? Float64Array : 'notsupported') : null\")") || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Uint8Array.hx b/std/js/html/compat/Uint8Array.hx index fa0caf45af0..a6ab2d457d1 100644 --- a/std/js/html/compat/Uint8Array.hx +++ b/std/js/html/compat/Uint8Array.hx @@ -94,7 +94,7 @@ class Uint8Array { } static function __init__() untyped { - var Uint8Array = __js__('typeof(window) != "undefined" && window.Uint8Array') || (__js__('typeof(global) != "undefined" && global.Uint8Array')) || _new; + var Uint8Array = untyped __js__("Function(\"return typeof Uint8Array != 'undefined' ? Uint8Array : null\")") || _new; } } \ No newline at end of file From 4307f762887618599d2ddde4d8fdfb6521ee2f57 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 10 May 2015 13:52:20 +0200 Subject: [PATCH 194/209] Revert 10e25d13d69140ac9934354fbacb1ae09325db39. --- std/js/html/compat/ArrayBuffer.hx | 2 +- std/js/html/compat/DataView.hx | 2 +- std/js/html/compat/Float32Array.hx | 2 +- std/js/html/compat/Float64Array.hx | 2 +- std/js/html/compat/Uint8Array.hx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/std/js/html/compat/ArrayBuffer.hx b/std/js/html/compat/ArrayBuffer.hx index 01f9c7d93b7..a38775d34a5 100644 --- a/std/js/html/compat/ArrayBuffer.hx +++ b/std/js/html/compat/ArrayBuffer.hx @@ -53,7 +53,7 @@ class ArrayBuffer { } static function __init__() untyped { - var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")"); + var ArrayBuffer = __js__('typeof(window) != "undefined" && window.ArrayBuffer') || __js__('typeof(global) != "undefined" && global.ArrayBuffer') || ArrayBuffer; if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10 } } \ No newline at end of file diff --git a/std/js/html/compat/DataView.hx b/std/js/html/compat/DataView.hx index da2a235d76a..bef1f6e54ff 100644 --- a/std/js/html/compat/DataView.hx +++ b/std/js/html/compat/DataView.hx @@ -138,7 +138,7 @@ class DataView { } static function __init__() untyped { - var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")"); + var DataView = __js__('typeof(window) != "undefined" && window.DataView') || (__js__('typeof(global) != "undefined" && global.DataView')) || DataView; } } \ No newline at end of file diff --git a/std/js/html/compat/Float32Array.hx b/std/js/html/compat/Float32Array.hx index 0b096f19977..0e3cb3464c6 100644 --- a/std/js/html/compat/Float32Array.hx +++ b/std/js/html/compat/Float32Array.hx @@ -103,7 +103,7 @@ class Float32Array { } static function __init__() untyped { - var Float32Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? Float32Array : null\")") || _new; + var Float32Array = __js__('typeof(window) != "undefined" && window.Float32Array') || (__js__('typeof(global) != "undefined" && global.Float32Array')) || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index 631f85e6803..f44a5c8c6b7 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -110,7 +110,7 @@ class Float64Array { } static function __init__() untyped { - var Float64Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? (typeof Float64Array != 'undefined' ? Float64Array : 'notsupported') : null\")") || _new; + var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || __js__('typeof(window) != "undefined" && window.Float32Array && "notsupported"') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Uint8Array.hx b/std/js/html/compat/Uint8Array.hx index a6ab2d457d1..fa0caf45af0 100644 --- a/std/js/html/compat/Uint8Array.hx +++ b/std/js/html/compat/Uint8Array.hx @@ -94,7 +94,7 @@ class Uint8Array { } static function __init__() untyped { - var Uint8Array = untyped __js__("Function(\"return typeof Uint8Array != 'undefined' ? Uint8Array : null\")") || _new; + var Uint8Array = __js__('typeof(window) != "undefined" && window.Uint8Array') || (__js__('typeof(global) != "undefined" && global.Uint8Array')) || _new; } } \ No newline at end of file From 54f700242598233477bb3fa7bdbf7e7b1259fe39 Mon Sep 17 00:00:00 2001 From: Gama11 Date: Sun, 10 May 2015 21:10:08 +0200 Subject: [PATCH 195/209] "Class not found" error msg should be "Type not found" This error is produced by invalid imports. A .hx module can contain any type (abstract, typedef, enum), not just classes. --- typecore.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typecore.ml b/typecore.ml index 72c5c979d5e..7b740a830d2 100644 --- a/typecore.ml +++ b/typecore.ml @@ -254,7 +254,7 @@ let unify_error_msg ctx = function msg let rec error_msg = function - | Module_not_found m -> "Class not found : " ^ Ast.s_type_path m + | Module_not_found m -> "Type not found : " ^ Ast.s_type_path m | Type_not_found (m,t) -> "Module " ^ Ast.s_type_path m ^ " does not define type " ^ t | Unify l -> let ctx = print_context() in From 01973ea67783aab8db0ca522bd030047cac7646b Mon Sep 17 00:00:00 2001 From: Gama11 Date: Mon, 11 May 2015 12:53:33 +0200 Subject: [PATCH 196/209] Replace "Class" with "Type" in deprecated list as well --- main.ml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/main.ml b/main.ml index 3c7c1a72f2e..9dbafc77dd8 100644 --- a/main.ml +++ b/main.ml @@ -122,25 +122,25 @@ let message ctx msg p = ctx.messages <- format msg p :: ctx.messages let deprecated = [ - "Class not found : IntIter","IntIter was renamed to IntIterator"; + "Type not found : IntIter","IntIter was renamed to IntIterator"; "EReg has no field customReplace","EReg.customReplace was renamed to EReg.map"; "#StringTools has no field isEOF","StringTools.isEOF was renamed to StringTools.isEof"; - "Class not found : haxe.BaseCode","haxe.BaseCode was moved to haxe.crypto.BaseCode"; - "Class not found : haxe.Md5","haxe.Md5 was moved to haxe.crypto.Md5"; - "Class not found : haxe.SHA1","haxe.SHA1 was moved to haxe.crypto.SHA1"; - "Class not found : Hash","Hash has been removed, use Map instead"; - "Class not found : IntHash","IntHash has been removed, use Map instead"; - "Class not found : haxe.FastList","haxe.FastList was moved to haxe.ds.GenericStack"; + "Type not found : haxe.BaseCode","haxe.BaseCode was moved to haxe.crypto.BaseCode"; + "Type not found : haxe.Md5","haxe.Md5 was moved to haxe.crypto.Md5"; + "Type not found : haxe.SHA1","haxe.SHA1 was moved to haxe.crypto.SHA1"; + "Type not found : Hash","Hash has been removed, use Map instead"; + "Type not found : IntHash","IntHash has been removed, use Map instead"; + "Type not found : haxe.FastList","haxe.FastList was moved to haxe.ds.GenericStack"; "#Std has no field format","Std.format has been removed, use single quote 'string ${escape}' syntax instead"; "Identifier 'EType' is not part of enum haxe.macro.ExprDef","EType has been removed, use EField instead"; "Identifier 'CType' is not part of enum haxe.macro.Constant","CType has been removed, use CIdent instead"; - "Class not found : haxe.rtti.Infos","Use @:rtti instead of implementing haxe.rtti.Infos"; - "Class not found : haxe.rtti.Generic","Use @:generic instead of implementing haxe.Generic"; - "Class not found : flash.utils.TypedDictionary","flash.utils.TypedDictionary has been removed, use Map instead"; - "Class not found : haxe.Stack", "haxe.Stack has been renamed to haxe.CallStack"; - "Class not found : neko.zip.Reader", "neko.zip.Reader has been removed, use haxe.zip.Reader instead"; - "Class not found : neko.zip.Writer", "neko.zip.Writer has been removed, use haxe.zip.Writer instead"; - "Class not found : haxe.Public", "Use @:publicFields instead of implementing or extending haxe.Public"; + "Type not found : haxe.rtti.Infos","Use @:rtti instead of implementing haxe.rtti.Infos"; + "Type not found : haxe.rtti.Generic","Use @:generic instead of implementing haxe.Generic"; + "Type not found : flash.utils.TypedDictionary","flash.utils.TypedDictionary has been removed, use Map instead"; + "Type not found : haxe.Stack", "haxe.Stack has been renamed to haxe.CallStack"; + "Type not found : neko.zip.Reader", "neko.zip.Reader has been removed, use haxe.zip.Reader instead"; + "Type not found : neko.zip.Writer", "neko.zip.Writer has been removed, use haxe.zip.Writer instead"; + "Type not found : haxe.Public", "Use @:publicFields instead of implementing or extending haxe.Public"; "#Xml has no field createProlog", "Xml.createProlog was renamed to Xml.createProcessingInstruction" ] From 22af519ad001af078c4c64d10df42980208e8843 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 11 May 2015 18:58:11 +0800 Subject: [PATCH 197/209] [cpp] Fix compile when no main is specified --- gencpp.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gencpp.ml b/gencpp.ml index e31e0aaf1b2..d69bdd16991 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -3013,7 +3013,7 @@ let generate_dummy_main common_ctx = let main_file = new_cpp_file common_ctx common_ctx.file ([],filename) in let output_main = (main_file#write) in generate_main_header output_main; - if is_main then output_main "\n#include \n\n"; generate_main_footer1 output_main; generate_main_footer2 output_main; main_file#close; From 3f4d4df0f31a4d85aac7477f74e15166780c1f46 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 11 May 2015 19:51:40 +0800 Subject: [PATCH 198/209] [cpp] Allow classes called 'String' in sub-packages --- gencpp.ml | 6 +++--- tests/unit/src/unit/hxcpp_issues/String.hx | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/unit/src/unit/hxcpp_issues/String.hx diff --git a/gencpp.ml b/gencpp.ml index d69bdd16991..27f6a0f0bde 100644 --- a/gencpp.ml +++ b/gencpp.ml @@ -3910,7 +3910,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla let sMemberFields = if List.length reflective_members>0 then begin output_cpp "static ::String sMemberFields[] = {\n"; List.iter dump_field_name reflective_members; - output_cpp "\tString(null()) };\n\n"; + output_cpp "\t::String(null()) };\n\n"; "sMemberFields" end else "0 /* sMemberFields */"; @@ -4083,7 +4083,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla let sStaticFields = if List.length reflective_statics > 0 then begin output_cpp "static ::String sStaticFields[] = {\n"; List.iter dump_field_name reflective_statics; - output_cpp "\tString(null()) };\n\n"; + output_cpp "\t::String(null()) };\n\n"; "sStaticFields"; end else "0 /* sStaticFields */" @@ -4346,7 +4346,7 @@ let write_resources common_ctx = incr idx; ) common_ctx.resources; - resource_file#write_i "{String(null()),0,0}"; + resource_file#write_i "{::String(null()),0,0}"; resource_file#end_block_line; resource_file#write ";\n\n"; resource_file#write "namespace hx { Resource *GetResources() { return __Resources; } } \n\n"; diff --git a/tests/unit/src/unit/hxcpp_issues/String.hx b/tests/unit/src/unit/hxcpp_issues/String.hx new file mode 100644 index 00000000000..6bc6e18c900 --- /dev/null +++ b/tests/unit/src/unit/hxcpp_issues/String.hx @@ -0,0 +1,13 @@ +package unit.hxcpp_issues; + +class String extends Test { + @:keep public static var x = 1; + @:keep public var y:Float; + @:keep public function z() return 1; + function test() { + y = 1.0; + t( Reflect.hasField(String, "x") ); + eq( Reflect.field(this, "y"),1.0); + eq( Reflect.field(this, "z")(),1); + } +} From 082467d75aa6894e53daac5b12184259e4c5d4d1 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 13:15:45 +0800 Subject: [PATCH 199/209] [unit test] should report result in checkDone or else the async tests will be ignored... --- tests/unit/src/unit/Test.hx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/unit/src/unit/Test.hx b/tests/unit/src/unit/Test.hx index fe85a059837..c646655a6f5 100644 --- a/tests/unit/src/unit/Test.hx +++ b/tests/unit/src/unit/Test.hx @@ -219,6 +219,20 @@ class Test { if( asyncWaits.length != 0 ) return; if( asyncCache.length == 0 ) { report("DONE ["+count+" tests]"); + trace("SUCCESS: " + success); + + //out.close(); + + #if js + if (js.Browser.supported) { + untyped js.Browser.window.success = success; + } + #end + + #if sys + Sys.exit(success ? 0 : 1); + #end + return; } resetTimer(); @@ -389,20 +403,6 @@ class Test { onError(e,"ABORTED",Type.getClassName(current)); } #end - - trace("SUCCESS: " + success); - - //out.close(); - - #if js - if (js.Browser.supported) { - untyped js.Browser.window.success = success; - } - #end - - #if sys - Sys.exit(success ? 0 : 1); - #end } } From 80e27f1898ccfcf46cf64e92bd5dc892336d1c5b Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 13:28:38 +0800 Subject: [PATCH 200/209] minor - use `report` instead of `trace` to print `SUCCESS:` --- tests/unit/src/unit/Test.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/src/unit/Test.hx b/tests/unit/src/unit/Test.hx index c646655a6f5..b6b146256ed 100644 --- a/tests/unit/src/unit/Test.hx +++ b/tests/unit/src/unit/Test.hx @@ -219,7 +219,7 @@ class Test { if( asyncWaits.length != 0 ) return; if( asyncCache.length == 0 ) { report("DONE ["+count+" tests]"); - trace("SUCCESS: " + success); + report("SUCCESS: " + success); //out.close(); From 5fc4f8d42cb303f60e13f0b94f7278e69be0ea98 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Mon, 11 May 2015 21:08:20 +0800 Subject: [PATCH 201/209] use Function() to access global stuffs (see #4138) --- std/js/html/compat/ArrayBuffer.hx | 2 +- std/js/html/compat/DataView.hx | 2 +- std/js/html/compat/Float32Array.hx | 2 +- std/js/html/compat/Float64Array.hx | 2 +- std/js/html/compat/Uint8Array.hx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/std/js/html/compat/ArrayBuffer.hx b/std/js/html/compat/ArrayBuffer.hx index a38775d34a5..cd8beeff7a3 100644 --- a/std/js/html/compat/ArrayBuffer.hx +++ b/std/js/html/compat/ArrayBuffer.hx @@ -53,7 +53,7 @@ class ArrayBuffer { } static function __init__() untyped { - var ArrayBuffer = __js__('typeof(window) != "undefined" && window.ArrayBuffer') || __js__('typeof(global) != "undefined" && global.ArrayBuffer') || ArrayBuffer; + var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")()"); if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10 } } \ No newline at end of file diff --git a/std/js/html/compat/DataView.hx b/std/js/html/compat/DataView.hx index bef1f6e54ff..4763f23fa03 100644 --- a/std/js/html/compat/DataView.hx +++ b/std/js/html/compat/DataView.hx @@ -138,7 +138,7 @@ class DataView { } static function __init__() untyped { - var DataView = __js__('typeof(window) != "undefined" && window.DataView') || (__js__('typeof(global) != "undefined" && global.DataView')) || DataView; + var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")()"); } } \ No newline at end of file diff --git a/std/js/html/compat/Float32Array.hx b/std/js/html/compat/Float32Array.hx index 0e3cb3464c6..7a0b782486d 100644 --- a/std/js/html/compat/Float32Array.hx +++ b/std/js/html/compat/Float32Array.hx @@ -103,7 +103,7 @@ class Float32Array { } static function __init__() untyped { - var Float32Array = __js__('typeof(window) != "undefined" && window.Float32Array') || (__js__('typeof(global) != "undefined" && global.Float32Array')) || _new; + var Float32Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? Float32Array : null\")()") || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index f44a5c8c6b7..b158e87d639 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -110,7 +110,7 @@ class Float64Array { } static function __init__() untyped { - var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || __js__('typeof(window) != "undefined" && window.Float32Array && "notsupported"') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new; + var Float64Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? (typeof Float64Array != 'undefined' ? Float64Array : 'notsupported') : null\")()") || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Uint8Array.hx b/std/js/html/compat/Uint8Array.hx index fa0caf45af0..98d84983237 100644 --- a/std/js/html/compat/Uint8Array.hx +++ b/std/js/html/compat/Uint8Array.hx @@ -94,7 +94,7 @@ class Uint8Array { } static function __init__() untyped { - var Uint8Array = __js__('typeof(window) != "undefined" && window.Uint8Array') || (__js__('typeof(global) != "undefined" && global.Uint8Array')) || _new; + var Uint8Array = untyped __js__("Function(\"return typeof Uint8Array != 'undefined' ? Uint8Array : null\")()") || _new; } } \ No newline at end of file From 00828b4f69077618c00626f24fa70605155ce518 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 00:41:26 +0800 Subject: [PATCH 202/209] provide polyfills of ArrayBuffer and DataView --- std/js/html/compat/ArrayBuffer.hx | 2 +- std/js/html/compat/DataView.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/std/js/html/compat/ArrayBuffer.hx b/std/js/html/compat/ArrayBuffer.hx index cd8beeff7a3..3db5b0f47c3 100644 --- a/std/js/html/compat/ArrayBuffer.hx +++ b/std/js/html/compat/ArrayBuffer.hx @@ -53,7 +53,7 @@ class ArrayBuffer { } static function __init__() untyped { - var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")()"); + var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")()") || js.html.compat.ArrayBuffer; if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10 } } \ No newline at end of file diff --git a/std/js/html/compat/DataView.hx b/std/js/html/compat/DataView.hx index 4763f23fa03..6b8a53d0698 100644 --- a/std/js/html/compat/DataView.hx +++ b/std/js/html/compat/DataView.hx @@ -138,7 +138,7 @@ class DataView { } static function __init__() untyped { - var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")()"); + var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")()") || js.html.compat.DataView; } } \ No newline at end of file From 8b0ddd4f61ad651402c87e768c4cca5e28ec8eb1 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 14:10:34 +0800 Subject: [PATCH 203/209] Fixed #4138. Fixed #4183. --- std/js/Boot.hx | 7 ++--- tests/unit/compile-js.hxml | 7 +++++ tests/unit/src/unit/issues/Issue4138.hx | 37 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 tests/unit/src/unit/issues/Issue4138.hx diff --git a/std/js/Boot.hx b/std/js/Boot.hx index 0d8de65b2cf..ce9c18aae92 100755 --- a/std/js/Boot.hx +++ b/std/js/Boot.hx @@ -242,12 +242,9 @@ class Boot { return __nativeClassName(o) != null; } - // resolve native JS class (with window or global): + // resolve native JS class in the global scope: static function __resolveNativeClass(name:String) untyped { - if (__js__("typeof window") != "undefined") - return window[name]; - else - return global[name]; + return untyped Function('return typeof $name != "undefined" ? $name : null')(); } } diff --git a/tests/unit/compile-js.hxml b/tests/unit/compile-js.hxml index ef21f93acc2..16667398efd 100644 --- a/tests/unit/compile-js.hxml +++ b/tests/unit/compile-js.hxml @@ -1,3 +1,10 @@ +-cp src +-main unit.issues.Issue4138 +-js bin/Issue4138_Worker.js +-D worker + +--next + compile-each.hxml unit.Test -js bin/unit.js \ No newline at end of file diff --git a/tests/unit/src/unit/issues/Issue4138.hx b/tests/unit/src/unit/issues/Issue4138.hx new file mode 100644 index 00000000000..a83fb6df922 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue4138.hx @@ -0,0 +1,37 @@ +package unit.issues; + +#if worker +import js.html.compat.ArrayBuffer; + +@:keep class Issue4138 { + static function main():Void { + var b = new js.html.ArrayBuffer(1); + // `Type.getClassName` uses `js.Boot.__resolveNativeClass`, thus will test for #4183 too. + (untyped postMessage)(Type.getClassName(Type.getClass(b))); + } +} +#else +class Issue4138 extends unit.Test +{ + #if js + public function test() + { + var NativeArrayBuffer = untyped Function("return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null")(); + if (js.Browser.supported && untyped js.Browser.window.Worker && NativeArrayBuffer != null){ + async(function(_, cb){ + var myWorker = new js.html.Worker("bin/Issue4138_Worker.js"); + myWorker.onmessage = function(e:Dynamic){ + var className:String = e.data; + f(className == Type.getClassName(js.html.compat.ArrayBuffer)); + cb(true); + } + myWorker.onerror = function(e){ + log('${e.message} (${e.filename}:${e.lineno})'); + t(false); + } + }, null, true); + } + } + #end +} +#end \ No newline at end of file From 6259409a814e2c805fa0d6ac2adb1f59526313a7 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 12 May 2015 08:57:56 +0200 Subject: [PATCH 204/209] CHANGES.txt update [skip ci] --- extra/CHANGES.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 205746b193e..4ca2bea5569 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -8,13 +8,27 @@ all : fixed detection of @:generic classes with constructor constraints all : fixed variable initialization check issue in loop condition - js : added variable number of arguments support in js.html.* classes - js : fixed DCE issue related to printing enums + all : fixed pattern matching on @:enum abstracts via field access (#4084) + all : fixed missing implicit casts in Map literals (#4100) + all : fixed various minor issues in haxe.xml.Parser + all : fixed class path issue when HAXE_STD_PATH is set (#4163) + js : fixed DCE issue related to printing enums (#4197) + js : fixed various issues with the new Bytes implementation + php : fixed EOF handling in FileInput.readByte (#4082) + cs/java : fixed Math.fround implementation (#4177) + cs/java : fixed some cases of Std.parseInt failing (#4132) + cpp : fixed compilation without -main (#4199) General improvements and optimizations: all : --macro keep no longer causes types to be included for compilation php : support interpolation in __php__ code + js : added variable number of arguments support in js.html.* classes + js : refined new HTML externs + + Macro features and changes: + + macro : [breaking] synced FClosure and FInstance with the compiler updates 2015-03-15: 3.2.0-RC1 From ae551d9cebc6bd9c385b68dba7baea1a5acb2db5 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 12 May 2015 08:59:48 +0200 Subject: [PATCH 205/209] sync haxelib --- extra/haxelib_src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/haxelib_src b/extra/haxelib_src index 68f25d97dc9..4fefbd17a2d 160000 --- a/extra/haxelib_src +++ b/extra/haxelib_src @@ -1 +1 @@ -Subproject commit 68f25d97dc991516c02a2665081ba5cc0d2ae23e +Subproject commit 4fefbd17a2d9a98200b621de801018af3896d68a From 7ae2b6713da4c34168abae64846375eea9871525 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 14:54:36 +0800 Subject: [PATCH 206/209] clean up the js.html.compat polyfill code --- std/js/html/compat/ArrayBuffer.hx | 2 +- std/js/html/compat/DataView.hx | 4 ++-- std/js/html/compat/Float32Array.hx | 4 ++-- std/js/html/compat/Float64Array.hx | 4 ++-- std/js/html/compat/Uint8Array.hx | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/std/js/html/compat/ArrayBuffer.hx b/std/js/html/compat/ArrayBuffer.hx index 3db5b0f47c3..b4ee2d61a3e 100644 --- a/std/js/html/compat/ArrayBuffer.hx +++ b/std/js/html/compat/ArrayBuffer.hx @@ -53,7 +53,7 @@ class ArrayBuffer { } static function __init__() untyped { - var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")()") || js.html.compat.ArrayBuffer; + var ArrayBuffer = Function("return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null")() || js.html.compat.ArrayBuffer; if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10 } } \ No newline at end of file diff --git a/std/js/html/compat/DataView.hx b/std/js/html/compat/DataView.hx index 6b8a53d0698..80405d67815 100644 --- a/std/js/html/compat/DataView.hx +++ b/std/js/html/compat/DataView.hx @@ -137,8 +137,8 @@ class DataView { } } - static function __init__() untyped { - var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")()") || js.html.compat.DataView; + static function __init__() { + var DataView = untyped Function("return typeof DataView != 'undefined' ? DataView : null")() || js.html.compat.DataView; } } \ No newline at end of file diff --git a/std/js/html/compat/Float32Array.hx b/std/js/html/compat/Float32Array.hx index 7a0b782486d..d73a05c1ff7 100644 --- a/std/js/html/compat/Float32Array.hx +++ b/std/js/html/compat/Float32Array.hx @@ -102,8 +102,8 @@ class Float32Array { return a; } - static function __init__() untyped { - var Float32Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? Float32Array : null\")()") || _new; + static function __init__() { + var Float32Array = untyped Function("return typeof Float32Array != 'undefined' ? Float32Array : null")() || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index b158e87d639..6b76649e3b1 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -109,8 +109,8 @@ class Float64Array { return a; } - static function __init__() untyped { - var Float64Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? (typeof Float64Array != 'undefined' ? Float64Array : 'notsupported') : null\")()") || _new; + static function __init__() { + var Float64Array = untyped Function("return typeof Float64Array != 'undefined' ? Float64Array : (typeof Float32Array != 'undefined' ? Float32Array : null)")() || _new; } } \ No newline at end of file diff --git a/std/js/html/compat/Uint8Array.hx b/std/js/html/compat/Uint8Array.hx index 98d84983237..4fd07f304c7 100644 --- a/std/js/html/compat/Uint8Array.hx +++ b/std/js/html/compat/Uint8Array.hx @@ -93,8 +93,8 @@ class Uint8Array { return a; } - static function __init__() untyped { - var Uint8Array = untyped __js__("Function(\"return typeof Uint8Array != 'undefined' ? Uint8Array : null\")()") || _new; + static function __init__() { + var Uint8Array = untyped Function("return typeof Uint8Array != 'undefined' ? Uint8Array : null")() || _new; } } \ No newline at end of file From 6f7d9912c437c93cfa4c7db55bb89315d9761297 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Tue, 12 May 2015 15:27:23 +0800 Subject: [PATCH 207/209] reverted to use Nicolas's logic --- std/js/html/compat/Float64Array.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/js/html/compat/Float64Array.hx b/std/js/html/compat/Float64Array.hx index 6b76649e3b1..3c809ccb982 100644 --- a/std/js/html/compat/Float64Array.hx +++ b/std/js/html/compat/Float64Array.hx @@ -110,7 +110,7 @@ class Float64Array { } static function __init__() { - var Float64Array = untyped Function("return typeof Float64Array != 'undefined' ? Float64Array : (typeof Float32Array != 'undefined' ? Float32Array : null)")() || _new; + var Float64Array = untyped Function("return typeof Float64Array != 'undefined' ? Float64Array : (typeof Float32Array != 'undefined' ? 'notsupported' : null)")() || _new; } } \ No newline at end of file From ddb899e88e7fbda5490d801a67be4d691ba21dee Mon Sep 17 00:00:00 2001 From: Hugh Date: Tue, 12 May 2015 16:18:44 +0800 Subject: [PATCH 208/209] Add nativeGen note --- extra/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 4ca2bea5569..9ec7fa16892 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -3,6 +3,7 @@ New features: all : added @:noPrivateAccess to re-enable access restrictions within @:privateAccess + cpp : some support for @:nativeGen metadata Bugfixes: From b39a37a804c383e3f52eeb0a53a19262e4f029d1 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 12 May 2015 10:40:52 +0200 Subject: [PATCH 209/209] set CHANGES.txt date [skip ci] --- extra/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index 9ec7fa16892..5d0363d77c5 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -1,4 +1,4 @@ -2015-??-??: 3.2.0 +2015-05-12: 3.2.0 New features: