gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/avm2 r9651: Fix conversion of String.charC


From: Tom Stellard
Subject: [Gnash-commit] /srv/bzr/gnash/avm2 r9651: Fix conversion of String.charCodeAt and String.fromCharCode
Date: Mon, 10 Nov 2008 23:13:19 +0800
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9651
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Mon 2008-11-10 23:13:19 +0800
message:
  Fix conversion of String.charCodeAt and String.fromCharCode
modified:
  testsuite/actionscript.all/haxe-swf9/as_to_hx.pl
=== modified file 'testsuite/actionscript.all/haxe-swf9/as_to_hx.pl'
--- a/testsuite/actionscript.all/haxe-swf9/as_to_hx.pl  2008-11-09 06:19:23 
+0000
+++ b/testsuite/actionscript.all/haxe-swf9/as_to_hx.pl  2008-11-10 15:13:19 
+0000
@@ -202,7 +202,7 @@
                #CHECK 5.3 - Must go after CHECK 5.5
                #Replace calls to str.split(a,b) with 
a==""?[]:str==""||a==null?[str]:str.split(a).slice(0,b)
                #                str                    a               b
-               $_ =~ 
s/(\w+)\.split\((.+),\s*(\w+)\s*\)/$2==""?[]:$1==""||$2==null?[$1]:$1.split($2).slice(0,$3)/g;
+               $_ =~ 
s/(\w+)\.split\((.+),\s*([-\w]+)\s*\)/$2==""?[]:$1==""||$2==null?[$1]:($3<1)?[]:$1.split($2).slice(0,$3)/g;
                
        }
 
@@ -213,18 +213,26 @@
        #Replace undefined with null.
        $_ =~ s/undefined/null/g;
 
+       #CHECK 10 - Must run before CHECK 9
        #Haxe only allows one argument to String.fromCharCode(), so replace
        #String.fromCharCode(1,2) with String.fromCharCode(1) + 
String.fromCharCode(2)
-       if($_ =~ /String.fromCharCode\(.+\)/){
+       if($_ =~ /String.fromCharCode\((.+)\)/){
                
                #TODO: Can this be combined with regex above?
                $_ =~ s/,\s*(\w+)\s*/) + String.fromCharCode($1/g;
        }
        
+       #CHECK 11 - Must run before CHECK 9
        #Convert calls to chr and ord.  I think these have been depreciated 
since SWF v5.
        $_ =~ s/chr\(\s*(\w+)\s*\)/String.fromCharCode($1)/g;
        $_ =~ s/ord\(\s*(\S+)\s*\)/$1.charCodeAt(0)/g;
 
+       #CHECK 9 - Must run after CHECK 10 and after CHECK 11
+       #Replace calls to String.fromCharCode(0) with "" When compiled with 
haxe a trace call
+       #will die if it is passed String.fromCharCode(0)
+       $_ =~ s/String.fromCharCode\(\s*0\s*\)/""/g;
+
+       $_ =~ 
s/\((.+?)\.charCodeAt\(\s*(\S*)\s*\)/($1.charCodeAt($2)==null?0:$1.charCodeAt($2)/g;
 
        #Replace String in "for .. in" loops that iterator over String's 
properties with 
        #Type.getInstanceFields(String).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]