Procházet zdrojové kódy

#else/#elseif changes
+ minor fixes

Nicolas Cannasse před 17 roky
rodič
revize
c9e845578b

+ 7 - 0
doc/CHANGES.txt

@@ -19,6 +19,13 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	f9dynamic is now dynamic and is mandatory on all platforms
 	public/private/dynamic are inherited by default when overriding a method
 	added Bytes api
+	removed Reflect.empty() : use {} instead
+	changed #else by #elseif, added #else
+	flash9 : optimized Hash,IntHash,StringBuf (use typed value)
+	Reflect.field/setField/callMethod , Type.enumIndex and StringBuf methods are now inlined
+	optimized haxe.Md5 : don't use statics
+	allow up to 8 parameters in Reflect.createInstance
+	flash9 : some minor optimizations in haxe.Serializer
 
 2008-04-05: 1.19
 	fixed flash9 Array.toString

+ 2 - 2
genxml.ml

@@ -172,12 +172,12 @@ let rec write_xml ch tabs x =
 	| CData s ->
 		IO.printf ch "<![CDATA[%s]]>" s
 
-let generate com ctx =
+let generate com ctx file =
 	let t = Common.timer "construct xml" in
 	let x = node "haxe" [] (List.map (gen_type_decl ctx) com.types) in
 	t();
 	let t = Common.timer "write xml" in
-	let ch = IO.output_channel (open_out_bin com.file) in
+	let ch = IO.output_channel (open_out_bin file) in
 	write_xml ch "" x;
 	IO.close_out ch;
 	t()

+ 1 - 1
main.ml

@@ -421,7 +421,7 @@ try
 		| None -> ()
 		| Some file ->
 			if com.verbose then print_endline ("Generating xml : " ^ com.file);
-			Genxml.generate com ctx);
+			Genxml.generate com ctx file);
 	end;
 	if not !no_output then List.iter (fun cmd ->
 		let t = Common.timer "command" in

+ 7 - 3
parser.ml

@@ -659,7 +659,7 @@ let parse ctx code file =
 			| _ :: l ->
 				mstack := l;
 				next_token())
-		| Macro "else" ->
+		| Macro "else" | Macro "elseif" ->
 			(match !mstack with
 			| [] -> raise Exit
 			| _ :: l ->
@@ -667,6 +667,8 @@ let parse ctx code file =
 				process_token (skip_tokens false))
 		| Macro "if" ->
 			process_token (enter_macro())
+		| Macro "error" ->
+			error Unimplemented (snd tk)
 		| Macro "line" ->
 			let line = (match next_token() with
 				| (Const (Int s),_) -> int_of_string s
@@ -688,7 +690,6 @@ let parse ctx code file =
 	and eval_macro allow_expr =
 		match Lexer.token code with
 		| (Const (Ident s),p) | (Const (Type s),p) ->
-			if s = "error" then error Unimplemented p;
 			let ok = Common.defined ctx s in
 			(match Lexer.token code with
 			| (Binop OpBoolOr,_) when allow_expr ->
@@ -714,9 +715,12 @@ let parse ctx code file =
 		match fst tk with
 		| Macro "end" ->
 			Lexer.token code
-		| Macro "else" when not test ->
+		| Macro "elseif" | Macro "else" when not test ->
 			skip_tokens test
 		| Macro "else" ->
+			mstack := snd tk :: !mstack;
+			Lexer.token code
+		| Macro "elseif" ->
 			enter_macro()
 		| Macro "if" ->
 			skip_tokens_loop test (skip_tokens false)

+ 5 - 5
std/Date.hx

@@ -114,7 +114,7 @@ extern class Date
 	#if neko
 		Date = neko.NekoDate__;
 		neko.Boot.__classes.Date = Date;
-	#else true
+	#else
 		Date.now = function() {
 			return __new__(Date);
 		};
@@ -122,7 +122,7 @@ extern class Date
 			var d : Date = __new__(Date);
 			#if flash9
 			d.setTime(t);
-			#else true
+			#else
 			d["setTime"]( t );
 			#end
 			return d;
@@ -137,7 +137,7 @@ extern class Date
 				d.setUTCHours(k[0]);
 				d.setUTCMinutes(k[1]);
 				d.setUTCSeconds(k[2]);
-				#else true
+				#else
 				d["setTime"](0);
 				d["setUTCHours"](k[0]);
 				d["setUTCMinutes"](k[1]);
@@ -170,10 +170,10 @@ extern class Date
 				+":"+(if( s < 10 ) "0"+s else ""+s);
 		};
 		#if flash9
-		#else flash
+		#elseif flash
 		Date.prototype[__unprotect__("__class__")] = Date;
 		Date[__unprotect__("__name__")] = ["Date"];
-		#else true
+		#else
 		Date.prototype.__class__ = Date;
 		Date.__name__ = ["Date"];
 		#end

+ 6 - 8
std/DateTools.hx

@@ -32,7 +32,8 @@
 class DateTools {
 
 	#if neko
-	#else true
+	static var date_format = neko.Lib.load("std","date_format",2);
+	#else
 	private static function __jsflash_format_get( d : Date, e : String ) : String {
 		return switch( e ){
 			case "%":
@@ -104,10 +105,6 @@ class DateTools {
 	}
 	#end
 
-	#if neko
-		static var date_format = neko.Lib.load("std","date_format",2);
-	#end
-
 	/**
 		Format the date [d] according to the format [f]. The format
 		is compatible with the [strftime] standard format, except that there
@@ -118,11 +115,12 @@ class DateTools {
 	public static function format( d : Date, f : String ) : String {
 		#if neko
 			untyped return new String(date_format(d.__t, f.__s));
-		#else js
+		#elseif js
 			return __jsflash_format(d, f );
-		#else flash
+		#elseif flash
 			return __jsflash_format(d, f );
-		#else error
+		#else
+			return null;
 		#end
 	}
 

+ 152 - 167
std/EReg.hx

@@ -45,19 +45,18 @@ class EReg {
 	**/
 	public function new( r : String, opt : String ) {
 		#if neko
-		var a = opt.split("g");
-		global = a.length > 1;
-		if( global )
-			opt = a.join("");
-		this.r = regexp_new_options(untyped r.__s, untyped opt.__s);
-		#else js
-		opt = opt.split("u").join(""); // 'u' (utf8) depends on page encoding
-		this.r = untyped __new__("RegExp",r,opt);
-		#else flash9
-		this.r = untyped __new__(__global__["RegExp"],r,opt);
-		#else flash
-		throw "Regular expressions are not implemented for Flash <= 8";
-		#else error
+			var a = opt.split("g");
+			global = a.length > 1;
+			if( global )
+				opt = a.join("");
+			this.r = regexp_new_options(untyped r.__s, untyped opt.__s);
+		#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);
+		#else
+			throw "Regular expressions are not implemented for this platform";
 		#end
 	}
 
@@ -67,27 +66,25 @@ class EReg {
 	**/
 	public function match( s : String ) : Bool {
 		#if neko
-		var p = regexp_match(r,untyped s.__s,0,s.length);
-		if( p )
-			last = s;
-		else
-			last = null;
-		return p;
-		#else js
-		untyped {
-			r.m = r.exec(s);
-			r.s = s;
-			r.l = RegExp.leftContext;
-			r.r = RegExp.rightContext;
-			return (r.m != null);
-		}
-		#else flash9
-		result = untyped r.exec(s);
-		return (result != null);
-		#else flash
-		throw "EReg::match not implemented";
-		return false;
-		#else error
+			var p = regexp_match(r,untyped s.__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);
+		#else
+			return false;
 		#end
 	}
 
@@ -98,15 +95,13 @@ class EReg {
 	**/
 	public function matched( n : Int ) : String {
 		#if neko
-		return new String(regexp_matched(r,n));
-		#else js
-		return untyped if( r.m != null && n >= 0 && n < r.m.length ) r.m[n] else throw "EReg::matched";
-		#else flash9
-		return untyped if( result != null && n >= 0 && n < result.length ) result[n] else throw "EReg::matched";
-		#else flash
-		throw "EReg::matched not implemented";
-		return "";
-		#else error
+			return new String(regexp_matched(r,n));
+		#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";
+		#else
+			return null;
 		#end
 	}
 
@@ -116,21 +111,19 @@ class EReg {
 	**/
 	public function matchedLeft() : String {
 		#if neko
-		var p = regexp_matched_pos(r,0);
-		return last.substr(0,p.pos);
-		#else js
-		untyped {
-			if( r.m == null ) throw "EReg::matchedLeft";
-			if( r.l == null ) return r.s.substr(0,r.m.index);
-			return r.l;
-		}
-		#else flash9
-		if( result == null ) throw "No string matched";
-		return result.input.substr(0,result.index);
-		#else flash
-		throw "EReg::matchedLeft not implemented";
-		return null;
-		#else error
+			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";
+			return result.input.substr(0,result.index);
+		#else
+			return null;
 		#end
 	}
 
@@ -140,26 +133,24 @@ class EReg {
 	**/
 	public function matchedRight() : String {
 		#if neko
-		var p = regexp_matched_pos(r,0);
-		var sz = p.pos+p.len;
-		return last.substr(sz,last.length-sz);
-		#else js
-		untyped {
-			if( r.m == null ) throw "EReg::matchedRight";
-			if( r.r == null ) {
-				var sz = r.m.index+r.m[0].length;
-				return r.s.substr(sz,r.s.length-sz);
+			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;
 			}
-			return r.r;
-		}
-		#else flash9
-		if( result == null ) throw "No string matched";
-		var rl = result.index + result[0].length;
-		return result.input.substr(rl,result.input.length - rl);
-		#else flash
-		throw "EReg::matchedRight not implemented";
-		return null;
-		#else error
+		#elseif flash9
+			if( result == null ) throw "No string matched";
+			var rl = result.index + result[0].length;
+			return result.input.substr(rl,result.input.length - rl);
+		#else
+			return null;
 		#end
 	}
 
@@ -169,17 +160,15 @@ class EReg {
 	**/
 	public function matchedPos() : { pos : Int, len : Int } {
 		#if neko
-		return regexp_matched_pos(r,0);
-		#else js
-		if( untyped r.m == null ) throw "EReg::matchedPos";
-		return untyped { pos : r.m.index, len : r.m[0].length };
-		#else flash9
-		if( result == null ) throw "No string matched";
-		return { pos : result.index, len : result[0].length };
-		#else flash
-		throw "EReg::matchedPos not implemented";
-		return null;
-		#else error
+			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 };
+		#else
+			return null;
 		#end
 	}
 
@@ -189,35 +178,33 @@ class EReg {
 	**/
 	public function split( s : String ) : Array<String> {
 		#if neko
-		var pos = 0;
-		var len = s.length;
-		var a = new Array();
-		var first = true;
-		do {
-			if( !regexp_match(r,untyped s.__s,pos,len) )
-				break;
-			var p = regexp_matched_pos(r,0);
-			if( p.len == 0 && !first ) {
-				if( p.pos == s.length )
+			var pos = 0;
+			var len = s.length;
+			var a = new Array();
+			var first = true;
+			do {
+				if( !regexp_match(r,untyped s.__s,pos,len) )
 					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;
-		#else (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);
-		#else flash
-		throw "EReg::split not implemented";
-		return null;
-		#else error
+				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);
+		#else
+			return null;
 		#end
 	}
 
@@ -228,60 +215,58 @@ class EReg {
 	**/
 	public function replace( s : String, by : String ) : String {
 		#if neko
-		var b = new StringBuf();
-		var pos = 0;
-		var len = s.length;
-		var a = by.split("$");
-		var first = true;
-		do {
-			if( !regexp_match(r,untyped s.__s,pos,len) )
-				break;
-			var p = regexp_matched_pos(r,0);
-			if( p.len == 0 && !first ) {
-				if( p.pos == s.length )
+			var b = new StringBuf();
+			var pos = 0;
+			var len = s.length;
+			var a = by.split("$");
+			var first = true;
+			do {
+				if( !regexp_match(r,untyped s.__s,pos,len) )
 					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,c-48) catch( e : String ) null;
-					if( p == null ){
+				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,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("$");
-						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 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();
-		#else (js || flash9)
-		return untyped s.replace(r,by);
-		#else flash
-		throw "EReg::replace not implemented";
-		return null;
-		#else error
+				}
+				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);
+		#else
+			return null;
 		#end
 	}
 

+ 31 - 28
std/Hash.hx

@@ -30,17 +30,19 @@
 **/
 class Hash<T> {
 
+	private var h : #if flash9 flash.utils.Dictionary #else Dynamic #end;
+
 	/**
 		Creates a new empty hashtable.
 	**/
 	public function new() : Void {
 		#if flash9
 		h = new flash.utils.Dictionary();
-		#else flash
+		#elseif flash
 		h = untyped __new__(_global["Object"]);
-		#else neko
+		#elseif neko
 		h = untyped __dollar__hnew(0);
-		#else js
+		#elseif js
 		untyped {
 			h = __js__("{}");
 			if( h.__proto__ != null ) {
@@ -48,7 +50,6 @@ class Hash<T> {
 				__js__("delete")(h.__proto__);
 			}
 		}
-		#else error
 		#end
 	}
 
@@ -58,11 +59,10 @@ class Hash<T> {
 	public function set( key : String, value : T ) : Void {
 		#if flash
 		untyped h["$"+key] = value;
-		#else js
+		#elseif js
 		untyped h["$"+key] = value;
-		#else neko
+		#elseif neko
 		untyped __dollar__hset(h,key.__s,value,null);
-		#else error
 		#end
 	}
 
@@ -72,11 +72,12 @@ class Hash<T> {
 	public function get( key : String ) : Null<T> {
 		#if flash
 		return untyped h["$"+key];
-		#else js
+		#elseif js
 		return untyped h["$"+key];
-		#else neko
+		#elseif neko
 		return untyped __dollar__hget(h,key.__s,null);
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -88,9 +89,9 @@ class Hash<T> {
 	public function exists( key : String ) : Bool {
 		#if flash9
 		return untyped h.hasOwnProperty("$"+key);
-		#else flash
+		#elseif flash
 		return untyped h["hasOwnProperty"]("$"+key);
-		#else js
+		#elseif js
 		try {
 			key = "$"+key;
 			return untyped this.hasOwnProperty.call(h,key);
@@ -101,9 +102,10 @@ class Hash<T> {
 			");
 			return false;
 		}
-		#else neko
+		#elseif neko
 		return untyped __dollar__hmem(h,key.__s,null);
-		#else error
+		#else
+		return false;
 		#end
 	}
 
@@ -117,19 +119,20 @@ class Hash<T> {
 		if( untyped !h.hasOwnProperty(key) ) return false;
 		untyped __delete__(h,key);
 		return true;
-		#else flash
+		#elseif flash
 		key = "$"+key;
 		if( untyped !h["hasOwnProperty"](key) ) return false;
 		untyped __delete__(h,key);
 		return true;
-		#else js
+		#elseif js
 		if( !exists(key) )
 			return false;
 		untyped __js__("delete")(h["$"+key]);
 		return true;
-		#else neko
+		#elseif neko
 		return untyped __dollar__hremove(h,key.__s,null);
-		#else error
+		#else
+		return false;
 		#end
 	}
 
@@ -139,20 +142,21 @@ class Hash<T> {
 	public function keys() : Iterator<String> {
 		#if flash9
 		return untyped (__hkeys__(h)).iterator();
-		#else flash
+		#elseif flash
 		return untyped (__hkeys__(h))["iterator"]();
-		#else js
+		#elseif js
 		var a = new Array<String>();
 		untyped __js__("
 			for(var i in this.h)
 				a.push(i.substr(1));
 		");
 		return a.iterator();
-		#else neko
+		#elseif neko
 		var l = new List<String>();
 		untyped __dollar__hiter(h,function(k,_) { l.push(new String(k)); });
 		return l.iterator();
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -167,25 +171,26 @@ class Hash<T> {
 			hasNext : function() { return this.it.hasNext(); },
 			next : function() { var i : Dynamic = this.it.next(); return this.ref[i]; }
 		};
-		#else flash
+		#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]; }
 		};
-		#else js
+		#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]; }
 		};
-		#else neko
+		#elseif neko
 		var l = new List<T>();
 		untyped __dollar__hiter(h,function(_,v) { l.push(v); });
 		return l.iterator();
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -208,6 +213,4 @@ class Hash<T> {
 		return s.toString();
 	}
 
-	private var h : Dynamic;
-
 }

+ 31 - 28
std/IntHash.hx

@@ -29,23 +29,24 @@
 **/
 class IntHash<T> {
 
+	private var h : #if flash9 flash.utils.Dictionary #else Dynamic #end;
+
 	/**
 		Creates a new empty hashtable.
 	**/
 	public function new() : Void {
 		#if flash9
 		h = new flash.utils.Dictionary();
-		#else flash
+		#elseif flash
 		h = untyped __new__(_global["Object"]);
-		#else neko
+		#elseif neko
 		h = untyped __dollar__hnew(0);
-		#else js
+		#elseif js
 		h = untyped __js__("{}");
 		untyped if( h.__proto__ != null ) {
 			h.__proto__ = null;
 			__js__("delete")(h.__proto__);
 		};
-		#else error
 		#end
 	}
 
@@ -55,11 +56,10 @@ class IntHash<T> {
 	public function set( key : Int, value : T ) : Void {
 		#if flash
 		untyped h[key] = value;
-		#else js
+		#elseif js
 		untyped h[key] = value;
-		#else neko
+		#elseif neko
 		untyped __dollar__hset(h,key,value,null);
-		#else error
 		#end
 	}
 
@@ -69,11 +69,12 @@ class IntHash<T> {
 	public function get( key : Int ) : Null<T> {
 		#if flash
 		return untyped h[key];
-		#else js
+		#elseif js
 		return untyped h[key];
-		#else neko
+		#elseif neko
 		return untyped __dollar__hget(h,key,null);
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -85,13 +86,14 @@ class IntHash<T> {
 	public function exists( key : Int ) : Bool {
 		#if flash9
 		return untyped h.hasOwnProperty(key);
-		#else flash
+		#elseif flash
 		return untyped h["hasOwnProperty"](key);
-		#else js
+		#elseif js
 		return untyped h[key] != null;
-		#else neko
+		#elseif neko
 		return untyped __dollar__hmem(h,key,null);
-		#else error
+		#else
+		return false;
 		#end
 	}
 
@@ -104,17 +106,18 @@ class IntHash<T> {
 		if( untyped !h.hasOwnProperty(key) ) return false;
 		untyped __delete__(h,key);
 		return true;
-		#else flash
+		#elseif flash
 		if( untyped !h["hasOwnProperty"](key) ) return false;
 		untyped __delete__(h,key);
 		return true;
-		#else js
+		#elseif js
 		if( untyped h[key] == null ) return false;
 		untyped  __js__("delete")(h[key]);
 		return true;
-		#else neko
+		#elseif neko
 		return untyped __dollar__hremove(h,key,null);
-		#else error
+		#else
+		return false;
 		#end
 	}
 
@@ -124,23 +127,24 @@ class IntHash<T> {
 	public function keys() : Iterator<Int> {
 		#if flash9
 		return untyped (__keys__(h)).iterator();
-		#else flash
+		#elseif flash
 		var l : Array<Int> = untyped __keys__(h);
 		for( x in 0...l.length )
 			l[x] = Std.int(l[x]);
 		return l.iterator();
-		#else js
+		#elseif js
 		var a = new Array();
 		untyped __js__("
 			for( x in this.h )
 				a.push(x);
 		");
 		return a.iterator();
-		#else neko
+		#elseif neko
 		var l = new List<Int>();
 		untyped __dollar__hiter(h,function(k,_) { l.push(k); });
 		return l.iterator();
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -155,25 +159,26 @@ class IntHash<T> {
 			hasNext : function() { return this.it.hasNext(); },
 			next : function() { var i = this.it.next(); return this.ref[i]; }
 		};
-		#else flash
+		#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]; }
 		};
-		#else js
+		#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]; }
 		};
-		#else neko
+		#elseif neko
 		var l = new List<T>();
 		untyped __dollar__hiter(h,function(_,v) { l.push(v); });
 		return l.iterator();
-		#else error
+		#else
+		return null;
 		#end
 	}
 
@@ -196,6 +201,4 @@ class IntHash<T> {
 		return s.toString();
 	}
 
-	private var h : Dynamic;
-
 }

+ 2 - 10
std/List.hx

@@ -49,11 +49,7 @@ class List<T> {
 		Add an element at the end of the list.
 	**/
 	public function add( item : T ) {
-		var x = #if neko
-			untyped __dollar__array(item,null)
-		#else true
-			[item,null]
-		#end;
+		var x = #if neko untyped __dollar__array(item,null) #else [item] #end;
 		if( h == null )
 			h = x;
 		else
@@ -66,11 +62,7 @@ class List<T> {
 		Push an element at the beginning of the list.
 	**/
 	public function push( item : T ) {
-		var x = #if neko
-			untyped __dollar__array(item,h)
-		#else true
-			[item,h]
-		#end;
+		var x = #if neko untyped __dollar__array(item,h) #else [item,h] #end;
 		h = x;
 		if( q == null )
 			q = x;

+ 8 - 8
std/Math.hx

@@ -58,12 +58,12 @@ extern class Math
 	private static function __init__() : Void untyped {
 	#if neko
 		Math = neko.NekoMath__;
-	#else true
+	#else
 		#if flash9
 		NaN = __global__["Number"].NaN;
 		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
 		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
-		#else true
+		#else
 		Math.NaN = Number["NaN"];
 		Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
 		Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
@@ -72,11 +72,11 @@ extern class Math
 			return
 			#if flash9
 			__global__["isFinite"](i);
-			#else flash
+			#elseif flash
 			_global["isFinite"](i);
-			#else js
+			#elseif js
 			__js__("isFinite")(i);
-			#else true
+			#else
 			false;
 			#end
 		};
@@ -84,11 +84,11 @@ extern class Math
 			return
 			#if flash9
 			__global__["isNaN"](i);
-			#else flash
+			#elseif flash
 			_global["isNaN"](i);
-			#else js
+			#elseif js
 			__js__("isNaN")(i);
-			#else true
+			#else
 			false;
 			#end
 		};

+ 117 - 150
std/Reflect.hx

@@ -29,112 +29,79 @@
 **/
 class Reflect {
 
-	/**
-		Creates an empty object.
-	**/
-	public static function empty() : {} {
-		return untyped
-		#if flash9
-			__new__(__global__["Object"])
-		#else flash
-			__new__(_global["Object"])
-		#else neko
-			__dollar__new(null)
-		#else js
-			__js__("{}")
-		#else error
-		#end
-			;
-	}
-
 	/**
 		Tells if an object has a field set. This doesn't take into account the object prototype (class methods).
 	**/
-	public static function hasField( o : Dynamic, field : String ) : Bool {
-		untyped{
+	public static function hasField( o : Dynamic, field : String ) : Bool untyped {
 		#if flash9
 			return o.hasOwnProperty( field );
-		#else flash
+		#elseif flash
 			return this["hasOwnProperty"]["call"](o,field);
-		#else js
+		#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;
-		#else neko
+		#elseif neko
 			return __dollar__typeof(o) == __dollar__tobject && __dollar__objfield(o,__dollar__hash(field.__s));
-		#else error
+		#else
+			return false;
 		#end
-		}
 	}
 
 	/**
 		Returns the field of an object, or null if [o] is not an object or doesn't have this field.
 	**/
-	public static function field( o : Dynamic, field : String ) : Dynamic {
-		untyped
+	public inline static function field( o : Dynamic, field : String ) : Dynamic untyped {
 		#if flash
-			return o[field]
-		#else js
-			try {
-				return o[field];
-			} catch( e : Dynamic ) {
-				return null;
-			}
-		#else neko
-			{
-				if( __dollar__typeof(o) != __dollar__tobject )
-					return null;
-				var fh = __dollar__hash(field.__s);
-				return __dollar__objget(o,fh);
-			}
-		#else error
+			return o[field];
+		#elseif js
+			return try o[field] catch( e : Dynamic ) null;
+		#elseif neko
+			return if( __dollar__typeof(o) != __dollar__tobject ) null else __dollar__objget(o,__dollar__hash(field.__s));
+		#else
+			return null;
 		#end
-			;
 	}
 
 	/**
 		Set an object field value.
 	**/
-	public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void {
-		untyped
+	public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
 		#if flash
 			o[field] = value;
-		#else js
+		#elseif js
 			o[field] = value;
-		#else neko
+		#elseif neko
 			if( __dollar__typeof(o) == __dollar__tobject )
 				__dollar__objset(o,__dollar__hash(field.__s),value);
-		#else error
 		#end
 	}
 
 	/**
 		Call a method with the given object and arguments.
 	**/
-	public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic {
-		return untyped
+	public inline static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
 		#if flash9
-			func.apply(o,args)
-		#else flash
-			func["apply"](o,args)
-		#else js
-			func.apply(o,args)
-		#else neko
-			__dollar__call(func,o,args.__neko())
-		#else error
+			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());
+		#else
+			return null;
 		#end
-			;
 	}
 
 	/**
 		Returns the list of fields of an object, excluding its prototype (class methods).
 	**/
-	public static function fields( o : Dynamic ) : Array<String> {
+	public static function fields( o : Dynamic ) : Array<String> untyped {
 		if( o == null ) return new Array();
-		untyped {
 		#if flash9
 			var a : Array<String> = __keys__(o);
 			var i = 0;
@@ -145,7 +112,7 @@ class Reflect {
 					++i;
 			}
 			return a;
-		#else flash
+		#elseif flash
 			var a : Array<String> = __keys__(o);
 			var i = 0;
 			while( i < a.length ) {
@@ -155,10 +122,10 @@ class Reflect {
 					++i;
 			}
 			return a;
-		#else js
+		#elseif js
 			var a = new Array();
-			if( untyped o.hasOwnProperty ) {
-				untyped __js__("
+			if( o.hasOwnProperty ) {
+				__js__("
 					for(var i in o)
 						if( o.hasOwnProperty(i) )
 							a.push(i);
@@ -168,7 +135,7 @@ class Reflect {
 				try{ t = o.__proto__; } catch( e : Dynamic ) { t = null; }
 				if( t != null )
 					o.__proto__ = null;
-				untyped __js__("
+				__js__("
 					for(var i in o)
 						if( i != \"__proto__\" )
 							a.push(i);
@@ -177,7 +144,7 @@ class Reflect {
 					o.__proto__ = t;
 			}
 			return a;
-		#else neko
+		#elseif neko
 			if( __dollar__typeof(o) != __dollar__tobject )
 				return new Array<String>();
 			else {
@@ -190,34 +157,37 @@ class Reflect {
 				}
 				return Array.new1(a,l);
 			}
-		#else error
+		#else
+			return new Array();
 		#end
-		}
 	}
 
 	/**
 		Tells if a value is a function or not.
 	**/
-	public static function isFunction( f : Dynamic ) : Bool {
-		return untyped
+	public static function isFunction( f : Dynamic ) : Bool untyped {
 		#if flash9
-			__typeof__(f) == "function"
-		#else flash
-			__typeof__(f) == "function" && f.__name__ == null
-		#else js
-			__js__("typeof(f)") == "function" && f.__name__ == null
-		#else neko
-			__dollar__typeof(f) == __dollar__tfunction
-		#else error
+			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;
+		#else
+			return false;
 		#end
-			;
 	}
 
 	/**
 		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);
+		#else
 		return ( a == b ) ? 0 : (((cast a) > (cast b)) ? 1 : -1);
+		#end
 	}
 
 	/**
@@ -230,15 +200,15 @@ class Reflect {
 		if( !isFunction(f1) || !isFunction(f2) )
 			return false;
 		#if neko
-		return false; // compare already done
-		#else flash9
-		return false; // VM-level closures
-		#else flash
-		return untyped f1["f"] == f2["f"] && f1["o"] == f2["o"] && f1["f"] != null;
-		#else js
-		return f1.scope == f2.scope && f1.method == f2.method && f1.method != null;
-		#else true
-		return
+			return false; // compare already done
+		#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;
+		#else
+			return false;
 		#end
 	}
 
@@ -248,59 +218,54 @@ class Reflect {
 	**/
 	public static function isObject( v : Dynamic ) : Bool untyped {
 		#if neko
-		return __dollar__typeof(v) == __dollar__tobject && v.__enum__ == null;
-		#else flash9
-		if( v == null )
-			return false;
-		var t = __typeof__(v);
-		if( t == "object" ) {
-			try {
-				if( v.__enum__ == true )
-					return false;
-			} catch( e : Dynamic ) {
+			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 true;
-		}
-		return (t == "string");
-		#else flash
-		var t = __typeof__(v);
-		return (t == "string" || (t == "object" && !v.__enum__) || (t == "function" && v.__name__ != null));
-		#else js
-		if( v == null )
+			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));
+		#else
 			return false;
-		var t = __js__("typeof(v)");
-		return (t == "string" || (t == "object" && !v.__enum__) || (t == "function" && v.__name__ != null));
-		#else error
 		#end
 	}
 
 	/**
 		Delete an object field.
 	**/
-	public static function deleteField( o : Dynamic, f : String ) : Bool {
+	public static function deleteField( o : Dynamic, f : String ) : Bool untyped {
 		#if flash9
-			untyped {
-				if( o.hasOwnProperty(f) != true ) return false;
-				__delete__(o,f);
-				return true;
-			}
-		#else flash
-			untyped {
-				if( this["hasOwnProperty"]["call"](o,f) != true ) return false;
-				__delete__(o,f);
-				return true;
-			}
-		#else js
-			untyped {
-				if( !hasField(o,f) ) return false;
-				__js__("delete")(o[f]);
-				return true;
-			}
-		#else neko
-			return untyped __dollar__objremove(o,__dollar__hash(f.__s))
-		#else error
+			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));
+		#else
+			return false;
 		#end
-			;
 	}
 
 	/**
@@ -308,12 +273,12 @@ class Reflect {
 	**/
 	public static function copy<T>( o : T ) : T {
 		#if neko
-		return untyped __dollar__new(o);
-		#else true
-		var o2 = cast empty();
-		for( f in Reflect.fields(o) )
-			Reflect.setField(o2,f,Reflect.field(o,f));
-		return o2;
+			return untyped __dollar__new(o);
+		#else
+			var o2 : Dynamic = {};
+			for( f in Reflect.fields(o) )
+				Reflect.setField(o2,f,Reflect.field(o,f));
+			return o2;
 		#end
 	}
 
@@ -323,18 +288,20 @@ class Reflect {
 	**/
 	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))); });
-		#else flash9
-		return function(__arguments__) { return f(__arguments__); };
-		#else js
-		return function() untyped {
-			var a = new Array();
-			for( i in 0...arguments.length )
-				a.push(arguments[i]);
-			return f(a);
-		};
-		#else flash
-		return function() { return f(untyped __arguments__); };
+			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__); };
+		#else
+			return null;
 		#end
 	}
 

+ 27 - 27
std/Std.hx

@@ -35,11 +35,11 @@ class Std {
 		return untyped
 		#if flash
 		flash.Boot.__instanceof(v,t);
-		#else neko
+		#elseif neko
 		neko.Boot.__instanceof(v,t);
-		#else js
+		#elseif js
 		js.Boot.__instanceof(v,t);
-		#else true
+		#else
 		false;
 		#end
 	}
@@ -51,11 +51,11 @@ class Std {
 		return untyped
 		#if flash
 		flash.Boot.__string_rec(s,"");
-		#else neko
+		#elseif neko
 		new String(__dollar__string(s));
-		#else js
+		#elseif js
 		js.Boot.__string_rec(s,"");
-		#else true
+		#else
 		"";
 		#end
 	}
@@ -66,7 +66,7 @@ class Std {
 	public #if flash9 inline #end static function int( x : Float ) : Int {
 		#if flash9
 		return untyped __int__(x);
-		#else true
+		#else
 		if( x < 0 ) return Math.ceil(x);
 		return Math.floor(x);
 		#end
@@ -89,12 +89,12 @@ class Std {
 		if( __global__["isNaN"](v) )
 			return null;
 		return v;
-		#else flash
+		#elseif flash
 		var v = _global["parseInt"](x);
 		if( Math.isNaN(v) )
 			return null;
 		return v;
-		#else neko
+		#elseif neko
 		var t = __dollar__typeof(x);
 		if( t == __dollar__tint )
 			return x;
@@ -103,12 +103,12 @@ class Std {
 		if( t != __dollar__tobject )
 			return null;
 		return __dollar__int(x.__s);
-		#else js
+		#elseif js
 		var v = __js__("parseInt")(x);
 		if( Math.isNaN(v) )
 			return null;
 		return v;
-		#else true
+		#else
 		return 0;
 		#end
 		}
@@ -121,13 +121,13 @@ class Std {
 		return untyped
 		#if flash9
 		__global__["parseFloat"](x);
-		#else flash
+		#elseif flash
 		_global["parseFloat"](x);
-		#else neko
+		#elseif neko
 		__dollar__float(x.__s);
-		#else js
+		#elseif js
 		__js__("parseFloat")(x);
-		#else true
+		#else
 		0;
 		#end
 	}
@@ -148,7 +148,7 @@ class Std {
 			return null;
 		else
 			return x.charCodeAt(0);
-		#else neko
+		#elseif neko
 		untyped {
 			var s = __dollar__ssize(x.__s);
 			if( s == 0 )
@@ -156,12 +156,12 @@ class Std {
 			else
 				return __dollar__sget(x.__s,0);
 		}
-		#else js
+		#elseif js
 		if( x == "" )
 			return null;
 		else
 			return x.charCodeAt(0);
-		#else true
+		#else
 		return null;
 		#end
 	}
@@ -173,13 +173,13 @@ class Std {
 		return untyped
 		#if flash9
 		Math.floor(Math.random()*x);
-		#else flash
+		#elseif flash
 		__random__(x);
-		#else neko
+		#elseif neko
 		Math._rand_int(Math.__rnd,x);
-		#else js
+		#elseif js
 		Math.floor(Math.random()*x);
-		#else true
+		#else
 		0;
 		#end
 	}
@@ -191,15 +191,15 @@ class Std {
 		return untyped
 		#if as3gen
 		throw "Not supported in AS3";
-		#else flash9
+		#elseif flash9
 		flash.Boot.__res[name];
-		#else flash
+		#elseif flash
 		flash.Boot.__res[name];
-		#else neko
+		#elseif neko
 		__dollar__objget(neko.Boot.__res,__dollar__hash(name.__s));
-		#else js
+		#elseif js
 		js.Boot.__res[name];
-		#else true
+		#else
 		null;
 		#end
 	}

+ 28 - 37
std/StringBuf.hx

@@ -34,57 +34,51 @@ class StringBuf {
 	**/
 	public function new() {
 		#if neko
-		b = __make();
-		#else flash
-		b = "";
-		#else js
-		b = "";
-		#else error
+			b = __make();
+		#else
+			b = "";
 		#end
 	}
 
 	/**
 		Adds the representation of any value to the string buffer.
 	**/
-	public function add( ?x : Dynamic ) {
+	public inline function add( ?x : Dynamic ) {
 		#if neko
-		__add(b,x);
-		#else true
-		b += x;
-		#else error
+			__add(b,x);
+		#else
+			b += x;
 		#end
 	}
 
 	/**
 		Adds a part of a string to the string buffer.
 	**/
-	public function addSub( s : String, pos : Int, ?len : Int ) {
+	public inline function addSub( s : String, pos : Int, ?len : Int ) {
 		#if neko
-		__add_sub(b,untyped s.__s,pos,len == null ? s.length - pos : len);
-		#else flash9
-		if( len == null )
-			b += s.substr(pos);
-		else
+			__add_sub(b,untyped s.__s,pos,len == null ? s.length - pos : len);
+		#elseif flash9
+			if( len == null )
+				b += s.substr(pos);
+			else
+				b += s.substr(pos,len);
+		#else
 			b += s.substr(pos,len);
-		#else flash
-		b += s.substr(pos,len);
-		#else js
-		b += s.substr(pos,len);
-		#else error
 		#end
 	}
 
 	/**
 		Adds a character to the string buffer.
 	**/
-	public function addChar( c : Int ) {
+	public inline function addChar( c : Int ) untyped {
 		#if neko
-		__add_char(b,c);
-		#else flash
-		b += untyped String["fromCharCode"](c);
-		#else js
-		b += untyped String.fromCharCode(c);
-		#else error
+			__add_char(b,c);
+		#elseif flash9
+			b += __global__["String.fromCharCode"](c);
+		#elseif flash
+			b += String["fromCharCode"](c);
+		#else
+			b += String.fromCharCode(c);
 		#end
 	}
 
@@ -92,18 +86,15 @@ class StringBuf {
 		Returns the content of the string buffer.
 		The buffer is not emptied by this operation.
 	**/
-	public function toString() : String {
+	public inline function toString() : String {
 		#if neko
-		return new String(__string(b));
-		#else flash
-		return b;
-		#else js
-		return b;
-		#else error
+			return new String(__string(b));
+		#else
+			return b;
 		#end
 	}
 
-	private var b : Dynamic;
+	private var b : #if neko Dynamic #else String #end;
 
 #if neko
 	static var __make : Dynamic = neko.Lib.load("std","buffer_new",0);

+ 86 - 84
std/StringTools.hx

@@ -35,32 +35,34 @@ class StringTools {
 	/**
 		Encode an URL by using the standard format.
 	**/
-	public static function urlEncode( s : String ) : String {
+	public static function urlEncode( s : String ) : String untyped {
 		#if flash9
-		return untyped __global__["encodeURIComponent"](s);
-		#else flash
-		return untyped _global["escape"](s);
-		#else neko
-		return new String(_urlEncode(untyped s.__s));
-		#else js
-		return untyped encodeURIComponent(s);
-		#else error
+			return __global__["encodeURIComponent"](s);
+		#elseif flash
+			return _global["escape"](s);
+		#elseif neko
+			return new String(_urlEncode(s.__s));
+		#elseif js
+			return encodeURIComponent(s);
+		#else
+			return null;
 		#end
 	}
 
 	/**
 		Decode an URL using the standard format.
 	**/
-	public static function urlDecode( s : String ) : String {
+	public static function urlDecode( s : String ) : String untyped {
 		#if flash9
-		return untyped __global__["decodeURIComponent"](s.split("+").join(" "));
-		#else flash
-		return untyped _global["unescape"](s);
-		#else neko
-		return new String(_urlDecode(untyped s.__s));
-		#else js
-		return untyped decodeURIComponent(s.split("+").join(" "));
-		#else error
+			return __global__["decodeURIComponent"](s.split("+").join(" "));
+		#elseif flash
+			return _global["unescape"](s);
+		#elseif neko
+			return new String(_urlDecode(s.__s));
+		#elseif js
+			return decodeURIComponent(s.split("+").join(" "));
+		#else
+			return null;
 		#end
 	}
 
@@ -191,33 +193,33 @@ class StringTools {
 	**/
 	public static function baseEncode( s : String, base : String ) : String {
 		#if neko
-		return new String(_baseEncode(untyped s.__s,untyped base.__s));
-		#else true
-		var len = base.length;
-		var nbits = 1;
-		while( len > 1 << nbits )
-			nbits++;
-		if( nbits > 8 || len != 1 << nbits )
-			throw "baseEncode: base must be a power of two.";
-		var size = Std.int((s.length * 8 + nbits - 1) / nbits);
-		var out = new StringBuf();
-		var buf = 0;
-		var curbits = 0;
-		var mask = ((1 << nbits) - 1);
-		var pin = 0;
-		while( size-- > 0 ){
-			while( curbits < nbits ){
-				curbits += 8;
-				buf <<= 8;
-				var t = s.charCodeAt(pin++);
-				if( t > 255 )
-					throw "baseEncode: bad chars";
-				buf |= t;
+			return new String(_baseEncode(untyped s.__s,untyped base.__s));
+		#else
+			var len = base.length;
+			var nbits = 1;
+			while( len > 1 << nbits )
+				nbits++;
+			if( nbits > 8 || len != 1 << nbits )
+				throw "baseEncode: base must be a power of two.";
+			var size = Std.int((s.length * 8 + nbits - 1) / nbits);
+			var out = new StringBuf();
+			var buf = 0;
+			var curbits = 0;
+			var mask = ((1 << nbits) - 1);
+			var pin = 0;
+			while( size-- > 0 ){
+				while( curbits < nbits ){
+					curbits += 8;
+					buf <<= 8;
+					var t = s.charCodeAt(pin++);
+					if( t > 255 )
+						throw "baseEncode: bad chars";
+					buf |= t;
+				}
+				curbits -= nbits;
+				out.addChar(base.charCodeAt((buf >> curbits) & mask));
 			}
-			curbits -= nbits;
-			out.addChar(base.charCodeAt((buf >> curbits) & mask));
-		}
-		return out.toString();
+			return out.toString();
 		#end
 	}
 
@@ -226,38 +228,38 @@ class StringTools {
 	**/
 	public static function baseDecode( s : String, base : String ) : String {
 		#if neko
-		return new String(_baseDecode(untyped s.__s,untyped base.__s));
-		#else true
-		var len = base.length;
-		var nbits = 1;
-		while( len > 1 << nbits )
-			nbits++;
-		if( nbits > 8 || len != 1 << nbits )
-			throw "baseDecode: base must be a power of two.";
-		var size = (s.length * 8 + nbits - 1) / nbits;
-		var tbl = new Array();
-		for( i in 0...256 )
-			tbl[i] = -1;
-		for( i in 0...len )
-			tbl[base.charCodeAt(i)] = i;
-		var size = (s.length * nbits) / 8;
-		var out = new StringBuf();
-		var buf = 0;
-		var curbits = 0;
-		var pin = 0;
-		while( size-- > 0 ){
-			while( curbits < 8 ){
-				curbits += nbits;
-				buf <<= nbits;
-				var i = tbl[s.charCodeAt(pin++)];
-				if( i == -1 )
-					throw "baseDecode: bad chars";
-				buf |= i;
+			return new String(_baseDecode(untyped s.__s,untyped base.__s));
+		#else
+			var len = base.length;
+			var nbits = 1;
+			while( len > 1 << nbits )
+				nbits++;
+			if( nbits > 8 || len != 1 << nbits )
+				throw "baseDecode: base must be a power of two.";
+			var size = (s.length * 8 + nbits - 1) / nbits;
+			var tbl = new Array();
+			for( i in 0...256 )
+				tbl[i] = -1;
+			for( i in 0...len )
+				tbl[base.charCodeAt(i)] = i;
+			var size = (s.length * nbits) / 8;
+			var out = new StringBuf();
+			var buf = 0;
+			var curbits = 0;
+			var pin = 0;
+			while( size-- > 0 ){
+				while( curbits < 8 ){
+					curbits += nbits;
+					buf <<= nbits;
+					var i = tbl[s.charCodeAt(pin++)];
+					if( i == -1 )
+						throw "baseDecode: bad chars";
+					buf |= i;
+				}
+				curbits -= 8;
+				out.addChar((buf >> curbits) & 0xFF);
 			}
-			curbits -= 8;
-			out.addChar((buf >> curbits) & 0xFF);
-		}
-		return out.toString();
+			return out.toString();
 		#end
 	}
 
@@ -271,15 +273,15 @@ class StringTools {
 			n = -n;
 		}
 		#if (flash || js)
-		var s : String = untyped n.toString(16);
-		s = s.toUpperCase();
-		#else true
-		var s = "";
-		var hexChars = "0123456789ABCDEF";
-		do {
-			s = hexChars.charAt(n%16) + s;
-			n = Std.int(n/16);
-		} while( n > 0 );
+			var s : String = untyped n.toString(16);
+			s = s.toUpperCase();
+		#else
+			var s = "";
+			var hexChars = "0123456789ABCDEF";
+			do {
+				s = hexChars.charAt(n%16) + s;
+				n = Std.int(n/16);
+			} while( n > 0 );
 		#end
 		if( digits != null )
 			while( s.length < digits )

+ 172 - 169
std/Type.hx

@@ -33,13 +33,11 @@ class Type {
 	**/
 	public static function toEnum( t : Dynamic ) : Enum untyped {
 		try {
-		#if flash9
-			if( !t.__isenum )
-				return null;
-		#else true
-			if( t.__ename__ == null )
-				return null;
-		#end
+			#if flash9
+				if( !t.__isenum ) return null;
+			#else
+				if( t.__ename__ == null ) return null;
+			#end
 			return t;
 		} catch( e : Dynamic ) {
 		}
@@ -51,13 +49,13 @@ class Type {
 	**/
 	public static function toClass( t : Dynamic ) : Class<Dynamic> untyped {
 		try {
-		#if flash9
-			if( !t.hasOwnProperty("prototype") )
-				return null;
-		#else true
-			if( t.__name__ == null )
-				return null;
-		#end
+			#if flash9
+				if( !t.hasOwnProperty("prototype") )
+					return null;
+			#else
+				if( t.__name__ == null )
+					return null;
+			#end
 			return t;
 		} catch( e : Dynamic ) {
 		}
@@ -78,24 +76,25 @@ class Type {
 			if( c.__isenum )
 				return null;
 			return c;
-		#else flash
+		#elseif flash
 			if( o.__enum__ != null )
 				return null;
 			return o.__class__;
-		#else js
+		#elseif js
 			if( o == null )
 				return null;
 			if( o.__enum__ != null )
 				return null;
 			return o.__class__;
-		#else neko
+		#elseif neko
 			if( __dollar__typeof(o) != __dollar__tobject )
 				return null;
 			var p = __dollar__objgetproto(o);
 			if( p == null )
 				return null;
 			return p.__class__;
-		#else error
+		#else
+			return null;
 		#end
 	}
 
@@ -114,17 +113,18 @@ class Type {
 			if( !c.__isenum )
 				return null;
 			return c;
-		#else flash
+		#elseif flash
 			return o.__enum__;
-		#else js
+		#elseif js
 			if( o == null )
 				return null;
 			return o.__enum__;
-		#else neko
+		#elseif neko
 			if( __dollar__typeof(o) != __dollar__tobject )
 				return null;
 			return o.__enum__;
-		#else error
+		#else
+			return null;
 		#end
 	}
 
@@ -138,7 +138,7 @@ class Type {
 			if( cname == "Object" )
 				return null;
 			return __as__(__global__["flash.utils.getDefinitionByName"](cname),Class);
-		#else true
+		#else
 			return c.__super__;
 		#end
 	}
@@ -153,7 +153,7 @@ class Type {
 		#if flash9
 			var str : String = untyped __global__["flash.utils.getQualifiedClassName"](c);
 			return str.split("::").join(".");
-		#else true
+		#else
 			var a : Array<String> = untyped c.__name__;
 			return a.join(".");
 		#end
@@ -166,7 +166,7 @@ class Type {
 		#if flash9
 			var n = untyped __global__["flash.utils.getQualifiedClassName"](e);
 			return n;
-		#else true
+		#else
 			var a : Array<String> = untyped e.__ename__;
 			return a.join(".");
 		#end
@@ -176,9 +176,8 @@ class Type {
 		Evaluates a class from a name. The class must have been compiled
 		to be accessible.
 	**/
-	public static function resolveClass( name : String ) : Class<Dynamic> {
+	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
 		var cl : Class<Dynamic>;
-		untyped {
 		#if flash9
 			try {
 				cl = __as__(__global__["flash.utils.getDefinitionByName"](name),Class);
@@ -188,15 +187,15 @@ class Type {
 			} catch( e : Dynamic ) {
 				return null;
 			}
-		#else flash
+		#elseif flash
 			cl = __eval__(name);
-		#else js
+		#elseif js
 			try {
 				cl = eval(name);
 			} catch( e : Dynamic ) {
 				cl = null;
 			}
-		#else neko
+		#elseif neko
 			var path = name.split(".");
 			cl = Reflect.field(untyped neko.Boot.__classes,path[0]);
 			var i = 1;
@@ -204,12 +203,10 @@ class Type {
 				cl = Reflect.field(cl,path[i]);
 				i += 1;
 			}
-		#else error
 		#end
 		// ensure that this is a class
 		if( cl == null || cl.__name__ == null )
 			return null;
-		}
 		return cl;
 	}
 
@@ -218,9 +215,8 @@ class Type {
 		Evaluates an enum from a name. The enum must have been compiled
 		to be accessible.
 	**/
-	public static function resolveEnum( name : String ) : Enum {
+	public static function resolveEnum( name : String ) : Enum untyped {
 		var e : Dynamic;
-		untyped {
 		#if flash9
 			try {
 				e = __global__["flash.utils.getDefinitionByName"](name);
@@ -230,15 +226,15 @@ class Type {
 			} catch( e : Dynamic ) {
 				return null;
 			}
-		#else flash
+		#elseif flash
 			e = __eval__(name);
-		#else js
+		#elseif js
 			try {
 				e = eval(name);
 			} catch( e : Dynamic ) {
 				e = null;
 			}
-		#else neko
+		#elseif neko
 			var path = name.split(".");
 			e = Reflect.field(neko.Boot.__classes,path[0]);
 			var i = 1;
@@ -246,12 +242,10 @@ class Type {
 				e = Reflect.field(e,path[i]);
 				i += 1;
 			}
-		#else error
 		#end
 		// ensure that this is an enum
 		if( e == null || e.__ename__ == null )
 			return null;
-		}
 		return e;
 	}
 
@@ -267,18 +261,25 @@ class Type {
 			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]);
 			default: throw "Too many arguments";
 			}
-		#else flash
+		#elseif flash
 			var o = { __constructor__ : cl, __proto__ : cl.prototype };
 			cl["apply"](o,args);
 			return o;
-		#else neko
-			return untyped __dollar__call(__dollar__objget(cl,__dollar__hash("new".__s)),cl,args.__neko());
-		#else js
-			if( args.length >= 6 ) throw "Too many arguments";
-			return untyped __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]);
-		#else error
+		#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]);
+		#else
+			return null;
 		#end
 	}
 
@@ -298,17 +299,18 @@ class Type {
 				throw e;
 			}
 			return null;
-		#else flash
+		#elseif flash
 			var o : Dynamic = __new__(_global["Object"]);
 			o.__proto__ = cl.prototype;
 			return o;
-		#else js
+		#elseif js
 			return __new__(cl,__js__("$_"));
-		#else neko
+		#elseif neko
 			var o = __dollar__new(null);
 			__dollar__objsetproto(o,cl.prototype);
 			return o;
-		#else error
+		#else
+			return null;
 		#end
 	}
 
@@ -334,7 +336,7 @@ class Type {
 	public static function getInstanceFields( c : Class<Dynamic> ) : Array<String> {
 		#if flash9
 			return describe(c,true);
-		#else true
+		#else
 			var a = Reflect.fields(untyped c.prototype);
 			c = untyped c.__super__;
 			while( c != null ) {
@@ -359,7 +361,7 @@ class Type {
 			var a = describe(c,false);
 			a.remove("__construct__");
 			return a;
-		#else true
+		#else
 			var a = Reflect.fields(c);
 			a.remove(__unprotect__("__name__"));
 			a.remove(__unprotect__("__interfaces__"));
@@ -388,85 +390,86 @@ class Type {
 	**/
 	public static function typeof( v : Dynamic ) : ValueType untyped {
 		#if neko
-		return switch( __dollar__typeof(v) ) {
-		case __dollar__tnull: TNull;
-		case __dollar__tint: TInt;
-		case __dollar__tfloat: TFloat;
-		case __dollar__tbool: TBool;
-		case __dollar__tfunction: TFunction;
-		case __dollar__tobject:
-			var c = v.__class__;
-			if( c != null )
-				TClass(c);
-			else {
-				var e = v.__enum__;
-				if( e != null )
-					TEnum(e);
-				else
-					TObject;
+			return switch( __dollar__typeof(v) ) {
+			case __dollar__tnull: TNull;
+			case __dollar__tint: TInt;
+			case __dollar__tfloat: TFloat;
+			case __dollar__tbool: TBool;
+			case __dollar__tfunction: TFunction;
+			case __dollar__tobject:
+				var c = v.__class__;
+				if( c != null )
+					TClass(c);
+				else {
+					var e = v.__enum__;
+					if( e != null )
+						TEnum(e);
+					else
+						TObject;
+				}
+			default: TUnknown;
 			}
-		default: TUnknown;
-		}
-		#else flash9
-		var cname = __global__["flash.utils.getQualifiedClassName"](v);
-		switch(cname) {
-		case "null": return TNull;
-		case "void": return TNull; // undefined
-		case "int": return TInt;
-		case "Number": return TFloat;
-		case "Boolean": return TBool;
-		case "Object": return TObject;
-		default:
-			var c : Dynamic;
-			try {
-				c = __global__["flash.utils.getDefinitionByName"](cname);
-				if( v.hasOwnProperty("prototype") )
-					return TObject;
-				if( c.__isenum )
-					return TEnum(c);
-				return TClass(c);
-			} catch( e : Dynamic ) {
-				if( cname == "builtin.as$0::MethodClosure" || cname.indexOf("-") != -1 )
-					return TFunction;
-				return if( c == null ) TFunction else TClass(c);
+		#elseif flash9
+			var cname = __global__["flash.utils.getQualifiedClassName"](v);
+			switch(cname) {
+			case "null": return TNull;
+			case "void": return TNull; // undefined
+			case "int": return TInt;
+			case "Number": return TFloat;
+			case "Boolean": return TBool;
+			case "Object": return TObject;
+			default:
+				var c : Dynamic;
+				try {
+					c = __global__["flash.utils.getDefinitionByName"](cname);
+					if( v.hasOwnProperty("prototype") )
+						return TObject;
+					if( c.__isenum )
+						return TEnum(c);
+					return TClass(c);
+				} catch( e : Dynamic ) {
+					if( cname == "builtin.as$0::MethodClosure" || cname.indexOf("-") != -1 )
+						return TFunction;
+					return if( c == null ) TFunction else TClass(c);
+				}
 			}
-		}
-		return null;
-		#else (flash || js)
-		switch( #if flash __typeof__ #else true __js__("typeof") #end(v) ) {
-		#if flash
-		case "null": return TNull;
-		#end
-		case "boolean": return TBool;
-		case "string": return TClass(String);
-		case "number":
-			if( v+1 == v )
-				return TFloat;
-			if( Math.ceil(v) == v )
-				return TInt;
-			return TFloat;
-		case "object":
-			#if js
-			if( v == null )
-				return TNull;
+			return null;
+		#elseif (flash || js)
+			switch( #if flash __typeof__ #else __js__("typeof") #end(v) ) {
+			#if flash
+			case "null": return TNull;
 			#end
-			var e = v.__enum__;
-			if( e != null )
-				return TEnum(e);
-			var c = v.__class__;
-			if( c != null )
-				return TClass(c);
-			return TObject;
-		case "function":
-			if( v.__name__ != null )
+			case "boolean": return TBool;
+			case "string": return TClass(String);
+			case "number":
+				if( v+1 == v )
+					return TFloat;
+				if( Math.ceil(v) == v )
+					return TInt;
+				return TFloat;
+			case "object":
+				#if js
+				if( v == null )
+					return TNull;
+				#end
+				var e = v.__enum__;
+				if( e != null )
+					return TEnum(e);
+				var c = v.__class__;
+				if( c != null )
+					return TClass(c);
 				return TObject;
-			return TFunction;
-		case "undefined":
-			return TNull;
-		default:
+			case "function":
+				if( v.__name__ != null )
+					return TObject;
+				return TFunction;
+			case "undefined":
+				return TNull;
+			default:
+				return TUnknown;
+			}
+		#else
 			return TUnknown;
-		}
-		#else error
 		#end
 	}
 
@@ -477,34 +480,34 @@ class Type {
 		if( a == b )
 			return true;
 		#if neko
-		try {
-			if( a.__enum__ == null || a.tag != b.tag )
+			try {
+				if( a.__enum__ == null || a.tag != b.tag )
+					return false;
+			} catch( e : Dynamic ) {
 				return false;
-		} catch( e : Dynamic ) {
-			return false;
-		}
-		for( i in 0...__dollar__asize(a.args) )
-			if( !enumEq(a.args[i],b.args[i]) )
+			}
+			for( i in 0...__dollar__asize(a.args) )
+				if( !enumEq(a.args[i],b.args[i]) )
+					return false;
+		#elseif flash9
+			try {
+				if( a.tag != b.tag )
+					return false;
+				for( i in 0...a.params.length )
+					if( !enumEq(a.params[i],b.params[i]) )
+						return false;
+			} catch( e : Dynamic ) {
 				return false;
-		#else flash9
-		try {
-			if( a.tag != b.tag )
+			}
+		#else
+			if( a[0] != b[0] )
 				return false;
-			for( i in 0...a.params.length )
-				if( !enumEq(a.params[i],b.params[i]) )
+			for( i in 2...a.length )
+				if( !enumEq(a[i],b[i]) )
 					return false;
-		} catch( e : Dynamic ) {
-			return false;
-		}
-		#else true
-		if( a[0] != b[0] )
-			return false;
-		for( i in 2...a.length )
-			if( !enumEq(a[i],b[i]) )
+			var e = a.__enum__;
+			if( e != b.__enum__ || e == null )
 				return false;
-		var e = a.__enum__;
-		if( e != b.__enum__ || e == null )
-			return false;
 		#end
 		return true;
 	}
@@ -513,37 +516,37 @@ class Type {
 		Returns the constructor of an enum
 	**/
 	public static function enumConstructor( e : Dynamic ) : String {
-	#if neko
-		return new String(e.tag);
-	#else flash9
-		return e.tag;
-	#else true
-		return e[0];
-	#end
+		#if neko
+			return new String(e.tag);
+		#elseif flash9
+			return e.tag;
+		#else
+			return e[0];
+		#end
 	}
 
 	/**
 		Returns the parameters of an enum
 	**/
 	public static function enumParameters( e : Dynamic ) : Array<Dynamic> {
-	#if neko
-		return if( e.args == null ) [] else untyped Array.new1(e.args,__dollar__asize(e.args));
-	#else flash9
-		return if( e.params == null ) [] else e.params;
-	#else true
-		return e.slice(2);
-	#end
+		#if neko
+			return if( e.args == null ) [] else untyped Array.new1(e.args,__dollar__asize(e.args));
+		#elseif flash9
+			return if( e.params == null ) [] else e.params;
+		#else
+			return e.slice(2);
+		#end
 	}
 
 	/**
 		Returns the index of the constructor of an enum
 	**/
-	public static function enumIndex( e : Dynamic ) : Int {
-	#if (neko || flash9)
-		return e.index;
-	#else true
-		return e[1];
-	#end
+	public inline static function enumIndex( e : Dynamic ) : Int {
+		#if (neko || flash9)
+			return e.index;
+		#else
+			return e[1];
+		#end
 	}
 
 }

+ 8 - 10
std/Xml.hx

@@ -223,17 +223,15 @@ extern class Xml {
 
 	static function __init__() : Void untyped {
 		#if neko
-		Xml = neko.NekoXml__;
-		neko.Boot.__classes.Xml = Xml;
-		#else js
-		Xml = js.JsXml__;
-		#else flash9
-		var ref = flash.FlashXml__;
-		#else flash
-		Xml = flash.FlashXml__;
-		#else error
+			Xml = neko.NekoXml__;
+			neko.Boot.__classes.Xml = Xml;
+		#elseif js
+			Xml = js.JsXml__;
+		#elseif flash9
+			var ref = flash.FlashXml__; // force compile
+		#elseif flash
+			Xml = flash.FlashXml__;
 		#end
-
 		#if !flash9
 		Xml.__name__ = ["Xml"];
 		#end

+ 1 - 1
std/flash/Boot.hx

@@ -200,7 +200,7 @@ class Boot {
 		a.splice(0,a.length);
 		#end
 		if( untyped Lib.onerror != null )
-			untyped Lib.onerror(__string_rec(v,""),#if debug old #else true [] #end);
+			untyped Lib.onerror(__string_rec(v,""),#if debug old #else [] #end);
 		else
 			__trace(__string_rec(v,"")+s,cast { fileName : "(uncaught exception)" });
 	}

+ 2 - 6
std/flash/Button.hx

@@ -1,11 +1,7 @@
 package flash;
 
-extern class Button
-#if flash_strict
-#else true
-implements Dynamic
-#end
-{
+extern class Button #if !flash_strict implements Dynamic #end {
+
 	var _alpha : Float;
 	var enabled : Bool;
 	var _focusrect : Bool;

+ 3 - 3
std/flash/Color.hx

@@ -13,8 +13,8 @@ typedef ColorTransform = {
 }
 #end
 
-extern class Color
-{
+extern class Color {
+
 	function new(target : MovieClip) : Void;
 
 	function setRGB(color:Int):Void;
@@ -23,7 +23,7 @@ extern class Color
 #if flash_strict
 	function setTransform(transformObject:ColorTransform):Void;
 	function getTransform():ColorTransform;
-#else true
+#else
 	function setTransform(transformObject:Dynamic):Void;
 	function getTransform() : { ra : Float, rb : Float, ga : Float, gb : Float, ba : Float, bb : Float, aa : Float, ab : Float };
 #end

+ 2 - 1
std/flash/ExtendedKey.hx

@@ -24,5 +24,6 @@ extern class ExtendedKey {
 
 }
 
-#else error
+#else
+	#error
 #end

+ 1 - 1
std/flash/Key.hx

@@ -42,7 +42,7 @@ extern class Key
 #if flash_strict
 	static function addListener(listener:KeyListener):Void;
 	static function removeListener(listener:KeyListener):Bool;
-#else true
+#else
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Bool;
 #end

+ 2 - 6
std/flash/LocalConnection.hx

@@ -1,11 +1,7 @@
 package flash;
 
-extern class LocalConnection
-#if flash_strict
-#else true
-implements Dynamic
-#end
-{
+extern class LocalConnection #if !flash_strict implements Dynamic #end {
+
 	function new() : Void;
 
 	function connect(connectionName:String):Bool;

+ 1 - 1
std/flash/Mouse.hx

@@ -20,7 +20,7 @@ extern class Mouse
 #if flash_strict
 	static function addListener(listener:MouseListener):Void;
 	static function removeListener(listener:MouseListener):Bool;
-#else true
+#else
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Bool;
 #end

+ 5 - 5
std/flash/MovieClip.hx

@@ -8,8 +8,7 @@ private extern class MCBounds {
 }
 
 extern class MovieClip
-#if flash_strict
-#else true
+#if !flash_strict
 implements Dynamic
 #end
 {
@@ -55,7 +54,7 @@ implements Dynamic
 
 	#if flash_strict
 	function swapDepths( depth : Int ) : Void;
-	#else true
+	#else
 	function swapDepths(mc : Dynamic) : Void;
 	#end
 	// function swapDepths( mc : String ) : Void;
@@ -164,9 +163,10 @@ implements Dynamic
 
 #end
 
-#if flash_v9
+
+	/** FP9 only **/
 	var forceSmoothing : Bool;
-#end
+
 
 // MT extension
 #if flash_strict

+ 2 - 3
std/flash/MovieClipLoader.hx

@@ -31,14 +31,13 @@ extern class MovieClipLoader
 #if flash_strict
 	function addListener(listener:MclListener):Bool;
 	function removeListener(listener:MclListener):Bool;
-#else true
+#else
 	function addListener(listener:Dynamic):Bool;
 	function removeListener(listener:Dynamic):Bool;
 #end
 
-#if flash_v9
+	/** in FP 9 **/
 	var checkPolicyFile : Bool;
-#end
 
 	private static function __init__() : Void untyped {
 		flash.MovieClipLoader = _global["MovieClipLoader"];

+ 2 - 6
std/flash/NetConnection.hx

@@ -1,11 +1,7 @@
 package flash;
 
-extern class NetConnection
-#if flash_strict
-#else true
-implements Dynamic
-#end
-{
+extern class NetConnection #if !flash_strict implements Dynamic #end {
+
 	var isConnected(default,null) : Bool;
 	var uri(default,null) : String;
 

+ 1 - 2
std/flash/NetStream.hx

@@ -10,9 +10,8 @@ extern class NetStream
 	var currentFps(default,null) : Float;
 	var liveDelay(default,null) : Float;
 
-#if flash_v9
+	/** FP9 only **/
 	var checkPolicyFile : Bool;
-#end
 
 	function new( connection : NetConnection ) : Void;
 	dynamic function onMetaData( info : Dynamic ) : Void;

+ 2 - 2
std/flash/Sound.hx

@@ -5,9 +5,9 @@ extern class Sound
 	var duration(default,null):Float;
 	var id3(default,null):Dynamic;
 	var position(default,null):Float;
-#if flash_v9
+
+	/** FP9 only **/
 	var checkPolicyFile : Bool;
-#end
 
 	function new( ?target:Dynamic ) : Void;
 

+ 0 - 2
std/flash/Stage.hx

@@ -10,7 +10,6 @@ extern class Stage
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Void;
 
-#if flash_v9
 	/**
 		Set to "fullScreen" in order to set Flash to fullscreen
 		(can only be done in Mouse/Keyboard event listener).
@@ -19,7 +18,6 @@ extern class Stage
 	static var displayState : String;
 	static var fullScreenSourceRect : flash.geom.Rectangle<Int>;
 	static dynamic function onFullScreen( full : Bool ) : Void;
-#end
 
 	private static function __init__() : Void untyped {
 		flash.Stage = _global["Stage"];

+ 1 - 2
std/flash/display/BitmapData.hx

@@ -43,9 +43,8 @@ extern class BitmapData {
 	function dispose() : Void;
 	function generateFilterRect(sourceRect : Rectangle<Int>, filter : flash.filters.BitmapFilter ) : Rectangle<Int>;
 
-#if flash_v9
+	/** FP9 only **/
 	function compare( b : BitmapData ) : BitmapData; // WTF ?
-#end
 
 }
 

+ 17 - 18
std/haxe/Firebug.hx

@@ -33,11 +33,11 @@ class Firebug {
 		} catch( e : Dynamic ) {
 			return false;
 		}
-		#else flash
+		#elseif flash
 		if( !flash.external.ExternalInterface.available )
 			return false;
 		return flash.external.ExternalInterface.call("console.error.toString") != null;
-		#else neko
+		#else
 		return true;
 		#end
 	}
@@ -45,9 +45,9 @@ class Firebug {
 	public static function redirectTraces() {
 		haxe.Log.trace = trace;
 		#if flash9
-		#else flash
+		#elseif flash
 		flash.Lib.setErrorHandler(onError);
-		#else js
+		#elseif js
 		js.Lib.setErrorHandler(onError);
 		#end
 	}
@@ -70,25 +70,24 @@ class Firebug {
 			var str = if( inf == null ) "" else inf.fileName + ":" + inf.lineNumber + " : ";
 			try	str += Std.string(v) catch( e : Dynamic ) str += "????";
 			#if flash9
-			// in Flash9, it is needed to use _self with getURL and
-			// only the latest call per frame is processed, so it's
-			// needed to use ExternalInterface (URLLoader displays
-			// security errors for remote files)
-			str = str.split("\\").join("\\\\");
-			flash.external.ExternalInterface.call("console."+type,str);
-			#else true
-			str = str.split("\\").join("\\\\").split("'").join("\\'").split("\n").join("\\n").split("\r").join("\\r");
-			str = StringTools.urlEncode(str);
-			var out = "javascript:console."+ type +"('"+str+"');";
-			flash.Lib.getURL(out);
+				// in Flash9, it is needed to use _self with getURL and
+				// only the latest call per frame is processed, so it's
+				// needed to use ExternalInterface (URLLoader displays
+				// security errors for remote files)
+				str = str.split("\\").join("\\\\");
+				flash.external.ExternalInterface.call("console."+type,str);
+			#else
+				str = str.split("\\").join("\\\\").split("'").join("\\'").split("\n").join("\\n").split("\r").join("\\r");
+				str = StringTools.urlEncode(str);
+				var out = "javascript:console."+ type +"('"+str+"');";
+				flash.Lib.getURL(out);
 			#end // flash9
-		#else js
+		#elseif js
 			untyped console[type]( (if( inf == null ) "" else inf.fileName+":"+inf.lineNumber+" : ") + Std.string(v) );
-		#else neko
+		#elseif neko
 			var str = inf.fileName + ":" + inf.lineNumber + " : ";
 			try str += Std.string(v) catch( e : Dynamic ) str += "???";
 			neko.Lib.print('<script type="text/javascript">console.'+type+'(decodeURIComponent("'+StringTools.urlEncode(str)+'"))</script>');
-		#else error
 		#end
 	}
 

+ 6 - 7
std/haxe/Http.hx

@@ -47,7 +47,7 @@ class Http {
 	var chunk_size : Int;
 	var chunk_buf : String;
 	var file : { param : String, filename : String, io : neko.io.Input, size : Int };
-#else js
+#elseif js
 	var async : Bool;
 	var postData : String;
 #end
@@ -64,7 +64,7 @@ class Http {
 		params = new Hash();
 		#if js
 		async = true;
-		#else neko
+		#elseif neko
 		cnxTimeout = 10;
 		#end
 	}
@@ -140,7 +140,7 @@ class Http {
 		r.send(uri);
 		if( !async )
 			onreadystatechange();
-	#else flash9
+	#elseif flash9
 		var loader = new flash.net.URLLoader();
 		loader.addEventListener( "complete", function(e){
 			me.onData( loader.data );
@@ -188,7 +188,7 @@ class Http {
 		}catch( e : Dynamic ){
 			onError("Exception: "+Std.string(e));
 		}
-	#else flash
+	#elseif flash
 		var r = new flash.LoadVars();
 		// on Firefox 1.5, onData is not called if host/port invalid (!)
 		r.onData = function(data) {
@@ -224,7 +224,7 @@ class Http {
 		}
 		if( !r.sendAndLoad(small_url,r,if( param ) { if( post ) "POST" else "GET"; } else null) )
 			onError("Failed to initialize Connection");
-	#else neko
+	#elseif neko
 		var me = this;
 		var output = new neko.io.StringOutput();
 		var old = onError;
@@ -578,8 +578,7 @@ class Http {
 	public dynamic function onStatus( status : Int ) {
 	}
 
-#if flash
-#else true
+#if !flash
 	public static function request( url : String ) : String {
 		var h = new Http(url);
 	#if js

+ 3 - 7
std/haxe/Log.hx

@@ -29,22 +29,18 @@ class Log {
 	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
 		#if flash
 		untyped flash.Boot.__trace(v,infos);
-		#else neko
+		#elseif neko
 		untyped __dollar__print(infos.fileName+":"+infos.lineNumber+": ",v,"\n");
-		#else js
+		#elseif js
 		untyped js.Boot.__trace(v,infos);
-		#else error
 		#end
 	}
 
 	public static dynamic function clear() : Void {
 		#if flash
 		untyped flash.Boot.__clear_trace();
-		#else js
+		#elseif js
 		untyped js.Boot.__clear_trace();
-		#else neko
-		// nothing
-		#else error
 		#end
 	}
 

+ 23 - 21
std/haxe/Md5.hx

@@ -29,21 +29,18 @@ package haxe;
 **/
 class Md5 {
 
-	public static function encode( s : String ) : String{
+	public static function encode( s : String ) : String {
 		#if neko
-			untyped return new String(base_encode(make_md5(s.__s),"0123456789abcdef".__s));
-		#else flash
-			return __jsflash_encode(s);
-		#else js
-			return __jsflash_encode(s);
-		#else error
+			return untyped new String(base_encode(make_md5(s.__s),"0123456789abcdef".__s));
+		#else
+			return inst.doEncode(s);
 		#end
 	}
 
 	#if neko
 	static var base_encode = neko.Lib.load("std","base_encode",2);
 	static var make_md5 = neko.Lib.load("std","make_md5",1);
-	#else true
+	#else
 
 /*
  * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
@@ -53,31 +50,36 @@ class Md5 {
  * See http://pajhome.org.uk/site/legal.html for details.
  */
 
-	private static function bitOR(a, b){
+	static var inst = new Md5();
+
+	function new() {
+	}
+
+	function bitOR(a, b){
 		var lsb = (a & 0x1) | (b & 0x1);
 		var msb31 = (a >>> 1) | (b >>> 1);
 		return (msb31 << 1) | lsb;
 	}
 
-	private static function bitXOR(a, b){
+	function bitXOR(a, b){
 		var lsb = (a & 0x1) ^ (b & 0x1);
 		var msb31 = (a >>> 1) ^ (b >>> 1);
 		return (msb31 << 1) | lsb;
 	}
 
-	private static function bitAND(a, b){
+	function bitAND(a, b){
 		var lsb = (a & 0x1) & (b & 0x1);
 		var msb31 = (a >>> 1) & (b >>> 1);
 		return (msb31 << 1) | lsb;
 	}
 
-	private static function addme(x, y) {
+	function addme(x, y) {
 		var lsw = (x & 0xFFFF)+(y & 0xFFFF);
 		var msw = (x >> 16)+(y >> 16)+(lsw >> 16);
 		return (msw << 16) | (lsw & 0xFFFF);
 	}
 
-	private static function rhex( num ){
+	function rhex( num ){
 		var str = "";
 		var hex_chr = "0123456789abcdef";
 		for( j in 0...4 ){
@@ -87,7 +89,7 @@ class Md5 {
 		return str;
 	}
 
-	private static function str2blks( str : String ){
+	function str2blks( str : String ){
 		var nblk = ((str.length + 8) >> 6) + 1;
 		var blks = new Array();
 		for( i in 0...(nblk * 16) ) blks[i] = 0;
@@ -107,31 +109,31 @@ class Md5 {
 		return blks;
 	}
 
-	private static function rol(num, cnt){
+	function rol(num, cnt){
 		return (num << cnt) | (num >>> (32 - cnt));
 	}
 
-	private static function cmn(q, a, b, x, s, t){
+	function cmn(q, a, b, x, s, t){
 		return addme(rol((addme(addme(a, q), addme(x, t))), s), b);
 	}
 
-	private static function ff(a, b, c, d, x, s, t){
+	function ff(a, b, c, d, x, s, t){
 		return cmn(bitOR(bitAND(b, c), bitAND((~b), d)), a, b, x, s, t);
 	}
 
-	private static function gg(a, b, c, d, x, s, t){
+	function gg(a, b, c, d, x, s, t){
 		return cmn(bitOR(bitAND(b, d), bitAND(c, (~d))), a, b, x, s, t);
 	}
 
-	private static function hh(a, b, c, d, x, s, t){
+	function hh(a, b, c, d, x, s, t){
 		return cmn(bitXOR(bitXOR(b, c), d), a, b, x, s, t);
 	}
 
-	private static function ii(a, b, c, d, x, s, t){
+	function ii(a, b, c, d, x, s, t){
 		return cmn(bitXOR(c, bitOR(b, (~d))), a, b, x, s, t);
 	}
 
-	private static function __jsflash_encode(str:String):String{
+	function doEncode( str:String ) : String {
 
 		var x = str2blks(str);
 		var a =  1732584193;

+ 13 - 10
std/haxe/Serializer.hx

@@ -115,7 +115,7 @@ class Serializer {
 			#if js
 			var ci = cache[i];
 			if( untyped __js__("typeof")(ci) == vt && ci == v ) {
-			#else true
+			#else
 			if( cache[i] == v ) {
 			#end
 				buf.add("r");
@@ -185,7 +185,10 @@ class Serializer {
 			case cast Array:
 				var ucount = 0;
 				buf.add("a");
-				var l = #if neko v.length #else true v[untyped "length"] #end;
+				#if flash9
+				var v : Array<Dynamic> = v;
+				#end
+				var l = #if (neko || flash9) v.length #else v[untyped "length"] #end;
 				for( i in 0...l ) {
 					if( v[i] == null )
 						ucount++;
@@ -263,7 +266,7 @@ class Serializer {
 				cache.push(v);
 				#if flash9
 				serializeClassFields(v,c);
-				#else true
+				#else
 				serializeFields(v);
 				#end
 			}
@@ -293,22 +296,22 @@ class Serializer {
 				for( i in 0...l )
 					serialize(v.args[i]);
 			}
-			#else flash9
+			#elseif flash9
 			if( useEnumIndex ) {
 				buf.add(":");
 				buf.add(v.index);
 			} else
 				serializeString(v.tag);
 			buf.add(":");
-			if( v.params == null )
+			var pl : Array<Dynamic> = v.params;
+			if( pl == null )
 				buf.add(0);
 			else {
-				var l : Int = v.params.length;
-				buf.add(l);
-				for( i in 0...l )
-					serialize(v.params[i]);
+				buf.add(pl.length);
+				for( p in pl )
+					serialize(p);
 			}
-			#else true
+			#else
 			if( useEnumIndex ) {
 				buf.add(":");
 				buf.add(v[1]);

+ 41 - 34
std/haxe/Stack.hx

@@ -44,13 +44,15 @@ class Stack {
 	**/
 	public static function callStack() : Array<StackItem> {
 		#if neko
-		var a = makeStack(untyped __dollar__callstack());
-		a.pop(); // remove Stack.callStack()
-		return a;
-		#else flash9
-		return null;
-		#else true
-		return makeStack("$s");
+			var a = makeStack(untyped __dollar__callstack());
+			a.pop(); // remove Stack.callStack()
+			return a;
+		#elseif flash9
+			return null;
+		#elseif (flash || js)
+			return makeStack("$s");
+		#else
+			return null;
 		#end
 	}
 
@@ -61,11 +63,13 @@ class Stack {
 	**/
 	public static function exceptionStack() : Array<StackItem> {
 		#if neko
-		return makeStack(untyped __dollar__excstack());
-		#else flash9
-		return null;		
-		#else true
-		return makeStack("$e");
+			return makeStack(untyped __dollar__excstack());
+		#elseif flash9
+			return null;
+		#elseif (flash ||js)
+			return makeStack("$e");
+		#else
+			return null;
 		#end
 	}
 
@@ -100,28 +104,31 @@ class Stack {
 
 	private static function makeStack(s) {
 		#if neko
-		var a = new Array();
-		var l = untyped __dollar__asize(s);
-		var i = 0;
-		while( i < l ) {
-			var x = s[i++];
-			if( x == null )
-				a.push(CFunction);
-			else if( untyped __dollar__typeof(x) == __dollar__tstring )
-				a.push(Module(new String(x)));
-			else
-				a.push(FilePos(new String(untyped x[0]),untyped x[1]));
-		}
-		return a;
-		#else flash9
-		#else true
-		var a : Array<String> = untyped #if flash __eval__(s) #else true try __js__("eval")(s) catch( e : Dynamic ) [] #end;
-		var m = new Array();
-		for( i in 0...a.length - if(s == "$s") 2 else 0 ) {
-			var d = a[i].split("::");
-			m.unshift(Method(d[0],d[1]));
-		}
-		return m;
+			var a = new Array();
+			var l = untyped __dollar__asize(s);
+			var i = 0;
+			while( i < l ) {
+				var x = s[i++];
+				if( x == null )
+					a.push(CFunction);
+				else if( untyped __dollar__typeof(x) == __dollar__tstring )
+					a.push(Module(new String(x)));
+				else
+					a.push(FilePos(new String(untyped x[0]),untyped x[1]));
+			}
+			return a;
+		#elseif flash9
+			return null;
+		#elseif (flash || js)
+			var a : Array<String> = untyped #if flash __eval__(s) #else try __js__("eval")(s) catch( e : Dynamic ) [] #end;
+			var m = new Array();
+			for( i in 0...a.length - if(s == "$s") 2 else 0 ) {
+				var d = a[i].split("::");
+				m.unshift(Method(d[0],d[1]));
+			}
+			return m;
+		#else
+			return null;
 		#end
 	}
 

+ 3 - 3
std/haxe/Template.hx

@@ -53,7 +53,7 @@ class Template {
 	static var expr_int = ~/^[0-9]+$/;
 	static var expr_float = ~/^([+-]?)(?=\d|,\d)\d*(,\d*)?([Ee]([+-]?\d+))?$/;
 
-	public static var globals = Reflect.empty();
+	public static var globals : Dynamic = {};
 
 	var expr : TemplateExpr;
 	var context : Dynamic;
@@ -69,7 +69,7 @@ class Template {
 	}
 
 	public function execute( context : Dynamic, ?macros : Dynamic ) {
-		this.macros = if( macros == null ) Reflect.empty() else macros;
+		this.macros = if( macros == null ) {} else macros;
 		this.context = context;
 		stack = new List();
 		buf = new StringBuf();
@@ -355,7 +355,7 @@ class Template {
 				var msg = "Macro call "+m+"("+plstr+") failed ("+Std.string(e)+")";
 				#if neko
 				neko.Lib.rethrow(msg);
-				#else true
+				#else
 				throw msg;
 				#end
 			}

+ 18 - 28
std/haxe/Timer.hx

@@ -39,24 +39,24 @@ class Timer {
 		#if flash9
 			var me = this;
 			id = untyped __global__["flash.utils.setInterval"](function() { me.run(); },time);
-		#else flash
+		#elseif flash
 			var me = this;
 			id = untyped _global["setInterval"](function() { me.run(); },time);
-		#else js
+		#elseif js
 			id = arr.length;
 			arr[id] = this;
 			timerId = untyped window.setInterval("haxe.Timer.arr["+id+"].run();",time);
 		#end
 	}
 
-	public function stop(){
+	public function stop() {
 		if( id == null )
 			return;
 		#if flash9
 			untyped __global__["flash.utils.clearInterval"](id);
-		#else flash
+		#elseif flash
 			untyped _global["clearInterval"](id);
-		#else js
+		#elseif js
 			untyped window.clearInterval(timerId);
 			arr[id] = null;
 			if( id > 100 && id == arr.length - 1 ) {
@@ -66,32 +66,21 @@ class Timer {
 					p--;
 				arr = arr.slice(0,p+1);
 			}
-		#else neko
 		#end
 		id = null;
 	}
 
-	public dynamic function run(){
+	public dynamic function run() {
 	}
 
-	public static function delayed( f : Void -> Void, time : Int ) : Void -> Void {
-		return function() {
-			var t = new haxe.Timer(time);
-			t.run = function() {
-				t.stop();
-				f();
-			};
+	public static function delay( f : Void -> Void, time : Int ) {
+		var t = new haxe.Timer(time);
+		t.run = function() {
+			t.stop();
+			f();
 		};
 	}
 
-	private static var fqueue = new Array<Void -> Void>();
-	public static function queue( f : Void -> Void, ?time : Int ) : Void {
-		fqueue.push(f);
-		haxe.Timer.delayed(function() {
-			fqueue.shift()();
-		},if( time == null ) 0 else time)();
-	}
-
 	#end
 
 	/**
@@ -99,12 +88,13 @@ class Timer {
 	**/
 	public static function stamp() : Float {
 		#if flash
-		return flash.Lib.getTimer() / 1000;
-		#else neko
-		return neko.Sys.time();
-		#else js
-		return Date.now().getTime() / 1000;
-		#else error
+			return flash.Lib.getTimer() / 1000;
+		#elseif neko
+			return neko.Sys.time();
+		#elseif js
+			return Date.now().getTime() / 1000;
+		#else
+			return 0;
 		#end
 	}
 

+ 2 - 2
std/haxe/Unserializer.hx

@@ -184,7 +184,7 @@ class Unserializer {
  			}
  			return a;
  		case 111: // o
-	 		var o = Reflect.empty();
+	 		var o = {};
 	 		cache.push(o);
 			unserializeObject(o);
 			return o;
@@ -264,7 +264,7 @@ class Unserializer {
 			var s = neko.Utf8.sub(buf,pos-upos,len);
 			pos += s.length;
 			upos += s.length - len;
-			#else true
+			#else
  			var s = buf.substr(pos,len);
  			pos += len;
  			#end

+ 4 - 100
std/haxe/remoting/AsyncConnection.hx

@@ -24,106 +24,10 @@
  */
 package haxe.remoting;
 
-class AsyncConnection implements Dynamic<AsyncConnection> {
+interface AsyncConnection implements Dynamic<AsyncConnection> {
 
-	var __data : Dynamic;
-	var __path : Array<String>;
-	var __error : { ref : Dynamic -> Void };
-	public var onError(getErrorHandler,setErrorHandler) : Dynamic -> Void;
-
-	function new( data : Dynamic, path ) {
-		__data = data;
-		__path = path;
-		__error = { ref : function(e) { throw e; } };
-	}
-
-	public function __resolve(field) {
-		var s = new AsyncConnection(__data,__path.copy());
-		s.__error = __error;
-		s.__path.push(field);
-		return s;
-	}
-
-	function getErrorHandler() {
-		return __error.ref;
-	}
-
-	function setErrorHandler(f) {
-		__error.ref = f;
-		return f;
-	}
-
-	public function call( params : Array<Dynamic>, ?onData : Dynamic -> Void ) : Void {
-		#if flash
-		if( Reflect.hasField(__data,"connect") ) {
-			var me = this;
-			var p = params.copy();
-			#if flash9
-			p.unshift(new flash.net.Responder(
-				function(r) { onData(r); },
-				function(e) { me.__error.ref(e); }
-			));
-			#else true
-			p.unshift({
-				onStatus : function(e) { me.__error.ref(e); },
-				onResult : function(r) { onData(r); }
-			});
-			#end
-			p.unshift(__path.join("."));
-			__data.call.apply(__data,p);
-			return;
-		}
-		#end
-		var h = new haxe.Http(__data);
-		var me = this;
-		var s = new haxe.Serializer();
-		s.serialize(__path);
-		s.serialize(params);
-		h.setHeader("X-Haxe-Remoting","1");
-		h.setParameter("__x",s.toString());
-		h.onData = function(data : String) {
-			var ok = true;
-			var v;
-			try {
-				if( data.substr(0,3) != "hxr" )
-					throw "Invalid response : '"+data+"'";
-				var s = new haxe.Unserializer(data.substr(3));
-				v = s.unserialize();
-			} catch( err : Dynamic ) {
-				ok = false;
-				me.__error.ref(err);
-			}
-			if( ok )
-				onData(v);
-		};
-		h.onError = function(e) { me.__error.ref(e); };
-		#if (neko && no_remoting_shutdown)
-		h.noShutdown = true;
-		#end
-		h.request(true);
-	}
-
-	public static function urlConnect( url : String ) {
-		return new AsyncConnection(url,[]);
-	}
-
-	#if flash
-	public static function amfConnect( gatewayUrl : String ) {
-		#if flash9
-		var c = new flash.net.NetConnection();
-		var cnx = new AsyncConnection(c,[]);
-		c.addEventListener(flash.events.NetStatusEvent.NET_STATUS,function(e:flash.events.NetStatusEvent) {
-			cnx.onError(e);
-		});
-		c.connect(gatewayUrl);
-		return cnx;
-		#else true
-		var c = new flash.NetConnection();
-		if( !c.connect(gatewayUrl) )
-			throw "Could not connected to gateway url "+gatewayUrl;
-		return new AsyncConnection(c,[]);
-		#end
-	}
-	#end
+	function resolve( name : String ) : AsyncConnection;
+	function call( params : Array<Dynamic>, ?result : Dynamic -> Void ) : Void;
+	function setErrorHandler( error : Dynamic -> Void ) : Void;
 
 }

+ 3 - 167
std/haxe/remoting/Connection.hx

@@ -24,173 +24,9 @@
  */
 package haxe.remoting;
 
-class Connection implements Dynamic<Connection> {
+interface Connection implements Dynamic<Connection> {
 
-	var __data : Dynamic;
-	var __path : Array<String>;
-
-	function new( data : Dynamic, path ) {
-		__data = data;
-		__path = path;
-	}
-
-	public function __resolve(field) {
-		var s = new Connection(__data,__path.copy());
-		s.__path.push(field);
-		return s;
-	}
-
-	#if flash9
-	static function escapeString( s : String ) {
-		return s.split("\\").join("\\\\");
-	}
-	#else flash
-	static function escapeString( s : String ) {
-		return s.split("\\").join("\\\\").split("&").join("&amp;");
-	}
-	#end
-
-	public function call( params : Array<Dynamic> ) : Dynamic {
-	#if flash
-		var p = __path.copy();
-		var f = p.pop();
-		var path = p.join(".");
-		var s = new haxe.Serializer();
-		s.serialize(params);
-		var params = escapeString(s.toString());
-		#if (flash8 || flash9)
-			var s = flash.external.ExternalInterface.call("haxe.remoting.Connection.doCall",path,f,params);
-			if( s == null )
-				throw "Failed to call JS method "+__path.join(".");
-			return new haxe.Unserializer(s).unserialize();
-		#else true
-			throw "JS method call is not supported on Flash < 8";
-		#end
-	#else js
-		var s = new haxe.Serializer();
-		var data;
-		if( __data.remotingCall == null ) {
-			var h = new haxe.Http(__data);
-			untyped h.async = false;
-			h.onData = function(d) { data = d; };
-			h.onError = function(e) { throw e; };
-			h.setHeader("X-Haxe-Remoting","1");
-			s.serialize(__path);
-			s.serialize(params);
-			h.setParameter("__x",s.toString());
-			h.request(true);
-			if( data.substr(0,3) != "hxr" )
-                throw "Invalid response : '"+data+"'";
-			data = data.substr(3);
-		} else {
-			var p = __path.copy();
-			var f = p.pop();
-			var path = p.join(".");
-			s.serialize(params);
-			var params = s.toString();
-			data = __data.remotingCall(path,f,params);
-			if( data == null )
-				throw "Failed to call Flash method "+__path.join(".");
-		}
-		return new haxe.Unserializer(data).unserialize();
-	#else neko
-		var cnx = AsyncConnection.urlConnect(__data);
-		var result = null;
-		untyped cnx.__path = __path;
-		cnx.onError = neko.Lib.rethrow;
-		cnx.call(params,function(d) { result = d; });
-		return result;
-	#else error
-	#end
-	}
-
-
-	static function doCall( path : String, f : String, params : String ) : String {
-		try {
-			var params = new haxe.Unserializer(params).unserialize();
-			#if flash
-			var obj = flash.Lib.eval(path);
-			#else js
-			var obj = js.Lib.eval(path);
-			#else true
-			var obj = null;
-			#end
-			var fun = Reflect.field(obj,f);
-			if( fun == null )
-				throw "Invalid remoting call : "+path+"."+f;
-			var v = Reflect.callMethod(obj,fun,params);
-			var s = new haxe.Serializer();
-			s.serialize(v);
-			#if flash
-			return escapeString(s.toString());
-			#else js
-			return s.toString()+"#";
-			#else true
-			return null;
-			#end
-		} catch( e : Dynamic ) {
-			var s = new haxe.Serializer();
-			s.serializeException(e);
-			return s.toString();
-		}
-	}
-
-	// ---- platform-specific ----
-
-	#if flash
-
-	#if no_js_remoting
-	public static function init() {
-	#else true
-	static function __init__() {
-	#end
-		#if flash9
-		var _ = function() { try flash.external.ExternalInterface.addCallback("remotingCall",doCall) catch( e : Dynamic ) {} }();
-		#else flash8
-		flash.external.ExternalInterface.addCallback("remotingCall",null,doCall);
-		#end
-	}
-
-	public static function jsConnect( ?name : String ) : Connection {
-		if( !flash.external.ExternalInterface.available )
-			throw "External Interface not available";
-		if( flash.external.ExternalInterface.call("haxe.remoting.Connection.jsRemoting") != "yes" )
-			throw "haxe.remoting.Connection is not available in JavaScript";
-		return new Connection(null,if( name == null ) [] else ["_cnx",name]);
-	}
-
-	#else js
-
-	static function __init__() {
-		untyped __js__("_cnx = new Object()");
-	}
-
-	static function jsRemoting() {
-		return "yes";
-	}
-
-	public static function bind( name : String, obj : Dynamic ) {
-		untyped __js__("_cnx")[name] = obj;
-	}
-
-	public static function flashConnect( objId : String ) : Connection {
-		var x : Dynamic = untyped window.document[objId];
-		if( x == null )
-			throw "Could not find flash object '"+objId+"'";
-		if( x.remotingCall == null ) throw "The flash object is not ready or does not contain haxe.remoting.Connection";
-		return new Connection(x,[]);
-	}
-
-	public static function urlConnect( url : String ) : Connection {
-		return new Connection(url,[]);
-	}
-
-	#else neko
-
-	public static function urlConnect( url : String ) : Connection {
-		return new Connection(url,[]);
-	}
-
-	#end
+	function resolve( name : String ) : Connection;
+	function call( params : Array<Dynamic> ) : Dynamic;
 
 }

+ 9 - 26
std/haxe/unit/TestRunner.hx

@@ -31,13 +31,12 @@ class TestRunner {
 
 #if flash9
 	static var tf : flash.text.TextField = null;
-#else flash
+#elseif flash
 	static var tf : flash.TextField = null;
 #end
 
-	public static dynamic function print( v : Dynamic ) {
+	public static dynamic function print( v : Dynamic ) untyped {
 		#if flash9
-		untyped {
 			if( tf == null ) {
 				tf = new flash.text.TextField();
 				tf.selectable = false;
@@ -46,9 +45,7 @@ class TestRunner {
 				flash.Lib.current.addChild(tf);
 			}
 			tf.appendText(v);
-		}
-		#else flash
-		untyped {
+		#elseif flash
 			var root = flash.Lib.current;
 			if( tf == null ) {
 				root.createTextField("__tf",1048500,0,0,flash.Stage.width,flash.Stage.height+30);
@@ -63,19 +60,15 @@ class TestRunner {
 				lines.shift();
 				tf.text = lines.join("\n");
 			}
-		}
-		#else neko
-		untyped __dollar__print(v);
-		#else js
-		untyped {
+		#elseif neko
+			__dollar__print(v);
+		#elseif js
 			var msg = StringTools.htmlEscape(js.Boot.__string_rec(v,"")).split("\n").join("<br/>");
 			var d = document.getElementById("haxe:trace");
 			if( d == null )
 				alert("haxe:trace element not found")
 			else
 				d.innerHTML += msg;
-		}
-		#else error
 		#end
 	}
 
@@ -101,16 +94,6 @@ class TestRunner {
 		return result.success;
 	}
 
-	function getBT( e : Dynamic ) {
-		#if flash9
-		if( e != null && Std.is(e,untyped __global__["Error"] ) )
-			return e.getStackTrace();
-		return null;
-		#else true
-		return haxe.Stack.toString(haxe.Stack.exceptionStack());
-		#end
-	}
-
 	function runCase( t:TestCase ) : Void 	{
 		var old = haxe.Log.trace;
 		haxe.Log.trace = customTrace;
@@ -141,7 +124,7 @@ class TestRunner {
 					}
 				}catch ( e : TestStatus ){
 					print("F");
-					t.currentTest.backtrace = getBT(e);
+					t.currentTest.backtrace = haxe.Stack.toString(haxe.Stack.exceptionStack());
 				}catch ( e : Dynamic ){
 					print("E");
 					#if js
@@ -150,10 +133,10 @@ class TestRunner {
 					}else{
 						t.currentTest.error = "exception thrown : "+e;
 					}
-					#else true
+					#else
 					t.currentTest.error = "exception thrown : "+e;
 					#end
-					t.currentTest.backtrace = getBT(e);
+					t.currentTest.backtrace = haxe.Stack.toString(haxe.Stack.exceptionStack());
 				}
 				result.add(t.currentTest);
 				t.tearDown();

+ 2 - 2
std/js/Boot.hx

@@ -36,7 +36,7 @@ class Boot {
 			#if jsfl
 			msg += __string_rec(v,"");
 			fl.trace(msg);
-			#else true
+			#else
 			msg += __unhtml(__string_rec(v,""))+"<br/>";
 			var d = document.getElementById("haxe:trace");
 			if( d == null )
@@ -51,7 +51,7 @@ class Boot {
 		untyped {
 			#if jsfl
 			fl.outputPanel.clear();
-			#else true
+			#else
 			var d = document.getElementById("haxe:trace");
 			if( d != null )
 				d.innerHTML = "";

+ 0 - 19
std/js/Dom.hx

@@ -173,13 +173,10 @@ typedef Document = {> HtmlDom,
 
 	// TODO : var URL : String;
 
-	#if w3c
-	#else true
 	// not W3C , need infos : var embeds : HtmlCollection<Embed>;
 	// var lastModified : Date; // commented : does not include date by default
 	var styleSheets : HtmlCollection<StyleSheet>;
 	function getElementsByTag( tag : String ) : HtmlCollection<HtmlDom>;
-	#end
 
 	function open() : Void;
 	function write( str : String ) : Void;
@@ -272,11 +269,6 @@ typedef IFrame = {> HtmlDom,
 	var name : String;
 	var scrolling : String;
 	var src : String;
-
-	#if w3c
-	#else true
-	var tabIndex : Int;
-	#end
 }
 
 typedef Image = {> HtmlDom,
@@ -293,11 +285,8 @@ typedef Image = {> HtmlDom,
 	var vspace : Int;
 	var width : Int;
 
-	#if w3c
-	#else true
 	var complete : Bool;
 	var lowsrc : String;
-	#end
 
 	var onabort : Event -> Void;
 	var onerror : Event -> Void;
@@ -314,12 +303,7 @@ typedef Link = {> HtmlDom,
 	var rev : String;
 	var target : String;
 	var type : String;
-
-	#if w3c
-	#else true
 	var name : String;
-	#end
-
 	var onload : Event -> Void;
 }
 
@@ -611,13 +595,10 @@ typedef Window = {
 	// setInterval
 	// setTimeout
 
-	#if w3c
-	#else true
 	var innerWidth : Int;
 	var innerHeight : Int;
 	var outerWidth : Int;
 	var outerHeight : Int;
-	#end
 
 	/* IE only ?
 	clientInformation

+ 1 - 1
std/js/Lib.hx

@@ -64,7 +64,7 @@ class Lib {
 				return f(msg,stack);
 			}
 		');
-		#else true
+		#else
 		__js__('
 			onerror = function(msg,url,line) {
 				var f = js.Lib.onerror;

+ 5 - 8
std/mtwin/web/Request.hx

@@ -51,16 +51,13 @@ class Request {
 	}
 
 	public function getParamsObject( ?keys : List<String> ) : Dynamic<String> {
-		var ret = cast Reflect.empty();
-		if( keys == null ){
-			for( k in params.keys() ){
+		var ret : Dynamic<String> = cast {};
+		if( keys == null )
+			for( k in params.keys() )
 				Reflect.setField( ret, k, params.get(k) );
-			}
-		}else{
-			for( k in keys ){
+		else
+			for( k in keys )
 				Reflect.setField( ret, k, params.get(k) );
-			}
-		}
 		return ret;
 	}
 

+ 1 - 1
std/neko/NekoXml__.hx

@@ -117,7 +117,7 @@ class NekoXml__ {
 		var r = new NekoXml__();
 		r.nodeType = Xml.Element;
 		r._nodeName = name;
-		r._attributes = cast Reflect.empty();
+		r._attributes = untyped __dollar__new(null);
 		r._children = new Array();
 		return r;
 	}

+ 1 - 1
std/neko/net/ProxyDetect.hx

@@ -122,7 +122,7 @@ class ProxyDetect {
 	static function parseOSXConfiguration(xml : Xml) : Dynamic {
 		switch( xml.nodeName ) {
 		case "dict":
-			var o = Reflect.empty();
+			var o = {};
 			var it = xml.elements();
 			for( x in it ) {
 				if( x.nodeName != "key" ) throw "Missing key";