CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 08/01/09 14:53:18
Modified files: . : ChangeLog server : movie_root.cpp movie_root.h server/vm : ASHandlers.cpp testsuite/misc-mtasc.all: level5.as level87.as level99.as testsuite/swfdec: PASSING Log message: Implement a movie_root service to request load of movies. Properly postpones load and target evaluation to next advance and CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5353&r2=1.5354 http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.144&r2=1.145 http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.100&r2=1.101 http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.174&r2=1.175 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/level5.as?cvsroot=gnash&r1=1.11&r2=1.12 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/level87.as?cvsroot=gnash&r1=1.3&r2=1.4 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/level99.as?cvsroot=gnash&r1=1.14&r2=1.15 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.80&r2=1.81 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5353 retrieving revision 1.5354 diff -u -b -r1.5353 -r1.5354 --- ChangeLog 9 Jan 2008 11:41:01 -0000 1.5353 +++ ChangeLog 9 Jan 2008 14:53:17 -0000 1.5354 @@ -1,5 +1,18 @@ 2008-01-09 Sandro Santilli <[EMAIL PROTECTED]> + * server/movie_root.{cpp,h}: add a loadMovie method + to schedule loads for next advance, using late + evaluation of target path (tested, but not automated). + * server/vm/ASHandlers.cpp (CommonGetUrl): delegate + movie loads to movie_root. + * testsuite/misc-mtasc.all/: level5.as, level87.as, + level99.as: frame count at loaded movie execution + succeed. + * testsuite/swfdec/PASSING: loadvariables-5.swf + succeeds (no idea why..) + +2008-01-09 Sandro Santilli <[EMAIL PROTECTED]> + * server/: as_value.cpp, movie_root.{cpp,h}: Add a movie_root::findCharacterByTarget() and use it for soft refs. Index: server/movie_root.cpp =================================================================== RCS file: /sources/gnash/gnash/server/movie_root.cpp,v retrieving revision 1.144 retrieving revision 1.145 diff -u -b -r1.144 -r1.145 --- server/movie_root.cpp 9 Jan 2008 11:41:01 -0000 1.144 +++ server/movie_root.cpp 9 Jan 2008 14:53:17 -0000 1.145 @@ -219,7 +219,6 @@ it->second = movie; } - movie->set_invalidated(); /// Notify placement @@ -981,15 +980,25 @@ try { - // Execute expired timers - // NOTE: can throw ActionLimitException - executeTimers(); - // Advance all non-unloaded characters in the LiveChars list // in reverse order (last added, first advanced) // NOTE: can throw ActionLimitException advanceLiveChars(); + // Process loadMovie requests + // + // NOTE: should be done before executing timers, + // see swfdec's test/trace/loadmovie-case-{5,6}.swf + // NOTE: processing loadMovie requests after advanceLiveChars + // is known to fix more tests in misc-mtasc.all/levels.swf + // to be checked if it keeps the swfdec testsuite safe + processLoadMovieRequests(); + + // Execute expired timers + // NOTE: can throw ActionLimitException + executeTimers(); + + cleanupUnloadedListeners(); // Process queued actions @@ -1345,7 +1354,6 @@ { _processingActionLevel = processActionQueue(_processingActionLevel); } - } void @@ -1419,6 +1427,7 @@ void movie_root::executeTimers() { + log_debug("Checking %d timers for expiration", _intervalTimers.size()); for (TimerMap::iterator it=_intervalTimers.begin(), itEnd=_intervalTimers.end(); it != itEnd; ) { @@ -1693,5 +1702,62 @@ return o->to_character(); } +void +movie_root::loadMovie(const URL& url, const std::string& target, movie_root::LoadMethod method) +{ + log_debug("movie_root::loadMovie(%s, %s)", url.str().c_str(), target.c_str()); + _loadMovieRequests.push_front(LoadMovieRequest(url, target, method)); +} + +void +movie_root::processLoadMovieRequest(const LoadMovieRequest& r) +{ + const std::string& target = r.getTarget(); + const URL& url = r.getURL(); + LoadMethod method = r.getMethod(); + + if ( target.compare(0, 6, "_level") == 0 && target.find_first_not_of("0123456789", 7) == string::npos ) + { + unsigned int levelno = atoi(target.c_str()+6); + log_debug(_("processLoadMovieRequest: Testing _level loading (level %u)"), levelno); + loadLevel(levelno, url); + return; + } + + character* ch = findCharacterByTarget(target); + if ( ! ch ) + { + log_debug("Target %s of a loadMovie request doesn't exist at processing time", target.c_str()); + return; + } + + sprite_instance* sp = ch->to_movie(); + if ( ! sp ) + { + log_unimpl("loadMovie against a %s character", typeName(*ch).c_str()); + return; + } + + if ( method ) + { + log_unimpl("loadMovie with method %s", method == 1 ? "GET" : method == 2 ? "POST" : "UNKWNOWN"); + } + + sp->loadMovie(url); +} + +void +movie_root::processLoadMovieRequests() +{ + log_debug("Processing %d loadMovie requests", _loadMovieRequests.size()); + for (LoadMovieRequests::iterator it=_loadMovieRequests.begin(); + it != _loadMovieRequests.end(); ) + { + const LoadMovieRequest& lr=*it; + processLoadMovieRequest(lr); + it = _loadMovieRequests.erase(it); + } +} + } // namespace gnash Index: server/movie_root.h =================================================================== RCS file: /sources/gnash/gnash/server/movie_root.h,v retrieving revision 1.100 retrieving revision 1.101 diff -u -b -r1.100 -r1.101 --- server/movie_root.h 9 Jan 2008 11:41:01 -0000 1.100 +++ server/movie_root.h 9 Jan 2008 14:53:17 -0000 1.101 @@ -15,7 +15,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: movie_root.h,v 1.100 2008/01/09 11:41:01 strk Exp $ */ +/* $Id: movie_root.h,v 1.101 2008/01/09 14:53:17 strk Exp $ */ /// \page events_handling Handling of user events /// @@ -78,6 +78,7 @@ #include "timers.h" // for composition #include "asobj/Key.h" #include "smart_ptr.h" // for memory management +#include "URL.h" // for loadMovie #include <vector> #include <list> @@ -607,8 +608,48 @@ character* findCharacterByTarget(const std::string& tgtstr) const; + /// URL access methods + enum LoadMethod { + NONE=0, + GET=1, + POST=2 + }; + + /// Queue a request for loading a movie + void loadMovie(const URL& url, const std::string& target, LoadMethod method=NONE); + private: + /// A load movie request + class LoadMovieRequest { + public: + LoadMovieRequest(const URL& u, const std::string& t, LoadMethod m) + : + _target(t), + _url(u), + _method(m) + {} + + const std::string& getTarget() const { return _target; } + const URL& getURL() const { return _url; } + LoadMethod getMethod() const { return _method; } + + private: + std::string _target; + URL _url; + LoadMethod _method; + }; + + /// Load movie requests + typedef std::list<LoadMovieRequest> LoadMovieRequests; + LoadMovieRequests _loadMovieRequests; + + /// Process all load movie requests + void processLoadMovieRequests(); + + /// Process a single load movie request + void processLoadMovieRequest(const LoadMovieRequest& r); + /// Listeners container typedef std::list< boost::intrusive_ptr<character> > CharacterList; Index: server/vm/ASHandlers.cpp =================================================================== RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v retrieving revision 1.174 retrieving revision 1.175 diff -u -b -r1.174 -r1.175 --- server/vm/ASHandlers.cpp 26 Dec 2007 18:03:47 -0000 1.174 +++ server/vm/ASHandlers.cpp 9 Jan 2008 14:53:18 -0000 1.175 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: ASHandlers.cpp,v 1.174 2007/12/26 18:03:47 strk Exp $ */ +/* $Id: ASHandlers.cpp,v 1.175 2008/01/09 14:53:18 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -2184,6 +2184,8 @@ if ( loadTargetFlag ) { + // TODO: always pass directly to movie_root::loadMovie ? + log_msg(_("getURL2 target load")); if ( sendVarsMethod ) @@ -2195,11 +2197,13 @@ if ( ! target_ch ) { - if ( target_string.compare(0, 6, "_level") == 0 && target_string.find_first_not_of("0123456789", 7) == string::npos ) + std::string s = PROPNAME(target_string); + if ( s.compare(0, 6, "_level") == 0 && s.find_first_not_of("0123456789", 7) == string::npos ) { unsigned int levelno = atoi(target_string.c_str()+6); log_debug(_("Testing _level loading (level %u)"), levelno); - VM::get().getRoot().loadLevel(levelno, url); + //VM::get().getRoot().loadLevel(levelno, url); + VM::get().getRoot().loadMovie(url, s); // TODO: add third argument for the method return; } @@ -2215,7 +2219,9 @@ return; } - target_movie->loadMovie(url); + //target_movie->loadMovie(url); + std::string s = boost::to_lower_copy(target.to_string()); + VM::get().getRoot().loadMovie(url, s); // TODO: add third argument for the method return; } @@ -2227,11 +2233,13 @@ sendVarsMethod); } - if ( target_string.compare(0, 6, "_level") == 0 && target_string.find_first_not_of("0123456789", 7) == string::npos ) + std::string s = PROPNAME(target_string); + if ( s.compare(0, 6, "_level") == 0 && s.find_first_not_of("0123456789", 7) == string::npos ) { unsigned int levelno = atoi(target_string.c_str()+6); log_debug(_("Testing _level loading (level %u)"), levelno); - VM::get().getRoot().loadLevel(levelno, url); + //VM::get().getRoot().loadLevel(levelno, url); + VM::get().getRoot().loadMovie(url, s); // TODO: add third argument for the method return; } Index: testsuite/misc-mtasc.all/level5.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/level5.as,v retrieving revision 1.11 retrieving revision 1.12 diff -u -b -r1.11 -r1.12 --- testsuite/misc-mtasc.all/level5.as 8 Jan 2008 22:48:40 -0000 1.11 +++ testsuite/misc-mtasc.all/level5.as 9 Jan 2008 14:53:18 -0000 1.12 @@ -28,7 +28,7 @@ { check_equals(mc._currentframe, 1); - xcheck_equals(_level0.frameno, 1); + check_equals(_level0.frameno, 1); // Check our depth check_equals(mc.getDepth(), -16379); Index: testsuite/misc-mtasc.all/level87.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/level87.as,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- testsuite/misc-mtasc.all/level87.as 8 Jan 2008 22:48:40 -0000 1.3 +++ testsuite/misc-mtasc.all/level87.as 9 Jan 2008 14:53:18 -0000 1.4 @@ -61,14 +61,14 @@ _level0.level87loaded = true; - xcheck_equals(_level0.frameno, 2); + check_equals(_level0.frameno, 2); // This one fails because gnash is executing code // in level99 before code in the first load of level87, // probably because it is *loading* level99 before level87, // which is in the order loads are requested rather then // reverse of it as it's common... - xcheck_equals(_level5._currentframe, 1); + check_equals(_level5._currentframe, 1); _level87.loadMovie("level87.swf"); } Index: testsuite/misc-mtasc.all/level99.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/level99.as,v retrieving revision 1.14 retrieving revision 1.15 diff -u -b -r1.14 -r1.15 --- testsuite/misc-mtasc.all/level99.as 8 Jan 2008 22:48:40 -0000 1.14 +++ testsuite/misc-mtasc.all/level99.as 9 Jan 2008 14:53:18 -0000 1.15 @@ -45,7 +45,7 @@ check_equals(mc._currentframe, 1); - xcheck_equals(_level0.frameno, 2); + check_equals(_level0.frameno, 2); // Check our depth check_equals(mc.getDepth(), -16285); Index: testsuite/swfdec/PASSING =================================================================== RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v retrieving revision 1.80 retrieving revision 1.81 diff -u -b -r1.80 -r1.81 --- testsuite/swfdec/PASSING 8 Jan 2008 12:09:09 -0000 1.80 +++ testsuite/swfdec/PASSING 9 Jan 2008 14:53:18 -0000 1.81 @@ -272,6 +272,7 @@ loadmovie-case-5.swf:a7d492cb23eef08a115d7a667c9b5089 loadmovie-case-6.swf:e5bc78b62bb2688bd99a57bfec7e4eb1 loadmovie-case-7.swf:0ce485bdd81c872df4b7327c1d048936 +loadvariables-5.swf:a24997be9ca59d8da2216f9527d0279a loadvars-5.swf:378a93e3fc7821a72f61332dcfa6cbf7 local.swf:12135ef5103f1b0dcc428308511b9c07 localToGlobal-propflags-5.swf:1c41fae7e9e502de76847c85e938d1a0 _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit