Nicolas Cannasse 19 лет назад
Родитель
Сommit
9ed24a2151

+ 2 - 2
genneko.ml

@@ -204,7 +204,7 @@ and gen_expr e =
 				) in
 				let cond = (match path with
 					| None -> (EConst True,p)
-					| Some path -> call p (field p (ident p "Boot") "__instanceof") [ident p "@tmp"; gen_type_path p path]
+					| Some path -> call p (field p (gen_type_path p (["neko"],"Boot")) "__instanceof") [ident p "@tmp"; gen_type_path p path]
 				) in
 				(EIf (cond,(EBlock [
 					EVars [v,Some (ident p "@tmp")],p;
@@ -374,7 +374,7 @@ let gen_packages h t =
 	loop [] (fst (type_path t))
 
 let gen_boot() =
-	call null_pos (field null_pos (ident null_pos "Boot") "__init") []
+	call null_pos (field null_pos (gen_type_path null_pos (["neko"],"Boot")) "__init") []
 
 let generate file types =
 	let h = Hashtbl.create 0 in

+ 1 - 1
genswf8.ml

@@ -1147,7 +1147,7 @@ let gen_type_def ctx t =
 		PMap.iter (fun _ f -> gen_enum_field ctx f) e.e_constrs
 
 let gen_boot ctx =
-	let id = gen_type ctx ([],"Boot") false in
+	let id = gen_type ctx (["flash"],"Boot") false in
 	(* r0 = Boot *)
 	push ctx [VStr id];
 	write ctx AEval;

+ 3 - 5
std/Std.hx

@@ -23,16 +23,14 @@
  * DAMAGE.
  */
 
-import Boot;
-
 class Std {
 
 	public static function instanceof( obj : Dynamic, vclass : Dynamic ) : Bool {
 		return untyped
 		#if flash
-		Boot.__instanceof(obj,vclass);
+		flash.Boot.__instanceof(obj,vclass);
 		#else neko
-		Boot.__instanceof(obj,vclass);
+		neko.Boot.__instanceof(obj,vclass);
 		#else error
 		#end
 	}
@@ -40,7 +38,7 @@ class Std {
 	public static function string( s : Dynamic ) : String {
 		return untyped
 		#if flash
-		Boot.__string_rec(s,"");
+		flash.Boot.__string_rec(s,"");
 		#else neko
 		__dollar__string(s);
 		#else error

+ 6 - 6
std/StringBuf.hx

@@ -38,7 +38,7 @@ class StringBuf {
 		#if neko
 		__add(b,x);
 		#else flash
-		b += untyped Boot.__string_rec(x,"");
+		b += untyped flash.Boot.__string_rec(x,"");
 		#else error
 		#end
 	}
@@ -73,11 +73,11 @@ class StringBuf {
 	private var b : Dynamic;
 
 #if neko
-	static var __make : Dynamic = Neko.load("std","buffer_new",0);
-	static var __add : Dynamic = Neko.load("std","buffer_add",2);
-	static var __add_char : Dynamic = Neko.load("std","buffer_add_char",2);
-	static var __add_sub : Dynamic = Neko.load("std","buffer_add_sub",4);
-	static var __string : Dynamic = Neko.load("std","buffer_string",1);
+	static var __make : Dynamic = neko.Lib.load("std","buffer_new",0);
+	static var __add : Dynamic = neko.Lib.load("std","buffer_add",2);
+	static var __add_char : Dynamic = neko.Lib.load("std","buffer_add_char",2);
+	static var __add_sub : Dynamic = neko.Lib.load("std","buffer_add_sub",4);
+	static var __string : Dynamic = neko.Lib.load("std","buffer_string",1);
 #end
 
 }

+ 35 - 12
std/flash/Boot.hx

@@ -108,16 +108,17 @@ class Boot {
 
 	private static function __trace(v,inf) {
 		untyped {
-			var tf = _root.__trace_txt;
+			var root = flash.Lib.current;
+			var tf = root.__trace_txt;
 			if( tf == null ) {
-				_root.createTextField("__trace_txt",1048500,0,0,Stage.width,Stage.height);
-				tf = _root.__trace_txt;
+				root.createTextField("__trace_txt",1048500,0,0,Stage.width,Stage.height);
+				tf = root.__trace_txt;
 				tf.selectable = false;
-				_root.__trace_lines = new Array<String>();
+				root.__trace_lines = new Array<String>();
 			}
 			var s = inf.fileName+":"+inf.lineNumber+": "+__string_rec(v,"");
-			var lines = _root.__trace_lines.concat(s.split("\n"));
-			_root.__trace_lines = lines;
+			var lines = root.__trace_lines.concat(s.split("\n"));
+			root.__trace_lines = lines;
 			var nlines = Stage.height / 16;
 			if( lines.length > nlines )
 				lines.splice(0,lines.length-nlines);
@@ -135,9 +136,8 @@ class Boot {
 	private static function __init(current) {
 		untyped {
 			var obj = _global["Object"];
-			if( flash == null )
-				flash = __new__(obj);
-			else if( flash.text == null )
+			var flash = current["flash"];
+			if( flash.text == null )
 				flash.text = __new__(obj);
 			flash.text.StyleSheet = TextField["StyleSheet"];
 			flash.system = __new__(obj);
@@ -208,9 +208,32 @@ class Boot {
 				}
 			};
 
-			Stage._global = _global;
-			Stage._root = _root;
-			Stage.current = current;
+			// 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"];
+
+			Lib._global = _global;
+			Lib._root = _root;
+			Lib.current = current;
 			Int = __new__(obj);
 			Float = _global["Number"];
 			// prevent closure creation by setting untyped

+ 1 - 1
std/flash/geom/Transform.hx

@@ -8,6 +8,6 @@ extern class Transform {
 	var concatenatedColorTransform : ColorTransform;
 	var pixelBounds : Rectangle<Float>;
 
-	function new( mc : MovieClip ) : Void;
+	function new( mc : flash.MovieClip ) : Void;
 
 }

+ 1 - 1
std/flash/text/StyleSheet.hx

@@ -6,7 +6,7 @@ extern class StyleSheet
 	function setStyle(name:String,style:Dynamic):Void;
 	function clear():Void;
 	function getStyleNames():Array<Dynamic>;
-	function transform(style:Dynamic):TextFormat;
+	function transform(style:Dynamic):flash.TextFormat;
 	function parseCSS(cssText:String):Bool;
 	function parse(cssText:String):Bool;
 	function load(url:String):Bool;

+ 25 - 24
std/haxe/ImportAll.hx

@@ -44,28 +44,29 @@ import StringBuf;
 // flash
 #if flash
 
-import Accessibility;
-import AsBroadCaster;
-import Boot;
-import Camera;
-import Color;
-import Key;
-import LoadVars;
-import LocalConnection;
-import Microphone;
-import Mouse;
-import MovieClip;
-import MovieClipLoader;
-import PrintJob;
-import Selection;
-import SharedObject;
-import Sound;
-import Stage;
-import System;
-import TextField;
-import TextFormat;
-import TextSnapshot;
-import Video;
+import flash.Boot;
+import flash.Lib;
+
+import flash.Accessibility;
+import flash.Camera;
+import flash.Color;
+import flash.Key;
+import flash.LoadVars;
+import flash.LocalConnection;
+import flash.Microphone;
+import flash.Mouse;
+import flash.MovieClip;
+import flash.MovieClipLoader;
+import flash.PrintJob;
+import flash.Selection;
+import flash.SharedObject;
+import flash.Sound;
+import flash.Stage;
+import flash.System;
+import flash.TextField;
+import flash.TextFormat;
+import flash.TextSnapshot;
+import flash.Video;
 
 import flash.text.StyleSheet;
 import flash.system.Capabilities;
@@ -104,7 +105,7 @@ import flash.text.TextRenderer;
 
 #if neko
 
-import Boot;
-import Neko;
+import neko.Boot;
+import neko.Lib;
 
 #end

+ 2 - 2
std/haxe/Log.hx

@@ -36,7 +36,7 @@ class Log {
 
 	public static function trace( v : Dynamic, infos : LogInfos ) : Void {
 		#if flash
-		untyped Boot.__trace(v,infos);
+		untyped flash.Boot.__trace(v,infos);
 		#else neko
 		untyped __dollar__print(infos.fileName+":"+infos.lineNumber+": ",v,"\n");
 		#else error
@@ -45,7 +45,7 @@ class Log {
 
 	public static function clear() : Void {
 		#if flash
-		untyped Boot.__clear_trace();
+		untyped flash.Boot.__clear_trace();
 		#else neko
 		// nothing
 		#else error

+ 1 - 0
std/neko/Boot.hx

@@ -22,6 +22,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  */
+package neko;
 
 class Boot {
 

+ 3 - 2
std/neko/Lib.hx

@@ -22,8 +22,9 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  */
+package neko;
 
-class Neko {
+class Lib {
 
 	public static function load( lib : String, prim : String, nargs : Int ) : Dynamic {
 		return untyped __dollar__loader.loadprim((lib+"@"+prim).__s,nargs);
@@ -33,4 +34,4 @@ class Neko {
 		untyped __dollar__print(v);
 	}
 
-}
+}

+ 1 - 0
std/neko/NekoArray__.hx

@@ -22,6 +22,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  */
+package neko;
 
 class NekoArray__<T> implements Array<T> {
 

+ 2 - 1
std/neko/NekoString__.hx

@@ -22,10 +22,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  */
+package neko;
 
 class NekoString__ implements String {
 
-	private static var __split : Dynamic = Neko.load("std","string_split",2);
+	private static var __split : Dynamic = Lib.load("std","string_split",2);
 
 	public var length : Int;