[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/movie_root.cpp server/mo...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/movie_root.cpp server/mo... |
Date: |
Fri, 09 Feb 2007 00:19:07 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/02/09 00:19:07
Modified files:
. : ChangeLog
server : movie_root.cpp movie_root.h sprite_instance.cpp
sprite_instance.h timers.cpp timers.h
server/asobj : xmlsocket.cpp
Log message:
* server/timers.{h,cpp}: add execution operator.
* server/movie_root.{h,cpp}: removed do_something method,
replaced by Timer's execution operator. Changed
add_interval_timer
to take a Timer& rather then a void*. Fixed
clear_interval_timer
to avoid modifying the Timer list consequently making interval
ids invalid (all commented, check out for details).
* server/sprite_instance.{h,cpp}: removed
{add,clear}_interval_timer
and do_somthing methods. Callers should use the ones in
movie_root.
* server/asobj/xmlsocket.cpp: don't register setInterval and
clearInterval functions as they should be globals !
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2281&r2=1.2282
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.152&r2=1.153
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2281
retrieving revision 1.2282
diff -u -b -r1.2281 -r1.2282
--- ChangeLog 8 Feb 2007 23:30:15 -0000 1.2281
+++ ChangeLog 9 Feb 2007 00:19:07 -0000 1.2282
@@ -1,3 +1,16 @@
+2007-02-08 Sandro Santilli <address@hidden>
+
+ * server/timers.{h,cpp}: add execution operator.
+ * server/movie_root.{h,cpp}: removed do_something method,
+ replaced by Timer's execution operator. Changed add_interval_timer
+ to take a Timer& rather then a void*. Fixed clear_interval_timer
+ to avoid modifying the Timer list consequently making interval
+ ids invalid (all commented, check out for details).
+ * server/sprite_instance.{h,cpp}: removed {add,clear}_interval_timer
+ and do_somthing methods. Callers should use the ones in movie_root.
+ * server/asobj/xmlsocket.cpp: don't register setInterval and
+ clearInterval functions as they should be globals !
+
2007-02-08 Tomas Groth Christensen <address@hidden>
* server/video_stream_instance.cpp, server/parser/video_stream_def.cpp:
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- server/movie_root.cpp 8 Feb 2007 17:01:01 -0000 1.38
+++ server/movie_root.cpp 9 Feb 2007 00:19:07 -0000 1.39
@@ -400,28 +400,34 @@
}
#endif
-int
-movie_root::add_interval_timer(void *timer)
+unsigned int
+movie_root::add_interval_timer(Timer& timer)
{
assert(testInvariant());
- Timer *ptr = static_cast<Timer *>(timer);
- m_interval_timers.push_back(ptr);
- return m_interval_timers.size();
+ int id = _intervalTimers.size();
+
+ // TODO: find first NULL element in vector for reuse ?
+ _intervalTimers.push_back(&timer);
+ return id;
}
-void
-movie_root::clear_interval_timer(int x)
+bool
+movie_root::clear_interval_timer(unsigned int x)
{
- m_interval_timers.erase(m_interval_timers.begin() + x-1);
- //m_interval_timers[x]->clearInterval();
+ if ( x >= _intervalTimers.size() ) return false;
+
+ Timer* timer = _intervalTimers[x];
+
+ // Check that _intervalTimers[x] does really exists.
+ if ( ! timer ) return false;
+
+ timer->clearInterval();
+ _intervalTimers[x] = NULL;
+
assert(testInvariant());
-}
-void
-movie_root::do_something(void * /* timer */)
-{
- log_msg("FIXME: %s: unimplemented\n", __FUNCTION__);
+ return true;
}
void
@@ -429,15 +435,21 @@
{
// GNASH_REPORT_FUNCTION;
+ // TODO: wrap this in a executeTimers() method
+ for (TimerList::iterator it=_intervalTimers.begin(),
+ itEnd=_intervalTimers.end();
+ it != itEnd;
+ ++it)
+ {
+ Timer* timerptr = *it;
+ if ( ! timerptr ) continue;
- if (m_interval_timers.size() > 0) {
- for (unsigned int i=0; i<m_interval_timers.size(); i++) {
- if (m_interval_timers[i]->expired()) {
- // printf("FIXME: Interval Timer Expired!\n");
+ Timer& timer = *timerptr;
+ if ( timer.expired() )
+ {
+ // log_msg("FIXME: Interval Timer Expired!\n");
//_movie->on_event_interval_timer();
- _movie->do_something(m_interval_timers[i]);
- //
clear_interval_timer(m_interval_timers[i]->getIntervalID()); // FIXME: we
shouldn't really disable the timer here
- }
+ timer();
}
}
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/movie_root.h 31 Jan 2007 15:24:13 -0000 1.33
+++ server/movie_root.h 9 Feb 2007 00:19:07 -0000 1.34
@@ -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.33 2007/01/31 15:24:13 bjacques Exp $ */
+/* $Id: movie_root.h,v 1.34 2007/02/09 00:19:07 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -78,7 +78,9 @@
#include "sprite_instance.h" // for inlines
// Forward declarations
-// none needed
+namespace gnash {
+ class Timer;
+}
namespace gnash
{
@@ -200,9 +202,18 @@
return _movie->get_movie_definition();
}
- int add_interval_timer(void *timer);
- void clear_interval_timer(int x);
- void do_something(void *timer);
+ /// Add an interval timer
+ //
+ /// @return an integer indentifying the timer
+ /// for subsequent call to clear_interval_timer
+ ///
+ unsigned int add_interval_timer(Timer& timer);
+
+ /// Remove timer identified by given integer
+ //
+ /// @return true on success, false on error (no such timer)
+ ///
+ bool clear_interval_timer(unsigned int x);
/// 0-based!!
size_t get_current_frame() const {
@@ -372,7 +383,15 @@
bool m_on_event_xmlsocket_ondata_called;
bool m_on_event_xmlsocket_onxml_called;
bool m_on_event_load_progress_called;
- std::vector<Timer *> m_interval_timers;
+
+ // TODO: should maintain refcount ?
+ // FIXME: std::vector is not an appropriate container
+ // for timers, as we'll be removing them from the
+ // list but still want Timer "identifiers" to be
+ // valid.
+ typedef std::vector<Timer *> TimerList;
+ TimerList _intervalTimers;
+
std::vector< as_object* > m_keypress_listeners;
character* m_active_input_text;
float m_time_remainder;
@@ -393,6 +412,7 @@
/// more info.
///
bool fire_mouse_event();
+
};
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -b -r1.152 -r1.153
--- server/sprite_instance.cpp 8 Feb 2007 17:01:01 -0000 1.152
+++ server/sprite_instance.cpp 9 Feb 2007 00:19:07 -0000 1.153
@@ -3183,40 +3183,6 @@
return f.getWidth();
}
-void sprite_instance::do_something(void *timer)
-{
- as_value val;
- as_object *obj, *this_ptr;
- as_environment *as_env;
-
- //printf("FIXME: %s:\n", __FUNCTION__);
- Timer *ptr = (Timer *)timer;
- //log_msg("INTERVAL ID is %d\n", ptr->getIntervalID());
-
- const as_value& timer_method = ptr->getASFunction();
- as_env = ptr->getASEnvironment();
- this_ptr = ptr->getASObject();
- obj = ptr->getObject();
- //m_as_environment.push(obj);
-
- as_c_function_ptr cfunc = timer_method.to_c_function();
- if (cfunc) {
- // It's a C function. Call it.
- //log_msg("Calling C function for interval timer\n");
- //(*cfunc)(&val, obj, as_env, 0, 0);
- (*cfunc)(fn_call(&val, obj, &m_as_environment, 0, 0));
-
- } else if (as_function* as_func = timer_method.to_as_function()) {
- // It's an ActionScript function. Call it.
- as_value method;
- //log_msg("Calling ActionScript function for interval timer\n");
- (*as_func)(fn_call(&val, (as_object *)this_ptr, as_env, 0, 0));
- //(*as_func)(&val, (as_object *)this_ptr, &m_as_environment, 1, 1);
- } else {
- log_error("error in call_method(): method is not a function\n");
- }
-}
-
character*
sprite_instance::get_character(int /* character_id */)
{
@@ -3234,18 +3200,6 @@
//}
-void
-sprite_instance::clear_interval_timer(int x)
-{
- _vm.getRoot().clear_interval_timer(x);
-}
-
-int
-sprite_instance::add_interval_timer(void *timer)
-{
- return _vm.getRoot().add_interval_timer(timer);
-}
-
sprite_instance*
sprite_instance::get_root_movie()
{
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- server/sprite_instance.h 8 Feb 2007 17:01:01 -0000 1.62
+++ server/sprite_instance.h 9 Feb 2007 00:19:07 -0000 1.63
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.62 2007/02/08 17:01:01 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.63 2007/02/09 00:19:07 strk Exp $ */
// Stateful live Sprite instance
@@ -104,16 +104,6 @@
virtual void has_keypress_event();
- // delegates to movie_root
- virtual int add_interval_timer(void *timer);
-
- // delegates to movie_root
- virtual void clear_interval_timer(int x);
-
-
- /// Interval timer timeout executor
- virtual void do_something(void *timer);
-
/// \brief
/// Return this sprite's relative root as
/// specified at contruction time
Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/timers.cpp 6 Dec 2006 10:58:34 -0000 1.20
+++ server/timers.cpp 9 Feb 2007 00:19:07 -0000 1.21
@@ -18,7 +18,7 @@
//
//
-/* $Id: timers.cpp,v 1.20 2006/12/06 10:58:34 strk Exp $ */
+/* $Id: timers.cpp,v 1.21 2007/02/09 00:19:07 strk Exp $ */
#include "timers.h"
#include "as_function.h" // for class as_function
@@ -27,6 +27,8 @@
#include "sprite_instance.h"
#include "fn_call.h"
#include "xml.h"
+#include "VM.h"
+#include "movie_root.h"
using namespace std;
@@ -140,31 +142,51 @@
return false;
}
- void
- timer_setinterval(const fn_call& fn)
- {
- int i;
- as_value method;
+void
+Timer::operator() ()
+{
+ //printf("FIXME: %s:\n", __FUNCTION__);
+ //log_msg("INTERVAL ID is %d\n", getIntervalID());
+
+ const as_value& timer_method = getASFunction();
+ as_environment* as_env = getASEnvironment();
+
+ as_object* obj = getObject();
+ as_value val = call_method(timer_method, as_env, obj, 0, 0);
+
+ //as_object* this_ptr = getASObject();
+ //as_value val = call_method(timer_method, as_env, this_ptr, 0, 0);
+
+}
+
+void
+timer_setinterval(const fn_call& fn)
+{
log_msg("%s: args=%d\n", __FUNCTION__, fn.nargs);
timer_as_object *ptr = new timer_as_object;
- // action_buffer m_action_buffer;
- //timer_as_object* ptr = (timer_as_object*) (as_object*) this_ptr;
- assert(ptr);
+ // Get interval function
+ as_function *as_func = fn.arg(0).to_as_function();
+ if ( ! as_func )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("Invalid call to setInterval(%s) "
+ "- first argument is not a function",
+ ss.str().c_str());
+ );
+ return;
+ }
- sprite_instance* mov = fn.env->get_target()->get_root_movie();
- as_function *as_func =
fn.env->bottom(fn.first_arg_bottom_index).to_as_function();
- as_value val(as_func);
- int ms =
static_cast<int>(fn.env->bottom(fn.first_arg_bottom_index-1).to_number());
- string local_name;
- as_value local_val;
+ // Get interval time
+ int ms = int(fn.arg(1).to_number());
fn.env->add_frame_barrier();
//method = env->get_variable("loopvar");
-#if 1
+#if 0
// FIXME: This is pretty gross, but something is broke elsewhere and it
doesn't
// seem to effect anything else. When a function is called from a executing
// function, like calling setInterval() from within the callback to
@@ -177,48 +199,33 @@
//method = env->get_variable(env->m_local_frames[i].m_name);
//if (method.get_type() != as_value::UNDEFINED)
{
- local_name = fn.env->m_local_frames[i].m_name;
- local_val = fn.env->m_local_frames[i].m_value;
+ string local_name = fn.env->m_local_frames[i].m_name;
+ as_value local_val = fn.env->m_local_frames[i].m_value;
fn.env->set_variable(local_name, local_val);
}
}
}
#endif
- // ptr->obj.setInterval(val, ms, (as_object *)ptr, env);
-
- //Ptr->obj.setInterval(val, ms);
- ptr->obj.setInterval(val, ms, (as_object *)ptr, fn.env);
-
- fn.result->set_int(mov->add_interval_timer(&ptr->obj));
- }
-
- void
- timer_expire(const fn_call& fn)
- {
- //log_msg("%s:\n", __FUNCTION__);
- timer_as_object* ptr = (timer_as_object*) (as_object*) fn.this_ptr;
- assert(ptr);
- const as_value& val = ptr->obj.getASFunction();
-
- if (as_function* as_func = val.to_as_function()) {
- // It's an ActionScript function. Call it.
- log_msg("Calling ActionScript function for setInterval Timer\n");
- (*as_func)(fn_call(fn.result, fn.this_ptr, fn.env, 0, 0));
- } else {
- log_error("FIXME: Couldn't find setInterval Timer!\n");
- }
- }
+ as_value val(as_func);
- void
- timer_clearinterval(const fn_call& fn)
- {
- //log_msg("%s: nargs = %d\n", __FUNCTION__, nargs);
+ //Ptr->obj.setInterval(val, ms);
+ ptr->obj.setInterval(val, ms, ptr, fn.env);
- double id = fn.env->bottom(fn.first_arg_bottom_index).to_number();
+ movie_root& root = VM::get().getRoot();
+ int id = root.add_interval_timer(ptr->obj);
+ fn.result->set_int(id);
+}
- sprite_instance* mov = fn.env->get_target()->get_root_movie();
- mov->clear_interval_timer((int)id);
- fn.result->set_bool(true);
- }
+void
+timer_clearinterval(const fn_call& fn)
+{
+ log_msg("%s: nargs = %d\n", __FUNCTION__, fn.nargs);
+
+ int id = int(fn.arg(0).to_number());
+
+ movie_root& root = VM::get().getRoot();
+ bool ret = root.clear_interval_timer(id);
+ fn.result->set_bool(ret);
+}
}
Index: server/timers.h
===================================================================
RCS file: /sources/gnash/gnash/server/timers.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/timers.h 23 Nov 2006 20:14:13 -0000 1.12
+++ server/timers.h 9 Feb 2007 00:19:07 -0000 1.13
@@ -78,6 +78,10 @@
_locals->push_back(var);
}
+ /// Execute timer function
+ void operator() ();
+
+
private:
int _which; // Which timer
Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/asobj/xmlsocket.cpp 18 Jan 2007 22:53:22 -0000 1.3
+++ server/asobj/xmlsocket.cpp 9 Feb 2007 00:19:07 -0000 1.4
@@ -25,6 +25,7 @@
#include "as_function.h"
#include "fn_call.h"
#include "sprite_instance.h"
+#include "VM.h"
#include "log.h"
@@ -527,13 +528,12 @@
}
#if 1
- sprite_instance* mov = fn.env->get_target()->get_root_movie();
Timer *timer = new Timer;
as_c_function_ptr ondata_handler =
(as_c_function_ptr)&xmlsocket_event_ondata;
timer->setInterval(ondata_handler, 50, ptr, fn.env);
timer->setObject(ptr);
- mov->add_interval_timer(timer);
+ VM::get().getRoot().add_interval_timer(*timer);
#endif
fn.env->pop();
@@ -603,11 +603,10 @@
//periodic_events.set_event_handler(xmlsock_obj);
-#if 1
+#if 0 // TODO: setInterval and clearInterval shall be _global methods
//
//as_c_function_ptr int_handler = (as_c_function_ptr)&timer_setinterval;
//env->set_member("setInterval", int_handler);
- // TODO: check this, sounds suspicious
fn.env->set_member("setInterval", timer_setinterval);
//as_c_function_ptr clr_handler = timer_clearinterval;
@@ -625,6 +624,7 @@
timer->setObject(xmlsock_obj);
current_movie->add_interval_timer(timer);
#endif
+#endif
fn.result->set_bool(xmlsock_obj);
@@ -633,7 +633,6 @@
//mallopt(M_TRIM_THRESHOLD,-1);
//mallopt(M_MMAP_THRESHOLD,16);
-#endif
}
- [Gnash-commit] gnash ChangeLog server/movie_root.cpp server/mo...,
Sandro Santilli <=