Răsfoiți Sursa

move IMap to haxe.Constraints in order to avoid circular references

Simon Krajewski 11 ani în urmă
părinte
comite
4e8152a682
39 a modificat fișierele cu 52 adăugiri și 55 ștergeri
  1. 2 15
      std/Map.hx
  2. 1 1
      std/cpp/_std/haxe/ds/IntMap.hx
  3. 1 1
      std/cpp/_std/haxe/ds/ObjectMap.hx
  4. 1 1
      std/cpp/_std/haxe/ds/StringMap.hx
  5. 1 1
      std/cs/_std/haxe/ds/IntMap.hx
  6. 1 1
      std/cs/_std/haxe/ds/ObjectMap.hx
  7. 1 1
      std/cs/_std/haxe/ds/StringMap.hx
  8. 1 1
      std/cs/_std/haxe/ds/WeakMap.hx
  9. 1 1
      std/flash/_std/haxe/ds/IntMap.hx
  10. 1 1
      std/flash/_std/haxe/ds/ObjectMap.hx
  11. 1 1
      std/flash/_std/haxe/ds/StringMap.hx
  12. 1 1
      std/flash/_std/haxe/ds/UnsafeStringMap.hx
  13. 1 1
      std/flash/_std/haxe/ds/WeakMap.hx
  14. 1 1
      std/flash8/_std/haxe/ds/IntMap.hx
  15. 1 1
      std/flash8/_std/haxe/ds/ObjectMap.hx
  16. 1 1
      std/flash8/_std/haxe/ds/StringMap.hx
  17. 11 1
      std/haxe/Constraints.hx
  18. 1 1
      std/haxe/ds/EnumValueMap.hx
  19. 1 1
      std/haxe/ds/IntMap.hx
  20. 1 1
      std/haxe/ds/ObjectMap.hx
  21. 1 1
      std/haxe/ds/StringMap.hx
  22. 1 1
      std/haxe/ds/WeakMap.hx
  23. 1 1
      std/java/_std/haxe/ds/IntMap.hx
  24. 1 1
      std/java/_std/haxe/ds/ObjectMap.hx
  25. 1 1
      std/java/_std/haxe/ds/StringMap.hx
  26. 1 1
      std/java/_std/haxe/ds/WeakMap.hx
  27. 1 1
      std/js/_std/haxe/ds/IntMap.hx
  28. 1 1
      std/js/_std/haxe/ds/ObjectMap.hx
  29. 1 1
      std/js/_std/haxe/ds/StringMap.hx
  30. 1 1
      std/neko/_std/haxe/ds/IntMap.hx
  31. 1 1
      std/neko/_std/haxe/ds/ObjectMap.hx
  32. 1 1
      std/neko/_std/haxe/ds/StringMap.hx
  33. 1 1
      std/php/_std/haxe/ds/IntMap.hx
  34. 1 1
      std/php/_std/haxe/ds/ObjectMap.hx
  35. 1 1
      std/php/_std/haxe/ds/StringMap.hx
  36. 1 1
      std/python/_std/haxe/ds/IntMap.hx
  37. 1 1
      std/python/_std/haxe/ds/ObjectMap.hx
  38. 1 1
      std/python/_std/haxe/ds/StringMap.hx
  39. 3 3
      tests/unit/unitstd/Map.unit.hx

+ 2 - 15
std/Map.hx

@@ -26,6 +26,7 @@ import haxe.ds.HashMap;
 import haxe.ds.ObjectMap;
 import haxe.ds.WeakMap;
 import haxe.ds.EnumValueMap;
+import haxe.Constraints.IMap;
 
  /**
 	Map allows key to value mapping for arbitrary value types, and many key
@@ -160,18 +161,4 @@ abstract Map<K,V>(IMap<K,V> ) {
 	@:from static inline function fromObjectMap<K:{ }, V>(map:ObjectMap<K,V>):Map<K,V> {
 		return cast map;
 	}
-}
-
-interface IMap<K,V> {
-	public function get(k:K):Null<V>;
-	public function set(k:K, v:V):Void;
-	public function exists(k:K):Bool;
-	public function remove(k:K):Bool;
-	public function keys():Iterator<K>;
-	public function iterator():Iterator<V>;
-	public function toString():String;
-}
-
-private typedef Hashable = {
-	function hashCode():Int;
-}
+}

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

@@ -36,7 +36,7 @@ package haxe.ds;
   inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); }
   inline Void set(Dynamic key, ::Dynamic value) { __int_hash_set(h,key,value); return null(); }
 ")
-@:coreApi class IntMap<T> implements Map.IMap<Int,T> {
+@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int,T> {
 
 	private var h : Dynamic;
 

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

@@ -22,7 +22,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap<K:{},V> implements Map.IMap<K,V> {
+class ObjectMap<K:{},V> implements haxe.Constraints.IMap<K,V> {
 	private var __Internal : IntMap<V>;
 	private var __KeyRefs : IntMap<K>;
 

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

@@ -21,7 +21,7 @@
  */
 package haxe.ds;
 
-@:coreApi class StringMap<T> implements Map.IMap<String,T> {
+@:coreApi class StringMap<T> implements haxe.Constraints.IMap<String,T> {
 	private var __Internal : Dynamic;
 
 	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.
  * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
  */
-@:coreApi class IntMap<T> implements Map.IMap<Int,T>
+@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int,T>
 {
 	private static inline var HASH_UPPER = 0.7;
 

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

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

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

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

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

@@ -25,7 +25,7 @@ import cs.NativeArray;
 import cs.system.WeakReference;
 
 // This implementation works by lazily evaluating the weak references, and only cleaning them up when needed.
-@:coreApi class WeakMap<K:{}, V> implements Map.IMap<K,V>
+@:coreApi class WeakMap<K:{}, V> implements haxe.Constraints.IMap<K,V>
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;

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

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

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

@@ -1,7 +1,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap<K:{},V> extends flash.utils.Dictionary implements Map.IMap<K,V> {
+class ObjectMap<K:{},V> extends flash.utils.Dictionary implements haxe.Constraints.IMap<K,V> {
 
 	public function new() {
 		super(false);

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

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

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

@@ -26,7 +26,7 @@ package haxe.ds;
 	As a result, it will be faster to access the map for reading, but it might fail
 	with some reserved keys such as `constructor` or `prototype`.
 **/
-class UnsafeStringMap<T> implements Map.IMap<String,T> {
+class UnsafeStringMap<T> implements haxe.Constraints.IMap<String,T> {
 
 	private var h : flash.utils.Dictionary;
 

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

@@ -1,7 +1,7 @@
 package haxe.ds;
 
 @:coreApi
-class WeakMap<K:{},V> extends flash.utils.Dictionary implements Map.IMap<K,V> {
+class WeakMap<K:{},V> extends flash.utils.Dictionary implements haxe.Constraints.IMap<K,V> {
 
 	public function new() {
 		super(true);

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

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

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

@@ -23,7 +23,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {
+class ObjectMap <K:{ }, V> implements haxe.Constraints.IMap<K,V> {
 
 	static var count = 0;
 

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

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

+ 11 - 1
std/haxe/Constraints.hx

@@ -38,4 +38,14 @@ abstract Function(Dynamic) { }
 	It is intended to be used as a type parameter constraint. If used as a real
 	type, the underlying type will be `Dynamic`.
 **/
-abstract FlatEnum(Dynamic) { }
+abstract FlatEnum(Dynamic) { }
+
+interface IMap<K,V> {
+	public function get(k:K):Null<V>;
+	public function set(k:K, v:V):Void;
+	public function exists(k:K):Bool;
+	public function remove(k:K):Bool;
+	public function keys():Iterator<K>;
+	public function iterator():Iterator<V>;
+	public function toString():String;
+}

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

@@ -28,7 +28,7 @@ package haxe.ds;
 	Keys are compared by value and recursively over their parameters. If any
 	parameter is not an enum value, `Reflect.compare` is used to compare them.
 **/
-class EnumValueMap<K:EnumValue, V> extends haxe.ds.BalancedTree<K, V> implements Map.IMap<K,V> {
+class EnumValueMap<K:EnumValue, V> extends haxe.ds.BalancedTree<K, V> implements haxe.Constraints.IMap<K,V> {
 
 	override function compare(k1:EnumValue, k2:EnumValue):Int {
 		var d = k1.getIndex() - k2.getIndex();

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

@@ -26,7 +26,7 @@ package haxe.ds;
 
 	See `Map` for documentation details.
 **/
-extern class IntMap<T> implements Map.IMap<Int,T> {
+extern class IntMap<T> implements haxe.Constraints.IMap<Int,T> {
 
 	/**
 		Creates a new IntMap.

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

@@ -30,7 +30,7 @@ package haxe.ds;
 
 	See `Map` for documentation details.
 **/
-extern class ObjectMap < K: { }, V > implements Map.IMap<K,V> {
+extern class ObjectMap < K: { }, V > implements haxe.Constraints.IMap<K,V> {
 
 	/**
 		Creates a new ObjectMap.

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

@@ -27,7 +27,7 @@ package haxe.ds;
 
 	See `Map` for documentation details.
 **/
-extern class StringMap<T> implements Map.IMap<String,T> {
+extern class StringMap<T> implements haxe.Constraints.IMap<String,T> {
 
 	/**
 		Creates a new StringMap.

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

@@ -29,7 +29,7 @@ package haxe.ds;
 
 	See `Map` for documentation details.
 **/
-class WeakMap<K: { },V> implements Map.IMap<K,V> {
+class WeakMap<K: { },V> implements haxe.Constraints.IMap<K,V> {
 
 	/**
 		Creates a new WeakMap.

+ 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)
  */
 
-@:coreApi class IntMap<T> implements Map.IMap<Int,T>
+@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int,T>
 {
 	private static inline var HASH_UPPER = 0.7;
 

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

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

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

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

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

@@ -25,7 +25,7 @@ import java.NativeArray;
 import java.lang.ref.WeakReference;
 import java.lang.ref.ReferenceQueue;
 
-@:coreApi class WeakMap<K:{}, V> implements Map.IMap<K,V>
+@:coreApi class WeakMap<K:{}, V> implements haxe.Constraints.IMap<K,V>
 {
 	@:extern private static inline var HASH_UPPER = 0.77;
 	@:extern private static inline var FLAG_EMPTY = 0;

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

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

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

@@ -23,7 +23,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap<K:{ }, V> implements Map.IMap<K,V> {
+class ObjectMap<K:{ }, V> implements haxe.Constraints.IMap<K,V> {
 
 	static var count = 0;
 

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

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

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

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

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

@@ -22,7 +22,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap<K:{},V> implements Map.IMap<K,V> {
+class ObjectMap<K:{},V> implements haxe.Constraints.IMap<K,V> {
 
 	static var count = 0;
 

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

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

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

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

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

@@ -23,7 +23,7 @@
 package haxe.ds;
 
 @:coreApi
-class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {
+class ObjectMap <K:{ }, V> implements haxe.Constraints.IMap<K,V> {
 	static function getId(key: { } ):String {
 		return untyped __php__("spl_object_hash($key)");
 	}

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

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

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

@@ -3,7 +3,7 @@ package haxe.ds;
 import python.lib.Dict;
 import python.Syntax;
 
-class IntMap<T> implements Map.IMap<Int, T> {
+class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
 	private var h : Dict<Int, T>;
 
 	public function new() : Void {

+ 1 - 1
std/python/_std/haxe/ds/ObjectMap.hx

@@ -3,7 +3,7 @@ package haxe.ds;
 import python.lib.Builtin;
 import python.lib.Dict;
 
-class ObjectMap<K:{},V> implements Map.IMap<K, V> {
+class ObjectMap<K:{},V> implements haxe.Constraints.IMap<K, V> {
 
 	var h : Dict<K,V>;
 

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

@@ -4,7 +4,7 @@ package haxe.ds;
 import python.Syntax;
 import python.lib.Dict;
 
-class StringMap<T> implements Map.IMap<String, T> {
+class StringMap<T> implements haxe.Constraints.IMap<String, T> {
 	private var h : Dict<String,T>;
 
 	public function new() : Void {

+ 3 - 3
tests/unit/unitstd/Map.unit.hx

@@ -6,9 +6,9 @@ map.set("foo", 1);
 map.set("bar", 2);
 map.set("baz", 3);
 var dynmap:Dynamic = map;
-var map2:Map.IMap<Dynamic,Dynamic> = dynmap;
-var map3:Map.IMap<String, Dynamic> = dynmap;
-var map4:Map.IMap<String, Int> = dynmap;
+var map2:haxe.Constraints.IMap<Dynamic,Dynamic> = dynmap;
+var map3:haxe.Constraints.IMap<String, Dynamic> = dynmap;
+var map4:haxe.Constraints.IMap<String, Int> = dynmap;
 Std.is(map, haxe.ds.StringMap) == true;
 map.exists("foo") == true;
 map.exists("bar") == true;