Browse Source

custom Boot name for flash9 (allow dynamic loading).

Nicolas Cannasse 18 years ago
parent
commit
18837017e7
3 changed files with 16 additions and 9 deletions
  1. 2 0
      doc/CHANGES.txt
  2. 6 4
      genswf8.ml
  3. 8 5
      genswf9.ml

+ 2 - 0
doc/CHANGES.txt

@@ -19,6 +19,8 @@
 	renamed Http.asyncRequest to customRequest
 	renamed Http.asyncRequest to customRequest
 	add classes to Neko module export table
 	add classes to Neko module export table
 	fixed parametrized enums for Flash6
 	fixed parametrized enums for Flash6
+	fixed bug with completion and interfaces
+	fixed --flash-use-stage in Flash9
 
 
 2007-03-06: 1.12
 2007-03-06: 1.12
 	added flash lite support with -D flash_lite
 	added flash lite support with -D flash_lite

+ 6 - 4
genswf8.ml

@@ -1380,10 +1380,12 @@ let generate_code file ver types hres =
 
 
 let generate file ver header infile types hres =
 let generate file ver header infile types hres =
 	let file , codeclip = (try let f , c = ExtString.String.split file "@" in f, Some c with _ -> file , None) in
 	let file , codeclip = (try let f , c = ExtString.String.split file "@" in f, Some c with _ -> file , None) in
-	let tag_code , movieclips = (if ver = 9 then
-			Genswf9.generate types hres , []
+	let tag_code, boot_name , movieclips = (if ver = 9 then
+			let c, b = Genswf9.generate types hres in
+			c,b,[]
 		else
 		else
-			generate_code file ver types hres
+			let c, m = generate_code file ver types hres in
+			c,"",m
 	) in
 	) in
 	let tag ?(ext=false) d = {
 	let tag ?(ext=false) d = {
 		tid = 0;
 		tid = 0;
@@ -1405,7 +1407,7 @@ let generate file ver header infile types hres =
 			]
 			]
 	) in
 	) in
 	let movieclips = ref movieclips in
 	let movieclips = ref movieclips in
-	let f9clips = ref [{ f9_cid = None; f9_classname = "flash.Boot" }] in
+	let f9clips = ref [{ f9_cid = None; f9_classname = boot_name }] in
 	let tagclips() = List.fold_left (fun acc m ->
 	let tagclips() = List.fold_left (fun acc m ->
 		incr base_id;
 		incr base_id;
 		tag ~ext:true (TClip { c_id = !base_id; c_frame_count = 1; c_tags = [] }) ::
 		tag ~ext:true (TClip { c_id = !base_id; c_frame_count = 1; c_tags = [] }) ::

+ 8 - 5
genswf9.ml

@@ -78,6 +78,7 @@ type context = {
 	gpublic : as3_rights index;
 	gpublic : as3_rights index;
 	debug : bool;
 	debug : bool;
 	mutable last_line : int;
 	mutable last_line : int;
+	boot : string;
 
 
 	(* per-function *)
 	(* per-function *)
 	mutable locals : (string,local) PMap.t;
 	mutable locals : (string,local) PMap.t;
@@ -245,6 +246,7 @@ let type_path ctx ?(getclass=false) path =
 		| [] , "Float" -> [] , "Number"
 		| [] , "Float" -> [] , "Number"
 		| [] , "Bool" -> [] , "Boolean"
 		| [] , "Bool" -> [] , "Boolean"
 		| ["flash"] , "FlashXml__" -> [] , "Xml"
 		| ["flash"] , "FlashXml__" -> [] , "Xml"
+		| ["flash"] , "Boot" -> [] , ctx.boot
 		| _ -> path
 		| _ -> path
 	) in
 	) in
 	let pid = string ctx (String.concat "." pack) in
 	let pid = string ctx (String.concat "." pack) in
@@ -1043,7 +1045,7 @@ let generate_construct ctx fdata cfields =
 	let args = List.map (fun (name,opt,_) -> name,opt) fdata.tf_args in
 	let args = List.map (fun (name,opt,_) -> name,opt) fdata.tf_args in
 	let f = begin_fun ctx args [fdata.tf_expr] false in
 	let f = begin_fun ctx args [fdata.tf_expr] false in
 	let id = ident ctx "skip_constructor" in
 	let id = ident ctx "skip_constructor" in
-	getvar ctx (VGlobal (type_path ctx (["flash"],"Boot"),true));
+	getvar ctx (VGlobal (type_path ctx ([],ctx.boot),true));
 	getvar ctx (VId id);
 	getvar ctx (VId id);
 	let j = jump ctx J3False in
 	let j = jump ctx J3False in
 	write ctx A3RetVoid;
 	write ctx A3RetVoid;
@@ -1237,7 +1239,7 @@ let generate_class ctx c =
 	let sc = {
 	let sc = {
 		cl3_name = name_id;
 		cl3_name = name_id;
 		cl3_super = (if c.cl_interface then None else Some (type_path ctx (match c.cl_super with None -> [],"Object" | Some (c,_) -> c.cl_path)));
 		cl3_super = (if c.cl_interface then None else Some (type_path ctx (match c.cl_super with None -> [],"Object" | Some (c,_) -> c.cl_path)));
-		cl3_sealed = true;
+		cl3_sealed = c.cl_path <> (["flash"],"Boot");
 		cl3_final = false;
 		cl3_final = false;
 		cl3_interface = c.cl_interface;
 		cl3_interface = c.cl_interface;
 		cl3_rights = None;
 		cl3_rights = None;
@@ -1280,7 +1282,7 @@ let generate_enum ctx e =
 	write ctx A3RetVoid;
 	write ctx A3RetVoid;
 	let construct = f() in
 	let construct = f() in
 	let f = begin_fun ctx [] [] true in
 	let f = begin_fun ctx [] [] true in
-	write ctx (A3GetProp (type_path ctx ~getclass:true (["flash"],"Boot")));
+	write ctx (A3GetProp (type_path ctx ~getclass:true ([],ctx.boot)));
 	write ctx A3This;
 	write ctx A3This;
 	write ctx (A3Call (ident ctx "enum_to_string",1));
 	write ctx (A3Call (ident ctx "enum_to_string",1));
 	write ctx A3Ret;
 	write ctx A3Ret;
@@ -1387,7 +1389,7 @@ let generate_inits ctx types =
 
 
 	(* define flash.Boot.init method *)
 	(* define flash.Boot.init method *)
 	write ctx A3GetScope0;
 	write ctx A3GetScope0;
-	write ctx (A3Get (type_path ctx (["flash"],"Boot")));
+	write ctx (A3Get (type_path ctx ([],ctx.boot)));
 	let finit = begin_fun ctx [] [] true in
 	let finit = begin_fun ctx [] [] true in
 	List.iter (fun t ->
 	List.iter (fun t ->
 		match t with
 		match t with
@@ -1418,6 +1420,7 @@ let generate types hres =
 	let empty_id = lookup "" strings in
 	let empty_id = lookup "" strings in
 	let rpublic = lookup (A3RPublic (Some empty_id)) brights in
 	let rpublic = lookup (A3RPublic (Some empty_id)) brights in
 	let ctx = {
 	let ctx = {
+		boot = "Boot_" ^ Printf.sprintf "%X" (Random.int 0xFFFFFF);
 		strings = strings;
 		strings = strings;
 		ints = new_lookup();
 		ints = new_lookup();
 		floats = new_lookup();
 		floats = new_lookup();
@@ -1461,7 +1464,7 @@ let generate types hres =
 		as3_functions = lookup_array ctx.functions;
 		as3_functions = lookup_array ctx.functions;
 		as3_unknown = "";
 		as3_unknown = "";
 	} in
 	} in
-	[Swf.TActionScript3 (Some (0,""),a)]
+	[Swf.TActionScript3 (Some (0,""),a)], ctx.boot
 
 
 
 
 (* ----------------------------------------------------------------------------------------
 (* ----------------------------------------------------------------------------------------