Browse Source

change Boot init.

Nicolas Cannasse 19 years ago
parent
commit
39b7a7654b

+ 4 - 0
std/flash/Accessibility.hx

@@ -6,4 +6,8 @@ extern class Accessibility
 	static function updateProperties() : Void;
 	// ? not documented ?
 	static function sendEvent(mc : MovieClip, childID : Dynamic, event : Dynamic, isNonHtml : Bool) : Void;
+
+	private static function __init__() : Void untyped {
+		flash.Accessibility = _global["Accessibility"];
+	}
 }

+ 25 - 51
std/flash/Boot.hx

@@ -176,9 +176,17 @@ class Boot {
 		}
 	}
 
-	private static function __init(current) {
-		untyped {
-			var obj = _global["Object"];
+	private static function __init(current) untyped {
+		// only if not set yet
+		if( !_global.haxeInitDone ) {
+			var obj = _global.Object;
+			_global.haxeInitDone = true;
+			_global.Int = __new__(obj);
+			_global.Bool = __new__(obj);
+			_global.Dynamic = __new__(obj);
+			_global.Bool["true"] = true;
+			_global.Bool["false"] = false;
+			_global.Float = _global.Number;
 			Array.prototype.copy = Array.prototype.slice;
 			Array.prototype.insert = function(i,x) {
 				this["splice"](i,0,x);
@@ -214,55 +222,21 @@ class Boot {
 					return null;
 				return x;
 			};
-			// copy base classes from root to flash package
-			// we can't make a loop since we need to assign short-type-ids
-			flash.Accessibility = _global["Accessibility"];
-			flash.Camera = _global["Camera"];
-			flash.Color = _global["Color"];
-			flash.Key = _global["Key"];
-			flash.LoadVars = _global["LoadVars"];
-			flash.LocalConnection = _global["LocalConnection"];
-			flash.Microphone = _global["Microphone"];
-			flash.Mouse = _global["Mouse"];
-			flash.MovieClip = _global["MovieClip"];
-			flash.MovieClipLoader = _global["MovieClipLoader"];
-			flash.PrintJob = _global["PrintJob"];
-			flash.Selection = _global["Selection"];
-			flash.SharedObject = _global["SharedObject"];
-			flash.Sound = _global["Sound"];
-			flash.Stage = _global["Stage"];
-			flash.System = _global["System"];
-			flash.TextField = _global["TextField"];
-			flash.TextFormat = _global["TextFormat"];
-			flash.TextSnapshot = _global["TextSnapshot"];
-			flash.Video = _global["Video"];
-			flash.XMLSocket = _global["XMLSocket"];
-			flash.NetConnection = _global["NetConnection"];
-			flash.NetStream = _global["NetStream"];
-
-			flash.text.StyleSheet = TextField["StyleSheet"];
-			flash.system.Capabilities = System.capabilities;
-			flash.system.Security = System.security;
-			flash.system.IME = System["IME"];
-
-			Lib._global = _global;
-			Lib._root = _root;
-			Lib.current = current;
-			Int = __new__(obj);
-			Bool = __new__(obj);
-			Bool["true"] = true;
-			Bool["false"] = false;
-			Float = _global["Number"];
-			// prevent closure creation by setting untyped
-			current["@instanceof"] = untyped __instanceof;
-			current["@closure"] = untyped __closure;
-			exc = new Array();
-			current["@exc"] = exc;
-
-			// fix firefox default alignement
-			if( flash.Stage.align == "" )
-				flash.Stage.align = "LT";
 		}
+		// create the array stack
+		if( exc == null )
+			exc = new Array();
+		// set the Lib variables
+		current.flash.Lib._global = _global;
+		current.flash.Lib._root = _root;
+		current.flash.Lib.current = current;
+		// prevent closure creation by setting untyped
+		current["@instanceof"] = untyped __instanceof;
+		current["@closure"] = untyped __closure;
+		current["@exc"] = exc;
+		// fix firefox default alignement
+		if( flash.Stage.align == "" )
+			flash.Stage.align = "LT";
 	}
 
 }

+ 4 - 2
std/flash/Camera.hx

@@ -40,6 +40,8 @@ extern class Camera {
 	var motionTimeOut:Float;
 	var loopback:Bool;
 
-}
-
+	private static function __init__() : Void untyped {
+		flash.Camera = _global["Camera"];
+	}
 
+}

+ 4 - 0
std/flash/Color.hx

@@ -28,4 +28,8 @@ extern class Color
 	function getTransform() : { ra : Float, rb : Float, ga : Float, gb : Float, ba : Float, bb : Float, aa : Float, ab : Float };
 #end
 
+	private static function __init__() : Void untyped {
+		flash.Color = _global["Color"];
+	}
+
 }

+ 4 - 0
std/flash/Key.hx

@@ -44,4 +44,8 @@ extern class Key
 	static function removeListener(listener:Dynamic):Bool;
 #end
 
+	private static function __init__() : Void untyped {
+		flash.Key = _global["Key"];
+	}
+
 }

+ 5 - 0
std/flash/LoadVars.hx

@@ -30,4 +30,9 @@ implements Dynamic<String>
 	#end
 
 	// undocumented var _customHeaders:Array<String>;
+
+	private static function __init__() : Void untyped {
+		flash.LoadVars = _global["LoadVars"];
+	}
+
 }

+ 5 - 0
std/flash/LocalConnection.hx

@@ -17,4 +17,9 @@ implements Dynamic
 	function allowInsecureDomain(domain:String):Bool;
 
 	function onStatus(infoObject:Dynamic):Void;
+
+	private static function __init__() : Void untyped {
+		flash.LocalConnection = _global["LocalConnection"];
+	}
+
 }

+ 4 - 2
std/flash/Microphone.hx

@@ -23,7 +23,9 @@ extern class Microphone
 
 	function onActivity(active:Bool):Void;
 	function onStatus(infoObject:Dynamic):Void;
-}
-
 
+	private static function __init__() : Void untyped {
+		flash.Microphone = _global["Microphone"];
+	}
 
+}

+ 4 - 2
std/flash/Mouse.hx

@@ -21,6 +21,8 @@ extern class Mouse
 	static function removeListener(listener:Dynamic):Bool;
 #end
 
-}
-
+	private static function __init__() : Void untyped {
+		flash.Mouse = _global["Mouse"];
+	}
 
+}

+ 4 - 0
std/flash/MovieClip.hx

@@ -151,6 +151,10 @@ implements Dynamic
   	function lineGradientStyle( fillType:String, colors:Array<Int>, alphas:Array<Float>, ratios:Array<Float>, matrix:Dynamic, ?spreadMethod : String, ?interpolationMethod:String, ?focalPointRatio:Float ) : Void;
 #end
 
+	private static function __init__() : Void untyped {
+		flash.MovieClip = _global["MovieClip"];
+	}
+
 }
 
 

+ 4 - 0
std/flash/MovieClipLoader.hx

@@ -36,4 +36,8 @@ extern class MovieClipLoader
 	function removeListener(listener:Dynamic):Bool;
 #end
 
+	private static function __init__() : Void untyped {
+		flash.MovieClipLoader = _global["MovieClipLoader"];
+	}
+
 }

+ 3 - 0
std/flash/NetConnection.hx

@@ -19,4 +19,7 @@ implements Dynamic
 	function onStatus(infoObject : Dynamic) : Void;
 	function onResult(infoObject : Dynamic) : Void;
 
+	private static function __init__() : Void untyped {
+		flash.NetConnection = _global["NetConnection"];
+	}
 }

+ 4 - 2
std/flash/NetStream.hx

@@ -31,6 +31,8 @@ extern class NetStream
 	function onCuePoint( info : Dynamic ) : Void;
 #end
 
-}
-
+	private static function __init__() : Void untyped {
+		flash.NetStream = _global["NetStream"];
+	}
 
+}

+ 5 - 0
std/flash/PrintJob.hx

@@ -12,4 +12,9 @@ extern class PrintJob
 	var pageWidth(default,null) : Float;
 	var pageHeight(default,null) : Float;
 	var orientation(default,null) : String;
+
+	private static function __init__() : Void untyped {
+		flash.PrintJob = _global["PrintJob"];
+	}
+
 }

+ 4 - 1
std/flash/Selection.hx

@@ -10,6 +10,9 @@ extern class Selection
 	static function setSelection(beginIndex:Int, endIndex:Int):Void;
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Bool;
-}
 
+	private static function __init__() : Void untyped {
+ 		flash.Selection = _global["Selection"];
+	}
 
+}

+ 5 - 0
std/flash/SharedObject.hx

@@ -24,4 +24,9 @@ extern class SharedObject
 	function clear() : Void;
 
 	var data:Dynamic;
+
+	private static function __init__() : Void untyped {
+		flash.SharedObject = _global["SharedObject"];
+	}
+
 }

+ 4 - 1
std/flash/Sound.hx

@@ -24,6 +24,9 @@ extern class Sound
 	function loadSound(url:String, isStreaming:Bool):Void;
 	function getBytesLoaded():Float;
 	function getBytesTotal():Float;
-}
 
+	private static function __init__() : Void untyped {
+		flash.Sound = _global["Sound"];
+	}
 
+}

+ 4 - 1
std/flash/Stage.hx

@@ -9,6 +9,9 @@ extern class Stage
 	static var showMenu:Bool;
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Void;
-}
 
+	private static function __init__() : Void untyped {
+		flash.Stage = _global["Stage"];
+	}
 
+}

+ 4 - 1
std/flash/System.hx

@@ -7,6 +7,9 @@ extern class System
 	static function showSettings(?tabID:Float):Void;
 	static function setClipboard(text:String):Void;
 	static function onStatus(infoObject:Dynamic):Void;
-}
 
+	private static function __init__() : Void untyped {
+		flash.System = _global["System"];
+	}
 
+}

+ 4 - 0
std/flash/TextField.hx

@@ -84,4 +84,8 @@ extern class TextField
 	function onScroller(scrolledField:TextField):Void;
 	function onSetFocus(oldFocus:Dynamic):Void;
 
+	private static function __init__() : Void untyped {
+		flash.TextField = _global["TextField"];
+	}
+
 }

+ 4 - 1
std/flash/TextFormat.hx

@@ -24,6 +24,9 @@ extern class TextFormat
                   ?leftMargin:Float, ?rightMargin:Float, ?indent:Float,
                   ?leading:Float ) : Void;
 	function getTextExtent(text:String, ?width : Float) : Dynamic;
-}
 
+	private static function __init__() : Void untyped {
+		flash.TextFormat = _global["TextFormat"];
+	}
 
+}

+ 4 - 1
std/flash/TextSnapshot.hx

@@ -10,6 +10,9 @@ extern class TextSnapshot
 	function hitTestTextNearPos(x:Float, y:Float, ?closeDist:Float):Float;
 	function setSelectColor(color:Int):Void;
 	function setSelected(start:Int, end:Int, select:Bool):Void;
-}
 
+	private static function __init__() : Void untyped {
+		flash.TextSnapshot = _global["TextSnapshot"];
+	}
 
+}

+ 4 - 1
std/flash/Video.hx

@@ -9,6 +9,9 @@ extern class Video
 
 	function attachVideo( source : Dynamic ) : Void;
 	function clear() : Void;
-}
 
+	private static function __init__() : Void untyped {
+ 		flash.Video = _global["Video"];
+	}
 
+}

+ 5 - 0
std/flash/XMLSocket.hx

@@ -10,4 +10,9 @@ extern class XMLSocket {
 	//function onXML( src : Xml ) : Void;
 	function onConnect( success : Bool ) : Void;
 	function onClose() : Void;
+
+	private static function __init__() : Void untyped {
+		flash.XMLSocket = _global["XMLSocket"];
+	}
+
 }

+ 5 - 0
std/flash/system/Capabilities.hx

@@ -29,4 +29,9 @@ extern class Capabilities
 	static var avHardwareDisable:Bool;
 	static var localFileReadDisable:Bool;
 	static var windowlessDisable:Bool;
+
+	private static function __init__() : Void untyped {
+		flash.system.Capabilities = _global.System.capabilities;
+	}
+
 }

+ 5 - 0
std/flash/system/IME.hx

@@ -19,4 +19,9 @@ extern class IME {
 	static function doConversion() : Bool;
 	static function addListener(listener:Dynamic) : Void;
 	static function removeListener(listener:Dynamic) : Bool;
+
+	private static function __init__() : Void untyped {
+		flash.system.IME = _global.System.IME;
+	}
+
 }

+ 5 - 0
std/flash/system/Security.hx

@@ -5,4 +5,9 @@ extern class Security
 	static function allowDomain():Void;
 	static function allowInsecureDomain():Void;
 	static function loadPolicyFile(url:String):Void;
+
+	private static function __init__() : Void untyped {
+		flash.system.Security = _global.System.security;
+	}
+
 }

+ 5 - 0
std/flash/text/StyleSheet.hx

@@ -11,4 +11,9 @@ extern class StyleSheet
 	function parse(cssText:String):Bool;
 	function load(url:String):Bool;
 	function onLoad(success:Bool):Void;
+
+	private static function __init__() : Void untyped {
+		flash.text.StyleSheet = _global.TextField.StyleSheet;
+	}
+
 }