|
@@ -31,7 +31,7 @@ class Hash<T> {
|
|
#else neko
|
|
#else neko
|
|
h = untyped __dollar__hnew(0);
|
|
h = untyped __dollar__hnew(0);
|
|
#else js
|
|
#else js
|
|
- h = untyped __new__("Object");
|
|
|
|
|
|
+ h = untyped __js__("{}");
|
|
#else error
|
|
#else error
|
|
#end
|
|
#end
|
|
}
|
|
}
|
|
@@ -62,7 +62,7 @@ class Hash<T> {
|
|
#if flash
|
|
#if flash
|
|
return untyped h.hasOwnProperty(key);
|
|
return untyped h.hasOwnProperty(key);
|
|
#else js
|
|
#else js
|
|
- return untyped h.hasOwnProperty(key);
|
|
|
|
|
|
+ return Reflect.hasField(h,key);
|
|
#else neko
|
|
#else neko
|
|
return untyped __dollar__hmem(h,key.__s,null);
|
|
return untyped __dollar__hmem(h,key.__s,null);
|
|
#else error
|
|
#else error
|
|
@@ -71,13 +71,11 @@ class Hash<T> {
|
|
|
|
|
|
public function remove( key : String ) : Bool {
|
|
public function remove( key : String ) : Bool {
|
|
#if flash
|
|
#if flash
|
|
- if( !exists(key) ) return false;
|
|
|
|
|
|
+ if( untyped !h.hasOwnProperty(key) ) return false;
|
|
untyped __delete__(h,key);
|
|
untyped __delete__(h,key);
|
|
return true;
|
|
return true;
|
|
#else js
|
|
#else js
|
|
- if( !exists(key) ) return false;
|
|
|
|
- untyped __js__("delete this.h[key]");
|
|
|
|
- return true;
|
|
|
|
|
|
+ return Reflect.deleteField(h,key);
|
|
#else neko
|
|
#else neko
|
|
return untyped __dollar__hremove(h,key.__s,null);
|
|
return untyped __dollar__hremove(h,key.__s,null);
|
|
#else error
|
|
#else error
|
|
@@ -88,7 +86,7 @@ class Hash<T> {
|
|
#if flash
|
|
#if flash
|
|
return untyped (__keys__(h)).iterator();
|
|
return untyped (__keys__(h)).iterator();
|
|
#else js
|
|
#else js
|
|
- return untyped js.Boot.__keys(h).iterator();
|
|
|
|
|
|
+ return Reflect.fields(h).iterator();
|
|
#else neko
|
|
#else neko
|
|
var l = new List<String>();
|
|
var l = new List<String>();
|
|
untyped __dollar__hiter(h,function(k,_) { l.push(new String(k)); });
|
|
untyped __dollar__hiter(h,function(k,_) { l.push(new String(k)); });
|
|
@@ -99,19 +97,19 @@ class Hash<T> {
|
|
|
|
|
|
public function iterator() : Iterator<T> {
|
|
public function iterator() : Iterator<T> {
|
|
#if flash
|
|
#if flash
|
|
- return untyped({
|
|
|
|
|
|
+ return untyped {
|
|
ref : h,
|
|
ref : h,
|
|
it : keys(),
|
|
it : keys(),
|
|
hasNext : function() { return this.it.hasNext(); },
|
|
hasNext : function() { return this.it.hasNext(); },
|
|
next : function() { var i = this.it.next(); return this.ref[i]; }
|
|
next : function() { var i = this.it.next(); return this.ref[i]; }
|
|
- });
|
|
|
|
|
|
+ };
|
|
#else js
|
|
#else js
|
|
- return untyped({
|
|
|
|
|
|
+ return untyped {
|
|
ref : h,
|
|
ref : h,
|
|
it : keys(),
|
|
it : keys(),
|
|
hasNext : function() { return this.it.hasNext(); },
|
|
hasNext : function() { return this.it.hasNext(); },
|
|
next : function() { var i = this.it.next(); return this.ref[i]; }
|
|
next : function() { var i = this.it.next(); return this.ref[i]; }
|
|
- });
|
|
|
|
|
|
+ };
|
|
#else neko
|
|
#else neko
|
|
var l = new List<T>();
|
|
var l = new List<T>();
|
|
untyped __dollar__hiter(h,function(_,v) { l.push(v); });
|
|
untyped __dollar__hiter(h,function(_,v) { l.push(v); });
|