Browse Source

cleared core api classes implementation.

Nicolas Cannasse 15 years ago
parent
commit
dcd32ad9aa
11 changed files with 76 additions and 1645 deletions
  1. 8 235
      std/EReg.hx
  2. 10 196
      std/Hash.hx
  3. 9 178
      std/IntHash.hx
  4. 3 53
      std/List.hx
  5. 5 14
      std/Math.hx
  6. 14 321
      std/Reflect.hx
  7. 7 175
      std/Std.hx
  8. 1 3
      std/StringBuf.hx
  9. 13 446
      std/Type.hx
  10. 0 19
      std/Xml.hx
  11. 6 5
      typeload.ml

+ 8 - 235
std/EReg.hx

@@ -30,48 +30,12 @@
 **/
 **/
 class EReg {
 class EReg {
 
 
-	var r : Dynamic;
-	#if flash9
-	var result : {> Array<String>, index : Int, input : String };
-	#end
-	#if (neko || php || cpp)
-	var last : String;
-	var global : Bool;
-	#end
-	#if php
-	var pattern : String;
-	var options : String;
-	var re : String;
-	var matches : ArrayAccess<Dynamic>;
-	#end
-
 	/**
 	/**
 		Creates a new regular expression with pattern [r] and
 		Creates a new regular expression with pattern [r] and
 		options [opt].
 		options [opt].
 	**/
 	**/
 	public function new( r : String, opt : String ) {
 	public function new( r : String, opt : String ) {
-		#if cpp
-			var a = opt.split("g");
-			global = a.length > 1;
-			if( global )
-				opt = a.join("");
-			this.r = regexp_new_options(r, opt);
-		#elseif js
-			opt = opt.split("u").join(""); // 'u' (utf8) depends on page encoding
-			this.r = untyped __new__("RegExp",r,opt);
-		#elseif flash9
-			this.r = untyped __new__(__global__["RegExp"],r,opt);
-		#elseif php
-			this.pattern = r;
-			var a = opt.split("g");
-			global = a.length > 1;
-			if( global )
-				opt = a.join("");
-			this.options = opt;
-			this.re = "/" + untyped __php__("str_replace")("/", "\\/", r) + "/" + opt;
-		#else
-			throw "Regular expressions are not implemented for this platform";
-		#end
+		throw "Regular expressions are not implemented for this platform";
 	}
 	}
 
 
 	/**
 	/**
@@ -79,34 +43,7 @@ class EReg {
 		Updates the internal state accordingly.
 		Updates the internal state accordingly.
 	**/
 	**/
 	public function match( s : String ) : Bool {
 	public function match( s : String ) : Bool {
-		#if cpp
-			var p = regexp_match(r,s,0,s.length);
-			if( p )
-				last = s;
-			else
-				last = null;
-			return p;
-		#elseif js
-			untyped {
-				r.m = r.exec(s);
-				r.s = s;
-				r.l = RegExp.leftContext;
-				r.r = RegExp.rightContext;
-				return (r.m != null);
-			}
-		#elseif flash9
-			result = untyped r.exec(s);
-			return (result != null);
-		#elseif php
-			var p : Int = untyped __php__("preg_match")(re, s, matches, __php__("PREG_OFFSET_CAPTURE"));
-			if(p > 0)
-				last = s;
-			else
-				last = null;
-			return p > 0;
-		#else
-			return false;
-		#end
+		return false;
 	}
 	}
 
 
 	/**
 	/**
@@ -115,23 +52,7 @@ class EReg {
 		is returned.
 		is returned.
 	**/
 	**/
 	public function matched( n : Int ) : String {
 	public function matched( n : Int ) : String {
-		#if cpp
-			var m = regexp_matched(r,n);
-			return m;
-		#elseif js
-			return untyped if( r.m != null && n >= 0 && n < r.m.length ) r.m[n] else throw "EReg::matched";
-		#elseif flash9
-			return untyped if( result != null && n >= 0 && n < result.length ) result[n] else throw "EReg::matched";
-		#elseif php
-			if( n < 0 ) throw "EReg::matched";
-			// we can't differenciate between optional groups at the end of a match
-			// that have not been matched and invalid groups
-			if( n >= untyped __call__("count", matches)) return null;
-			if(untyped __php__("$this->matches[$n][1] < 0")) return null;
-			return untyped __php__("$this->matches[$n][0]");
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -139,25 +60,7 @@ class EReg {
 		of the matched substring.
 		of the matched substring.
 	**/
 	**/
 	public function matchedLeft() : String {
 	public function matchedLeft() : String {
-		#if cpp
-			var p = regexp_matched_pos(r,0);
-			return last.substr(0,p.pos);
-		#elseif js
-			untyped {
-				if( r.m == null ) throw "No string matched";
-				if( r.l == null ) return r.s.substr(0,r.m.index);
-				return r.l;
-			}
-		#elseif flash9
-			if( result == null ) throw "No string matched";
-			var s = result.input;
-			return s.substr(0,result.index);
-		#elseif php
-			if( untyped __call__("count", matches) == 0 ) throw "No string matched";
-			return last.substr(0, untyped __php__("$this->matches[0][1]"));
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -165,31 +68,7 @@ class EReg {
 		of the matched substring.
 		of the matched substring.
 	**/
 	**/
 	public function matchedRight() : String {
 	public function matchedRight() : String {
-		#if cpp
-			var p = regexp_matched_pos(r,0);
-			var sz = p.pos+p.len;
-			return last.substr(sz,last.length-sz);
-		#elseif js
-			untyped {
-				if( r.m == null ) throw "No string matched";
-				if( r.r == null ) {
-					var sz = r.m.index+r.m[0].length;
-					return r.s.substr(sz,r.s.length-sz);
-				}
-				return r.r;
-			}
-		#elseif flash9
-			if( result == null ) throw "No string matched";
-			var rl = result.index + result[0].length;
-			var s = result.input;
-			return s.substr(rl,s.length - rl);
-		#elseif php
-			if( untyped __call__("count", matches) == 0 ) throw "No string matched";
-			var x : Int = untyped __php__("$this->matches[0][1]") + __php__("strlen")(__php__("$this->matches[0][0]"));
-			return last.substr(x);
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -197,19 +76,7 @@ class EReg {
 		original matched string.
 		original matched string.
 	**/
 	**/
 	public function matchedPos() : { pos : Int, len : Int } {
 	public function matchedPos() : { pos : Int, len : Int } {
-		#if cpp
-			return regexp_matched_pos(r,0);
-		#elseif js
-			if( untyped r.m == null ) throw "No string matched";
-			return untyped { pos : r.m.index, len : r.m[0].length };
-		#elseif flash9
-			if( result == null ) throw "No string matched";
-			return { pos : result.index, len : result[0].length };
-		#elseif php
-			return untyped { pos : __php__("$this->matches[0][1]"), len : __php__("strlen")(__php__("$this->matches[0][0]")) };
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -217,37 +84,7 @@ class EReg {
 		the separators.
 		the separators.
 	**/
 	**/
 	public function split( s : String ) : Array<String> {
 	public function split( s : String ) : Array<String> {
-		#if cpp
-			var pos = 0;
-			var len = s.length;
-			var a = new Array();
-			var first = true;
-			do {
-				if( !regexp_match(r,s,pos,len) )
-					break;
-				var p = regexp_matched_pos(r,0);
-				if( p.len == 0 && !first ) {
-					if( p.pos == s.length )
-						break;
-					p.pos += 1;
-				}
-				a.push(s.substr(pos,p.pos - pos));
-				var tot = p.pos + p.len - pos;
-				pos += tot;
-				len -= tot;
-				first = false;
-			} while( global );
-			a.push(s.substr(pos,len));
-			return a;
-		#elseif (js || flash9)
-			// we can't use directly s.split because it's ignoring the 'g' flag
-			var d = "#__delim__#";
-			return untyped s.replace(r,d).split(d);
-		#elseif php
-			return untyped __php__("new _hx_array(preg_split($this->re, $s, $this->hglobal ? -1 : 2))");
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -256,64 +93,7 @@ class EReg {
 		while replacing. [$$] means the [$] character.
 		while replacing. [$$] means the [$] character.
 	**/
 	**/
 	public function replace( s : String, by : String ) : String {
 	public function replace( s : String, by : String ) : String {
-		#if cpp
-			var b = new StringBuf();
-			var pos = 0;
-			var len = s.length;
-			var a = by.split("$");
-			var first = true;
-			do {
-				if( !regexp_match(r,s,pos,len) )
-					break;
-				var p = regexp_matched_pos(r,0);
-				if( p.len == 0 && !first ) {
-					if( p.pos == s.length )
-						break;
-					p.pos += 1;
-				}
-				b.addSub(s,pos,p.pos-pos);
-				if( a.length > 0 )
-					b.add(a[0]);
-				var i = 1;
-				while( i < a.length ) {
-					var k = a[i];
-					var c = k.charCodeAt(0);
-					// 1...9
-					if( c >= 49 && c <= 57 ) {
-						var p = try regexp_matched_pos(r,Std.int(c)-48) catch( e : String ) null;
-						if( p == null ){
-							b.add("$");
-							b.add(k);
-						}else{
-						b.addSub(s,p.pos,p.len);
-						b.addSub(k,1,k.length - 1);
-						}
-					} else if( c == null ) {
-						b.add("$");
-						i++;
-						var k2 = a[i];
-						if( k2 != null && k2.length > 0 )
-							b.add(k2);
-					} else
-						b.add("$"+k);
-					i++;
-				}
-				var tot = p.pos + p.len - pos;
-				pos += tot;
-				len -= tot;
-				first = false;
-			} while( global );
-			b.addSub(s,pos,len);
-			return b.toString();
-		#elseif (js || flash9)
-			return untyped s.replace(r,by);
-		#elseif php
-			by = untyped __call__("str_replace", "$$", "\\$", by);
-			untyped __php__("if(!preg_match('/\\\\([^?].+?\\\\)/', $this->re)) $by = preg_replace('/\\$(\\d+)/', '\\\\\\$\\1', $by)");
-			return untyped __php__("preg_replace")(re, by, s, global ? -1 : 1);
-		#else
-			return null;
-		#end
+		return null;
 	}
 	}
 
 
 	/**
 	/**
@@ -334,11 +114,4 @@ class EReg {
 		return buf.toString();
 		return buf.toString();
 	}
 	}
 
 
-#if cpp
-	static var regexp_new_options : String -> String -> Dynamic = cpp.Lib.load("regexp","regexp_new_options",2);
-	static var regexp_match : Dynamic -> String -> Int -> Int -> Dynamic = cpp.Lib.load("regexp","regexp_match",4);
-	static var regexp_matched : Dynamic -> Int -> Dynamic = cpp.Lib.load("regexp","regexp_matched",2);
-	static var regexp_matched_pos : Dynamic -> Int -> { pos : Int, len : Int } = cpp.Lib.load("regexp","regexp_matched_pos",2);
-#end
-
 }
 }

+ 10 - 196
std/Hash.hx

@@ -28,236 +28,50 @@
 	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.
 **/
 **/
-class Hash<T> #if php implements php.IteratorAggregate<T> #end {
-
-	private var h : #if flash9 flash.utils.Dictionary #elseif php ArrayAccess<T> #else Dynamic #end;
+extern class Hash<T> {
 
 
 	/**
 	/**
 		Creates a new empty hashtable.
 		Creates a new empty hashtable.
 	**/
 	**/
-	public function new() : Void {
-		#if flash9
-		h = new flash.utils.Dictionary();
-		#elseif flash
-		h = untyped __new__(_global["Object"]);
-		#elseif neko
-		h = untyped __dollar__hnew(0);
-		#elseif js
-		untyped {
-			h = __js__("{}");
-			if( h.__proto__ != null ) {
-				h.__proto__ = null;
-				__js__("delete")(h.__proto__);
-			}
-		}
-		#elseif cpp
-		h = {};
-		#elseif php
-		h = untyped __call__('array');
-		#end
-	}
+	public function new() : Void;
 
 
 	/**
 	/**
 		Set a value for the given key.
 		Set a value for the given key.
 	**/
 	**/
-	public function set( key : String, value : T ) : Void {
-		#if flash
-		untyped h["$"+key] = value;
-		#elseif js
-		untyped h["$"+key] = value;
-		#elseif neko
-		untyped __dollar__hset(h,key.__s,value,null);
-		#elseif cpp
-		untyped h.__SetField(key,value);
-		#elseif php
-		untyped h[key] = value;
-		#end
-	}
+	public function set( key : String, value : T ) : Void;
 
 
 	/**
 	/**
 		Get a value for the given key.
 		Get a value for the given key.
 	**/
 	**/
-	public function get( key : String ) : Null<T> {
-		#if flash
-		return untyped h["$"+key];
-		#elseif js
-		return untyped h["$"+key];
-		#elseif neko
-		return untyped __dollar__hget(h,key.__s,null);
-		#elseif cpp
-		return untyped h.__Field(key);
-		#elseif php
-		untyped __php__("if(!isset($this->h[$key])) return null");
-		return untyped h[key];
-		#else
-		return null;
-		#end
-	}
+	public function get( key : String ) : Null<T>;
 
 
 	/**
 	/**
 		Tells if a value exists for the given key.
 		Tells if a value exists for the given key.
 		In particular, it's useful to tells if a key has
 		In particular, it's useful to tells if a key has
 		a [null] value versus no value.
 		a [null] value versus no value.
 	**/
 	**/
-	public function exists( key : String ) : Bool {
-		#if flash9
-		return untyped h.hasOwnProperty("$"+key);
-		#elseif flash
-		return untyped h["hasOwnProperty"]("$"+key);
-		#elseif js
-		try {
-			key = "$"+key;
-			return untyped this.hasOwnProperty.call(h,key);
-		}catch(e:Dynamic){
-			untyped __js__("
-				for(var i in this.h)
-					if( i == key ) return true;
-			");
-			return false;
-		}
-		#elseif neko
-		return untyped __dollar__hmem(h,key.__s,null);
-		#elseif cpp
-		return untyped h.__HasField(key);
-		#elseif php
-		return untyped __call__("array_key_exists", key, h);
-		#else
-		return false;
-		#end
-	}
+	public function exists( key : String ) : Bool;
 
 
 	/**
 	/**
 		Removes a hashtable entry. Returns [true] if
 		Removes a hashtable entry. Returns [true] if
 		there was such entry.
 		there was such entry.
 	**/
 	**/
-	public function remove( key : String ) : Bool {
-		#if flash9
-		key = "$"+key;
-		if( untyped !h.hasOwnProperty(key) ) return false;
-		untyped __delete__(h,key);
-		return true;
-		#elseif flash
-		key = "$"+key;
-		if( untyped !h["hasOwnProperty"](key) ) return false;
-		untyped __delete__(h,key);
-		return true;
-		#elseif js
-		if( !exists(key) )
-			return false;
-		untyped __js__("delete")(h["$"+key]);
-		return true;
-		#elseif neko
-		return untyped __dollar__hremove(h,key.__s,null);
-		#elseif cpp
-		return untyped __global__.__hxcpp_anon_remove(h,key);
-		#elseif php
-		if(!untyped __call__("isset", h[key])) return false;
-		untyped __call__("unset", h[key]);
-		return true;
-		#else
-		return false;
-		#end
-	}
+	public function remove( key : String ) : Bool;
+
 
 
 	/**
 	/**
 		Returns an iterator of all keys in the hashtable.
 		Returns an iterator of all keys in the hashtable.
 	**/
 	**/
-	public function keys() : Iterator<String> {
-		#if flash9
-		return untyped (__hkeys__(h)).iterator();
-		#elseif flash
-		return untyped (__hkeys__(h))["iterator"]();
-		#elseif js
-		var a = new Array<String>();
-		untyped __js__("
-			for(var i in this.h)
-				a.push(i.substr(1));
-		");
-		return a.iterator();
-		#elseif neko
-		var l = new List<String>();
-		untyped __dollar__hiter(h,function(k,_) { l.push(new String(k)); });
-		return l.iterator();
-		#elseif cpp
-		var a:Array<String> = [];
-		untyped h.__GetFields(a);
-		return a.iterator();
-		#elseif php
-		return untyped __call__("new _hx_array_iterator", __call__("array_keys", h));
-		#else
-		return null;
-		#end
-	}
+	public function keys() : Iterator<String>;
 
 
 	/**
 	/**
 		Returns an iterator of all values in the hashtable.
 		Returns an iterator of all values in the hashtable.
 	**/
 	**/
-	public function iterator() : Iterator<T> {
-		#if flash9
-		return untyped {
-			ref : h,
-			it : __keys__(h).iterator(),
-			hasNext : function() { return this.it.hasNext(); },
-			next : function() { var i : Dynamic = this.it.next(); return this.ref[i]; }
-		};
-		#elseif flash
-		return untyped {
-			ref : h,
-			it : __keys__(h)["iterator"](),
-			hasNext : function() { return this.it[__unprotect__("hasNext")](); },
-			next : function() { var i = this.it[__unprotect__("next")](); return this.ref[i]; }
-		};
-		#elseif js
-		return untyped {
-			ref : h,
-			it : keys(),
-			hasNext : function() { return this.it.hasNext(); },
-			next : function() { var i = this.it.next(); return this.ref["$"+i]; }
-		};
-		#elseif neko
-		var l = new List<T>();
-		untyped __dollar__hiter(h,function(_,v) { l.push(v); });
-		return l.iterator();
-		#elseif cpp
-		var a:Array<String> = [];
-		untyped h.__GetFields(a);
-		var it = a.iterator();
-		return untyped {
-			hasNext : function() { return it.hasNext(); },
-			next : function() { return  untyped h.__Field(it.next()); }
-		};
-		#elseif php
-		return untyped __call__("new _hx_array_iterator", __call__("array_values", h));
-		#else
-		return null;
-		#end
-	}
+	public function iterator() : Iterator<T>;
 
 
 	/**
 	/**
 		Returns an displayable representation of the hashtable content.
 		Returns an displayable representation of the hashtable content.
 	**/
 	**/
+	public function toString() : String;
 
 
-	public function toString() {
-		var s = new StringBuf();
-		s.add("{");
-		var it = keys();
-		for( i in it ) {
-			s.add(i);
-			s.add(" => ");
-			s.add(Std.string(get(i)));
-			if( it.hasNext() )
-				s.add(", ");
-		}
-		s.add("}");
-		return s.toString();
-	}
-	
-	/**
-		Implement IteratorAggregate for native php iteration
-	**/
-	#if php
-	function getIterator() {
-		return iterator();
-	}
-	#end
 }
 }

+ 9 - 178
std/IntHash.hx

@@ -27,217 +27,48 @@
 	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.
 **/
 **/
-class IntHash<T> #if php implements php.IteratorAggregate<T> #end {
-
-	private var h : #if flash9 flash.utils.Dictionary #elseif php ArrayAccess<Int> #else Dynamic #end;
+extern class IntHash<T> {
 
 
 	/**
 	/**
 		Creates a new empty hashtable.
 		Creates a new empty hashtable.
 	**/
 	**/
-	public function new() : Void {
-		#if flash9
-		h = new flash.utils.Dictionary();
-		#elseif flash
-		h = untyped __new__(_global["Object"]);
-		#elseif neko
-		h = untyped __dollar__hnew(0);
-		#elseif js
-		h = untyped __js__("{}");
-		untyped if( h.__proto__ != null ) {
-			h.__proto__ = null;
-			__js__("delete")(h.__proto__);
-		};
-		#elseif php
-		h = untyped __call__('array');
-		#elseif cpp
-		h = untyped __global__.__int_hash_create();
-		#end
-	}
+	public function new() : Void;
 
 
 	/**
 	/**
 		Set a value for the given key.
 		Set a value for the given key.
 	**/
 	**/
-	public function set( key : Int, value : T ) : Void {
-		#if (flash || php)
-		untyped h[key] = value;
-		#elseif js
-		untyped h[key] = value;
-		#elseif neko
-		untyped __dollar__hset(h,key,value,null);
-		#elseif cpp
-		untyped __global__.__int_hash_set(h,key,value);
-		#end
-	}
-
+	public function set( key : Int, value : T ) : Void;
 	/**
 	/**
 		Get a value for the given key.
 		Get a value for the given key.
 	**/
 	**/
-	public function get( key : Int ) : Null<T> {
-		#if flash
-		return untyped h[key];
-		#elseif js
-		return untyped h[key];
-		#elseif neko
-		return untyped __dollar__hget(h,key,null);
-		#elseif php
-		untyped __php__("if(!isset($this->h[$key])) return null");
-		return untyped h[key];
-		#elseif cpp
-		return untyped __global__.__int_hash_get(h,key);
-		#else
-		return null;
-		#end
-	}
+	public function get( key : Int ) : Null<T>;
 
 
 	/**
 	/**
 		Tells if a value exists for the given key.
 		Tells if a value exists for the given key.
 		In particular, it's useful to tells if a key has
 		In particular, it's useful to tells if a key has
 		a [null] value versus no value.
 		a [null] value versus no value.
 	**/
 	**/
-	public function exists( key : Int ) : Bool {
-		#if flash9
-		return untyped h.hasOwnProperty(key);
-		#elseif flash
-		return untyped h["hasOwnProperty"](key);
-		#elseif js
-		return untyped h[key] != null;
-		#elseif neko
-		return untyped __dollar__hmem(h,key,null);
-		#elseif php
-		return untyped __call__("isset", h[key]);
-		#elseif cpp
-		return untyped __global__.__int_hash_exists(h,key);
-		#else
-		return false;
-		#end
-	}
+	public function exists( key : Int ) : Bool;
 
 
 	/**
 	/**
 		Removes a hashtable entry. Returns [true] if
 		Removes a hashtable entry. Returns [true] if
 		there was such entry.
 		there was such entry.
 	**/
 	**/
-	public function remove( key : Int ) : Bool {
-		#if flash9
-		if( untyped !h.hasOwnProperty(key) ) return false;
-		untyped __delete__(h,key);
-		return true;
-		#elseif flash
-		if( untyped !h["hasOwnProperty"](key) ) return false;
-		untyped __delete__(h,key);
-		return true;
-		#elseif js
-		if( untyped h[key] == null ) return false;
-		untyped  __js__("delete")(h[key]);
-		return true;
-		#elseif neko
-		return untyped __dollar__hremove(h,key,null);
-		#elseif php
-		if(!untyped __call__("isset", h[key])) return false;
-		untyped __call__("unset", h[key]);
-		return true;
-		#elseif cpp
-		return untyped __global__.__int_hash_remove(h,key);
-		#else
-		return false;
-		#end
-	}
+	public function remove( key : Int ) : Bool;
 
 
 	/**
 	/**
 		Returns an iterator of all keys in the hashtable.
 		Returns an iterator of all keys in the hashtable.
 	**/
 	**/
-	public function keys() : Iterator<Int> {
-		#if flash9
-		return untyped (__keys__(h)).iterator();
-		#elseif flash
-		var l : Array<Int> = untyped __keys__(h);
-		for( x in 0...l.length )
-			l[x] = Std.int(l[x]);
-		return l.iterator();
-		#elseif js
-		var a = new Array();
-		untyped __js__("
-			for( x in this.h )
-				a.push(x);
-		");
-		return a.iterator();
-		#elseif neko
-		var l = new List<Int>();
-		untyped __dollar__hiter(h,function(k,_) { l.push(k); });
-		return l.iterator();
-		#elseif php
-		return untyped __call__("new _hx_array_iterator", __call__("array_keys", h));
-		#elseif cpp
-		var a:Array<Int> = untyped __global__.__int_hash_keys(h);
-		return a.iterator();
-		#else
-		return null;
-		#end
-	}
+	public function keys() : Iterator<Int>;
 
 
 	/**
 	/**
 		Returns an iterator of all values in the hashtable.
 		Returns an iterator of all values in the hashtable.
 	**/
 	**/
-	public function iterator() : Iterator<T> {
-		#if flash9
-		return untyped {
-			ref : h,
-			it : keys(),
-			hasNext : function() { return this.it.hasNext(); },
-			next : function() { var i = this.it.next(); return this.ref[i]; }
-		};
-		#elseif flash
-		return untyped {
-			ref : h,
-			it : keys(),
-			hasNext : function() { return this.it[__unprotect__("hasNext")](); },
-			next : function() { var i = this.it[__unprotect__("next")](); return this.ref[i]; }
-		};
-		#elseif js
-		return untyped {
-			ref : h,
-			it : keys(),
-			hasNext : function() { return this.it.hasNext(); },
-			next : function() { var i = this.it.next(); return this.ref[i]; }
-		};
-		#elseif neko
-		var l = new List<T>();
-		untyped __dollar__hiter(h,function(_,v) { l.push(v); });
-		return l.iterator();
-		#elseif php
-		return untyped __call__("new _hx_array_iterator", __call__("array_values", h));
-		#elseif cpp
-		var a:Array<Dynamic> = untyped __global__.__int_hash_values(h);
-		return a.iterator();
-		#else
-		return null;
-		#end
-	}
+	public function iterator() : Iterator<T>;
 
 
 	/**
 	/**
 		Returns an displayable representation of the hashtable content.
 		Returns an displayable representation of the hashtable content.
 	**/
 	**/
+	public function toString() : String;
 
 
-	public function toString() {
-		var s = new StringBuf();
-		s.add("{");
-		var it = keys();
-		for( i in it ) {
-			s.add(i);
-			s.add(" => ");
-			s.add(Std.string(get(i)));
-			if( it.hasNext() )
-				s.add(", ");
-		}
-		s.add("}");
-		return s.toString();
-	}
-
-	/**
-		Implement IteratorAggregate for native php iteration
-	**/
-	#if php
-	function getIterator() {
-		return iterator();
-	}
-	#end
 }
 }

+ 3 - 53
std/List.hx

@@ -28,15 +28,10 @@
 	that are chained together. It's optimized so that adding or removing an
 	that are chained together. It's optimized so that adding or removing an
 	element doesn't imply to copy the whole array content everytime.
 	element doesn't imply to copy the whole array content everytime.
 **/
 **/
-class List<T> #if php implements php.IteratorAggregate<T> #end {
+class List<T> {
 
 
-	#if php
-	private var h : ArrayAccess<Dynamic>;
-	private var q : ArrayAccess<Dynamic>;
-	#else
 	private var h : Array<Dynamic>;
 	private var h : Array<Dynamic>;
 	private var q : Array<Dynamic>;
 	private var q : Array<Dynamic>;
-	#end
 
 
 	/**
 	/**
 		The number of elements in this list.
 		The number of elements in this list.
@@ -54,19 +49,12 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 		Add an element at the end of the list.
 		Add an element at the end of the list.
 	**/
 	**/
 	public function add( item : T ) {
 	public function add( item : T ) {
-		var x = #if neko untyped __dollar__array(item,null) #elseif php untyped __call__('array', item, null) #else [item] #end;
+		var x = #if neko untyped __dollar__array(item,null) #else [item] #end;
 		if( h == null )
 		if( h == null )
-		#if php
-			untyped __php__("$this->h =& $x");
-		else
-			untyped __php__("$this->q[1] =& $x");
-		untyped __php__("$this->q =& $x");
-		#else
 			h = x;
 			h = x;
 		else
 		else
 			q[1] = x;
 			q[1] = x;
 		q = x;
 		q = x;
-		#end
 		length++;
 		length++;
 	}
 	}
 
 
@@ -76,20 +64,12 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 	public function push( item : T ) {
 	public function push( item : T ) {
 		var x = #if neko
 		var x = #if neko
 			untyped __dollar__array(item,h)
 			untyped __dollar__array(item,h)
-		#elseif php
-			untyped __call__('array', item, __php__("&$this->h"))
 		#else
 		#else
 			[item,h]
 			[item,h]
 		#end;
 		#end;
-		#if php
-		untyped __php__("$this->h =& $x");
-		if( q == null )
-			untyped __php__("$this->q =& $x");
-		#else
 		h = x;
 		h = x;
 		if( q == null )
 		if( q == null )
 			q = x;
 			q = x;
-		#end
 		length++;
 		length++;
 	}
 	}
 
 
@@ -148,23 +128,6 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 	**/
 	**/
 	public function remove( v : T ) : Bool {
 	public function remove( v : T ) : Bool {
 		var prev = null;
 		var prev = null;
-		#if php
-		var l = untyped __php__("& $this->h");
-		while( l != null ) {
-			if(untyped __php__("$l[0] === $v")) {
-				if( prev == null )
-					untyped __php__("$this->h =& $l[1]");
-				else
-					untyped __php__("$prev[1] =& $l[1]");
-				if(untyped __physeq__(q, l))
-					untyped __php__("$this->q =& $prev");
-				length--;
-				return true;
-			}
-			untyped __php__("$prev =& $l");
-			untyped __php__("$l =& $l[1]");
-		}
-		#else
 		var l = h;
 		var l = h;
 		while( l != null ) {
 		while( l != null ) {
 			if( l[0] == v ) {
 			if( l[0] == v ) {
@@ -180,7 +143,6 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 			prev = l;
 			prev = l;
 			l = l[1];
 			l = l[1];
 		}
 		}
-		#end
 		return false;
 		return false;
 	}
 	}
 
 
@@ -188,9 +150,6 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 		Returns an iterator on the elements of the list.
 		Returns an iterator on the elements of the list.
 	**/
 	**/
 	public function iterator() : Iterator<T> {
 	public function iterator() : Iterator<T> {
-#if php
-		return untyped __call__("new _hx_list_iterator", this);
-#else
 		return cast {
 		return cast {
 			h : h,
 			h : h,
 			hasNext : function() {
 			hasNext : function() {
@@ -206,7 +165,6 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 				}
 				}
 			}
 			}
 		}
 		}
-#end
 	}
 	}
 
 
 	/**
 	/**
@@ -277,13 +235,5 @@ class List<T> #if php implements php.IteratorAggregate<T> #end {
 		}
 		}
 		return b;
 		return b;
 	}
 	}
-	
-	/**
-		Implement IteratorAggregate for native php iteration
-	**/
-	#if php
-	function getIterator() {
-		return iterator();
-	}
-	#end
+
 }
 }

+ 5 - 14
std/Math.hx

@@ -55,21 +55,17 @@ extern class Math
 	static function isFinite( f : Float ) : Bool;
 	static function isFinite( f : Float ) : Bool;
 	static function isNaN( f : Float ) : Bool;
 	static function isNaN( f : Float ) : Bool;
 
 
-#if !php
 	private static function __init__() : Void untyped {
 	private static function __init__() : Void untyped {
-	#if neko
-		Math = neko.NekoMath__;
-		neko.Boot.__classes.Math = Math;
-	#else
-		#if flash9
+	#if flash9
 		NaN = __global__["Number"].NaN;
 		NaN = __global__["Number"].NaN;
 		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
 		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
 		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
 		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
-		#else
+	#else
+		Math.__name__ = ["Math"];
 		Math.NaN = Number["NaN"];
 		Math.NaN = Number["NaN"];
 		Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
 		Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
 		Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
 		Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
-		#end
+	#end
 		Math.isFinite = function(i) {
 		Math.isFinite = function(i) {
 			return
 			return
 			#if flash9
 			#if flash9
@@ -94,13 +90,8 @@ extern class Math
 			false;
 			false;
 			#end
 			#end
 		};
 		};
-	#end
-	#if flash9
-	#else
-		Math.__name__ = ["Math"];
-	#end
 	}
 	}
-#end
+
 }
 }
 
 
 
 

+ 14 - 321
std/Reflect.hx

@@ -27,377 +27,70 @@
 	The Reflect API is a way to manipulate values dynamicly through an
 	The Reflect API is a way to manipulate values dynamicly through an
 	abstract interface in an untyped manner. Use with care.
 	abstract interface in an untyped manner. Use with care.
 **/
 **/
-class Reflect {
+extern class Reflect {
 
 
 	/**
 	/**
 		Tells if an object has a field set. This doesn't take into account the object prototype (class methods).
 		Tells if an object has a field set. This doesn't take into account the object prototype (class methods).
 	**/
 	**/
-	public #if php inline #end static function hasField( o : Dynamic, field : String ) : Bool untyped {
-		#if flash9
-			return o.hasOwnProperty( field );
-		#elseif flash
-			return this["hasOwnProperty"]["call"](o,field);
-		#elseif js
-			if( o.hasOwnProperty != null )
-				return o.hasOwnProperty(field);
-			var arr = fields(o);
-			for( t in arr.iterator() )
-				if( t == field ) return true;
-			return false;
-		#elseif neko
-			return __dollar__typeof(o) == __dollar__tobject && __dollar__objfield(o,__dollar__hash(field.__s));
-		#elseif cpp
-			return o!=null && o.__HasField(field);
-		#elseif php
-			return __call__("_hx_has_field", o, field);
-		#else
-			return false;
-		#end
-	}
+	public static function hasField( o : Dynamic, field : String ) : Bool;
 
 
 	/**
 	/**
 		Returns the field of an object, or null if [o] is not an object or doesn't have this field.
 		Returns the field of an object, or null if [o] is not an object or doesn't have this field.
 	**/
 	**/
-	public #if !php inline #end static function field( o : Dynamic, field : String ) : Dynamic untyped {
-		#if flash9
-			return (o == null) ? null : o[field];
-		#elseif flash
-			return o[field];
-		#elseif cpp
-			return (o==null) ? null : o.__Field(field);
-		#elseif js
-			var v = null;
-			try {
-				v = o[field];
-			} catch( e : Dynamic ) {
-			}
-			return v;
-		#elseif neko
-			return if( __dollar__typeof(o) != __dollar__tobject ) null else __dollar__objget(o,__dollar__hash(field.__s));
-		#elseif php
-			return __call__("_hx_field", o, field);
-		#else
-			return null;
-		#end
-	}
+	public static function field( o : Dynamic, field : String ) : Dynamic;
+
 
 
 	/**
 	/**
 		Set an object field value.
 		Set an object field value.
 	**/
 	**/
-	public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
-		#if flash
-			o[field] = value;
-		#elseif js
-			o[field] = value;
-		#elseif cpp
-			if (o!=null)
-				o.__SetField(field,value);
-		#elseif neko
-			if( __dollar__typeof(o) == __dollar__tobject )
-				__dollar__objset(o,__dollar__hash(field.__s),value);
-		#elseif php
-			__setfield__(o, field, value);
-		#end
-	}
+	public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void;
 
 
 	/**
 	/**
 		Call a method with the given object and arguments.
 		Call a method with the given object and arguments.
 	**/
 	**/
-	public #if !(php||cpp) inline #end static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
-		#if flash9
-			return func.apply(o,args);
-		#elseif flash
-			return func["apply"](o,args);
-		#elseif js
-			return func.apply(o,args);
-		#elseif neko
-			return __dollar__call(func,o,args.__neko());
-		#elseif php
-			if(__call__("is_string", o) && !__call__("is_array", func)) {
-				if(args.length == 0) return __call__("call_user_func", field(o, func));
-				else if(args.length == 1) return __call__("call_user_func", field(o, func), args[0]);
-				else return __call__("call_user_func", field(o, func), args[0], args[1]);
-			}
-			return __call__("call_user_func_array", __call__("is_callable", func) ? func : __call__("array", o, func), (null == args ? __call__("array") : __field__(args, "»a")));
-		#elseif cpp
-			if (func!=null && func.__GetType()==__global__.vtString)
-				func = o.__Field(func);
-			untyped func.__SetThis(o);
-         return untyped func.__Run(args);
-		#else
-			return null;
-		#end
-	}
+	public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic;
 
 
 	/**
 	/**
 		Returns the list of fields of an object, excluding its prototype (class methods).
 		Returns the list of fields of an object, excluding its prototype (class methods).
 	**/
 	**/
-	public static function fields( o : Dynamic ) : Array<String> untyped {
-		if( o == null ) return new Array();
-		#if flash9
-			var a : Array<String> = __keys__(o);
-			var i = 0;
-			while( i < a.length ){
-				if( !o.hasOwnProperty(a[i]) )
-					a.splice(i,1);
-				else
-					++i;
-			}
-			return a;
-		#elseif flash
-			var a : Array<String> = __keys__(o);
-			var i = 0;
-			while( i < a.length ) {
-				if( !a["hasOwnProperty"]["call"](o,a[i]) )
-					a.splice(i,1);
-				else
-					++i;
-			}
-			return a;
-		#elseif js
-			var a = new Array();
-			if( o.hasOwnProperty ) {
-				__js__("
-					for(var i in o)
-						if( o.hasOwnProperty(i) )
-							a.push(i);
-				");
-			} else {
-				var t;
-				try{ t = o.__proto__; } catch( e : Dynamic ) { t = null; }
-				if( t != null )
-					o.__proto__ = null;
-				__js__("
-					for(var i in o)
-						if( i != \"__proto__\" )
-							a.push(i);
-				");
-				if( t != null )
-					o.__proto__ = t;
-			}
-			return a;
-		#elseif cpp
-			var a : Array<String> = [];
-			o.__GetFields(a);
-			return a;
-		#elseif neko
-			if( __dollar__typeof(o) != __dollar__tobject )
-				return new Array<String>();
-			else {
-				var a : neko.NativeArray<Int> = __dollar__objfields(o);
-				var i = 0;
-				var l = __dollar__asize(a);
-				while( i < l ) {
-					a[i] = new String(__dollar__field(a[i]));
-					i++;
-				}
-				return Array.new1(a,l);
-			}
-		#elseif php
-			return __php__('$o instanceof _hx_array')
-					? __php__("new _hx_array(array('concat','copy','insert','iterator','length','join','pop','push','remove','reverse','shift','slice','sort','splice','toString','unshift'))")
-					: (__call__('is_string', o)
-						? __php__("new _hx_array(array('charAt','charCodeAt','indexOf','lastIndexOf','length','split','substr','toLowerCase','toString','toUpperCase'))")
-						: __php__("new _hx_array(_hx_get_object_vars($o))"));
-		#else
-			return new Array();
-		#end
-	}
+	public static function fields( o : Dynamic ) : Array<String>;
 
 
 	/**
 	/**
 		Tells if a value is a function or not.
 		Tells if a value is a function or not.
 	**/
 	**/
-	public static function isFunction( f : Dynamic ) : Bool untyped {
-		#if flash9
-			return __typeof__(f) == "function";
-		#elseif flash
-			return __typeof__(f) == "function" && f.__name__ == null;
-		#elseif js
-			return __js__("typeof(f)") == "function" && f.__name__ == null;
-		#elseif neko
-			return __dollar__typeof(f) == __dollar__tfunction;
-		#elseif php
-			return __php__("(is_array($f) && is_callable($f)) || _hx_is_lambda($f)") || (__php__("is_array($f)") && hasField(__php__("$f[0]"), __php__("$f[1]")) && __php__("$f[1]") != "length");
-		#elseif cpp
-			return f!=null && f.__GetType() ==  __global__.vtFunction;
-		#else
-			return false;
-		#end
-	}
+	public static function isFunction( f : Dynamic ) : Bool;
 
 
 	/**
 	/**
 		Generic comparison function, does not work for methods, see [compareMethods]
 		Generic comparison function, does not work for methods, see [compareMethods]
 	**/
 	**/
-	public static function compare<T>( a : T, b : T ) : Int {
-		#if neko
-		return untyped __dollar__compare(a,b);
-		#elseif (flash9 || cpp)
-		var a : Dynamic = a;
-		var b : Dynamic = b;
-		return ( a == b ) ? 0 : ((a > b) ? 1 : -1);
-		#else
-		return ( a == b ) ? 0 : (((cast a) > (cast b)) ? 1 : -1);
-		#end
-	}
+	public static function compare<T>( a : T, b : T ) : Int;
 
 
 	/**
 	/**
 		Compare two methods closures. Returns true if it's the same method of the same instance.
 		Compare two methods closures. Returns true if it's the same method of the same instance.
 		Does not work on Neko platform.
 		Does not work on Neko platform.
 	**/
 	**/
-	public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool {
-		#if !neko
-		if( f1 == f2 )
-			return true;
-		if( !isFunction(f1) || !isFunction(f2) )
-			return false;
-		#end
-		#if neko
-			return same_closure(f1,f2);
-		#elseif flash9
-			return false; // VM-level closures
-		#elseif flash
-			return untyped f1["f"] == f2["f"] && f1["o"] == f2["o"] && f1["f"] != null;
-		#elseif js
-			return f1.scope == f2.scope && f1.method == f2.method && f1.method != null;
-		#elseif php
-			if(untyped __call__("is_array", f1) && untyped __call__("is_array", f1))
-				return untyped __php__("$f1[0] === $f2[0] && $f1[1] == $f2[1]");
-			if(untyped __call__("is_string", f1) && untyped __call__("is_string", f2))
-				return f1 == f2;
-			return false;
-		#elseif cpp
-			return untyped __global__.__hxcpp_same_closure(f1,f2);
-		#else
-			return false;
-		#end
-	}
+	public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool;
 
 
 	/**
 	/**
 		Tells if a value is an object or not.
 		Tells if a value is an object or not.
 
 
 	**/
 	**/
-	public static function isObject( v : Dynamic ) : Bool untyped {
-		#if neko
-			return __dollar__typeof(v) == __dollar__tobject && v.__enum__ == null;
-		#elseif flash9
-			if( v == null )
-				return false;
-			var t = __typeof__(v);
-			if( t == "object" ) {
-				try {
-					if( v.__enum__ == true )
-						return false;
-				} catch( e : Dynamic ) {
-				}
-				return true;
-			}
-			return (t == "string");
-		#elseif flash
-			var t = __typeof__(v);
-			return (t == "string" || (t == "object" && !v.__enum__) || (t == "function" && v.__name__ != null));
-		#elseif js
-			if( v == null )
-				return false;
-			var t = __js__("typeof(v)");
-			return (t == "string" || (t == "object" && !v.__enum__) || (t == "function" && v.__name__ != null));
-		#elseif php
-			if( v == null )
-				return false;
-			if(__call__("is_object", v))
-				return __php__("$v instanceof _hx_anonymous") || Type.getClass(v) != null;
-			if(__php__("is_string($v) && !_hx_is_lambda($v)")) return true;
-			return false;
-		#elseif cpp
-			if (v==null) return false;
-			var t:Int = v.__GetType();
-			return t ==  __global__.vtObject || t==__global__.vtClass || t==__global__.vtString ||
-					t==__global__.vtArray;
-		#else
-			return false;
-		#end
-	}
+	public static function isObject( v : Dynamic ) : Bool;
 
 
 	/**
 	/**
 		Delete an object field.
 		Delete an object field.
 	**/
 	**/
-	public static function deleteField( o : Dynamic, f : String ) : Bool untyped {
-		#if flash9
-			if( o.hasOwnProperty(f) != true ) return false;
-			__delete__(o,f);
-			return true;
-		#elseif flash
-			if( this["hasOwnProperty"]["call"](o,f) != true ) return false;
-			__delete__(o,f);
-			return true;
-		#elseif js
-			if( !hasField(o,f) ) return false;
-			__js__("delete")(o[f]);
-			return true;
-		#elseif neko
-			return __dollar__objremove(o,__dollar__hash(f.__s));
-		#elseif php
-			if(!hasField(o,f)) return false;
-			untyped __php__("if(isset($o->»dynamics[$f])) unset($o->»dynamics[$f]); else unset($o->$f)");
-			return true;
-		#elseif cpp
-			if (o==null) return false;
-			return __hxcpp_anon_remove(o,f);
-		#else
-			return false;
-		#end
-	}
+	public static function deleteField( o : Dynamic, f : String ) : Bool;
 
 
 	/**
 	/**
 		Make a copy of the fields of an object.
 		Make a copy of the fields of an object.
 	**/
 	**/
-	public static function copy<T>( o : T ) : T {
-		#if neko
-			return untyped __dollar__new(o);
-		#else
-			#if php
-				if(untyped __call__("is_string", o)) return o;
-			#elseif cpp
-				if (o==null) return null;
-				if(untyped o.__GetType()==__global__.vtString ) return o;
-				if(untyped o.__GetType()==__global__.vtArray )
-					return untyped o.__Field("copy")();
-			#end
-			var o2 : Dynamic = {};
-			for( f in Reflect.fields(o) )
-				Reflect.setField(o2,f,Reflect.field(o,f));
-			return o2;
-		#end
-	}
+	public static function copy<T>( o : T ) : T;
 
 
 	/**
 	/**
 		Transform a function taking an array of arguments into a function that can
 		Transform a function taking an array of arguments into a function that can
 		be called with any number of arguments.
 		be called with any number of arguments.
 	**/
 	**/
-	public static function makeVarArgs( f : Array<Dynamic> -> Dynamic ) : Dynamic {
-		#if neko
-			return untyped __dollar__varargs(function(a) { return f(Array.new1(a,__dollar__asize(a))); });
-		#elseif flash9
-			return function(__arguments__) { return f(__arguments__); };
-		#elseif js
-			return function() untyped {
-				var a = new Array();
-				for( i in 0...arguments.length )
-					a.push(arguments[i]);
-				return f(a);
-			};
-		#elseif flash
-			return function() { return f(untyped __arguments__); };
-		#elseif php
-			untyped __php__("return array(new _hx_lambda(array('f' => &$f), null, array('args'), 'return call_user_func($f, new _hx_array($args));'), 'makeArgs')");
-		#elseif cpp
-			return untyped __global__.__hxcpp_create_var_args(f);
-		#else
-			return null;
-		#end
-	}
-
-	#if neko
-	static var same_closure = try neko.Lib.load("std","same_closure",2) catch( e : Dynamic ) function(f1,f2) return f1 == f2;
-	#end
+	public static function makeVarArgs( f : Array<Dynamic> -> Dynamic ) : Dynamic;
 
 
 }
 }

+ 7 - 175
std/Std.hx

@@ -26,204 +26,36 @@
 /**
 /**
 	The Std class provides standard methods for manipulating basic types.
 	The Std class provides standard methods for manipulating basic types.
 **/
 **/
-class Std {
+extern class Std {
 
 
 	/**
 	/**
 		Tells if a value v is of the type t.
 		Tells if a value v is of the type t.
 	**/
 	**/
-	public static function is( v : Dynamic, t : Dynamic ) : Bool {
-		return untyped
-		#if flash
-		flash.Boot.__instanceof(v,t);
-		#elseif neko
-		neko.Boot.__instanceof(v,t);
-		#elseif js
-		js.Boot.__instanceof(v,t);
-		#elseif php
-		untyped __call__("_hx_instanceof", v,t);
-		#elseif cpp
-		__global__.__instanceof(v,t);
-		#else
-		false;
-		#end
-	}
+	public static function is( v : Dynamic, t : Dynamic ) : Bool;
 
 
 	/**
 	/**
 		Convert any value to a String
 		Convert any value to a String
 	**/
 	**/
-	public static function string( s : Dynamic ) : String {
-		return untyped
-		#if flash
-		flash.Boot.__string_rec(s,"");
-		#elseif neko
-		new String(__dollar__string(s));
-		#elseif js
-		js.Boot.__string_rec(s,"");
-		#elseif php
-		__call__("_hx_string_rec", s, '');
-		#elseif cpp
-		s==null ? "null" : s.toString();
-		#else
-		"";
-		#end
-	}
+	public static function string( s : Dynamic ) : String;
 
 
 	/**
 	/**
 		Convert a Float to an Int, rounded down.
 		Convert a Float to an Int, rounded down.
 	**/
 	**/
-	public #if (flash9 || php) inline #end static function int( x : Float ) : Int {
-		#if flash9
-		return untyped __int__(x);
-		#elseif php
-		return untyped __php__("intval")(x);
-		#elseif cpp
-		return untyped __global__.__int__(x);
-		#else
-		if( x < 0 ) return Math.ceil(x);
-		return Math.floor(x);
-		#end
-	}
+	public static function int( x : Float ) : Int;
 
 
 	/**
 	/**
 		Convert a String to an Int, parsing different possible representations. Returns [null] if could not be parsed.
 		Convert a String to an Int, parsing different possible representations. Returns [null] if could not be parsed.
 	**/
 	**/
-	public static function parseInt( x : String ) : Null<Int> {
-		untyped {
-		#if flash9
-		var v = __global__["parseInt"](x);
-		if( __global__["isNaN"](v) )
-			return null;
-		return v;
-		#elseif flash
-		var v = _global["parseInt"](x);
-		if( Math.isNaN(v) )
-			return null;
-		return v;
-		#elseif neko
-		var t = __dollar__typeof(x);
-		if( t == __dollar__tint )
-			return x;
-		if( t == __dollar__tfloat )
-			return __dollar__int(x);
-		if( t != __dollar__tobject )
-			return null;
-		return __dollar__int(x.__s);
-		#elseif js
-		var v = __js__("parseInt")(x);
-		if( Math.isNaN(v) )
-			return null;
-		return v;
-		#elseif php
-		if(!__php__("is_numeric")(x)) return null;
-		return x.substr(0, 2).toLowerCase() == "0x" ? __php__("intval(substr($x, 2), 16)") : __php__("intval($x)");
-		#elseif cpp
-		if (x==null) return null;
-		return __global__.__hxcpp_parse_int(x);
-		#else
-		return 0;
-		#end
-		}
-	}
+	public static function parseInt( x : String ) : Null<Int>;
 
 
 	/**
 	/**
 		Convert a String to a Float, parsing different possible reprensations.
 		Convert a String to a Float, parsing different possible reprensations.
 	**/
 	**/
-	public static function parseFloat( x : String ) : Float {
-		return untyped
-		#if flash9
-		__global__["parseFloat"](x);
-		#elseif flash
-		_global["parseFloat"](x);
-		#elseif neko
-		__dollar__float(x.__s);
-		#elseif js
-		__js__("parseFloat")(x);
-		#elseif php
-		__php__("is_numeric($x) ? floatval($x) : acos(1.01)");
-		#elseif cpp
-		__global__.__hxcpp_parse_float(x);
-		#else
-		0;
-		#end
-	}
+	public static function parseFloat( x : String ) : Float;
 
 
 	/**
 	/**
 		Return a random integer between 0 included and x excluded.
 		Return a random integer between 0 included and x excluded.
 	**/
 	**/
-	public static function random( x : Int ) : Int {
-		return untyped
-		#if flash9
-		Math.floor(Math.random()*x);
-		#elseif flash
-		__random__(x);
-		#elseif neko
-		Math._rand_int(Math.__rnd,x);
-		#elseif js
-		Math.floor(Math.random()*x);
-		#elseif php
-		__call__("rand", 0, x-1);
-		#elseif cpp
-		__global__.rand() % x;
-		#else
-		0;
-		#end
-	}
-
-	/**
-		Initialization the things needed for reflection
-	**/
-	static function __init__() untyped {
-		#if js
-			String.prototype.__class__ = String;
-			String.__name__ = ["String"];
-			Array.prototype.__class__ = Array;
-			Array.__name__ = ["Array"];
-			Int = { __name__ : ["Int"] };
-			Dynamic = { __name__ : ["Dynamic"] };
-			Float = __js__("Number");
-			Float.__name__ = ["Float"];
-			Bool = { __ename__ : ["Bool"] };
-			Class = { __name__ : ["Class"] };
-			Enum = {};
-			Void = { __ename__ : ["Void"] };
-		#elseif cpp
-			null;
-		#elseif flash9
-			null;
-		#elseif flash
-			var g : Dynamic = _global;
-			g["Int"] = { __name__ : ["Int"] };
-			g["Bool"] = { __ename__ : ["Bool"] };
-			g.Dynamic = { __name__ : [__unprotect__("Dynamic")] };
-			g.Class = { __name__ : [__unprotect__("Class")] };
-			g.Enum = {};
-			g.Void = { __ename__ : [__unprotect__("Void")] };
-			g["Float"] = _global["Number"];
-			g["Float"][__unprotect__("__name__")] = ["Float"];
-			Array.prototype[__unprotect__("__class__")] = Array;
-			Array[__unprotect__("__name__")] = ["Array"];
-			String.prototype[__unprotect__("__class__")] = String;
-			String[__unprotect__("__name__")] = ["String"];
-			g["ASSetPropFlags"](Array.prototype,null,7);
-		#elseif neko
-			Int = { __name__ : ["Int"] };
-			Float = { __name__ : ["Float"] };
-			Bool = { __ename__ : ["Bool"] };
-			Dynamic = { __name__ : ["Dynamic"] };
-			Class = { __name__ : ["Class"] };
-			Enum = {};
-			Void = { __ename__ : ["Void"] };
-			var cl = neko.Boot.__classes;
-			cl.String = String;
-			cl.Array = Array;
-			cl.Int = Int;
-			cl.Float = Float;
-			cl.Bool = Bool;
-			cl.Dynamic = Dynamic;
-			cl.Class = Class;
-			cl.Enum = Enum;
-			cl.Void = Void;
-		#end
-	}
+	public static function random( x : Int ) : Int;
 
 
 }
 }

+ 1 - 3
std/StringBuf.hx

@@ -93,9 +93,7 @@ class StringBuf {
 	}
 	}
 
 
 	private var b :
 	private var b :
-	#if neko
-		Dynamic
-	#elseif (js || cpp)
+	#if (js || cpp)
 		Array<Dynamic>
 		Array<Dynamic>
 	#else
 	#else
 		String
 		String

+ 13 - 446
std/Type.hx

@@ -43,505 +43,72 @@ enum ValueType {
 	The haXe Reflection API enables you to retreive informations about any value,
 	The haXe Reflection API enables you to retreive informations about any value,
 	Classes and Enums at runtime.
 	Classes and Enums at runtime.
 **/
 **/
-class Type {
+extern class Type {
 
 
 	/**
 	/**
 		Returns the class of a value or [null] if this value is not a Class instance.
 		Returns the class of a value or [null] if this value is not a Class instance.
 	**/
 	**/
-	public static function getClass<T>( o : T ) : Class<T> untyped {
-		#if flash9
-			var cname = __global__["flash.utils.getQualifiedClassName"](o);
-			if( cname == "null" || cname == "Object" || cname == "int" || cname == "Number" || cname == "Boolean" )
-				return null;
-			if( o.hasOwnProperty("prototype") )
-				return null;
-			var c = __as__(__global__["flash.utils.getDefinitionByName"](cname),Class);
-			if( c.__isenum )
-				return null;
-			return c;
-		#elseif flash
-			if( o.__enum__ != null )
-				return null;
-			return o.__class__;
-		#elseif js
-			if( o == null )
-				return null;
-			if( o.__enum__ != null )
-				return null;
-			return o.__class__;
-		#elseif neko
-			if( __dollar__typeof(o) != __dollar__tobject )
-				return null;
-			var p = __dollar__objgetproto(o);
-			if( p == null )
-				return null;
-			return p.__class__;
-		#elseif php
-			if(o == null) return null;
-			untyped if(__call__("is_array",  o)) {
-				if(__call__("count", o) == 2 && __call__("is_callable", o)) return null;
-				return __call__("_hx_ttype", 'Array');
-			}
-			if(untyped __call__("is_string", o)) {
-				if(__call__("_hx_is_lambda", untyped o)) return null;
-				return __call__("_hx_ttype", 'String');
-			}
-			if(!untyped __call__("is_object", o)) {
-				return null;
-			}
-			var c = __call__("get_class", o);
-			if(c == false || c == '_hx_anonymous' || __call__("is_subclass_of", c, "enum"))
-				return null;
-			else
-				return __call__("_hx_ttype", c);
-		#elseif cpp
-			if (o==null || !Reflect.isObject(o))  return null;
-			var c = o.__GetClass();
-			switch(c.toString())
-			{
-				case "__Anon" : return null;
-				case "Class" : return null;
-			}
-			return c;
-		#else
-			return null;
-		#end
-	}
+	public static function getClass<T>( o : T ) : Class<T>;
 
 
 	/**
 	/**
 		Returns the enum of a value or [null] if this value is not an Enum instance.
 		Returns the enum of a value or [null] if this value is not an Enum instance.
 	**/
 	**/
-	public static function getEnum( o : Dynamic ) : Enum<Dynamic> untyped {
-		#if flash9
-			var cname = __global__["flash.utils.getQualifiedClassName"](o);
-			if( cname == "null" || cname.substr(0,8) == "builtin." )
-				return null;
-			// getEnum(Enum) should be null
-			if( o.hasOwnProperty("prototype") )
-				return null;
-			var c = __as__(__global__["flash.utils.getDefinitionByName"](cname),Class);
-			if( !c.__isenum )
-				return null;
-			return c;
-		#elseif flash
-			return o.__enum__;
-		#elseif js
-			if( o == null )
-				return null;
-			return o.__enum__;
-		#elseif neko
-			if( __dollar__typeof(o) != __dollar__tobject )
-				return null;
-			return o.__enum__;
-		#elseif php
-			if(!__php__("$o instanceof Enum"))
-				return null;
-			else
-				return __php__("_hx_ttype(get_class($o))");
-		#elseif cpp
-			if (o==null) return null;
-			return o.__GetClass();
-		#else
-			return null;
-		#end
-	}
+	public static function getEnum( o : Dynamic ) : Enum<Dynamic>;
 
 
 
 
 	/**
 	/**
 		Returns the super-class of a class, or null if no super class.
 		Returns the super-class of a class, or null if no super class.
 	**/
 	**/
-	public static function getSuperClass( c : Class<Dynamic> ) : Class<Dynamic> untyped {
-		#if flash9
-			var cname = __global__["flash.utils.getQualifiedSuperclassName"](c);
-			if( cname == "Object" )
-				return null;
-			return __as__(__global__["flash.utils.getDefinitionByName"](cname),Class);
-		#elseif php
-			var s = __php__("get_parent_class")(c.__tname__);
-			if(s == false)
-				return null;
-			else
-				return __call__("_hx_ttype", s);
-		#elseif cpp
-			return c.GetSuper();
-		#else
-			return c.__super__;
-		#end
-	}
+	public static function getSuperClass( c : Class<Dynamic> ) : Class<Dynamic>;
 
 
 
 
 	/**
 	/**
 		Returns the complete name of a class.
 		Returns the complete name of a class.
 	**/
 	**/
-	public static function getClassName( c : Class<Dynamic> ) : String {
-		if( c == null )
-			return null;
-		#if flash9
-			var str : String = untyped __global__["flash.utils.getQualifiedClassName"](c);
-			switch( str ) {
-			case "int": return "Int";
-			case "Number": return "Float";
-			case "Boolean": return "Bool";
-			default:
-			}
-			return str.split("::").join(".");
-		#elseif php
-			return untyped c.__qname__;
-		#elseif cpp
-			return untyped c.mName;
-		#else
-			var a : Array<String> = untyped c.__name__;
-			return a.join(".");
-		#end
-	}
+	public static function getClassName( c : Class<Dynamic> ) : String;
 
 
 	/**
 	/**
 		Returns the complete name of an enum.
 		Returns the complete name of an enum.
 	**/
 	**/
-	public static function getEnumName( e : Enum<Dynamic> ) : String {
-		#if flash9
-			return getClassName(cast e);
-		#elseif php
-			return untyped e.__qname__;
-		#elseif (cpp)
-			return untyped e.__ToString();
-		#else
-			var a : Array<String> = untyped e.__ename__;
-			return a.join(".");
-		#end
-	}
+	public static function getEnumName( e : Enum<Dynamic> ) : String;
 
 
 	/**
 	/**
 		Evaluates a class from a name. The class must have been compiled
 		Evaluates a class from a name. The class must have been compiled
 		to be accessible.
 		to be accessible.
 	**/
 	**/
-	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
-		#if php
-			var c = untyped __call__("_hx_qtype", name);
-			if(__php__("$c instanceof _hx_class"))
-				return c;
-			else
-				return null;
-		#elseif cpp
-			var result:Class<Dynamic> = Class.Resolve(name);
-			if (result!=null && result.__IsEnum() )
-				return null;
-			return result;
-		#else
-			var cl : Class<Dynamic>;
-		#if flash9
-			try {
-				cl = __as__(__global__["flash.utils.getDefinitionByName"](name),Class);
-				if( cl.__isenum )
-					return null;
-				return cl; // skip test below
-			} catch( e : Dynamic ) {
-				switch( name ) {
-				case "Int": return Int;
-				case "Float": return Float;
-				}
-				return null;
-			}
-		#elseif flash
-			cl = __eval__(name);
-		#elseif js
-			try {
-				#if js_namespace
-				if (name.indexOf('.') < 0)
-					cl = eval(js.Boot.__ns + '.' + name);
-				else
-					cl = eval(name);
-				#else
-				cl = eval(name);
-				#end
-			} catch( e : Dynamic ) {
-				cl = null;
-			}
-		#elseif neko
-			var path = name.split(".");
-			cl = Reflect.field(untyped neko.Boot.__classes,path[0]);
-			var i = 1;
-			while( cl != null && i < path.length ) {
-				cl = Reflect.field(cl,path[i]);
-				i += 1;
-			}
-		#else
-			cl = null;
-		#end
-			// ensure that this is a class
-			if( cl == null || cl.__name__ == null )
-				return null;
-			return cl;
-		#end
-	}
+	public static function resolveClass( name : String ) : Class<Dynamic>;
 
 
 
 
 	/**
 	/**
 		Evaluates an enum from a name. The enum must have been compiled
 		Evaluates an enum from a name. The enum must have been compiled
 		to be accessible.
 		to be accessible.
 	**/
 	**/
-	public static function resolveEnum( name : String ) : Enum<Dynamic> untyped {
-		#if php
-			var e = untyped __call__("_hx_qtype", name);
-			if(untyped __php__("$e instanceof _hx_enum"))
-				return e;
-			else
-				return null;
-		#elseif cpp
-			var result:Class<Dynamic> = Class.Resolve(name);
-			if (result!=null && !result.__IsEnum() )
-				return null;
-			return result;
-		#else
-			var e : Dynamic;
-		#if flash9
-			try {
-				e = __global__["flash.utils.getDefinitionByName"](name);
-				if( !e.__isenum )
-					return null;
-				return e;
-			} catch( e : Dynamic ) {
-				if( name == "Bool" ) return Bool;
-				return null;
-			}
-		#elseif flash
-			e = __eval__(name);
-		#elseif js
-			try {
-				#if js_namespace
-				if (name.indexOf('.') < 0)
-					e = eval(js.Boot.__ns + '.' + name);
-				else
-					e = eval(name);
-				#else
-				e = eval(name);
-				#end
-			} catch( err : Dynamic ) {
-				e = null;
-			}
-		#elseif neko
-			var path = name.split(".");
-			e = Reflect.field(neko.Boot.__classes,path[0]);
-			var i = 1;
-			while( e != null && i < path.length ) {
-				e = Reflect.field(e,path[i]);
-				i += 1;
-			}
-		#else
-			e = null;
-		#end
-			// ensure that this is an enum
-			if( e == null || e.__ename__ == null )
-				return null;
-			return e;
-		#end
-	}
+	public static function resolveEnum( name : String ) : Enum<Dynamic>;
 
 
 	/**
 	/**
 		Creates an instance of the given class with the list of constructor arguments.
 		Creates an instance of the given class with the list of constructor arguments.
 	**/
 	**/
-	public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T untyped {
-		#if flash9
-			return switch( args.length ) {
-			case 0: __new__(cl);
-			case 1: __new__(cl,args[0]);
-			case 2: __new__(cl,args[0],args[1]);
-			case 3: __new__(cl,args[0],args[1],args[2]);
-			case 4: __new__(cl,args[0],args[1],args[2],args[3]);
-			case 5: __new__(cl,args[0],args[1],args[2],args[3],args[4]);
-			case 6: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]);
-			case 7: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
-			case 8: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
-			case 9: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
-			case 10: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]);
-			case 11: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]);
-			case 12: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]);
-			case 13: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]);
-			case 14: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13]);
-			default: throw "Too many arguments";
-			}
-		#elseif flash
-			if( cl == Array ) return new Array();
-			var o = { __constructor__ : cl, __proto__ : cl.prototype };
-			cl["apply"](o,args);
-			return o;
-		#elseif neko
-			return __dollar__call(__dollar__objget(cl,__dollar__hash("new".__s)),cl,args.__neko());
-		#elseif js
-			if( args.length <= 3 )
-				return __new__(cl,args[0],args[1],args[2]);
-			if( args.length > 8 )
-				throw "Too many arguments";
-			return __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
-		#elseif php
-			if(cl.__qname__ == 'Array') return [];
-			if(cl.__qname__ == 'String') return args[0];
-			var c = cl.__rfl__();
-			if(c == null) return null;
-			return __php__("$inst = $c->getConstructor() ? $c->newInstanceArgs($args->»a) : $c->newInstanceArgs()");
-		#elseif cpp
-			if (cl!=null)
-				return cl.mConstructArgs(args);
-			return null;
-		#else
-			return null;
-		#end
-	}
-
+	public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T;
 	/**
 	/**
 		Similar to [Reflect.createInstance] excepts that the constructor is not called.
 		Similar to [Reflect.createInstance] excepts that the constructor is not called.
 		This enables you to create an instance without any side-effect.
 		This enables you to create an instance without any side-effect.
 	**/
 	**/
-	public static function createEmptyInstance<T>( cl : Class<T> ) : T untyped {
-		#if flash9
-			try {
-				flash.Boot.skip_constructor = true;
-				var i = __new__(cl);
-				flash.Boot.skip_constructor = false;
-				return i;
-			} catch( e : Dynamic ) {
-				flash.Boot.skip_constructor = false;
-				throw e;
-			}
-			return null;
-		#elseif flash
-			if( cl == Array ) return new Array();
-			var o : Dynamic = __new__(_global["Object"]);
-			o.__proto__ = cl.prototype;
-			return o;
-		#elseif js
-			return __new__(cl,__js__("$_"));
-		#elseif neko
-			var o = __dollar__new(null);
-			__dollar__objsetproto(o,cl.prototype);
-			return o;
-		#elseif php
-			if(cl.__qname__ == 'Array') return [];
-			if(cl.__qname__ == 'String') return '';
-			try {
-				__php__("php_Boot::$skip_constructor = true");
-				var rfl = cl.__rfl__();
-				if(rfl == null) return null;
-				var m = __php__("$rfl->getConstructor()");
-				var nargs : Int = m.getNumberOfRequiredParameters();
-				var i;
-				if(nargs > 0) {
-					var args = __call__("array_fill", 0, m.getNumberOfRequiredParameters(), null);
-					i = __php__("$rfl->newInstanceArgs($args)");
-				} else {
-					i = __php__("$rfl->newInstanceArgs(array())");
-				}
-				__php__("php_Boot::$skip_constructor = false");
-				return i;
-			} catch( e : Dynamic ) {
-				__php__("php_Boot::$skip_constructor = false");
-				throw "Unable to instantiate " + Std.string(cl);
-			}
-			return null;
-		#elseif cpp
-			return cl.mConstructEmpty();
-		#else
-			return null;
-		#end
-	}
+	public static function createEmptyInstance<T>( cl : Class<T> ) : T;
 
 
 	/**
 	/**
 		Create an instance of an enum by using a constructor name and parameters.
 		Create an instance of an enum by using a constructor name and parameters.
 	**/
 	**/
-	public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
-		#if cpp
-		if (untyped e.mConstructEnum != null)
-			return untyped e.mConstructEnum(constr,params);
-		return null;
-		#else
-		var f = Reflect.field(e,constr);
-		if( f == null ) throw "No such constructor "+constr;
-		if( Reflect.isFunction(f) ) {
-			if( params == null ) throw "Constructor "+constr+" need parameters";
-			return Reflect.callMethod(e,f,params);
-		}
-		if( params != null && params.length != 0 )
-			throw "Constructor "+constr+" does not need parameters";
-		return f;
-		#end
-	}
+	public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T;
 
 
 	/**
 	/**
 		Create an instance of an enum by using a constructor index and parameters.
 		Create an instance of an enum by using a constructor index and parameters.
 	**/
 	**/
-	public static function createEnumIndex<T>( e : Enum<T>, index : Int, ?params : Array<Dynamic> ) : T {
-		var c = Type.getEnumConstructs(e)[index];
-		if( c == null ) throw index+" is not a valid enum constructor index";
-		return createEnum(e,c,params);
-	}
-
-	#if flash9
-	static function describe( t : Dynamic, fact : Bool ) untyped {
-		var fields = new Array();
-		var xml : flash.xml.XML = __global__["flash.utils.describeType"](t);
-		if( fact )
-			xml = xml.factory[0];
-		var methods = xml.child("method");
-		for( i in 0...methods.length() )
-			fields.push( Std.string(methods[i].attribute("name")) );
-		var vars = xml.child("variable");
-		for( i in 0...vars.length() )
-			fields.push( Std.string(vars[i].attribute("name")) );
-		var accs = xml.child("accessor");
-		for( i in 0...accs.length() )
-			fields.push( Std.string(accs[i].attribute("name")) );
-		return fields;
-	}
-	#end
+	public static function createEnumIndex<T>( e : Enum<T>, index : Int, ?params : Array<Dynamic> ) : T;
 
 
 	/**
 	/**
 		Returns the list of instance fields.
 		Returns the list of instance fields.
 	**/
 	**/
-	public static function getInstanceFields( c : Class<Dynamic> ) : Array<String> {
-		#if flash9
-			return describe(c,true);
-		#elseif php
-			if(untyped c.__qname__ == 'String') return ['substr', 'charAt', 'charCodeAt', 'indexOf', 'lastIndexOf', 'split', 'toLowerCase', 'toUpperCase', 'toString', 'length'];
-			if(untyped c.__qname__ == 'Array') return  ['push', 'concat', 'join', 'pop', 'reverse', 'shift', 'slice', 'sort', 'splice', 'toString', 'copy', 'unshift', 'insert', 'remove', 'iterator', 'length'];
-			untyped __php__("
-			$rfl = $c->__rfl__();
-			if($rfl === null) return new _hx_array(array());
-			$r = array();
-			$internals = array('__construct', '__call', '__get', '__set', '__isset', '__unset', '__toString');
-			$ms = $rfl->getMethods();
-			while(list(, $m) = each($ms)) {
-				$n = $m->getName();
-				if(!$m->isStatic() && ! in_array($n, $internals)) $r[] = $n;
-			}
-			$ps = $rfl->getProperties();
-			while(list(, $p) = each($ps))
-				if(!$p->isStatic()) $r[] = $p->getName()");
-			return untyped __php__("new _hx_array(array_values(array_unique($r)))");
-		#elseif cpp
-			return untyped c.GetInstanceFields();
-		#else
-
-			var a = Reflect.fields(untyped c.prototype);
-			#if js
-				a.remove("__class__");
-			#else
-				c = untyped c.__super__;
-				while( c != null ) {
-					for( f in Reflect.fields(untyped c.prototype) ) {
-						a.remove(f);
-						a.push(f);
-					}
-					c = untyped c.__super__;
-				}
-				a.remove("__class__");
-				#if neko
-				a.remove("__serialize");
-				a.remove("__string");
-				#end
-			#end
-			return a;
-		#end
-	}
+	public static function getInstanceFields( c : Class<Dynamic> ) : Array<String>;
 
 
 	/**
 	/**
 		Returns the list of a class static fields.
 		Returns the list of a class static fields.

+ 0 - 19
std/Xml.hx

@@ -225,25 +225,6 @@ extern class Xml {
 	**/
 	**/
 	function toString() : String;
 	function toString() : String;
 
 
-#if !(php || neko)
-	static function __init__() : Void untyped {
-		#if js
-			Xml = js.JsXml__;
-		#elseif flash9
-			var ref = flash.FlashXml__; // force compile
-		#end
-		#if !flash9
-		Xml.__name__ = ["Xml"];
-		#end
-		Xml.Element = "element";
-		Xml.PCData = "pcdata";
-		Xml.CData = "cdata";
-		Xml.Comment = "comment";
-		Xml.DocType = "doctype";
-		Xml.Prolog = "prolog";
-		Xml.Document = "document";
-	}
-#end
 }
 }
 
 
 
 

+ 6 - 5
typeload.ml

@@ -575,15 +575,16 @@ let init_core_api ctx c =
 			let ctx2 = (!do_create) com in
 			let ctx2 = (!do_create) com in
 			ctx.core_api := Some ctx2;
 			ctx.core_api := Some ctx2;
 			ctx2
 			ctx2
-		| Some c -> 
+		| Some c ->
 			c
 			c
 	) in
 	) in
 	let t = load_instance ctx2 { tpackage = fst c.cl_path; tname = snd c.cl_path; tparams = []; tsub = None; } c.cl_pos true in
 	let t = load_instance ctx2 { tpackage = fst c.cl_path; tname = snd c.cl_path; tparams = []; tsub = None; } c.cl_pos true in
 	match t with
 	match t with
-	| TInst (ccore,_) -> 
+	| TInst (ccore,_) ->
 		let check_fields fcore fl =
 		let check_fields fcore fl =
-			PMap.iter (fun i f ->				
-				let f2 = try PMap.find f.cf_name fl with Not_found -> error ("Missing field " ^ i ^ " required by core type") c.cl_pos in				
+			PMap.iter (fun i f ->
+				if not f.cf_public then () else
+				let f2 = try PMap.find f.cf_name fl with Not_found -> error ("Missing field " ^ i ^ " required by core type") c.cl_pos in
 				let p = (match f2.cf_expr with None -> c.cl_pos | Some e -> e.epos) in
 				let p = (match f2.cf_expr with None -> c.cl_pos | Some e -> e.epos) in
 				(try
 				(try
 					type_eq EqCoreType (apply_params ccore.cl_types (List.map snd c.cl_types) f.cf_type) f2.cf_type
 					type_eq EqCoreType (apply_params ccore.cl_types (List.map snd c.cl_types) f.cf_type) f2.cf_type
@@ -614,7 +615,7 @@ let init_class ctx c p herits fields =
 	c.cl_interface <- List.mem HInterface herits;
 	c.cl_interface <- List.mem HInterface herits;
 	set_heritance ctx c herits p;
 	set_heritance ctx c herits p;
 	let core_api = has_meta ":core_api" c.cl_meta in
 	let core_api = has_meta ":core_api" c.cl_meta in
-	if core_api then ctx.delays := [(fun() -> init_core_api ctx c)] :: !(ctx.delays);	
+	if core_api then ctx.delays := [(fun() -> init_core_api ctx c)] :: !(ctx.delays);
 	let tthis = TInst (c,List.map snd c.cl_types) in
 	let tthis = TInst (c,List.map snd c.cl_types) in
 	let rec extends_public c =
 	let rec extends_public c =
 		List.exists (fun (c,_) -> c.cl_path = (["haxe"],"Public") || extends_public c) c.cl_implements ||
 		List.exists (fun (c,_) -> c.cl_path = (["haxe"],"Public") || extends_public c) c.cl_implements ||