CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/03/27 14:52:06
Modified files:
. : ChangeLog
server/vm : Makefile.am
server : movie_root.cpp movie_root.h
Added files:
server/vm : ExecutableCode.h
Log message:
* server/vm/: Makefile.am, ExecutableCode.h:
Add definition of a generic Executable Code
for use as element of the global Action Queue.
* server/movie_root.{cpp,h}: add support for
a global Action Queue.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2690&r2=1.2691
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/Makefile.am?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ExecutableCode.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.40&r2=1.41
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2690
retrieving revision 1.2691
diff -u -b -r1.2690 -r1.2691
--- ChangeLog 27 Mar 2007 10:04:45 -0000 1.2690
+++ ChangeLog 27 Mar 2007 14:52:04 -0000 1.2691
@@ -1,3 +1,11 @@
+2007-03-27 Sandro Santilli <[EMAIL PROTECTED]>
+
+ * server/vm/: Makefile.am, ExecutableCode.h:
+ Add definition of a generic Executable Code
+ for use as element of the global Action Queue.
+ * server/movie_root.{cpp,h}: add support for
+ a global Action Queue.
+
2007-03-27 Bastiaan Jacques <[EMAIL PROTECTED]>
* server/as_object.h: Print the passed pointer type
Index: server/vm/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/vm/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/vm/Makefile.am 11 Feb 2007 06:21:29 -0000 1.7
+++ server/vm/Makefile.am 27 Mar 2007 14:52:05 -0000 1.8
@@ -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: Makefile.am,v 1.7 2007/02/11 06:21:29 rsavoye Exp $
+# $Id: Makefile.am,v 1.8 2007/03/27 14:52:05 strk Exp $
AUTOMAKE_OPTIONS =
@@ -49,6 +49,7 @@
noinst_HEADERS = \
ASHandlers.h \
ActionExec.h \
+ ExecutableCode.h \
VM.h \
action.h \
fn_call.h \
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/movie_root.cpp 28 Feb 2007 17:25:26 -0000 1.44
+++ server/movie_root.cpp 27 Mar 2007 14:52:05 -0000 1.45
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -31,11 +31,13 @@
#include "render.h"
#include "VM.h"
#include "tu_random.h"
+#include "ExecutableCode.h"
#include <iostream>
#include <string>
#include <typeinfo>
#include <cassert>
+#include <boost/ptr_container/ptr_list.hpp>
using namespace std;
@@ -477,6 +479,8 @@
_movie->advance(delta_time);
+ processActionQueue();
+
#ifdef GNASH_DEBUG
size_t curframe = _movie->get_current_frame();
@@ -648,5 +652,51 @@
_movie->add_invalidated_bounds(ranges, force);
}
+void
+movie_root::processActionQueue()
+{
+
+#ifdef GNASH_DEBUG
+ static unsigned calls=0;
+ ++calls;
+ bool actionsToProcess = !_actionQueue.empty();
+ if ( actionsToProcess ) log_msg(" Processing action queue (call %u)",
calls);
+#endif
+
+ // _actionQueue may be changed due to actions (appended-to)
+ // this loop might be optimized by using an iterator
+ // and a final call to .clear()
+ while ( ! _actionQueue.empty() )
+ {
+ ExecutableCode& code = _actionQueue.front();
+ code.execute();
+ _actionQueue.pop_front();
+ }
+
+ assert(_actionQueue.empty());
+
+#ifdef GNASH_DEBUG
+ if ( actionsToProcess ) log_msg(" Done processing action queue (call
%u)", calls);
+#endif
+}
+
+void
+movie_root::pushAction(const action_buffer& buf,
boost::intrusive_ptr<sprite_instance> target)
+{
+#ifdef GNASH_DEBUG
+ log_msg("Pushed action buffer for target %s",
target->getTargetPath().c_str());
+#endif
+ _actionQueue.push_back(new GlobalCode(buf, target));
+}
+
+void
+movie_root::pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<sprite_instance> target)
+{
+#ifdef GNASH_DEBUG
+ log_msg("Pushed function (event hanlder?) with target %s",
target->getTargetPath().c_str());
+#endif
+ _actionQueue.push_back(new FunctionCode(func, target));
+}
+
} // namespace gnash
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/movie_root.h 28 Feb 2007 17:25:26 -0000 1.40
+++ server/movie_root.h 27 Mar 2007 14:52:05 -0000 1.41
@@ -14,7 +14,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.40 2007/02/28 17:25:26 udog Exp $ */
+/* $Id: movie_root.h,v 1.41 2007/03/27 14:52:05 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -80,9 +80,12 @@
#include <vector>
#include <set>
+#include <boost/ptr_container/ptr_list.hpp>
// Forward declarations
-// none needed
+namespace gnash {
+ class ExecutableCode; // for ActionQueue
+}
namespace gnash
{
@@ -380,8 +383,21 @@
_movie->clear_invalidated();
}
+ /// Push an executable code to the ActionQueue
+ void pushAction(const action_buffer& buf,
boost::intrusive_ptr<sprite_instance> target);
+
+ /// Push a function code to the ActionQueue
+ void pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<sprite_instance> target);
+
private:
+ typedef boost::ptr_list<ExecutableCode> ActionQueue;
+
+ ActionQueue _actionQueue;
+
+ /// Process all actions in the queue
+ void processActionQueue();
+
// TODO: use Range2d<int> ?
int m_viewport_x0, m_viewport_y0;
int m_viewport_width, m_viewport_height;
Index: server/vm/ExecutableCode.h
===================================================================
RCS file: server/vm/ExecutableCode.h
diff -N server/vm/ExecutableCode.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ server/vm/ExecutableCode.h 27 Mar 2007 14:52:05 -0000 1.1
@@ -0,0 +1,107 @@
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+/* $Id: ExecutableCode.h,v 1.1 2007/03/27 14:52:05 strk Exp $ */
+
+#ifndef GNASH_EXECUTABLECODE_H
+#define GNASH_EXECUTABLECODE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tu_config.h"
+
+#include "smart_ptr.h"
+#include "as_function.h"
+#include "sprite_instance.h"
+#include "ActionExec.h"
+#include "fn_call.h"
+
+namespace gnash
+{
+
+/// Any executable code
+class ExecutableCode {
+
+public:
+ ExecutableCode() {}
+
+ virtual void execute()=0;
+
+ virtual ~ExecutableCode() {}
+};
+
+/// Global code (out of any function)
+class GlobalCode: public ExecutableCode {
+
+public:
+
+ GlobalCode(const action_buffer& nBuffer,
boost::intrusive_ptr<sprite_instance> nTarget)
+ :
+ buffer(nBuffer),
+ target(nTarget)
+ {}
+
+ virtual void execute()
+ {
+ if ( ! target->isUnloaded() )
+ {
+ ActionExec exec(buffer, target->get_environment());
+ exec();
+ }
+ else
+ {
+ log_msg("Sprite %s unloaded, won't execute global code
in it", target->getTargetPath().c_str());
+ }
+ }
+
+private:
+
+ const action_buffer& buffer;
+
+ boost::intrusive_ptr<sprite_instance> target;
+};
+
+/// Function code
+class FunctionCode: public ExecutableCode {
+
+public:
+
+ FunctionCode(boost::intrusive_ptr<as_function> nFunc,
boost::intrusive_ptr<sprite_instance> nTarget)
+ :
+ func(nFunc),
+ target(nTarget)
+ {}
+
+ virtual void execute()
+ {
+ //log_msg("Execution of FunctionCode unimplemented yet");
+ func->call(fn_call(target.get(), &(target->get_environment()),
0, 0));
+ }
+
+private:
+
+ boost::intrusive_ptr<as_function> func;
+
+ boost::intrusive_ptr<sprite_instance> target;
+};
+
+
+
+} // namespace gnash
+
+#endif // GNASH_EXECUTABLECODE_H
_______________________________________________
Gnash-commit mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-commit