Преглед изворни кода

don't use b64 encoding for text ressources

Nicolas Cannasse пре 15 година
родитељ
комит
d46deb4db5
4 измењених фајлова са 18 додато и 4 уклоњено
  1. 1 0
      doc/CHANGES.txt
  2. 10 2
      genswf8.ml
  3. 4 1
      std/flash/Boot.hx
  4. 3 1
      std/haxe/Resource.hx

+ 1 - 0
doc/CHANGES.txt

@@ -11,6 +11,7 @@
 	php: fixed issues with classes that implement Dynamic
 	all : ignore #! line at beginning of the hx file
 	haxelib : added tags, added documentation
+	flash8 : don't use b64 encoding for text ressources
 
 2009-07-26: 2.04
 	flash9 : fixed get_full_path error with -D fdb

+ 10 - 2
genswf8.ml

@@ -934,8 +934,16 @@ and gen_call ctx e el =
 		let count = ref 0 in
 		Hashtbl.iter (fun name data ->
 			incr count;
-			push ctx [VStr ("name",false);VStr (name,true);VStr ("data",false)];
-			gen_big_string ctx (Codegen.bytes_serialize data);
+			push ctx [VStr ("name",false);VStr (name,true)];
+			(* if the data contains \0 or is not UTF8 valid, encode into bytes *)
+			(try 
+				(try ignore(String.index data '\000'); raise Exit; with Not_found -> ());
+				UTF8.validate data;
+				push ctx [VStr ("str",false)];
+				gen_big_string ctx data;
+			with _ ->
+				push ctx [VStr ("data",false)];
+				gen_big_string ctx (Codegen.bytes_serialize data));
 			push ctx [VInt 2];
 			write ctx AObject;
 			ctx.stack_size <- ctx.stack_size - 4;

+ 4 - 1
std/flash/Boot.hx

@@ -159,7 +159,10 @@ class Boot {
 		var root = flash.Lib.current;
 		var tf : flash.TextField = root.__trace_txt;
 		if( tf == null ) {
-			root.createTextField("__trace_txt",1048500,0,0,Stage.width,Stage.height+30);
+			var w = Stage.width, h = Stage.height;
+			if( w == 0 ) w = 800;
+			if( h == 0 ) h = 600;
+			root.createTextField("__trace_txt",1048500,0,0,w,h+30);
 			tf = root.__trace_txt;
 			var format = tf.getTextFormat();
 			format.font = "_sans";

+ 3 - 1
std/haxe/Resource.hx

@@ -65,7 +65,7 @@ class Resource {
 		return haxe.io.Bytes.ofData(array);
 	}
 #else
-	static var content : Array<{ name : String, data : String }>;
+	static var content : Array<{ name : String, data : String, str : String }>;
 
 	public static function listNames() : Array<String> {
 		var names = new Array();
@@ -80,6 +80,7 @@ class Resource {
 				#if neko
 				return new String(x.data);
 				#else
+				if( x.str != null ) return x.str;
 				var b : haxe.io.Bytes = haxe.Unserializer.run(x.data);
 				return b.toString();
 				#end
@@ -93,6 +94,7 @@ class Resource {
 				#if neko
 				return haxe.io.Bytes.ofData(cast x.data);
 				#else
+				if( x.str != null ) return haxe.io.Bytes.ofString(x.str);
 				return haxe.Unserializer.run(x.data);
 				#end
 			}