Skip to content

Commit

Permalink
changed IMap to an interface (fixed issue HaxeFoundation#1629)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Apr 12, 2013
1 parent 6535acc commit d59a168
Show file tree
Hide file tree
Showing 29 changed files with 48 additions and 43 deletions.
3 changes: 2 additions & 1 deletion main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let global_cache = ref None

let executable_path() =
Extc.executable_path()

let is_debug_run() =
try Sys.getenv "HAXEDEBUG" = "1" with _ -> false

Expand Down Expand Up @@ -822,6 +822,7 @@ try
if com.platform <> Cross then failwith "Multiple targets";
Common.init_platform com pf;
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;
in
let define f = Arg.Unit (fun () -> Common.define com f) in
Expand Down
14 changes: 7 additions & 7 deletions std/Map.hx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ abstract Map< K, V > (IMap< K, 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> {
return new ObjectMap<K, V>();
Expand All @@ -147,16 +147,16 @@ abstract Map< K, V > (IMap< 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 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 > {
return map;
}
}

typedef IMap < K, V > = {
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;
Expand Down
2 changes: 1 addition & 1 deletion std/cpp/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class IntMap<T> {
@:coreApi class IntMap<T> implements Map.IMap<Int,T> {

private var h : Dynamic;

Expand Down
4 changes: 2 additions & 2 deletions std/cpp/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
package haxe.ds;

@: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
private var __Internal : IntMap<V>;

public function new(?weakKeys:Bool = false) : Void {
public function new() : Void {
__Internal = new IntMap<V>();
}

Expand Down
2 changes: 1 addition & 1 deletion std/cpp/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class StringMap<T> {
@:coreApi class StringMap<T> implements Map.IMap<String,T> {
private var __Internal : Dynamic;

public function new() : Void {
Expand Down
2 changes: 1 addition & 1 deletion std/cs/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
@:coreApi class IntMap<T> implements Map.IMap<Int,T>
{
private static inline var HASH_UPPER = 0.7;

Expand Down
4 changes: 2 additions & 2 deletions std/cs/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package haxe.ds;

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 FLAG_EMPTY = 0;
Expand Down Expand Up @@ -56,7 +56,7 @@ import cs.NativeArray;
private var maxProbe:Int;
#end

public function new(?weakKeys:Bool) : Void
public function new() : Void
{
cachedIndex = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion std/cs/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package haxe.ds;

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 FLAG_EMPTY = 0;
Expand Down
2 changes: 1 addition & 1 deletion std/flash/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class IntMap<T> {
@:coreApi class IntMap<T> implements Map.IMap<Int,T> {

private var h : flash.utils.Dictionary;

Expand Down
6 changes: 5 additions & 1 deletion std/flash/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package haxe.ds;

@: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> {
return untyped this[key];
}
Expand Down
2 changes: 1 addition & 1 deletion std/flash/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class StringMap<T> {
@:coreApi class StringMap<T> implements Map.IMap<String,T> {

private var h :flash.utils.Dictionary;

Expand Down
2 changes: 1 addition & 1 deletion std/flash8/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class IntMap<T> {
@:coreApi class IntMap<T> implements Map.IMap<Int,T>{

private var h : Dynamic;

Expand Down
4 changes: 2 additions & 2 deletions std/flash8/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package haxe.ds;

@:coreApi
class ObjectMap <K:{ }, V> {
class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {

static var count = 0;

Expand All @@ -37,7 +37,7 @@ class ObjectMap <K:{ }, V> {

var h: { };

public function new(?weakKeys:Bool = false):Void {
public function new():Void {
h = untyped __new__(_global["Object"]);
untyped h.__keys__ = untyped __new__(_global["Object"]);
}
Expand Down
2 changes: 1 addition & 1 deletion std/flash8/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class StringMap<T> {
@:coreApi class StringMap<T> implements Map.IMap<String,T> {

private var h : Dynamic;

Expand Down
2 changes: 1 addition & 1 deletion std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package haxe.ds;
Hashtable over a set of elements, using [Int] as keys.
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.
Expand Down
4 changes: 2 additions & 2 deletions std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

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 get(key:K):Null<V>;
public function exists(key:K):Bool;
Expand Down
2 changes: 1 addition & 1 deletion std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package haxe.ds;
Other kind of keys are not possible on all platforms since they
can't always be implemented efficiently.
**/
extern class StringMap<T> {
extern class StringMap<T> implements Map.IMap<String,T> {

/**
Creates a new empty hashtable.
Expand Down
2 changes: 1 addition & 1 deletion std/java/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import java.NativeArray;
* (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;

Expand Down
4 changes: 2 additions & 2 deletions std/java/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package haxe.ds;

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 FLAG_EMPTY = 0;
Expand Down Expand Up @@ -56,7 +56,7 @@ import java.NativeArray;
private var maxProbe:Int;
#end

public function new(?weakKeys:Bool = false) : Void
public function new() : Void
{
cachedIndex = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion std/java/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package haxe.ds;

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 FLAG_EMPTY = 0;
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class IntMap<T> {
@:coreApi class IntMap<T> implements Map.IMap<Int,T> {

private var h : Dynamic;

Expand Down
4 changes: 2 additions & 2 deletions std/js/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package haxe.ds;

@:coreApi
class ObjectMap<K:{ }, V> {
class ObjectMap<K:{ }, V> implements Map.IMap<K,V> {

static var count = 0;

Expand All @@ -37,7 +37,7 @@ class ObjectMap<K:{ }, V> {

var h : { };

public inline function new(weakKeys:Bool = false):Void {
public function new() : Void {
h = { };
untyped h.__keys__ = { };
}
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class StringMap<T> {
@:coreApi class StringMap<T> implements Map.IMap<String,T> {

private var h : Dynamic;

Expand Down
2 changes: 1 addition & 1 deletion std/neko/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class IntMap<T> {
@:coreApi class IntMap<T> implements Map.IMap<Int,T> {

private var h : Dynamic;

Expand Down
4 changes: 2 additions & 2 deletions std/neko/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package haxe.ds;

@:coreApi
class ObjectMap<K:{},V> {
class ObjectMap<K:{},V> implements Map.IMap<K,V> {

static var count = 0;

Expand All @@ -39,7 +39,7 @@ class ObjectMap<K:{},V> {
var h : { };
var k : { };

public function new(weakKeys:Bool = false) : Void {
public function new() : Void {
h = untyped __dollar__hnew(0);
k = untyped __dollar__hnew(0);
}
Expand Down
2 changes: 1 addition & 1 deletion std/neko/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.ds;

@:coreApi class StringMap<T> {
@:coreApi class StringMap<T> implements Map.IMap<String,T> {

private var h : Dynamic;

Expand Down
2 changes: 1 addition & 1 deletion std/php/_std/haxe/ds/IntMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
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>;
public function new() : Void {
h = untyped __call__('array');
Expand Down
4 changes: 2 additions & 2 deletions std/php/_std/haxe/ds/ObjectMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
package haxe.ds;

@:coreApi
class ObjectMap <K:{ }, V> {
class ObjectMap <K:{ }, V> implements Map.IMap<K,V> {
static function getId(key: { } ):String {
return untyped __php__("spl_object_hash($key)");
}

var h : ArrayAccess<V>;
var hk : ArrayAccess<K>;

public function new(weakKeys:Bool = false):Void {
public function new():Void {
h = untyped __call__('array');
hk = untyped __call__('array');
}
Expand Down
2 changes: 1 addition & 1 deletion std/php/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
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>;

public function new() : Void {
Expand Down

0 comments on commit d59a168

Please sign in to comment.