Browse Source

rewrite charCodeAt to charCodeAtHX on as3 target

Simon Krajewski 13 years ago
parent
commit
3c5678435c
2 changed files with 8 additions and 3 deletions
  1. 4 3
      genas3.ml
  2. 4 0
      std/flash/Boot.hx

+ 4 - 3
genas3.ml

@@ -292,8 +292,8 @@ let generate_resources infos =
 		let dir = (infos.com.file :: ["__res"]) in
 		create_dir [] dir;
 		let add_resource name data =
-			let ch = open_out_bin (String.concat "/" (dir @ [name])) in
-			output_string ch data;
+			let ch = open_out_bin (String.concat "/" (dir @ [name])) in
+			output_string ch data;
 			close_out ch
 		in
 		Hashtbl.iter (fun name data -> add_resource name data) infos.com.resources;
@@ -507,9 +507,10 @@ and gen_field_access ctx t s =
 		| [], "Date", "now"
 		| [], "Date", "fromTime"
 		| [], "Date", "fromString"
-		| [], "String", "charCodeAt"
 		->
 			print ctx "[\"%s\"]" s
+		| [], "String", "charCodeAt" ->
+			spr ctx "[\"charCodeAtHX\"]"
 		| [], "Date", "toString" ->
 			print ctx "[\"toStringHX\"]"
 		| [], "String", "cca" ->

+ 4 - 0
std/flash/Boot.hx

@@ -238,7 +238,11 @@ class Boot extends flash.display.MovieClip {
 		aproto.setPropertyIsEnumerable("insert", false);
 		aproto.setPropertyIsEnumerable("remove", false);
 		aproto.setPropertyIsEnumerable("iterator", false);
+		#if as3
+		String.prototype.charCodeAtHX = function(i) : Null<Int> {
+		#else
 		String.prototype.charCodeAt = function(i) : Null<Int> {
+		#end
 			var s : String = __this__;
 			var x : Float = s.cca(i);
 			if( __global__["isNaN"](x) )