2
0
Эх сурвалжийг харах

changed IMap to an interface (fixed issue #1629)

Simon Krajewski 12 жил өмнө
parent
commit
d59a168704

+ 2 - 1
main.ml

@@ -53,7 +53,7 @@ let global_cache = ref None
 
 
 let executable_path() =
 let executable_path() =
 	Extc.executable_path()
 	Extc.executable_path()
-	
+
 let is_debug_run() =
 let is_debug_run() =
 	try Sys.getenv "HAXEDEBUG" = "1" with _ -> false
 	try Sys.getenv "HAXEDEBUG" = "1" with _ -> false
 
 
@@ -822,6 +822,7 @@ try
 		if com.platform <> Cross then failwith "Multiple targets";
 		if com.platform <> Cross then failwith "Multiple targets";
 		Common.init_platform com pf;
 		Common.init_platform com pf;
 		com.file <- file;
 		com.file <- file;
+		message ctx ("Compiling to " ^ (platform_name pf)) Ast.null_pos;
 		if (pf = Flash8 || pf = Flash) && file_extension file = "swc" then Common.define com Define.Swc;
 		if (pf = Flash8 || pf = Flash) && file_extension file = "swc" then Common.define com Define.Swc;
 	in
 	in
 	let define f = Arg.Unit (fun () -> Common.define com f) in
 	let define f = Arg.Unit (fun () -> Common.define com f) in

+ 7 - 7
std/Map.hx

@@ -131,9 +131,9 @@ abstract Map< K, V > (IMap< K, V > ) {
 		return new IntMap<V>();
 		return new IntMap<V>();
 	}
 	}
 
 
-	@:to static inline function toHashMap<K:Hashable>(t:IMap < K, V >):HashMap<K,V> {
-		return new HashMap<K, V>();
-	}
+	//@:to static inline function toHashMap<K:Hashable>(t:IMap < K, V >):HashMap<K,V> {
+		//return new HashMap<K, V>();
+	//}
 	
 	
 	@:to static inline function toObjectMap<K:{ }>(t:IMap < K, V >):ObjectMap<K,V> {
 	@:to static inline function toObjectMap<K:{ }>(t:IMap < K, V >):ObjectMap<K,V> {
 		return new ObjectMap<K, V>();
 		return new ObjectMap<K, V>();
@@ -147,16 +147,16 @@ abstract Map< K, V > (IMap< K, V > ) {
 		return map;
 		return map;
 	}
 	}
 	
 	
-	@:from static inline function fromHashMap < K:Hashable, V > (map:HashMap< K, V > ):Map< K, V > {
-		return map;
-	}
+	//@:from static inline function fromHashMap < K:Hashable, V > (map:HashMap< K, V > ):Map< K, V > {
+		//return map;
+	//}
 	
 	
 	@:from static inline function fromObjectMap < K: { }, V > (map:ObjectMap< K, V > ):Map< K, V > {
 	@:from static inline function fromObjectMap < K: { }, V > (map:ObjectMap< K, V > ):Map< K, V > {
 		return map;
 		return map;
 	}
 	}
 }
 }
 
 
-typedef IMap < K, V > = {
+interface IMap < K, V > {
 	public function get(k:K):Null<V>;
 	public function get(k:K):Null<V>;
 	public function set(k:K, v:V):Void;
 	public function set(k:K, v:V):Void;
 	public function exists(k:K):Bool;
 	public function exists(k:K):Bool;

+ 1 - 1
std/cpp/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> {
+@:coreApi class IntMap<T> implements Map.IMap<Int,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 2 - 2
std/cpp/_std/haxe/ds/ObjectMap.hx

@@ -22,11 +22,11 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap<K,V> {
+class ObjectMap<K,V> implements Map.IMap<K,V> {
    // TODO: Might need to add separate hash to keep track of references to keys
    // TODO: Might need to add separate hash to keep track of references to keys
 	private var __Internal : IntMap<V>;
 	private var __Internal : IntMap<V>;
 
 
-	public function new(?weakKeys:Bool = false) : Void {
+	public function new() : Void {
 		__Internal = new IntMap<V>();
 		__Internal = new IntMap<V>();
 	}
 	}
 
 

+ 1 - 1
std/cpp/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T>  {
+@:coreApi class StringMap<T> implements Map.IMap<String,T> {
 	private var __Internal : Dynamic;
 	private var __Internal : Dynamic;
 
 
 	public function new() : Void {
 	public function new() : Void {

+ 1 - 1
std/cs/_std/haxe/ds/IntMap.hx

@@ -33,7 +33,7 @@ import cs.NativeArray;
  * Thanks also to Jonas Malaco Filho for his Haxe-written IntMap code inspired by Python tables.
  * Thanks also to Jonas Malaco Filho for his Haxe-written IntMap code inspired by Python tables.
  * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
  * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
  */
  */
-@:coreApi class IntMap<T>
+@:coreApi class IntMap<T> implements Map.IMap<Int,T>
 {
 {
 	private static inline var HASH_UPPER = 0.7;
 	private static inline var HASH_UPPER = 0.7;
 
 

+ 2 - 2
std/cs/_std/haxe/ds/ObjectMap.hx

@@ -23,7 +23,7 @@ package haxe.ds;
 
 
 import cs.NativeArray;
 import cs.NativeArray;
 
 
-@:coreApi class ObjectMap<K, V>
+@:coreApi class ObjectMap<K, V> implements Map.IMap<K,V>
 {
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;
 	@:extern private static inline var FLAG_EMPTY = 0;
@@ -56,7 +56,7 @@ import cs.NativeArray;
 	private var maxProbe:Int;
 	private var maxProbe:Int;
 #end
 #end
 
 
-	public function new(?weakKeys:Bool) : Void
+	public function new() : Void
 	{
 	{
 		cachedIndex = -1;
 		cachedIndex = -1;
 	}
 	}

+ 1 - 1
std/cs/_std/haxe/ds/StringMap.hx

@@ -23,7 +23,7 @@ package haxe.ds;
 
 
 import cs.NativeArray;
 import cs.NativeArray;
 
 
-@:coreApi class StringMap<T>
+@:coreApi class StringMap<T> implements Map.IMap<String,T>
 {
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;
 	@:extern private static inline var FLAG_EMPTY = 0;

+ 1 - 1
std/flash/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> {
+@:coreApi class IntMap<T> implements Map.IMap<Int,T> {
 
 
 	private var h : flash.utils.Dictionary;
 	private var h : flash.utils.Dictionary;
 
 

+ 5 - 1
std/flash/_std/haxe/ds/ObjectMap.hx

@@ -1,8 +1,12 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap<K,V> extends flash.utils.Dictionary {
+class ObjectMap<K,V> extends flash.utils.Dictionary implements Map.IMap<K,V> {
 
 
+	public function new() {
+		super(false);
+	}
+	
 	public inline function get( key : K ) : Null<V> {
 	public inline function get( key : K ) : Null<V> {
 		return untyped this[key];
 		return untyped this[key];
 	}
 	}

+ 1 - 1
std/flash/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T> {
+@:coreApi class StringMap<T> implements Map.IMap<String,T> {
 
 
 	private var h :flash.utils.Dictionary;
 	private var h :flash.utils.Dictionary;
 
 

+ 1 - 1
std/flash8/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> {
+@:coreApi class IntMap<T> implements Map.IMap<Int,T>{
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 2 - 2
std/flash8/_std/haxe/ds/ObjectMap.hx

@@ -23,7 +23,7 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap <K:{ }, V> {
+class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {
 	
 	
 	static var count = 0;
 	static var count = 0;
 	
 	
@@ -37,7 +37,7 @@ class ObjectMap <K:{ }, V> {
 	
 	
 	var h: { };
 	var h: { };
 	
 	
-	public function new(?weakKeys:Bool = false):Void {
+	public function new():Void {
 		h = untyped __new__(_global["Object"]);
 		h = untyped __new__(_global["Object"]);
 		untyped h.__keys__ = untyped __new__(_global["Object"]);
 		untyped h.__keys__ = untyped __new__(_global["Object"]);
 	}
 	}

+ 1 - 1
std/flash8/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T> {
+@:coreApi class StringMap<T> implements Map.IMap<String,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 1 - 1
std/haxe/ds/IntMap.hx

@@ -25,7 +25,7 @@ package haxe.ds;
 	Hashtable over a set of elements, using [Int] as keys.
 	Hashtable over a set of elements, using [Int] as keys.
 	On Flash and Javascript, the underlying structure is an Object.
 	On Flash and Javascript, the underlying structure is an Object.
 **/
 **/
-extern class IntMap<T> {
+extern class IntMap<T> implements Map.IMap<Int,T> {
 
 
 	/**
 	/**
 		Creates a new empty hashtable.
 		Creates a new empty hashtable.

+ 2 - 2
std/haxe/ds/ObjectMap.hx

@@ -22,8 +22,8 @@
 
 
 package haxe.ds;
 package haxe.ds;
 
 
-extern class ObjectMap < K: { }, V > {
-	public function new(?weakKeys:Bool = false):Void;
+extern class ObjectMap < K: { }, V > implements Map.IMap<K,V> {
+	public function new():Void;
 	public function set(key:K, value:V):Void;
 	public function set(key:K, value:V):Void;
 	public function get(key:K):Null<V>;
 	public function get(key:K):Null<V>;
 	public function exists(key:K):Bool;
 	public function exists(key:K):Bool;

+ 1 - 1
std/haxe/ds/StringMap.hx

@@ -27,7 +27,7 @@ package haxe.ds;
 	Other kind of keys are not possible on all platforms since they
 	Other kind of keys are not possible on all platforms since they
 	can't always be implemented efficiently.
 	can't always be implemented efficiently.
 **/
 **/
-extern class StringMap<T> {
+extern class StringMap<T> implements Map.IMap<String,T> {
 
 
 	/**
 	/**
 		Creates a new empty hashtable.
 		Creates a new empty hashtable.

+ 1 - 1
std/java/_std/haxe/ds/IntMap.hx

@@ -31,7 +31,7 @@ import java.NativeArray;
  * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
  * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
  */
  */
 
 
-@:coreApi class IntMap<T>
+@:coreApi class IntMap<T> implements Map.IMap<Int,T>
 {
 {
 	private static inline var HASH_UPPER = 0.7;
 	private static inline var HASH_UPPER = 0.7;
 
 

+ 2 - 2
std/java/_std/haxe/ds/ObjectMap.hx

@@ -23,7 +23,7 @@ package haxe.ds;
 
 
 import java.NativeArray;
 import java.NativeArray;
 
 
-@:coreApi class ObjectMap<K, V>
+@:coreApi class ObjectMap<K, V> implements Map.IMap<K,V>
 {
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;
 	@:extern private static inline var FLAG_EMPTY = 0;
@@ -56,7 +56,7 @@ import java.NativeArray;
 	private var maxProbe:Int;
 	private var maxProbe:Int;
 #end
 #end
 
 
-	public function new(?weakKeys:Bool = false) : Void
+	public function new() : Void
 	{
 	{
 		cachedIndex = -1;
 		cachedIndex = -1;
 	}
 	}

+ 1 - 1
std/java/_std/haxe/ds/StringMap.hx

@@ -23,7 +23,7 @@ package haxe.ds;
 
 
 import java.NativeArray;
 import java.NativeArray;
 
 
-@:coreApi class StringMap<T>
+@:coreApi class StringMap<T> implements Map.IMap<String,T>
 {
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;
 	@:extern private static inline var FLAG_EMPTY = 0;

+ 1 - 1
std/js/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> {
+@:coreApi class IntMap<T> implements Map.IMap<Int,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 2 - 2
std/js/_std/haxe/ds/ObjectMap.hx

@@ -23,7 +23,7 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap<K:{ }, V> {
+class ObjectMap<K:{ }, V> implements Map.IMap<K,V> {
 	
 	
 	static var count = 0;
 	static var count = 0;
 	
 	
@@ -37,7 +37,7 @@ class ObjectMap<K:{ }, V> {
 	
 	
 	var h : { };
 	var h : { };
 	
 	
-	public inline function new(weakKeys:Bool = false):Void {
+	public function new() : Void {
 		h = { };
 		h = { };
 		untyped h.__keys__ = { };
 		untyped h.__keys__ = { };
 	}
 	}

+ 1 - 1
std/js/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T> {
+@:coreApi class StringMap<T> implements Map.IMap<String,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 1 - 1
std/neko/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> {
+@:coreApi class IntMap<T> implements Map.IMap<Int,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 2 - 2
std/neko/_std/haxe/ds/ObjectMap.hx

@@ -22,7 +22,7 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap<K:{},V> {
+class ObjectMap<K:{},V> implements Map.IMap<K,V> {
 
 
 	static var count = 0;
 	static var count = 0;
 	
 	
@@ -39,7 +39,7 @@ class ObjectMap<K:{},V> {
 	var h : { };
 	var h : { };
 	var k : { };
 	var k : { };
 	
 	
-	public function new(weakKeys:Bool = false) : Void {
+	public function new() : Void {
 		h = untyped __dollar__hnew(0);
 		h = untyped __dollar__hnew(0);
 		k = untyped __dollar__hnew(0);
 		k = untyped __dollar__hnew(0);
 	}
 	}

+ 1 - 1
std/neko/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T> {
+@:coreApi class StringMap<T> implements Map.IMap<String,T> {
 
 
 	private var h : Dynamic;
 	private var h : Dynamic;
 
 

+ 1 - 1
std/php/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class IntMap<T> implements php.IteratorAggregate<T> {
+@:coreApi class IntMap<T> implements php.IteratorAggregate<T> implements Map.IMap<Int,T> {
 	private var h : ArrayAccess<Int>;
 	private var h : ArrayAccess<Int>;
 	public function new() : Void {
 	public function new() : Void {
 		h = untyped __call__('array');
 		h = untyped __call__('array');

+ 2 - 2
std/php/_std/haxe/ds/ObjectMap.hx

@@ -23,7 +23,7 @@
 package haxe.ds;
 package haxe.ds;
 
 
 @:coreApi
 @:coreApi
-class ObjectMap <K:{ }, V> {
+class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {
 	static function getId(key: { } ):String {
 	static function getId(key: { } ):String {
 		return untyped __php__("spl_object_hash($key)");
 		return untyped __php__("spl_object_hash($key)");
 	}
 	}
@@ -31,7 +31,7 @@ class ObjectMap <K:{ }, V> {
 	var h : ArrayAccess<V>;
 	var h : ArrayAccess<V>;
 	var hk : ArrayAccess<K>;
 	var hk : ArrayAccess<K>;
 	
 	
-	public function new(weakKeys:Bool = false):Void {
+	public function new():Void {
 		h = untyped __call__('array');
 		h = untyped __call__('array');
 		hk = untyped __call__('array');
 		hk = untyped __call__('array');
 	}
 	}

+ 1 - 1
std/php/_std/haxe/ds/StringMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:coreApi class StringMap<T> implements php.IteratorAggregate<T> {
+@:coreApi class StringMap<T> implements php.IteratorAggregate<T> implements Map.IMap<String,T> {
 	private var h : ArrayAccess<T>;
 	private var h : ArrayAccess<T>;
 
 
 	public function new() : Void {
 	public function new() : Void {