瀏覽代碼

Merge branch 'development' into feature/eval-libuv

Simon Krajewski 6 年之前
父節點
當前提交
4da20b83bb

+ 1 - 1
extra/haxelib_src

@@ -1 +1 @@
-Subproject commit 25a8ff4dd04be4dd1e151139d679f11fbc871721
+Subproject commit 0ea7cd696bdc4a2d63c4ea0e1466c3a40dd97de5

+ 1 - 1
src/core/error.ml

@@ -34,7 +34,7 @@ let short_type ctx t =
 	let tstr = s_type ctx t in
 	if String.length tstr > 150 then String.sub tstr 0 147 ^ "..." else tstr
 
-let unify_error_msg ctx = function
+let unify_error_msg ctx err = match err with
 	| Cannot_unify (t1,t2) ->
 		s_type ctx t1 ^ " should be " ^ s_type ctx t2
 	| Invalid_field_type s ->

+ 2 - 0
src/core/tPrinting.ml

@@ -48,6 +48,8 @@ let rec s_type ctx t =
 		(match c.cl_kind with
 		| KExpr e -> Ast.Printer.s_expr e
 		| _ -> s_type_path c.cl_path ^ s_type_params ctx tl)
+	| TType ({ t_type = TAnon { a_status = { contents = Statics { cl_kind = KAbstractImpl a }}}}, _) ->
+		"Abstract<" ^ (s_type_path a.a_path) ^ ">"
 	| TType (t,tl) ->
 		s_type_path t.t_path ^ s_type_params ctx tl
 	| TAbstract (a,tl) ->

+ 1 - 1
src/generators/genlua.ml

@@ -917,8 +917,8 @@ and gen_expr ?(local=true) ctx e = begin
     | TWhile (cond,e,Ast.NormalWhile) ->
         gen_loop ctx "while" cond e
     | TWhile (cond,e,Ast.DoWhile) ->
-        println ctx "while true do ";
         gen_block_element ctx e;
+        newline ctx;
         gen_loop ctx "while" cond e
     | TObjectDecl [] ->
         spr ctx "_hx_e()";

+ 2 - 0
std/js/lib/Map.hx

@@ -108,3 +108,5 @@ extern class Map<K, V> {
 		return new HaxeIterator(this.entries());
 	}
 }
+
+@:deprecated typedef MapEntry<K, V> = KeyValue<K, V>;

+ 57 - 0
std/php/ArrayIterator.hx

@@ -0,0 +1,57 @@
+/*
+ * Copyright (C)2005-2019 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 php;
+
+/**
+	@see https://www.php.net/manual/en/class.arrayiterator.php
+**/
+@:native('ArrayIterator')
+extern class ArrayIterator<K, V> implements php.ArrayAccess<K, V> implements SeekableIterator<K, V> implements Countable implements Serializable {
+	@:phpClassConst static final STD_PROP_LIST:Int;
+	@:phpClassConst static final ARRAY_AS_PROPS:Int;
+
+	function new(?array:NativeArray, ?flags:Int);
+	function append(value:V):Void;
+	function asort():Void;
+	function count():Int;
+	function current():V;
+	function getArrayCopy():NativeArray;
+	function getFlags():Int;
+	function key():K;
+	function ksort():Void;
+	function natcasesort():Void;
+	function natsort():Void;
+	function next():Void;
+	function offsetExists(offset:K):Bool;
+	function offsetGet(offset:K):V;
+	function offsetSet(offset:K, value:V):Void;
+	function offsetUnset(offset:K):Void;
+	function rewind():Void;
+	function seek(position:Int):Void;
+	function serialize():String;
+	function setFlags(flags:Int):Void;
+	function uasort(cmp_function:(a:V, b:V) -> Int):Void;
+	function uksort(cmp_function:(a:K, b:K) -> Int):Void;
+	function unserialize(serialized:String):Void;
+	function valid():Bool;
+}

+ 31 - 0
std/php/Countable.hx

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C)2005-2019 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 php;
+
+/**
+	@see https://www.php.net/manual/en/class.countable.php
+**/
+@:native('Countable')
+extern interface Countable {
+	function count():Int;
+}

+ 5 - 3
std/php/IteratorAggregate.hx

@@ -22,13 +22,15 @@
 
 package php;
 
+/**
+	@see https://www.php.net/manual/en/class.iteratoraggregate.php
+**/
 @:native('IteratorAggregate')
-extern interface IteratorAggregate<T> {
+extern interface IteratorAggregate<T> extends Traversable {
 	/**
 		This method is not public to not induce Haxe users to use it ;)
 		Use iterator() instead.
-		The return type would be Aggregator that is unusable in Haxe
 	**/
-	private function getIterator():Iterator<T>; //
+	private function getIterator():Traversable;
 
 }

+ 36 - 0
std/php/NativeIterator.hx

@@ -0,0 +1,36 @@
+/*
+ * Copyright (C)2005-2019 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 php;
+
+/**
+	Native PHP interface.
+	@see https://www.php.net/manual/en/class.iterator.php
+**/
+@:native('Iterator')
+extern interface NativeIterator<K, V> extends Traversable {
+	function current():V;
+	function key():K;
+	function next():Void;
+	function rewind():Void;
+	function valid():Bool;
+}

+ 31 - 0
std/php/SeekableIterator.hx

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C)2005-2019 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 php;
+
+/**
+	@see https://www.php.net/manual/en/class.seekableiterator.php
+**/
+@:native('SeekableIterator')
+extern interface SeekableIterator<K, V> extends NativeIterator<K, V> {
+	function seek(position:Int):Void;
+}

+ 32 - 0
std/php/Serializable.hx

@@ -0,0 +1,32 @@
+/*
+ * Copyright (C)2005-2019 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 php;
+
+/**
+	@see https://www.php.net/manual/en/class.serializable.php
+**/
+@:native('Serializable')
+extern interface Serializable {
+    function serialize():String;
+    function unserialize(serialized:String):Void;
+}

+ 8 - 2
std/php/_std/Array.hx

@@ -21,11 +21,12 @@
  */
 
 import php.*;
+import php.ArrayIterator as NativeArrayIterator;
 
 using php.Global;
 
 @:coreApi
-final class Array<T> implements ArrayAccess<Int, T> {
+final class Array<T> implements ArrayAccess<Int, T> implements IteratorAggregate<T> {
 	public var length(default, null):Int;
 
 	var arr:NativeIndexedArray<T>;
@@ -228,6 +229,11 @@ final class Array<T> implements ArrayAccess<Int, T> {
 		}
 	}
 
+	@:noCompletion @:keep
+	private function getIterator():Traversable {
+		return new NativeArrayIterator(arr);
+	}
+
 	static function wrap<T>(arr:NativeIndexedArray<T>):Array<T> {
 		var a = new Array();
 		a.arr = arr;
@@ -272,4 +278,4 @@ private extern interface ArrayAccess<K, V> {
 	private function offsetGet(offset:K):V;
 	private function offsetSet(offset:K, value:V):Void;
 	private function offsetUnset(offset:K):Void;
-}
+}

+ 1 - 1
tests/misc/projects/Issue7526/compile-fail.hxml.stderr

@@ -1,4 +1,4 @@
 Main.hx:16: characters 9-29 : Class<C> should be { member : Int }
 Main.hx:16: characters 9-29 : The field member is not public
-Main.hx:17: characters 9-29 : Class<_Main.A_Impl_> should be { member : Int }
+Main.hx:17: characters 9-29 : Abstract<A> should be { member : Int }
 Main.hx:17: characters 9-29 : The field member is not public

+ 7 - 0
tests/misc/projects/Issue8819/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	static function main() {
+		Type.allEnums(Foo);
+	}
+}
+
+enum abstract Foo(String) {}

+ 1 - 0
tests/misc/projects/Issue8819/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 2 - 0
tests/misc/projects/Issue8819/compile-fail.hxml.stderr

@@ -0,0 +1,2 @@
+Main.hx:3: characters 17-20 : Abstract<Foo> should be Enum<Unknown<0>>
+Main.hx:3: characters 17-20 : For function argument 'e'