CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/11/30 19:01:03
Modified files: . : ChangeLog server : as_value.cpp testsuite/actionscript.all: Number.as Log message: add support for parsing hex strings in swf6+ CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5032&r2=1.5033 http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.99&r2=1.100 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Number.as?cvsroot=gnash&r1=1.34&r2=1.35 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5032 retrieving revision 1.5033 diff -u -b -r1.5032 -r1.5033 --- ChangeLog 30 Nov 2007 18:36:06 -0000 1.5032 +++ ChangeLog 30 Nov 2007 19:01:02 -0000 1.5033 @@ -1,5 +1,11 @@ 2007-11-30 Sandro Santilli <[EMAIL PROTECTED]> + * server/as_value.cpp (to_number): add support for parsing hex + strings in swf6+ + * testsuite/actionscript.all/Number.as: success in hex parsing tests. + +2007-11-30 Sandro Santilli <[EMAIL PROTECTED]> + * testsuite/actionscript.all/Number.as: add test for '0xRRGGBB' automatic conversion to number in SWF6+ (gnash fails). * testsuite/misc-mtasc.all/: Makefile.am, TextFieldTest.as: Index: server/as_value.cpp =================================================================== RCS file: /sources/gnash/gnash/server/as_value.cpp,v retrieving revision 1.99 retrieving revision 1.100 diff -u -b -r1.99 -r1.100 --- server/as_value.cpp 26 Nov 2007 20:43:47 -0000 1.99 +++ server/as_value.cpp 30 Nov 2007 19:01:03 -0000 1.100 @@ -54,6 +54,33 @@ // Define the macro below to make to_primitive verbose //#define GNASH_DEBUG_CONVERSION_TO_PRIMITIVE 1 +namespace { + +uint8_t parseHex(char c) +{ + switch (c) + { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + case 'a': case 'A': return 10; + case 'b': case 'B': return 11; + case 'c': case 'C': return 12; + case 'd': case 'D': return 13; + case 'e': case 'E': return 14; + case 'f': case 'F': return 15; + } +} + +} + namespace gnash { // @@ -345,6 +372,19 @@ { case STRING: { + std::string s = getStr(); + + if ( swfversion > 5 ) + { + if ( s.length() == 8 && s[0] == '0' && ( s[1] == 'x' || s[1] == 'X' ) ) + { + uint8_t r = (parseHex(s[2])<<4) + parseHex(s[3]); + uint8_t g = (parseHex(s[4])<<4) + parseHex(s[5]); + uint8_t b = (parseHex(s[6])<<4) + parseHex(s[7]); + return (double)((r<<16)|(g<<8)|b); + } + } + // @@ Moock says the rule here is: if the // string is a valid float literal, then it // gets converted; otherwise it is set to NaN. Index: testsuite/actionscript.all/Number.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Number.as,v retrieving revision 1.34 retrieving revision 1.35 diff -u -b -r1.34 -r1.35 --- testsuite/actionscript.all/Number.as 30 Nov 2007 18:36:06 -0000 1.34 +++ testsuite/actionscript.all/Number.as 30 Nov 2007 19:01:03 -0000 1.35 @@ -27,7 +27,7 @@ // TODO: test with SWF target != 6 (the only one tested so far) // -rcsid="$Id: Number.as,v 1.34 2007/11/30 18:36:06 strk Exp $"; +rcsid="$Id: Number.as,v 1.35 2007/11/30 19:01:03 strk Exp $"; #include "check.as" @@ -258,8 +258,10 @@ // string:0xFF0000 number:0xFF0000 equality #if OUTPUT_VERSION > 5 - xcheck_equals("0xFF0000", 0xFF0000); - xcheck_equals("0XFF0000", 0xFF0000); + check_equals("0xFF0000", 0xFF0000); + check_equals("0XFF0000", 0xFF0000); + check_equals("0Xff0000", 0xFF0000); + check("0Xff000000" != 0xFF000000); #else check("0xFF0000" != 0xFF0000); check("0XFF0000" != 0xFF0000); @@ -453,8 +455,8 @@ check_totals(146); #else #if OUTPUT_VERSION < 7 - check_totals(156); + check_totals(158); #else - check_totals(154); + check_totals(156); #endif #endif _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit