[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11627: Move functions around, drop
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11627: Move functions around, drop obsolete files. |
Date: |
Mon, 16 Nov 2009 14:51:04 +0100 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11627 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-11-16 14:51:04 +0100
message:
Move functions around, drop obsolete files.
Use boost preprocessor to avoid writing code out.
Various minor changes to make functions cleaner.
removed:
libcore/vm/action.h
renamed:
libcore/vm/action.cpp => libcore/event_id.cpp
modified:
extensions/gtk2/gtkext.cpp
gui/gnash.cpp
gui/pythonmod/gnash-view.cpp
libcore/ClassHierarchy.cpp
libcore/DisplayObject.cpp
libcore/Makefile.am
libcore/MovieClip.cpp
libcore/TextField.cpp
libcore/Timers.cpp
libcore/Timers.h
libcore/as_object.cpp
libcore/as_object.h
libcore/as_value.cpp
libcore/as_value.h
libcore/asobj/Array_as.cpp
libcore/asobj/AsBroadcaster.cpp
libcore/asobj/Date_as.cpp
libcore/asobj/Global_as.h
libcore/asobj/Globals.cpp
libcore/asobj/Object.cpp
libcore/asobj/flash/display/BitmapData_as.cpp
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/asobj/flash/filters/BitmapFilter_as.cpp
libcore/asobj/flash/geom/Matrix_as.cpp
libcore/asobj/flash/geom/Rectangle_as.cpp
libcore/asobj/flash/geom/Transform_as.cpp
libcore/asobj/flash/net/SharedObject_as.cpp
libcore/asobj/flash/net/XMLSocket_as.cpp
libcore/asobj/flash/ui/ContextMenuItem_as.cpp
libcore/asobj/flash/ui/ContextMenu_as.cpp
libcore/asobj/flash/xml/XMLDocument_as.cpp
libcore/asobj/flash/xml/XMLNode_as.h
libcore/movie_root.h
libcore/swf/SWF.h
libcore/swf/tag_loaders.cpp
libcore/vm/ASHandlers.cpp
libcore/vm/ASHandlers.h
libcore/vm/ExecutableCode.h
libcore/vm/Machine.cpp
libcore/vm/Makefile.am
libcore/vm/fn_call.h
libcore/event_id.cpp
=== modified file 'extensions/gtk2/gtkext.cpp'
--- a/extensions/gtk2/gtkext.cpp 2009-08-20 06:55:15 +0000
+++ b/extensions/gtk2/gtkext.cpp 2009-11-16 11:16:48 +0000
@@ -88,7 +88,7 @@
const char *event = (const char *)data;
as_value handler = callbacks[event];
- as_function *as_func = handler.to_as_function();
+ as_function *as_func = handler.to_function();
// start the debugger when this callback is activated.
// debugger.enabled(true);
@@ -228,7 +228,7 @@
if (fn.nargs > 0) {
GtkExt *window = dynamic_cast<GtkExt
*>(fn.arg(0).to_object(*getGlobal(fn)).get());
string name = fn.arg(1).to_string();
- as_value func = fn.arg(2).to_as_function();
+ as_value func = fn.arg(2).to_function();
//int data = fn.arg(3).to_int();
dbglogfile << "Adding callback " << func.to_string()
=== modified file 'gui/gnash.cpp'
--- a/gui/gnash.cpp 2009-10-01 23:46:57 +0000
+++ b/gui/gnash.cpp 2009-11-16 11:16:48 +0000
@@ -144,7 +144,7 @@
// << _(" CTRL-A Toggle antialiasing (doesn't work)") << endl
// << _(" CTRL-T Debug. Test the set_variable() function") <<
endl
// << _(" CTRL-G Debug. Test the get_variable() function") <<
endl
-// << _(" CTRL-M Debug. Test the call_method() function") << endl
+// << _(" CTRL-M Debug. Test the invoke() function") << endl
<< endl;
}
=== modified file 'gui/pythonmod/gnash-view.cpp'
--- a/gui/pythonmod/gnash-view.cpp 2009-11-15 16:10:30 +0000
+++ b/gui/pythonmod/gnash-view.cpp 2009-11-16 13:51:04 +0000
@@ -38,6 +38,7 @@
#include "SystemClock.h"
#include "smart_ptr.h"
#include "DisplayObject.h"
+#include "Global_as.h"
#ifdef USE_FFMPEG
# include "MediaHandlerFfmpeg.h"
=== modified file 'libcore/ClassHierarchy.cpp'
--- a/libcore/ClassHierarchy.cpp 2009-11-13 08:19:10 +0000
+++ b/libcore/ClassHierarchy.cpp 2009-11-16 11:16:48 +0000
@@ -116,7 +116,7 @@
!us.to_object(gl)->hasOwnProperty(NSV::PROP_uuPROTOuu))
{
us.to_object(gl)->set_prototype(
- super.to_as_function()->getPrototype());
+ super.to_function()->getPrototype());
}
return us;
}
@@ -177,7 +177,7 @@
super.set_undefined();
return super;
}
- assert(super.to_as_function());
+ assert(super.to_function());
}
Global_as& gl = getGlobal(fn);
@@ -190,7 +190,7 @@
!us.to_object(gl)->hasOwnProperty(NSV::PROP_uuPROTOuu)) {
us.to_object(gl)->set_prototype(
- super.to_as_function()->getPrototype());
+ super.to_function()->getPrototype());
}
}
else
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-11-15 15:46:12 +0000
+++ b/libcore/DisplayObject.cpp 2009-11-16 11:16:48 +0000
@@ -504,7 +504,7 @@
as_value tmp;
if (_object->get_member(id.functionKey(), &tmp)) {
- return tmp.to_as_function();
+ return tmp.to_function();
}
return false;
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am 2009-11-15 14:33:03 +0000
+++ b/libcore/Makefile.am 2009-11-16 12:29:31 +0000
@@ -59,6 +59,7 @@
ClassHierarchy.cpp \
as_environment.cpp \
as_function.cpp \
+ event_id.cpp \
Relay.cpp \
as_object.cpp \
as_value.cpp \
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-11-13 13:14:22 +0000
+++ b/libcore/MovieClip.cpp 2009-11-16 12:34:46 +0000
@@ -23,7 +23,6 @@
#include "MovieFactory.h"
#include "log.h"
-#include "action.h" // for call_method_parsed (call_method_args)
#include "MovieClip.h"
#include "movie_definition.h"
#include "as_value.h"
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-11-13 12:54:06 +0000
+++ b/libcore/TextField.cpp 2009-11-16 12:34:46 +0000
@@ -40,7 +40,6 @@
#include "flash/ui/Keyboard_as.h" // for keyboard events
#include "movie_root.h" // for killing focus
#include "as_environment.h" // for parse_path
-#include "action.h" // for as_standard_member enum
#include "VM.h"
#include "builtin_function.h"
#include "NativeFunction.h"
@@ -132,7 +131,7 @@
createTextFieldObject(Global_as& gl)
{
as_value tf(gl.getMember(NSV::CLASS_TEXT_FIELD));
- as_function* ctor = tf.to_as_function();
+ as_function* ctor = tf.to_function();
if (!ctor) return 0;
fn_call::Args args;
as_environment env(getVM(gl));
@@ -3286,7 +3285,7 @@
TextField* text = ensure<IsDisplayObject<TextField> >(fn);
Global_as& gl = getGlobal(fn);
- as_function* ctor = gl.getMember(NSV::CLASS_TEXT_FORMAT).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_TEXT_FORMAT).to_function();
if (!ctor) return as_value();
=== modified file 'libcore/Timers.cpp'
--- a/libcore/Timers.cpp 2009-08-20 06:55:15 +0000
+++ b/libcore/Timers.cpp 2009-11-16 11:21:48 +0000
@@ -23,7 +23,7 @@
#include "fn_call.h"
#include "VM.h"
#include "movie_root.h"
-#include "action.h" // call_method
+#include "Global_as.h"
#include <limits> // for numeric_limits
#include <functional>
@@ -31,53 +31,35 @@
namespace gnash {
-Timer::Timer()
- :
- _interval(0),
- _start(std::numeric_limits<unsigned long>::max()),
- _object(0),
- _runOnce(false)
-{
-}
-
Timer::~Timer()
{
}
-void
-Timer::setInterval(as_function& method, unsigned long ms,
- boost::intrusive_ptr<as_object> this_ptr,
- ArgsContainer& args, bool runOnce)
-{
- _function = &method;
- _interval = ms;
- _object = this_ptr;
- _args = args;
- _runOnce = runOnce;
- start();
-}
-
-void
-Timer::setInterval(as_function& method, unsigned long ms,
- boost::intrusive_ptr<as_object> this_ptr, bool runOnce)
-{
- _function = &method;
- _interval = ms;
- _object = this_ptr;
- _runOnce = runOnce;
- start();
-}
-
-void
-Timer::setInterval(boost::intrusive_ptr<as_object> this_ptr,
- const std::string& methodName, unsigned long ms,
- std::vector<as_value>& args, bool runOnce)
-{
- _object = this_ptr;
- _methodName = methodName;
- _interval = ms;
- _args = args;
- _runOnce = runOnce;
+Timer::Timer(as_function& method, unsigned long ms,
+ as_object* this_ptr, const fn_call::Args& args, bool runOnce)
+ :
+ _interval(ms),
+ _start(std::numeric_limits<unsigned long>::max()),
+ _function(&method),
+ _methodName(0),
+ _object(this_ptr),
+ _args(args),
+ _runOnce(runOnce)
+{
+ start();
+}
+
+Timer::Timer(as_object* this_ptr, string_table::key methodName,
+ unsigned long ms, const fn_call::Args& args, bool runOnce)
+ :
+ _interval(ms),
+ _start(std::numeric_limits<unsigned long>::max()),
+ _function(0),
+ _methodName(methodName),
+ _object(this_ptr),
+ _args(args),
+ _runOnce(runOnce)
+{
start();
}
@@ -120,17 +102,17 @@
as_value timer_method;
- as_object* super = _object->get_super(_function ? 0 : _methodName.c_str());
+ // If _function is not 0, _methodName should be 0 anyway, but the
+ // ternary operator is there for clarity.
+ as_object* super = _object->get_super(_function ? 0 : _methodName);
VM& vm = getVM(*_object);
- if (_function.get() ) {
- timer_method.set_as_function(_function.get());
+ if (_function) {
+ timer_method.set_as_function(_function);
}
else {
- string_table::key k = vm.getStringTable().find(_methodName);
as_value tmp;
-
- if ( ! _object->get_member(k, &tmp) ) {
+ if (!_object->get_member(_methodName, &tmp)) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("object %p has no member named %s (interval method)",
_object, _methodName);
@@ -138,12 +120,12 @@
return;
}
- as_function* f = tmp.to_as_function();
+ as_function* f = tmp.to_function();
if (!f) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("member %s of object %p (interval method) is not "
- "a function (%s)", _methodName, (void*)_object.get(), tmp);
+ "a function (%s)", _methodName, (void*)_object, tmp);
);
return;
}
@@ -153,11 +135,9 @@
as_environment env(vm);
// Copy args
- fn_call::Args::container_type argsCopy(_args);
- fn_call::Args args;
- args.swap(argsCopy);
+ fn_call::Args argsCopy(_args);
- call_method(timer_method, env, _object.get(), args, super);
+ invoke(timer_method, env, _object, argsCopy, super);
}
@@ -165,8 +145,7 @@
void
Timer::markReachableResources() const
{
- std::for_each(_args.begin(), _args.end(),
- std::mem_fun_ref(&as_value::setReachable));
+ _args.setReachable();
if (_function) _function->setReachable();
if (_object) _object->setReachable();
=== modified file 'libcore/Timers.h'
--- a/libcore/Timers.h 2009-04-01 05:59:00 +0000
+++ b/libcore/Timers.h 2009-11-16 10:40:56 +0000
@@ -53,35 +53,9 @@
{
public:
- /// Arguments list type
- typedef std::vector<as_value> ArgsContainer;
-
- /// Construct a disabled (cleared) timer.
- Timer();
-
~Timer();
- /// Setup the Timer, enabling it.
- //
- /// @param method
- /// The function to call from execution operator.
- /// Will be stored in an intrusive_ptr.
- ///
- /// @param ms
- /// The number of milliseconds between expires.
- ///
- /// @param this_ptr
- /// The object to be used as 'this' pointer when calling the
- /// associated function. Will be stored in an intrusive_ptr.
- /// It is allowed to be NULL as long as fn_call is allowed
- /// a NULL as 'this_ptr' (we might want to change this).
- ///
- /// @param runOnce
- /// If true the interval will run only once. False if omitted.
- void setInterval(as_function& method, unsigned long ms,
- boost::intrusive_ptr<as_object> this_ptr, bool runOnce = false);
-
- /// Setup the Timer, enabling it.
+ /// Construct a Timer, enabling it.
//
/// @param method
/// The function to call from execution operator.
@@ -101,11 +75,10 @@
///
/// @param runOnce
/// If true the interval will run only once. False if omitted.
- void setInterval(as_function& method, unsigned long ms,
- boost::intrusive_ptr<as_object> this_ptr,
- std::vector<as_value>& args, bool runOnce = false);
+ Timer(as_function& method, unsigned long ms, as_object* this_ptr,
+ const fn_call::Args& args, bool runOnce = false);
- /// Setup the Timer to call a late-evaluated object method, enabling it.
+ /// Construct the Timer to call a late-evaluated object method, enabling
it.
//
/// @param this_ptr
/// The object to be used as 'this' pointer when calling the
@@ -124,9 +97,8 @@
///
/// @param runOnce
/// If true the interval will run only once. False if omitted.
- void setInterval(boost::intrusive_ptr<as_object> obj,
- const std::string& methodName, unsigned long ms,
- std::vector<as_value>& args, bool runOnce = false);
+ Timer(as_object* obj, string_table::key methodName, unsigned long ms,
+ const fn_call::Args& args, bool runOnce = false);
/// Clear the timer, ready for reuse
//
@@ -212,16 +184,17 @@
/// The associated function (if statically-bound) stored in
/// an intrusive pointer
- boost::intrusive_ptr<as_function> _function;
+ as_function* _function;
- /// The associated method name, stored in an intrusive pointer
- std::string _methodName;
+ string_table::key _methodName;
/// Context for the function call. Will be used as 'this' pointer.
- boost::intrusive_ptr<as_object> _object;
+ as_object* _object;
/// List of arguments
- ArgsContainer _args;
+ //
+ /// This must be copied before passing to a function call.
+ const fn_call::Args _args;
/// True if the timer should execute only once (for setTimeout)
bool _runOnce;
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/as_object.cpp 2009-11-16 12:34:46 +0000
@@ -33,7 +33,6 @@
#include "GnashException.h"
#include "fn_call.h"
#include "Object.h"
-#include "action.h"
#include "Array_as.h"
#include "as_function.h"
#include "Global_as.h"
@@ -140,7 +139,7 @@
virtual bool isSuper() const { return true; }
- virtual as_object* get_super(const char* fname=0);
+ virtual as_object* get_super(string_table::key fname = 0);
// Fetching members from 'super' yelds a lookup on the associated
prototype
virtual bool get_member(string_table::key name, as_value* val,
@@ -192,7 +191,7 @@
};
as_object*
-as_super::get_super(const char* fname)
+as_super::get_super(string_table::key fname)
{
// Super references the super class of our class prototype.
// Our class prototype is __proto__.
@@ -206,11 +205,8 @@
return new as_super(getGlobal(*this), proto);
}
- string_table& st = getStringTable(*this);
- string_table::key k = st.find(fname);
-
as_object* owner = 0;
- proto->findProperty(k, 0, &owner);
+ proto->findProperty(fname, 0, &owner);
if (!owner) return 0;
if (owner == proto) return new as_super(getGlobal(*this), proto);
@@ -458,7 +454,7 @@
}
as_object*
-as_object::get_super(const char* fname)
+as_object::get_super(string_table::key fname)
{
// Super references the super class of our class prototype.
// Our class prototype is __proto__.
@@ -467,12 +463,9 @@
// Our class prototype is __proto__.
as_object* proto = get_prototype();
- if ( fname && getSWFVersion(*this) > 6)
- {
+ if (fname && getSWFVersion(*this) > 6) {
as_object* owner = 0;
- string_table& st = getStringTable(*this);
- string_table::key k = st.find(fname);
- findProperty(k, 0, &owner);
+ findProperty(fname, 0, &owner);
// should be 0 if findProperty returned 0
if (owner != this) proto = owner;
}
@@ -492,7 +485,7 @@
return NULL;
}
//log_debug("%p.__constructor__ is %s", ctorVal);
- return ctorVal.to_as_function();
+ return ctorVal.to_function();
}
int
@@ -1141,106 +1134,6 @@
return ret;
}
-as_value
-callMethod(as_object* obj, string_table::key methodName)
-{
- if (!obj) return as_value();
-
- as_value method;
-
- if (!obj->get_member(methodName, &method))
- {
- return as_value();
- }
-
- as_environment env(getVM(*obj));
-
- return call_method0(method, env, obj);
-}
-
-as_value
-callMethod(as_object* obj, string_table::key methodName, const as_value& arg0)
-{
- if (!obj) return as_value();
- as_value method;
-
- if (!obj->get_member(methodName, &method))
- {
- return as_value();
- }
-
- as_environment env(getVM(*obj));
-
- fn_call::Args args;
- args += arg0;
-
- return call_method(method, env, obj, args);
-}
-
-as_value
-callMethod(as_object* obj, string_table::key methodName, const as_value& arg0,
- const as_value& arg1)
-{
- if (!obj) return as_value();
- as_value method;
-
- if (!obj->get_member(methodName, &method))
- {
- return as_value();
- }
-
- as_environment env(getVM(*obj));
-
- fn_call::Args args;
- args += arg0, arg1;
-
- return call_method(method, env, obj, args);
-}
-
-as_value
-callMethod(as_object* obj, string_table::key methodName,
- const as_value& arg0, const as_value& arg1, const as_value& arg2)
-{
- if (!obj) return as_value();
- as_value ret;
- as_value method;
-
- if (!obj->get_member(methodName, &method))
- {
- return ret;
- }
-
- as_environment env(getVM(*obj));
-
- fn_call::Args args;
- args += arg0, arg1, arg2;
-
- ret = call_method(method, env, obj, args);
-
- return ret;
-}
-
-as_value
-callMethod(as_object* obj, string_table::key methodName, const as_value& arg0,
- const as_value& arg1, const as_value& arg2, const as_value& arg3)
-{
- if (!obj) return as_value();
- as_value method;
-
- if (!obj->get_member(methodName, &method))
- {
- return as_value();
- }
-
- as_environment env(getVM(*obj));
-
- fn_call::Args args;
- args += arg0, arg1, arg2, arg3;
-
- return call_method(method, env, obj, args);
-
-}
-
as_object*
as_object::get_path_element(string_table::key key)
{
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2009-11-15 16:26:27 +0000
+++ b/libcore/as_object.h 2009-11-16 12:17:00 +0000
@@ -644,7 +644,7 @@
/// itself, or __proto__.__proto__ if this is not a prototype
/// object. This is only conceptual however, and may be more
/// convoluted to obtain the actual super.
- virtual as_object* get_super(const char* fname=0);
+ virtual as_object* get_super(string_table::key fname = 0);
/// Get the constructor for this object.
///
@@ -1190,31 +1190,6 @@
return relay;
}
-/// Call a method of this object in an AS-compatible way
-//
-/// @param name
-/// Name of the method. Will be converted to lowercase
-/// if the current VM is initialized for a target
-/// up to SWF6.
-///
-/// @param ...
-/// nargs as_value references
-///
-/// @return value of the member (possibly undefined),
-/// or undefined if not found. Use get_member if you
-/// need to know wheter it was found or not.
-///
-as_value callMethod(as_object* obj, string_table::key name);
-as_value callMethod(as_object* obj, string_table::key name,
- const as_value& arg0);
-as_value callMethod(as_object* obj, string_table::key name,
- const as_value& arg0, const as_value& arg1);
-as_value callMethod(as_object* obj, string_table::key name,
- const as_value& arg0, const as_value& arg1, const as_value& arg2);
-as_value callMethod(as_object* obj, string_table::key name,
- const as_value& arg0, const as_value& arg1, const as_value& arg2,
- const as_value& arg3);
-
/// Get the VM from an as_object
VM& getVM(const as_object& o);
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/as_value.cpp 2009-11-16 12:34:46 +0000
@@ -26,7 +26,6 @@
#include "as_environment.h" // for MOVIECLIP values
#include "VM.h" // for MOVIECLIP values
#include "movie_root.h" // for MOVIECLIP values
-#include "action.h" // for call_method0
#include "utility.h" // for typeName()
#include "GnashNumeric.h"
#include "namedStrings.h"
@@ -568,7 +567,8 @@
assert(obj);
as_environment env(getVM(*obj));
- as_value ret = call_method0(method, env, obj);
+ fn_call::Args args;
+ as_value ret = invoke(method, env, obj, args);
#if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
log_debug("to_primitive: method call returned %s", ret);
#endif
@@ -957,7 +957,7 @@
// Return value as an ActionScript function. Returns NULL if value is
// not an ActionScript function.
as_function*
-as_value::to_as_function() const
+as_value::to_function() const
{
if (m_type == AS_FUNCTION) {
// OK.
@@ -2185,7 +2185,7 @@
log_debug("amf0 read date: %e", dub);
#endif
- as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_function();
if (ctor) {
fn_call::Args args;
args += dub;
=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h 2009-11-13 07:50:48 +0000
+++ b/libcore/as_value.h 2009-11-16 11:16:48 +0000
@@ -457,7 +457,7 @@
/// \brief
/// Return value as an ActionScript function ptr
/// or NULL if it is not an ActionScript function.
- as_function* to_as_function() const;
+ as_function* to_function() const;
/// Return value as a primitive type
//
=== modified file 'libcore/asobj/Array_as.cpp'
--- a/libcore/asobj/Array_as.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/asobj/Array_as.cpp 2009-11-16 12:34:46 +0000
@@ -31,7 +31,6 @@
#include "fn_call.h"
#include "Global_as.h"
#include "GnashException.h"
-#include "action.h"
#include "VM.h"
#include "Object.h"
#include "GnashNumeric.h"
@@ -612,7 +611,7 @@
as_value ret(0.0);
fn_call::Args args;
args += b, a;
- ret = call_method(cmp_method, _env, _object, args);
+ ret = invoke(cmp_method, _env, _object, args);
return (*_zeroCmp)(ret.to_int());
}
@@ -1029,7 +1028,7 @@
}
else if (fn.arg(0).is_function()) {
// Get comparison function
- as_function* as_func = fn.arg(0).to_as_function();
+ as_function* as_func = fn.arg(0).to_function();
assert(as_func);
=== modified file 'libcore/asobj/AsBroadcaster.cpp'
--- a/libcore/asobj/AsBroadcaster.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/asobj/AsBroadcaster.cpp 2009-11-16 11:16:48 +0000
@@ -91,11 +91,11 @@
as_value method;
o->get_member(_eventKey, &method);
- _fn.super = o->get_super(_eventName.c_str());
+ _fn.super = o->get_super(_eventKey);
if (method.is_function()) {
_fn.this_ptr = o.get();
- method.to_as_function()->call(_fn);
+ method.to_function()->call(_fn);
}
++_dispatched;
=== modified file 'libcore/asobj/Date_as.cpp'
--- a/libcore/asobj/Date_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/Date_as.cpp 2009-11-16 11:16:48 +0000
@@ -417,7 +417,7 @@
// date.
if (!fn.isInstantiation()) {
Global_as& gl = getGlobal(fn);
- as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_function();
if (!ctor) return as_value();
fn_call::Args args;
return ctor->constructInstance(fn.env(), args);
=== modified file 'libcore/asobj/Global_as.h'
--- a/libcore/asobj/Global_as.h 2009-11-15 16:26:27 +0000
+++ b/libcore/asobj/Global_as.h 2009-11-16 12:18:30 +0000
@@ -22,6 +22,16 @@
#include "as_object.h" // for inheritance
#include "Object.h"
#include "fn_call.h"
+#include "GnashException.h"
+#include "as_function.h"
+
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/seq/for_each.hpp>
+#include <boost/preprocessor/control.hpp>
+#include <boost/preprocessor/expand.hpp>
// Forward declarations
namespace gnash {
@@ -176,6 +186,79 @@
return cl;
}
+/// Call an as_value on an as_object.
+//
+/// The call will fail harmlessly if the as_value is not a function.
+inline DSOEXPORT as_value
+invoke(const as_value& method, const as_environment& env, as_object* this_ptr,
+ fn_call::Args& args, as_object* super = 0,
+ const movie_definition* callerDef = 0)
+{
+
+ as_value val;
+ fn_call call(this_ptr, env, args);
+ call.super = super;
+ call.callerDef = callerDef;
+
+ try {
+ if (as_function* func = method.to_function()) {
+ // Call function.
+ val = (*func)(call);
+ }
+ else {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Attempt to call a value which is not "
+ "a function (%s)", method);
+ );
+ return val;
+ }
+ }
+ catch (ActionTypeError& e) {
+ assert(val.is_undefined());
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("%s", e.what());
+ );
+ }
+ return val;
+}
+
+/// Helper macro for callMethod arguments.
+#define VALUE_ARG(z, n, t) BOOST_PP_COMMA_IF(n) t arg##n
+
+/// Call a member function of this object in an AS-compatible way
+//
+/// This is a macro to cope with a varying number of arguments. The function
+/// signature is as follows:
+//
+/// as_value callMethod(as_object* obj, string_table::key key,
+/// const as_value& arg1, ..., const as_value& argN);
+//
+/// If the member function exists and is a function, invoke() is called on
+/// the member with the object as the this pointer.
+//
+/// @param obj The object to call the method on. This may be null, in
+/// which case the call is a no-op. This is because calling
+/// methods on null or non-objects in AS is harmless.
+/// @param name The name of the method.
+///
+/// @param arg0..argN The arguments to pass
+///
+/// @return The return value of the call (possibly undefined).
+#define CALL_METHOD(x, n, t) \
+inline as_value \
+callMethod(as_object* obj, string_table::key key BOOST_PP_COMMA_IF(n)\
+ BOOST_PP_REPEAT(n, VALUE_ARG, const as_value&)) {\
+ if (!obj) return as_value();\
+ as_value func;\
+ if (!obj->get_member(key, &func)) return as_value();\
+ fn_call::Args args;\
+ BOOST_PP_EXPR_IF(n, (args += BOOST_PP_REPEAT(n, VALUE_ARG, ));)\
+ return invoke(func, as_environment(getVM(*obj)), obj, args);\
+}
+
+/// The maximum number of as_value arguments allowed in callMethod functions.
+#define MAX_ARGS 4
+BOOST_PP_REPEAT(BOOST_PP_INC(MAX_ARGS), CALL_METHOD, )
/// Convenience function for finding a class constructor.
//
@@ -184,7 +267,7 @@
getClassConstructor(const fn_call& fn, const std::string& s)
{
const as_value ctor(fn.env().find_object(s));
- return ctor.to_as_function();
+ return ctor.to_function();
}
} // namespace gnash
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-11-15 16:26:27 +0000
+++ b/libcore/asobj/Globals.cpp 2009-11-16 11:16:48 +0000
@@ -1256,7 +1256,7 @@
string_table& st = getStringTable(fn);
- as_function* ctor = gl.getMember(NSV::CLASS_ERROR).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_ERROR).to_function();
if (ctor) {
fn_call::Args args;
as_object* proto = ctor->constructInstance(fn.env(), args).get();
@@ -1289,9 +1289,9 @@
unsigned timer_arg = 1;
- boost::intrusive_ptr<as_object> obj =
fn.arg(0).to_object(getGlobal(fn));
- if ( ! obj )
- {
+ as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+ if (!obj) {
+
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
log_aserror("Invalid call to setInterval(%s) "
@@ -1301,12 +1301,12 @@
return as_value();
}
- std::string methodName;
+ string_table::key methodName(0);
// Get interval function
- boost::intrusive_ptr<as_function> as_func = obj->to_function();
+ as_function* as_func = obj->to_function();
if (!as_func) {
- methodName = fn.arg(1).to_string();
+ methodName = getStringTable(fn).find(fn.arg(1).to_string());
timer_arg = 2;
}
@@ -1327,20 +1327,19 @@
// TODO: check validity of interval time number ?
// Parse arguments
- Timer::ArgsContainer args;
- for (unsigned i=timer_arg+1; i<fn.nargs; ++i) {
- args.push_back(fn.arg(i));
+ fn_call::Args args;
+ for (unsigned i = timer_arg + 1; i < fn.nargs; ++i) {
+ args += fn.arg(i);
}
- std::auto_ptr<Timer> timer(new Timer);
+ std::auto_ptr<Timer> timer;
if (as_func) {
- timer->setInterval(*as_func, ms, fn.this_ptr, args);
+ timer.reset(new Timer(*as_func, ms, fn.this_ptr, args));
}
else {
- timer->setInterval(obj, methodName, ms, args);
+ timer.reset(new Timer(obj, methodName, ms, args));
}
-
movie_root& root = getRoot(fn);
int id = root.add_interval_timer(timer);
return as_value(id);
@@ -1362,7 +1361,7 @@
unsigned timer_arg = 1;
- boost::intrusive_ptr<as_object> obj =
fn.arg(0).to_object(getGlobal(fn));
+ as_object* obj = fn.arg(0).to_object(getGlobal(fn));
if (!obj) {
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
@@ -1373,12 +1372,12 @@
return as_value();
}
- std::string methodName;
+ string_table::key methodName(0);
// Get interval function
- boost::intrusive_ptr<as_function> as_func = obj->to_function();
+ as_function* as_func = obj->to_function();
if (!as_func) {
- methodName = fn.arg(1).to_string();
+ methodName = getStringTable(fn).find(fn.arg(1).to_string());
timer_arg = 2;
}
@@ -1397,20 +1396,19 @@
static_cast<unsigned long>(fn.arg(timer_arg).to_number());
// Parse arguments
- Timer::ArgsContainer args;
- for (unsigned i=timer_arg+1; i<fn.nargs; ++i) {
- args.push_back(fn.arg(i));
+ fn_call::Args args;
+ for (unsigned i = timer_arg + 1; i < fn.nargs; ++i) {
+ args += fn.arg(i);
}
- std::auto_ptr<Timer> timer(new Timer);
+ std::auto_ptr<Timer> timer;
if (as_func) {
- timer->setInterval(*as_func, ms, fn.this_ptr, args, true);
+ timer.reset(new Timer(*as_func, ms, fn.this_ptr, args, true));
}
else {
- timer->setInterval(obj, methodName, ms, args, true);
+ timer.reset(new Timer(obj, methodName, ms, args, true));
}
-
movie_root& root = getRoot(fn);
int id = root.add_interval_timer(timer);
@@ -1472,7 +1470,7 @@
throw ActionTypeError();
}
- as_function* ctor = clval.to_as_function();
+ as_function* ctor = clval.to_function();
// This is also not properly tested.
if (!ctor) throw ActionTypeError();
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/asobj/Object.cpp 2009-11-16 11:16:48 +0000
@@ -244,7 +244,7 @@
return as_value(false);
}
- as_function* getter = fn.arg(1).to_as_function();
+ as_function* getter = fn.arg(1).to_function();
if (!getter)
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -258,7 +258,7 @@
const as_value& setterval = fn.arg(2);
if (!setterval.is_null())
{
- setter = setterval.to_as_function();
+ setter = setterval.to_function();
if (!setter)
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -313,7 +313,7 @@
return as_value(false);
}
- as_function* theclass = fn.arg(1).to_as_function();
+ as_function* theclass = fn.arg(1).to_function();
if ( ! theclass )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -492,7 +492,7 @@
std::string propname = propval.to_string();
string_table::key propkey = st.find(propname);
- as_function* trig = funcval.to_as_function();
+ as_function* trig = funcval.to_function();
as_value cust; if ( fn.nargs > 2 ) cust = fn.arg(2);
return as_value(obj->watch(propkey, *trig, cust));
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp 2009-11-16 11:16:48
+0000
@@ -584,7 +584,7 @@
// If it's not found construction will fail.
as_value rectangle(fn.env().find_object("flash.geom.Rectangle"));
- boost::intrusive_ptr<as_function> rectCtor = rectangle.to_as_function();
+ boost::intrusive_ptr<as_function> rectCtor = rectangle.to_function();
if (!rectCtor) {
log_error("Failed to construct flash.geom.Rectangle!");
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2009-11-13 12:29:42
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2009-11-16 11:16:48
+0000
@@ -1224,7 +1224,7 @@
// If not found, construction fails.
as_value textSnapshot(fn.env().find_object("TextSnapshot"));
- boost::intrusive_ptr<as_function> tsCtor = textSnapshot.to_as_function();
+ boost::intrusive_ptr<as_function> tsCtor = textSnapshot.to_function();
if (!tsCtor) {
IF_VERBOSE_ASCODING_ERRORS(
@@ -2318,7 +2318,7 @@
// If not found, construction fails.
as_value transform(fn.env().find_object("flash.geom.Transform"));
- boost::intrusive_ptr<as_function> transCtor = transform.to_as_function();
+ boost::intrusive_ptr<as_function> transCtor = transform.to_function();
if (!transCtor) {
log_error("Failed to construct flash.geom.Transform!");
=== modified file 'libcore/asobj/flash/filters/BitmapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BitmapFilter_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/filters/BitmapFilter_as.cpp 2009-11-16 11:16:48
+0000
@@ -80,7 +80,7 @@
// it, so entering infinite recursion, we'll cheat and assume that
// the object 'where' is the filters package.
as_function* constructor =
- where.getMember(st.find("BitmapFilter")).to_as_function();
+ where.getMember(st.find("BitmapFilter")).to_function();
as_object* proto;
if (constructor) {
=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp 2009-11-16 11:16:48 +0000
@@ -159,7 +159,7 @@
as_value matrixClass(fn.env().find_object("flash.geom.Matrix"));
- as_function* ctor = matrixClass.to_as_function();
+ as_function* ctor = matrixClass.to_function();
if (!ctor) {
return as_value();
}
@@ -412,7 +412,7 @@
// Construct a Point and set its properties.
as_value pointClass(fn.env().find_object("flash.geom.Point"));
- boost::intrusive_ptr<as_function> pointCtor = pointClass.to_as_function();
+ boost::intrusive_ptr<as_function> pointCtor = pointClass.to_function();
if (!pointCtor) {
log_error("Failed to construct flash.geom.Point!");
@@ -728,7 +728,7 @@
// Construct a Point and set its properties.
as_value pointClass(fn.env().find_object("flash.geom.Point"));
- boost::intrusive_ptr<as_function> pointCtor = pointClass.to_as_function();
+ boost::intrusive_ptr<as_function> pointCtor = pointClass.to_function();
if (!pointCtor) {
log_error("Failed to construct flash.geom.Point!");
=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-11-16 11:16:48 +0000
@@ -421,7 +421,7 @@
as_value point(fn.env().find_object("flash.geom.Point"));
- boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
+ boost::intrusive_ptr<as_function> pointCtor = point.to_function();
if (!pointCtor) {
log_error("Failed to construct flash.geom.Point!");
=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-11-04 13:37:17 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-11-16 11:16:48 +0000
@@ -124,7 +124,7 @@
as_value colorTrans(fn.env().find_object("flash.geom.ColorTransform"));
boost::intrusive_ptr<as_function> colorTransformCtor =
- colorTrans.to_as_function();
+ colorTrans.to_function();
if (!colorTransformCtor) {
log_error("Failed to construct flash.geom.ColorTransform!");
@@ -235,7 +235,7 @@
// If it's not found, construction will fail.
as_value matrix(fn.env().find_object("flash.geom.Matrix"));
- boost::intrusive_ptr<as_function> matrixCtor = matrix.to_as_function();
+ boost::intrusive_ptr<as_function> matrixCtor = matrix.to_function();
if (!matrixCtor) {
log_error("Failed to construct flash.geom.Matrix!");
=== modified file 'libcore/asobj/flash/net/SharedObject_as.cpp'
--- a/libcore/asobj/flash/net/SharedObject_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/net/SharedObject_as.cpp 2009-11-16 12:34:46
+0000
@@ -27,7 +27,6 @@
#include "GnashFileUtilities.h" // stat
#include "SimpleBuffer.h"
#include "as_value.h"
-#include "action.h"
#include "amf.h"
#include "element.h"
#include "sol.h"
=== modified file 'libcore/asobj/flash/net/XMLSocket_as.cpp'
--- a/libcore/asobj/flash/net/XMLSocket_as.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/asobj/flash/net/XMLSocket_as.cpp 2009-11-16 11:16:48 +0000
@@ -352,7 +352,7 @@
as_value tmp;
string_table& st = getStringTable(owner());
if (!owner().get_member(st.find(name), &tmp) ) return ret;
- ret = tmp.to_as_function();
+ ret = tmp.to_function();
return ret;
}
@@ -541,7 +541,7 @@
Global_as& gl = getGlobal(fn);
- as_function* ctor = gl.getMember(NSV::CLASS_XML).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_XML).to_function();
fn_call::Args args;
args += xmlin;
=== modified file 'libcore/asobj/flash/ui/ContextMenuItem_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenuItem_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/ui/ContextMenuItem_as.cpp 2009-11-16 11:16:48
+0000
@@ -69,7 +69,7 @@
string_table& st = getStringTable(fn);
as_function* ctor =
- gl.getMember(st.find("ContextMenuItem")).to_as_function();
+ gl.getMember(st.find("ContextMenuItem")).to_function();
if (!ctor) return as_value();
=== modified file 'libcore/asobj/flash/ui/ContextMenu_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-11-13 12:29:42 +0000
+++ b/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-11-16 11:16:48 +0000
@@ -127,7 +127,7 @@
Global_as& gl = getGlobal(fn);
- as_function* ctor = gl.getMember(NSV::CLASS_CONTEXTMENU).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_CONTEXTMENU).to_function();
if (!ctor) {
return as_value();
}
=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp 2009-11-13 12:29:42
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp 2009-11-16 11:16:48
+0000
@@ -625,7 +625,7 @@
if ( o == NULL )
{
Global_as& gl = *VM::get().getGlobal();
- as_function* ctor = gl.getMember(NSV::CLASS_XMLNODE).to_as_function();
+ as_function* ctor = gl.getMember(NSV::CLASS_XMLNODE).to_function();
if (!ctor) return 0;
// XML.prototype is an XMLNode(1, "");
=== modified file 'libcore/asobj/flash/xml/XMLNode_as.h'
--- a/libcore/asobj/flash/xml/XMLNode_as.h 2009-08-27 06:01:23 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.h 2009-11-16 12:51:33 +0000
@@ -24,8 +24,8 @@
#include "gnashconfig.h"
#endif
+#include "as_object.h"
#include "smart_ptr.h" // GNASH_USE_GC
-#include "action.h"
#include "log.h"
#include <list>
=== renamed file 'libcore/vm/action.cpp' => 'libcore/event_id.cpp'
--- a/libcore/vm/action.cpp 2009-11-06 07:38:41 +0000
+++ b/libcore/event_id.cpp 2009-11-16 12:34:46 +0000
@@ -18,17 +18,8 @@
//
-#include "action.h"
-#include "as_object.h"
#include "log.h"
-#include "as_function.h"
-#include "SWF.h"
-#include "GnashException.h"
-#include "as_environment.h"
-#include "fn_call.h"
#include "event_id.h"
-#include "VM.h"
-#include "StringPredicates.h"
#include "namedStrings.h"
#include <string>
@@ -40,60 +31,6 @@
namespace gnash {
//
-// action stuff
-//
-
-//
-// Function/method dispatch.
-//
-
-/// @param this_ptr this is ourself.
-as_value
-call_method(const as_value& method, const as_environment& env,
- as_object* this_ptr, fn_call::Args& args, as_object* super,
- const movie_definition* callerDef)
-{
- as_value val;
- fn_call call(this_ptr, env, args);
- call.super = super;
- call.callerDef = callerDef;
-
- try
- {
- if ( as_function* as_func = method.to_as_function() )
- {
- // It's an ActionScript function. Call it.
- val = (*as_func)(call);
- }
- else
- {
- boost::format fmt = boost::format(_("Attempt to call a "
- "value which is neither a C nor an ActionScript "
- "function (%s)")) % method;
- throw ActionTypeError(fmt.str());
- }
- }
- catch (ActionTypeError& e)
- {
- assert(val.is_undefined());
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("%s", e.what());
- );
- }
-
- return val;
-}
-
-as_value
-call_method0(const as_value& method, const as_environment& env,
- as_object* this_ptr)
-{
- fn_call::Args args;
- return call_method(method, env, this_ptr, args);
-}
-
-
-//
// event_id
//
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-11-15 15:46:12 +0000
+++ b/libcore/movie_root.h 2009-11-16 08:55:32 +0000
@@ -743,7 +743,7 @@
return _lastKeyEvent;
}
- const std::bitset<key::KEYCOUNT>& unreleasedKeys() const {
+ const Keys& unreleasedKeys() const {
return _unreleasedKeys;
}
@@ -1088,7 +1088,7 @@
unsigned int _lastTimerId;
/// bit-array for recording the unreleased keys
- std::bitset<key::KEYCOUNT> _unreleasedKeys;
+ Keys _unreleasedKeys;
key::code _lastKeyEvent;
=== modified file 'libcore/swf/SWF.h'
--- a/libcore/swf/SWF.h 2009-06-15 11:32:49 +0000
+++ b/libcore/swf/SWF.h 2009-11-16 11:16:48 +0000
@@ -426,7 +426,7 @@
/// argument, call the method (function) of the object,
/// push the returned value on the stack.
///
- /// http://sswf.sourceforge.net/SWFalexref.html#action_call_method
+ /// http://sswf.sourceforge.net/SWFalexref.html#action_invoke
///
ACTION_CALLMETHOD = 0x52,
=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp 2009-07-13 08:06:09 +0000
+++ b/libcore/swf/tag_loaders.cpp 2009-11-16 12:34:46 +0000
@@ -24,7 +24,6 @@
#include "IOChannel.h" // for StreamAdapter inheritance
#include "utility.h"
-#include "action.h"
#include "action_buffer.h"
#include "Font.h"
#include "log.h"
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-11-15 15:46:12 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-11-16 12:42:06 +0000
@@ -49,6 +49,8 @@
#include "GnashNumeric.h"
#include "Global_as.h"
#include "DisplayObject.h"
+#include "as_environment.h"
+#include "as_value.h"
#include <string>
#include <vector>
@@ -80,12 +82,24 @@
as_object* construct_object(as_function* ctor_as_func, as_environment& env,
unsigned int nargs);
as_object* convertToObject(Global_as& gl, const as_value& val);
+
+ /// Common code for ActionGetUrl and ActionGetUrl2
+ //
+ /// @see http://sswf.sourceforge.net/SWFalexref.html#action_get_url2
+ /// @see http://sswf.sourceforge.net/SWFalexref.html#action_get_url
+ ///
+ /// @param target
+ /// the target window or _level1 to _level10
+ ///
+ /// @param method
+ /// 0:NONE, 1:GET, 2:POST
+ ///
+ void commonGetURL(as_environment& env, as_value target,
+ const std::string& url, boost::uint8_t method);
}
namespace SWF { // gnash::SWF
-
-
static void unsupported_action_handler(ActionExec& thread)
{
log_error(_("Unsupported action handler invoked, code at pc is %#x"),
@@ -541,14 +555,14 @@
// Will abort if code.read_string returns 0, but action
// buffer should always have a null terminator at the
- // end. This replaces an assertion in CommonGetUrl.
+ // end. This replaces an assertion in commonGetURL.
const std::string target(code.read_string(pc + 3 + urlLength));
IF_VERBOSE_ACTION (
log_action(_("GetUrl: target=%s url=%s"), target, url);
);
- CommonGetUrl(env, target, url, 0u);
+ commonGetURL(env, target, url, 0u);
}
void
@@ -1313,7 +1327,7 @@
as_object* instance = convertToObject(getGlobal(thread.env), env.top(0));
// Get the "super" function
- as_function* super = env.top(1).to_as_function();
+ as_function* super = env.top(1).to_function();
// Invalid args!
if (!super || ! instance)
@@ -2070,209 +2084,6 @@
// @@ TODO range checks
}
-// Common code for GetUrl and GetUrl2. See:
-// http://sswf.sourceforge.net/SWFalexref.html#action_get_url
-// http://sswf.sourceforge.net/SWFalexref.html#action_get_url2
-//
-// Testcases:
-//
-// - http://www.garfield.com/comics/comics_todays.html
-// lower_todayscomic.swf should render four flash files in its canvas
-//
-// - http://www.voiptalk.org
-// pressing 'My Account' button should open
-// https://www.voiptalk.org/products/login.php
-// NOTE: this is affected by the GetUrl bug reported with an excerpt
-// from Colin Moock book, see below. (won't work, and won't fix)
-//
-// - http://www.uptoten.com
-// Should load in _level0, with loadTargetFlag set.
-//
-// Method isbBit-packed as follows:
-// SendVarsMethod:2 (0:NONE 1:GET 2:POST)
-// Reserved:4
-// LoadTargetFlag:1
-// LoadVariableFlag:1
-/// @param target the target window, or _level1..10
-void
-SWFHandlers::CommonGetUrl(as_environment& env, as_value target,
- const std::string& url, boost::uint8_t method)
-{
-
- if (url.empty()) {
- log_error(_("Bogus empty GetUrl url in SWF file, skipping"));
- return;
- }
-
- // Parse the method bitfield
- bool loadTargetFlag = method & 64;
- bool loadVariableFlag = method & 128;
-
- MovieClip::VariablesMethod sendVarsMethod;
-
- // handle malformed sendVarsMethod
- if ((method & 3) == 3) {
- log_error(_("Bogus GetUrl2 send vars method "
- " in SWF file (both GET and POST requested). Using GET"));
- sendVarsMethod = MovieClip::METHOD_GET;
- }
- else sendVarsMethod =
- static_cast<MovieClip::VariablesMethod>(method & 3);
-
- std::string target_string;
- if (!target.is_undefined() && !target.is_null()) {
- target_string = target.to_string();
- }
-
- VM& vm = getVM(env);
- movie_root& m = vm.getRoot();
-
- // If the url starts with "FSCommand:", then this is
- // a message for the host app.
- StringNoCaseEqual noCaseCompare;
- if (noCaseCompare(url.substr(0, 10), "FSCommand:"))
- {
- m.handleFsCommand(url.substr(10), target_string);
- return;
- }
-
- // If the url starts with "print:", then this is
- // a print request.
- if (noCaseCompare(url.substr(0, 6), "print:"))
- {
- log_unimpl("print: URL");
- return;
- }
-
- //
- // From "ActionScript: The Definitive Guide" by Colin Moock p. 470
- // --------8<------------------------------------------------------
- // In most browsers, getURL() relative links are resolved relative
- // to the HTML file that contains the .swf file. In IE 4.5 and older
- // versions on Macintosh, relative links are resolved relative to
- // the location of the .swf file, not the HTML file, which causes
- // problems when the two are in different directories. To avoid
- // the problem, either place the .swf and the .html file in the
- // same directory or use absolute URLs when invoking getURL().
- // --------8<------------------------------------------------------
- //
- // We'll resolve relative to our "base url".
- // The base url must be set with the set_base_url() command.
- //
-
- log_debug(_("get url: target=%s, url=%s, method=%x "
- "(sendVars:%X, loadTarget:%d, loadVariable:%d)"),
- target_string, url, static_cast<int>(method),
- sendVarsMethod, loadTargetFlag, loadVariableFlag);
-
- DisplayObject* target_ch = env.find_target(target.to_string());
- MovieClip* target_movie = target_ch ? target_ch->to_movie() : 0;
-
- if (loadVariableFlag)
- {
- log_debug(_("getURL2 loadVariable"));
-
- if (!target_ch)
- {
- log_error(_("getURL: target %s not found"), target_string);
- // might want to invoke the external url opener here...
- return;
- }
-
- if (!target_movie)
- {
- log_error(_("getURL: target %s is not a sprite"), target_string);
- // might want to invoke the external url opener here...
- return;
- }
-
- target_movie->loadVariables(url, sendVarsMethod);
-
- return;
- }
-
- std::string varsToSend;
- if (sendVarsMethod != MovieClip::METHOD_NONE)
- {
-
- // TESTED: variables sent are those in current target,
- // no matter the target found on stack (which
- // is the target to load the resource into).
- //
- as_object* curtgt = getObject(env.get_target());
- if (!curtgt) {
- log_error(_("CommonGetUrl: current target is undefined"));
- return;
- }
- getURLEncodedVars(*curtgt, varsToSend);
- }
-
-
- if ( loadTargetFlag )
- {
- log_debug(_("getURL2 target load"));
-
- if (!target_ch)
- {
- unsigned int levelno;
- if (isLevelTarget(getSWFVersion(env), target_string, levelno))
- {
- log_debug(_("Testing _level loading (level %u)"), levelno);
-
- m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
- return;
- }
-
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Unknown loadMovie target: %s"),
- target_string);
- );
-
- // TESTED: Even if the target is created right-after
- // the load request, the player won't load
- // into it. In other words, the target MUST
- // exist at time of interpreting the GETURL2
- // tag with loadTarget flag.
-
- return;
- }
-
- if (!target_movie)
- {
- log_error(_("get url: target %s is not a sprite"), target_string);
- return;
- }
-
- std::string s = target_movie->getTarget(); // or getOrigTarget ?
- if (s != target_movie->getOrigTarget())
- {
- log_debug(_("TESTME: target of a loadMovie changed its target "
- "path"));
- }
-
- // TODO: try to trigger this !
- assert(m.findCharacterByTarget(s) == target_movie );
-
- m.loadMovie(url, s, varsToSend, sendVarsMethod);
- return;
- }
-
- unsigned int levelno;
- if (isLevelTarget(getSWFVersion(env), target_string, levelno))
- {
- log_debug(_("Testing _level loading (level %u)"), levelno);
- m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
- return;
- }
-
- // Just plain getURL
- // This should be the original URL string, as the hosting application
- // will decide how to resolve the URL. If there is no hosting
- // application, movie_root::getURL will resolve the URL.
- m.getURL(url, target_string, varsToSend, sendVarsMethod);
-
-}
-
// Common code for SetTarget and SetTargetExpression. See:
// http://sswf.sourceforge.net/SWFalexref.html#action_set_target
// http://sswf.sourceforge.net/SWFalexref.html#action_get_dynamic
@@ -2324,7 +2135,7 @@
}
else {
const std::string& url = url_val.to_string();
- CommonGetUrl(env, env.top(0), url, method);
+ commonGetURL(env, env.top(0), url, method);
}
env.drop(2);
@@ -2646,12 +2457,12 @@
)
}
}
- else if ( function.to_as_function()->isSuper() )
+ else if ( function.to_function()->isSuper() )
{
this_ptr = thread.getThisPointer();
// the new 'super' will be computed from the old one
- as_function* oldSuper = function.to_as_function();
+ as_function* oldSuper = function.to_function();
super = oldSuper->get_super();
}
@@ -2678,7 +2489,7 @@
args += env.pop();
}
- as_value result = call_method(function, env, this_ptr,
+ as_value result = invoke(function, env, this_ptr,
args, super, &(thread.code.getMovieDefinition()));
env.push(result);
@@ -2744,7 +2555,7 @@
unsigned nargs = unsigned(env.pop().to_number());
as_value constructorval = thread.getVariable(classname);
- boost::intrusive_ptr<as_function> constructor =
constructorval.to_as_function();
+ boost::intrusive_ptr<as_function> constructor =
constructorval.to_function();
if ( ! constructor )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -3128,7 +2939,7 @@
// Get number of args, modifying it if not enough values are on the stack.
unsigned nargs = unsigned(env.pop().to_number());
unsigned available_args = env.stack_size();
- if ( available_args < nargs )
+ if (available_args < nargs)
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("Attempt to call a method with %u arguments "
@@ -3150,7 +2961,7 @@
bool hasMethodName = ((!method_name.is_undefined()) &&
(!method_string.empty()) );
- boost::intrusive_ptr<as_object> obj =
convertToObject(getGlobal(thread.env), obj_value);
+ as_object* obj = convertToObject(getGlobal(thread.env), obj_value);
if (!obj) {
// SWF integrity check
IF_VERBOSE_ASCODING_ERRORS(
@@ -3162,13 +2973,15 @@
return;
}
- as_object* this_ptr = obj.get();
+ as_object* this_ptr = obj;
- if ( obj->isSuper() )
- {
- if ( thread.isFunction() ) this_ptr = thread.getThisPointer();
+ if (obj->isSuper()) {
+ if (thread.isFunction()) this_ptr = thread.getThisPointer();
}
- as_object* super = obj->get_super(hasMethodName ? method_string.c_str() :
0);
+
+ string_table& st = getStringTable(env);
+ as_object* super =
+ obj->get_super(hasMethodName ? st.find(method_string) : 0);
as_value method_val;
@@ -3246,7 +3059,7 @@
args += env.pop();
}
- as_value result = call_method(method_val, env, this_ptr,
+ as_value result = invoke(method_val, env, this_ptr,
args, super, &(thread.code.getMovieDefinition()));
env.push(result);
@@ -3311,7 +3124,7 @@
}
}
- boost::intrusive_ptr<as_function> method = method_val.to_as_function();
+ boost::intrusive_ptr<as_function> method = method_val.to_function();
if (!method) {
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("ActionNewMethod: method name is undefined "
@@ -3523,8 +3336,8 @@
as_environment& env = thread.env;
- as_function* super = env.top(0).to_as_function();
- as_function* sub = env.top(1).to_as_function();
+ as_function* super = env.top(0).to_function();
+ as_function* sub = env.top(1).to_function();
if ( ! super || ! sub )
{
@@ -3965,6 +3778,209 @@
return ctor_as_func->constructInstance(env, args).get();
}
+// Common code for GetUrl and GetUrl2. See:
+// http://sswf.sourceforge.net/SWFalexref.html#action_get_url
+// http://sswf.sourceforge.net/SWFalexref.html#action_get_url2
+//
+// Testcases:
+//
+// - http://www.garfield.com/comics/comics_todays.html
+// lower_todayscomic.swf should render four flash files in its canvas
+//
+// - http://www.voiptalk.org
+// pressing 'My Account' button should open
+// https://www.voiptalk.org/products/login.php
+// NOTE: this is affected by the GetUrl bug reported with an excerpt
+// from Colin Moock book, see below. (won't work, and won't fix)
+//
+// - http://www.uptoten.com
+// Should load in _level0, with loadTargetFlag set.
+//
+// Method isbBit-packed as follows:
+// SendVarsMethod:2 (0:NONE 1:GET 2:POST)
+// Reserved:4
+// LoadTargetFlag:1
+// LoadVariableFlag:1
+/// @param target the target window, or _level1..10
+void
+commonGetURL(as_environment& env, as_value target,
+ const std::string& url, boost::uint8_t method)
+{
+
+ if (url.empty()) {
+ log_error(_("Bogus empty GetUrl url in SWF file, skipping"));
+ return;
+ }
+
+ // Parse the method bitfield
+ bool loadTargetFlag = method & 64;
+ bool loadVariableFlag = method & 128;
+
+ MovieClip::VariablesMethod sendVarsMethod;
+
+ // handle malformed sendVarsMethod
+ if ((method & 3) == 3) {
+ log_error(_("Bogus GetUrl2 send vars method "
+ " in SWF file (both GET and POST requested). Using GET"));
+ sendVarsMethod = MovieClip::METHOD_GET;
+ }
+ else sendVarsMethod =
+ static_cast<MovieClip::VariablesMethod>(method & 3);
+
+ std::string target_string;
+ if (!target.is_undefined() && !target.is_null()) {
+ target_string = target.to_string();
+ }
+
+ VM& vm = getVM(env);
+ movie_root& m = vm.getRoot();
+
+ // If the url starts with "FSCommand:", then this is
+ // a message for the host app.
+ StringNoCaseEqual noCaseCompare;
+ if (noCaseCompare(url.substr(0, 10), "FSCommand:"))
+ {
+ m.handleFsCommand(url.substr(10), target_string);
+ return;
+ }
+
+ // If the url starts with "print:", then this is
+ // a print request.
+ if (noCaseCompare(url.substr(0, 6), "print:"))
+ {
+ log_unimpl("print: URL");
+ return;
+ }
+
+ //
+ // From "ActionScript: The Definitive Guide" by Colin Moock p. 470
+ // --------8<------------------------------------------------------
+ // In most browsers, getURL() relative links are resolved relative
+ // to the HTML file that contains the .swf file. In IE 4.5 and older
+ // versions on Macintosh, relative links are resolved relative to
+ // the location of the .swf file, not the HTML file, which causes
+ // problems when the two are in different directories. To avoid
+ // the problem, either place the .swf and the .html file in the
+ // same directory or use absolute URLs when invoking getURL().
+ // --------8<------------------------------------------------------
+ //
+ // We'll resolve relative to our "base url".
+ // The base url must be set with the set_base_url() command.
+ //
+
+ log_debug(_("get url: target=%s, url=%s, method=%x "
+ "(sendVars:%X, loadTarget:%d, loadVariable:%d)"),
+ target_string, url, static_cast<int>(method),
+ sendVarsMethod, loadTargetFlag, loadVariableFlag);
+
+ DisplayObject* target_ch = env.find_target(target.to_string());
+ MovieClip* target_movie = target_ch ? target_ch->to_movie() : 0;
+
+ if (loadVariableFlag)
+ {
+ log_debug(_("getURL2 loadVariable"));
+
+ if (!target_ch)
+ {
+ log_error(_("getURL: target %s not found"), target_string);
+ // might want to invoke the external url opener here...
+ return;
+ }
+
+ if (!target_movie)
+ {
+ log_error(_("getURL: target %s is not a sprite"), target_string);
+ // might want to invoke the external url opener here...
+ return;
+ }
+
+ target_movie->loadVariables(url, sendVarsMethod);
+
+ return;
+ }
+
+ std::string varsToSend;
+ if (sendVarsMethod != MovieClip::METHOD_NONE)
+ {
+
+ // TESTED: variables sent are those in current target,
+ // no matter the target found on stack (which
+ // is the target to load the resource into).
+ //
+ as_object* curtgt = getObject(env.get_target());
+ if (!curtgt) {
+ log_error(_("commonGetURL: current target is undefined"));
+ return;
+ }
+ getURLEncodedVars(*curtgt, varsToSend);
+ }
+
+
+ if ( loadTargetFlag )
+ {
+ log_debug(_("getURL2 target load"));
+
+ if (!target_ch)
+ {
+ unsigned int levelno;
+ if (isLevelTarget(getSWFVersion(env), target_string, levelno))
+ {
+ log_debug(_("Testing _level loading (level %u)"), levelno);
+
+ m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
+ return;
+ }
+
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Unknown loadMovie target: %s"),
+ target_string);
+ );
+
+ // TESTED: Even if the target is created right-after
+ // the load request, the player won't load
+ // into it. In other words, the target MUST
+ // exist at time of interpreting the GETURL2
+ // tag with loadTarget flag.
+
+ return;
+ }
+
+ if (!target_movie)
+ {
+ log_error(_("get url: target %s is not a sprite"), target_string);
+ return;
+ }
+
+ std::string s = target_movie->getTarget(); // or getOrigTarget ?
+ if (s != target_movie->getOrigTarget())
+ {
+ log_debug(_("TESTME: target of a loadMovie changed its target "
+ "path"));
+ }
+
+ // TODO: try to trigger this !
+ assert(m.findCharacterByTarget(s) == target_movie );
+
+ m.loadMovie(url, s, varsToSend, sendVarsMethod);
+ return;
+ }
+
+ unsigned int levelno;
+ if (isLevelTarget(getSWFVersion(env), target_string, levelno))
+ {
+ log_debug(_("Testing _level loading (level %u)"), levelno);
+ m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
+ return;
+ }
+
+ // Just plain getURL
+ // This should be the original URL string, as the hosting application
+ // will decide how to resolve the URL. If there is no hosting
+ // application, movie_root::getURL will resolve the URL.
+ m.getURL(url, target_string, varsToSend, sendVarsMethod);
+
+}
+
}
=== modified file 'libcore/vm/ASHandlers.h'
--- a/libcore/vm/ASHandlers.h 2009-06-15 11:32:49 +0000
+++ b/libcore/vm/ASHandlers.h 2009-11-16 12:42:06 +0000
@@ -20,13 +20,13 @@
#include <string>
#include <map>
#include <vector>
-#include "action.h" // we should get rid of this probably
#include "SWF.h"
// Forward declarations
namespace gnash {
- class ActionExec;
+ class ActionExec;
+ class as_environment;
}
namespace gnash {
@@ -121,21 +121,6 @@
static container_type & get_handlers();
- /// Common code for ActionGetUrl and ActionGetUrl2
- //
- /// @see http://sswf.sourceforge.net/SWFalexref.html#action_get_url2
- /// @see http://sswf.sourceforge.net/SWFalexref.html#action_get_url
- ///
- /// @param target
- /// the target window or _level1 to _level10
- ///
- /// @param method
- /// 0:NONE, 1:GET, 2:POST
- ///
- static void CommonGetUrl(as_environment& env,
- as_value target, const std::string& url,
- boost::uint8_t method);
-
/// Common code for SetTarget and SetTargetExpression
//
/// @see http://sswf.sourceforge.net/SWFalexref.html#action_set_target
=== modified file 'libcore/vm/ExecutableCode.h'
--- a/libcore/vm/ExecutableCode.h 2009-11-13 12:29:42 +0000
+++ b/libcore/vm/ExecutableCode.h 2009-11-16 12:17:00 +0000
@@ -26,6 +26,7 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "as_function.h"
#include "ActionExec.h"
+#include "Global_as.h"
#include "fn_call.h"
namespace gnash
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2009-11-15 16:26:27 +0000
+++ b/libcore/vm/Machine.cpp 2009-11-16 12:34:46 +0000
@@ -25,7 +25,6 @@
#include "MultiName.h"
#include "fn_call.h"
#include "abc_function.h"
-#include "action.h"
#include "Object.h"
#include "VM.h"
#include "Globals.h"
@@ -1249,7 +1248,7 @@
boost::uint32_t argc = mStream->read_V32();
ENSURE_OBJECT(_stack.top(argc + 1)); // The func
ENSURE_OBJECT(_stack.top(argc)); // The 'this'
- as_function *f = _stack.top(argc + 1).to_as_function();
+ as_function *f = _stack.top(argc + 1).to_function();
as_object *obj = _stack.top(argc).to_object(*_global);
// We start with argc + 2 values related to this call
// on the stack. We want to end with 1 value. We pass
@@ -1274,7 +1273,7 @@
case SWF::ABC_ACTION_CONSTRUCT:
{
boost::uint32_t argc = mStream->read_V32();
- as_function *f = _stack.top(argc).to_as_function();
+ as_function *f = _stack.top(argc).to_function();
if (!f) {
log_abc("CONSTRUCT: No function on stack!");
break;
@@ -1309,7 +1308,7 @@
else
#endif
if (f->getValue(*obj).is_function())
- func = f->getValue(*obj).to_as_function();
+ func = f->getValue(*obj).to_function();
else
{
// Definitely an error, and not the kind we can handle.
@@ -1369,7 +1368,7 @@
if (!b) throw ASReferenceError();
as_function *f = // b->isGetterSetter() ? b->getGetter() :
- b->getValue(*super).to_as_function();
+ b->getValue(*super).to_function();
if (opcode == SWF::ABC_ACTION_CALLSUPER) {
pushCall(f, super, _stack.top(argc), argc, 0);
@@ -1431,7 +1430,7 @@
log_abc("Calling method %s on object %s",
property, object_val);
as_environment env = as_environment(_vm);
- result = call_method(property,env,object,args);
+ result = invoke(property,env,object,args);
}
else {
@@ -1474,7 +1473,7 @@
#endif
}
//else
- func = b->getValue(obj).to_as_function();
+ func = b->getValue(obj).to_function();
if (opcode == SWF::ABC_ACTION_CALLPROPVOID)
pushCall(func, obj, mIgnoreReturn, argc, -shift - 1);
@@ -1538,7 +1537,7 @@
}
as_value c = super->getMember(NSV::PROP_CONSTRUCTOR, 0);
- pushCall(c.to_as_function(), super, mIgnoreReturn,
+ pushCall(c.to_function(), super, mIgnoreReturn,
argc, -1);
break;
@@ -1586,7 +1585,7 @@
// TODO: don't do this. Classes should not be functions;
// we should always use the constructor member, most
// likely.
- boost::intrusive_ptr<as_function> ctor =
c.to_as_function();
+ boost::intrusive_ptr<as_function> ctor = c.to_function();
if (ctor) {
boost::intrusive_ptr<as_object> newobj =
@@ -1609,7 +1608,7 @@
as_value val = c.to_object(*_global)->getMember(
NSV::PROP_CONSTRUCTOR, 0);
- call_method(val, env, c.to_object(*_global), args);
+ invoke(val, env, c.to_object(*_global), args);
// Push the constructed property
push_stack(c);
@@ -1734,7 +1733,7 @@
NSV::PROP_uuCONSTRUCTORuu, 0);
fn_call::Args args;
- as_value value = call_method(property, env, new_class,
+ as_value value = invoke(property, env, new_class,
args);
log_abc("NEWCLASS(%2%) finished. Return: %1%", value,
=== modified file 'libcore/vm/Makefile.am'
--- a/libcore/vm/Makefile.am 2009-11-13 08:19:10 +0000
+++ b/libcore/vm/Makefile.am 2009-11-16 12:29:31 +0000
@@ -43,7 +43,6 @@
ASHandlers.cpp \
ActionExec.cpp \
VM.cpp \
- action.cpp \
CallStack.cpp \
$(NULL)
@@ -60,7 +59,6 @@
MultiName.h \
ActionExec.h \
ExecutableCode.h \
- action.h \
with_stack_entry.h \
$(NULL)
=== removed file 'libcore/vm/action.h'
--- a/libcore/vm/action.h 2009-08-20 06:55:15 +0000
+++ b/libcore/vm/action.h 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009 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 3 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
-
-// Implementation and helpers for SWF actions.
-
-
-#ifndef GNASH_ACTION_H
-#define GNASH_ACTION_H
-
-#include "dsodefs.h" // for DSOEXPORT
-
-#include "as_object.h"
-#include "smart_ptr.h"
-#include "fn_call.h"
-
-#include <vector>
-#include <memory>
-
-namespace gnash {
- class as_environment;
- class as_object;
- class as_value;
- class movie_definition;
-
- //
- // Some handy helpers
- //
-
- // Dispatching methods from C++.
- as_value call_method0(const as_value& method,
- const as_environment& env, as_object* this_ptr);
-
- /// Call a method, be it an as_function or a c_function.
- //
- /// This is a thin wrapper around operator() and fn_call,
- /// probably worth dropping.
- ///
- DSOEXPORT as_value call_method(const as_value& method,
- const as_environment& env,
- // this is ourself
- as_object* this_ptr,
- fn_call::Args& args,
- // the super object
- as_object* super=0,
- // the movie_definition containing caller code
- // or 0 for spontaneous calls
- const movie_definition* callerDef=0);
-
-
-} // end namespace gnash
-
-
-#endif // GNASH_ACTION_H
-
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h 2009-10-26 15:30:50 +0000
+++ b/libcore/vm/fn_call.h 2009-11-16 10:40:56 +0000
@@ -22,21 +22,21 @@
#include "gnashconfig.h"
#endif
-#include "as_environment.h" // for inlines (arg)
-#include "as_object.h" // for dtor visibility by boost::intrusive_ptr
+#include "as_environment.h"
+#include "as_object.h"
#include "smart_ptr.h"
+#include "as_value.h"
#include "VM.h"
-#include <cassert> // for inlines (arg)
-#include <ostream> // for inlines (dump_args)
-#include <sstream> // for inlines (dump_args)
+#include <cassert>
+#include <ostream>
+#include <sstream>
+#include <algorithm>
// Forward declarations
namespace gnash {
class as_environment;
class as_function;
- class as_object;
- class as_value;
class movie_definition;
}
@@ -65,6 +65,12 @@
FunctionArgs() {}
+ /// The copy constructor copies all the arguments.
+ FunctionArgs(const FunctionArgs& other)
+ :
+ _v(other._v)
+ {}
+
FunctionArgs& operator+=(const T& t) {
_v.push_back(t);
return *this;
@@ -75,6 +81,15 @@
return *this;
}
+ /// Mark any reachable resources
+ //
+ /// This is only for cases where the lifetime of a FunctionArgs object
+ /// extends beyond a function call.
+ void setReachable() const {
+ std::for_each(_v.begin(), _v.end(),
+ std::mem_fun_ref(&as_value::setReachable));
+ }
+
void swap(std::vector<T>& to) {
std::swap(_v, to);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11627: Move functions around, drop obsolete files.,
Benjamin Wolsey <=