Gnash
0.8.11dev
|
A simple SWF-defined Function. More...
#include <Function.h>
Classes | |
struct | Argument |
Public Types | |
typedef std::vector< as_object * > | ScopeStack |
Public Member Functions | |
Function (const action_buffer &ab, as_environment &env, size_t start, const ScopeStack &with_stack) | |
Create an ActionScript function as defined in an action_buffer starting at offset 'start'. More... | |
virtual | ~Function () |
const ScopeStack & | getScopeStack () const |
const action_buffer & | getActionBuffer () const |
size_t | getStartPC () const |
size_t | getLength () const |
virtual boost::uint8_t | registers () const |
Get the number of registers required for function execution. More... | |
void | add_arg (boost::uint8_t reg, const ObjectURI &name) |
Add an expected argument for the function. More... | |
void | setLength (size_t len) |
Set the length in bytes of the function code. More... | |
virtual as_value | call (const fn_call &fn) |
Dispatch. More... | |
virtual void | markReachableResources () const |
Mark reachable resources. Override from as_object. More... | |
![]() | |
virtual | ~as_function () |
Destructor. More... | |
virtual as_function * | to_function () |
Return this as_object as an as_function. More... | |
virtual std::string | stringValue () const |
Return the string value of this as_object subclass. More... | |
as_object * | construct (as_object &newobj, const as_environment &env, FunctionArgs< as_value > &args) |
Run this function as a constructor on an object. More... | |
virtual bool | isBuiltin () |
Return true if this is a built-in class. More... | |
![]() | |
DSOTEXPORT | as_object (const Global_as &global) |
Construct an ActionScript object with no prototype associated. More... | |
virtual | ~as_object () |
The as_object dtor does nothing special. More... | |
Property * | findProperty (const ObjectURI &uri, as_object **owner=0) |
Find a property, scanning the inheritance chain. More... | |
VM & | vm () const |
Return a reference to this as_object's global object. More... | |
void | dump_members () |
Dump all properties using log_debug. More... | |
virtual bool | set_member (const ObjectURI &uri, const as_value &val, bool ifFound=false) |
Set a member value. More... | |
void | init_member (const std::string &name, const as_value &val, int flags=DefaultFlags) |
Initialize a member value by string. More... | |
void | init_member (const ObjectURI &uri, const as_value &val, int flags=DefaultFlags) |
Initialize a member value by key. More... | |
void | init_property (const std::string &key, as_function &getter, as_function &setter, int flags=DefaultFlags) |
Initialize a getter/setter property by name. More... | |
void | init_property (const std::string &key, as_c_function_ptr getter, as_c_function_ptr setter, int flags=DefaultFlags) |
Initialize a getter/setter property by name. More... | |
void | init_property (const ObjectURI &uri, as_function &getter, as_function &setter, int flags=DefaultFlags) |
Initialize a getter/setter property by key. More... | |
void | init_property (const ObjectURI &uri, as_c_function_ptr getter, as_c_function_ptr setter, int flags=DefaultFlags) |
Initialize a getter/setter property by key. More... | |
bool | init_destructive_property (const ObjectURI &uri, as_function &getter, int flags=PropFlags::dontEnum) |
Initialize a destructive getter property. More... | |
bool | init_destructive_property (const ObjectURI &uri, as_c_function_ptr getter, int flags=PropFlags::dontEnum) |
Initialize a destructive getter property. More... | |
void | init_readonly_property (const std::string &key, as_function &getter, int flags=DefaultFlags) |
Use this method for read-only properties. More... | |
void | init_readonly_property (const std::string &key, as_c_function_ptr getter, int flags=DefaultFlags) |
Use this method for read-only properties. More... | |
bool | watch (const ObjectURI &uri, as_function &trig, const as_value &cust) |
Add a watch trigger, overriding any other defined for same name. More... | |
bool | unwatch (const ObjectURI &uri) |
Remove a watch trigger. More... | |
virtual bool | get_member (const ObjectURI &uri, as_value *val) |
Get a property by name if it exists. More... | |
virtual as_object * | get_super (const ObjectURI &fname) |
as_object * | get_super () |
DSOTEXPORT std::pair< bool, bool > | delProperty (const ObjectURI &uri) |
Delete a property of this object, unless protected from deletion. More... | |
Property * | getOwnProperty (const ObjectURI &uri) |
Get this object's own named property, if existing. More... | |
void | set_member_flags (const ObjectURI &uri, int setTrue, int setFalse=0) |
Set member flags (probably used by ASSetPropFlags) More... | |
virtual bool | isSuper () const |
Return true if this is a 'super' object. More... | |
void | addInterface (as_object *ctor) |
Add an interface to the list of interfaces. More... | |
bool | instanceOf (as_object *ctor) |
Check whether this object is an instance of the given constructor. More... | |
bool | prototypeOf (as_object &instance) |
Check whether this object is in another object's inheritance chain. More... | |
void | setPropFlags (const as_value &props, int set_false, int set_true) |
Set property flags. More... | |
void | copyProperties (const as_object &o) |
Copy properties from the given object. More... | |
void | clearProperties () |
Drop all properties from this object. More... | |
template<typename T > | |
void | visitProperties (PropertyVisitor &visitor) const |
Visit the properties of this object by key/as_value pairs. More... | |
void | visitKeys (KeyVisitor &visitor) const |
Visit all visible property identifiers. More... | |
void | add_property (const std::string &key, as_function &getter, as_function *setter) |
Add a getter/setter property if no member already has that name. More... | |
as_object * | get_prototype () const |
Return this object's proto member. More... | |
void | set_prototype (const as_value &proto) |
Set this object's proto member. More... | |
void | setRelay (Relay *p) |
Set the as_object's Relay object. More... | |
Relay * | relay () const |
Access the as_object's Relay object. More... | |
bool | array () const |
Return true if this object should be treated as an array. More... | |
void | setArray (bool array=true) |
Set whether this object should be treated as an array. More... | |
DisplayObject * | displayObject () const |
Return the DisplayObject associated with this object. More... | |
void | setDisplayObject (DisplayObject *d) |
Set the DisplayObject associated with this as_object. More... | |
![]() | |
GcResource (GC &gc) | |
Create a Garbage-collected resource associated with a GC. More... | |
void | setReachable () const |
Mark this resource as being reachable. More... | |
bool | isReachable () const |
Return true if this object is marked as reachable. More... | |
void | clearReachable () const |
Clear the reachable flag. More... | |
Protected Attributes | |
std::vector< Argument > | _args |
as_environment & | _env |
@ might need some kind of ref count here, but beware cycles More... | |
const ConstantPool * | _pool |
The ConstantPool in effect at time of function definition. More... | |
Additional Inherited Members | |
![]() | |
static const int | DefaultFlags |
The most common flags for built-in properties. More... | |
![]() | |
UserFunction (Global_as &gl) | |
virtual | ~UserFunction ()=0 |
This is an abstract base class! More... | |
![]() | |
as_function (Global_as &gl) | |
Construct a function. More... | |
![]() | |
as_object (VM &vm) | |
Construct an as_object associated with a VM. More... | |
![]() | |
virtual | ~GcResource () |
Delete this resource. More... | |
A simple SWF-defined Function.
This represents a callable Function defined in a SWF. The basic version creates a scope in which 'arguments' array, 'this', 'super', and the expected argument names are defined. For a more advanced function, see Function2.
typedef std::vector<as_object*> gnash::Function::ScopeStack |
gnash::Function::Function | ( | const action_buffer & | ab, |
as_environment & | env, | ||
size_t | start, | ||
const ScopeStack & | with_stack | ||
) |
Create an ActionScript function as defined in an action_buffer starting at offset 'start'.
References gnash::action_buffer::size().
|
inlinevirtual |
Add an expected argument for the function.
For ordinary Functions the register is disregarded. This is only relevant for Function2s. All argument names are declared as variables in the function scope, whether the argument is passed or not.
reg | The register for the argument. |
name | The name of the argument. |
References _args.
Dispatch.
This is only needed for SWF5 (temp switch of target) We do always and base 'target' value on SWF version. TODO: simplify code by maybe using a custom as_environment instead, so to get an "original" target being the one set now (rather then the really original one) TODO: test scope when calling functions defined in another timeline (target, in particular).
Implements gnash::as_function.
Reimplemented in gnash::Function2.
References _args, _env, _pool, gnash::fn_call::arg(), gnash::FrameGuard::callFrame(), gnash::VM::calling(), gnash::Global_as::createArray(), gnash::VM::currentCall(), gnash::declareLocal(), gnash::CallFrame::function(), gnash::as_environment::get_original_target(), gnash::as_object::get_super(), gnash::getArguments(), gnash::getGlobal(), gnash::getSWFVersion(), gnash::getVM(), gnash::key::i, gnash::key::n, name, gnash::fn_call::nargs, gnash::NSV::PROP_ARGUMENTS, gnash::NSV::PROP_SUPER, gnash::NSV::PROP_THIS, gnash::setLocal(), gnash::fn_call::super, gnash::as_environment::target(), gnash::fn_call::this_ptr, and gnash::as_object::vm().
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Mark reachable resources. Override from as_object.
Reachable resources from this object are its scope stack and the prototype.
Reimplemented from gnash::as_object.
References _env, gnash::renderer::opengl::for_each(), gnash::as_environment::markReachableResources(), gnash::as_object::markReachableResources(), and gnash::GcResource::setReachable().
|
inlinevirtual |
Get the number of registers required for function execution.
For ordinary Functions this is always 0.
Implements gnash::UserFunction.
Reimplemented in gnash::Function2.
void gnash::Function::setLength | ( | size_t | len | ) |
Set the length in bytes of the function code.
References gnash::action_buffer::size().
|
protected |
Referenced by add_arg(), gnash::Function2::call(), and call().
|
protected |
@ might need some kind of ref count here, but beware cycles
Referenced by gnash::Function2::call(), call(), and markReachableResources().
|
protected |
The ConstantPool in effect at time of function definition.
Referenced by gnash::Function2::call(), and call().