CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/10/05 22:17:54
Modified files: . : ChangeLog server/asobj : AsBroadcaster.cpp AsBroadcaster.h testsuite/actionscript.all: AsBroadcaster.as Log message: * server/asobj/AsBroadcaster.{cpp,h} (initialize): query addListener and removeListener methods from the global AsBroadcaster, using any overridden member (shown to be needed by swfdec testsuite). * testsuite/actionscript.all/AsBroadcaster.as: the new tests are fixed, added a TODO for adding more. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4546&r2=1.4547 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/AsBroadcaster.cpp?cvsroot=gnash&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/AsBroadcaster.h?cvsroot=gnash&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/AsBroadcaster.as?cvsroot=gnash&r1=1.6&r2=1.7 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4546 retrieving revision 1.4547 diff -u -b -r1.4546 -r1.4547 --- ChangeLog 5 Oct 2007 20:59:38 -0000 1.4546 +++ ChangeLog 5 Oct 2007 22:17:53 -0000 1.4547 @@ -1,3 +1,12 @@ +2007-10-05 Sandro Santilli <[EMAIL PROTECTED]> + + * server/asobj/AsBroadcaster.{cpp,h} (initialize): query + addListener and removeListener methods from the global + AsBroadcaster, using any overridden member (shown + to be needed by swfdec testsuite). + * testsuite/actionscript.all/AsBroadcaster.as: the new tests + are fixed, added a TODO for adding more. + 2007-10-05 Benjamin Wolsey <[EMAIL PROTECTED]> * gui/gui.cpp: Handle key releases again. Index: server/asobj/AsBroadcaster.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/AsBroadcaster.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- server/asobj/AsBroadcaster.cpp 23 Sep 2007 08:48:18 -0000 1.6 +++ server/asobj/AsBroadcaster.cpp 5 Oct 2007 22:17:54 -0000 1.7 @@ -105,23 +105,40 @@ void AsBroadcaster::initialize(as_object& o) { + as_object* asb = getAsBroadcaster(); + log_debug("Initializing object %p as an AsBroadcaster", (void*)&o); - // TODO: reserch on protection flags for these methods - o.set_member(NSV::PROP_ADD_LISTENER, new builtin_function(AsBroadcaster::addListener_method)); - o.set_member(NSV::PROP_REMOVE_LISTENER, new builtin_function(AsBroadcaster::removeListener_method)); + + as_value tmp; + + if ( asb->get_member(NSV::PROP_ADD_LISTENER, &tmp) ) + { + o.set_member(NSV::PROP_ADD_LISTENER, tmp); + } + + if ( asb->get_member(NSV::PROP_REMOVE_LISTENER, &tmp) ) + { + o.set_member(NSV::PROP_REMOVE_LISTENER, tmp); + } + o.set_member(NSV::PROP_BROADCAST_MESSAGE, new builtin_function(AsBroadcaster::broadcastMessage_method)); o.set_member(NSV::PROP_uLISTENERS, new as_array_object()); #ifndef NDEBUG - as_value tmp; assert(o.get_member(NSV::PROP_uLISTENERS, &tmp)); assert(tmp.is_object()); + assert(o.get_member(NSV::PROP_BROADCAST_MESSAGE, &tmp)); + assert(tmp.is_function()); + +#if 0 // we can't rely on the following, due to possible override + // of the AsBroadcaster properties used to intialize this + // object assert(o.get_member(NSV::PROP_ADD_LISTENER, &tmp)); assert(tmp.is_function()); assert(o.get_member(NSV::PROP_REMOVE_LISTENER, &tmp)); assert(tmp.is_function()); - assert(o.get_member(NSV::PROP_BROADCAST_MESSAGE, &tmp)); - assert(tmp.is_function()); +#endif // 0 + #endif } @@ -375,11 +392,9 @@ return as_value(obj); // will keep alive } -void -AsBroadcaster_init(as_object& global) +as_object* +AsBroadcaster::getAsBroadcaster() { - // _global.AsBroadcaster is NOT a class, but a simple object - VM& vm = VM::get(); int swfVersion = vm.getSWFVersion(); @@ -391,9 +406,20 @@ if ( swfVersion >= 6 ) { obj->init_member("initialize", new builtin_function(AsBroadcaster::initialize_method)); + obj->init_member("addListener", new builtin_function(AsBroadcaster::addListener_method)); + obj->init_member("removeListener", new builtin_function(AsBroadcaster::removeListener_method)); + obj->init_member("broadcastMessage", new builtin_function(AsBroadcaster::broadcastMessage_method)); } } - global.init_member("AsBroadcaster", obj.get()); + + return obj.get(); +} + +void +AsBroadcaster_init(as_object& global) +{ + // _global.AsBroadcaster is NOT a class, but a simple object + global.init_member("AsBroadcaster", AsBroadcaster::getAsBroadcaster()); } } // end of gnash namespace Index: server/asobj/AsBroadcaster.h =================================================================== RCS file: /sources/gnash/gnash/server/asobj/AsBroadcaster.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- server/asobj/AsBroadcaster.h 11 Sep 2007 17:01:23 -0000 1.1 +++ server/asobj/AsBroadcaster.h 5 Oct 2007 22:17:54 -0000 1.2 @@ -57,6 +57,11 @@ /// AsBroadcaster.initialize() AS method static as_value initialize_method(const fn_call& fn); + /// Return the global AsBroadcaster + /// (the native one, immune to any override) + /// + static as_object* getAsBroadcaster(); + private: static as_value addListener_method(const fn_call& fn); Index: testsuite/actionscript.all/AsBroadcaster.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/actionscript.all/AsBroadcaster.as,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- testsuite/actionscript.all/AsBroadcaster.as 5 Oct 2007 20:50:44 -0000 1.6 +++ testsuite/actionscript.all/AsBroadcaster.as 5 Oct 2007 22:17:54 -0000 1.7 @@ -19,7 +19,7 @@ // compile this test case with Ming makeswf, and then // execute it like this gnash -1 -r 0 -v out.swf -rcsid="$Id: AsBroadcaster.as,v 1.6 2007/10/05 20:50:44 strk Exp $"; +rcsid="$Id: AsBroadcaster.as,v 1.7 2007/10/05 22:17:54 strk Exp $"; #include "check.as" @@ -45,12 +45,12 @@ // and a lookup should be issued by 'initalize' so that overridden // functions are attached to the initialized object rather then // the original one (from swfdec/test/trace/asbroadcaster-override.as) -xcheck_equals(typeof(AsBroadcaster.addListener), 'function'); -xcheck(AsBroadcaster.hasOwnProperty('addListener')); -xcheck_equals(typeof(AsBroadcaster.removeListener), 'function'); -xcheck(AsBroadcaster.hasOwnProperty('removeListener')); -xcheck_equals(typeof(AsBroadcaster.broadcastMessage), 'function'); -xcheck(AsBroadcaster.hasOwnProperty('broadcastMessage')); +check_equals(typeof(AsBroadcaster.addListener), 'function'); +check(AsBroadcaster.hasOwnProperty('addListener')); +check_equals(typeof(AsBroadcaster.removeListener), 'function'); +check(AsBroadcaster.hasOwnProperty('removeListener')); +check_equals(typeof(AsBroadcaster.broadcastMessage), 'function'); +check(AsBroadcaster.hasOwnProperty('broadcastMessage')); bc = new AsBroadcaster; check_equals(typeof(bc), 'object'); @@ -242,7 +242,7 @@ check_equals(typeof(ret), 'undefined'); //-------------------------------- -// broadcaseMessage with args +// broadcastMessage with args //-------------------------------- _root.total = 0; @@ -273,6 +273,14 @@ bcast.broadcastMessage('setSum', 'one', 'two', 'three'); check_equals(_root.total, '0onetwothree'); +//----------------------------------------------------------------------------------- +// TODO: test override of AsBroadcaster.{addListener,removeListener,broadcastMessage} +// swfdec contains tests for this, which should now be pretty succeeding except for +// not-directly related checks which trigger failure due to all-or-nothing nature of +// the swfdec testsuite. +// See swfdec/test/trace/asbroadcaster-override.as for more info +//----------------------------------------------------------------------------------- + #endif // OUTPUT_VERSION >= 6 totals(); _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit