CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/10/06 08:17:49
Modified files: . : ChangeLog server/asobj : gstring.h string.cpp server/vm : ASHandlers.cpp testsuite/swfdec: PASSING Log message: * server/asobj/string.{h,cpp} (init_string_instance): when in SWF6 fetch constructor from the global object, to use any overrided one (swfdec testsuite contains a test for this). * server/vm/ASHandlers.cpp (ActionGetMember): drop special handling for 'length' (it's incorrect and was marked with a FIXME). * testsuite/swfdec/PASSING: string-convert-{6,7} succeed now. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4551&r2=1.4552 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/gstring.h?cvsroot=gnash&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.38&r2=1.39 http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.140&r2=1.141 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.36&r2=1.37 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4551 retrieving revision 1.4552 diff -u -b -r1.4551 -r1.4552 --- ChangeLog 6 Oct 2007 07:08:52 -0000 1.4551 +++ ChangeLog 6 Oct 2007 08:17:46 -0000 1.4552 @@ -1,5 +1,14 @@ 2007-10-06 Sandro Santilli <[EMAIL PROTECTED]> + * server/asobj/string.{h,cpp} (init_string_instance): when in SWF6 fetch + constructor from the global object, to use any overrided one + (swfdec testsuite contains a test for this). + * server/vm/ASHandlers.cpp (ActionGetMember): drop special handling + for 'length' (it's incorrect and was marked with a FIXME). + * testsuite/swfdec/PASSING: string-convert-{6,7} succeed now. + +2007-10-06 Sandro Santilli <[EMAIL PROTECTED]> + * server/asobj/string.cpp (string_index_of): only use second argument if it casts to positive integer. * testsuite/actionscript.all/String.as: more tests. Index: server/asobj/gstring.h =================================================================== RCS file: /sources/gnash/gnash/server/asobj/gstring.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- server/asobj/gstring.h 1 Jul 2007 10:54:32 -0000 1.6 +++ server/asobj/gstring.h 6 Oct 2007 08:17:47 -0000 1.7 @@ -39,7 +39,13 @@ // Initialize the global String class void string_class_init(as_object& global); -/// Return a String instance +/// Return a String instance (possibibly NULL!) +// +/// This function will use the native String constructor in SWF5, but +/// any function registered by user as the _global.String for SWF6 and higher. +/// In the second case, not finding a proper constructor might result in +/// returning the NULL object. +/// boost::intrusive_ptr<as_object> init_string_instance(const char* val); } Index: server/asobj/string.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -b -r1.38 -r1.39 --- server/asobj/string.cpp 6 Oct 2007 07:08:52 -0000 1.38 +++ server/asobj/string.cpp 6 Oct 2007 08:17:48 -0000 1.39 @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: string.cpp,v 1.38 2007/10/06 07:08:52 strk Exp $ */ +/* $Id: string.cpp,v 1.39 2007/10/06 08:17:48 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,6 +33,7 @@ #include "GnashException.h" #include "VM.h" // for registering static GcResources (constructor and prototype) #include "Object.h" // for getObjectInterface +#include "namedStrings.h" #include <boost/algorithm/string/case_conv.hpp> @@ -597,10 +598,54 @@ boost::intrusive_ptr<as_object> init_string_instance(const char* val) { - boost::intrusive_ptr<builtin_function> cl = getStringConstructor(); + // TODO: get the environment passed in !! as_environment env; + + // TODO: get VM from the environment ? + VM& vm = VM::get(); + int swfVersion = vm.getSWFVersion(); + + boost::intrusive_ptr<as_function> cl; + + if ( swfVersion < 6 ) + { + cl = getStringConstructor(); + } + else + { + as_object* global = vm.getGlobal(); + as_value clval; + if ( ! global->get_member(NSV::CLASS_STRING, &clval) ) + { + log_debug("UNTESTED: String instantiation requested but _global doesn't contain a 'String' symbol. Returning the NULL object."); + return cl; + //cl = getStringConstructor(); + } + else if ( ! clval.is_function() ) + { + log_debug("UNTESTED: String instantiation requested but _global.String is not a function (%s). Returning the NULL object.", + clval.to_debug_string().c_str()); + return cl; + //cl = getStringConstructor(); + } + else + { + cl = clval.to_as_function(); + assert(cl); + } + } + +#ifndef NDEBUG + size_t prevStackSize = env.stack_size(); +#endif env.push(val); - return cl->constructInstance(env, 1, 0); + boost::intrusive_ptr<as_object> ret = cl->constructInstance(env, 1, 0); + env.drop(1); +#ifndef NDEBUG + assert( prevStackSize == env.stack_size()); +#endif + + return ret; } } // namespace gnash Index: server/vm/ASHandlers.cpp =================================================================== RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v retrieving revision 1.140 retrieving revision 1.141 diff -u -b -r1.140 -r1.141 --- server/vm/ASHandlers.cpp 5 Oct 2007 00:01:38 -0000 1.140 +++ server/vm/ASHandlers.cpp 6 Oct 2007 08:17:48 -0000 1.141 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: ASHandlers.cpp,v 1.140 2007/10/05 00:01:38 strk Exp $ */ +/* $Id: ASHandlers.cpp,v 1.141 2007/10/06 08:17:48 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -2931,12 +2931,6 @@ target.to_debug_string().c_str(), (void*)obj.get()); ); - // Special case: String has a member "length" - // @@ FIXME: we shouldn't have all this "special" cases --strk; - if (target.is_string() && member_name.to_string_versioned(version) == "length") { - int len = target.to_string_versioned(version).size(); - env.top(1).set_int(len); - } else { if ( ! thread.getObjectMember(*obj, member_name.to_string(&env), env.top(1)) ) { env.top(1).set_undefined(); @@ -2948,7 +2942,7 @@ member_name.to_debug_string().c_str(), env.top(1).to_debug_string().c_str()); ); - } + env.drop(1); } Index: testsuite/swfdec/PASSING =================================================================== RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v retrieving revision 1.36 retrieving revision 1.37 diff -u -b -r1.36 -r1.37 --- testsuite/swfdec/PASSING 5 Oct 2007 00:01:39 -0000 1.36 +++ testsuite/swfdec/PASSING 6 Oct 2007 08:17:48 -0000 1.37 @@ -82,6 +82,8 @@ set-overwrite-global-6.swf set-overwrite-global-7.swf string-convert-5.swf +string-convert-6.swf +string-convert-7.swf with-delete-5.swf with-delete-6.swf with-delete-7.swf _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit