Gnash
0.8.10
|
ActionScript Function, either builtin or SWF-defined. More...
#include <as_function.h>
Public Member Functions | |
virtual | ~as_function () |
Destructor. | |
virtual as_function * | to_function () |
Return this as_object as an as_function. | |
virtual as_value | call (const fn_call &fn)=0 |
Function dispatch. | |
virtual std::string | stringValue () const |
Return the string value of this as_object subclass. | |
as_object * | construct (as_object &newobj, const as_environment &env, FunctionArgs< as_value > &args) |
Run this function as a constructor on an object. | |
virtual bool | isBuiltin () |
Return true if this is a built-in class. | |
Protected Member Functions | |
as_function (Global_as &gl) | |
Construct a function. |
ActionScript Function, either builtin or SWF-defined.
In ActionScript, every Function is also a class. The *exported interface* of the class is defined as a 'prototype' member of the function object.
Any instance of the class defined by this function will inherit any member of the class 'prototype'. To have an object inherit from a class you can set its __proto__ member so to point to the class prototype, ie:
function MyClass() {} MyClass.prototype.doit = function() { trace("doing it"; }
var myobj = new Object; myobj.__proto__ = MyClass.prototype;
The 'prototype' of a class must provide a 'constructor' member, which would point back to the Function object itself, which is used as the constructor, so given the code above you can assert that:
myobj.__proto__.constructor == MyClass
This class will automatically setup the 'prototype' member if not explicitly provided (ie: will set 'constructor' so that it points to the instance).
virtual gnash::as_function::~as_function | ( | ) | [inline, virtual] |
Destructor.
gnash::as_function::as_function | ( | Global_as & | gl | ) | [protected] |
Construct a function.
Function dispatch.
Override from as_object, although as_objects cannot generally be called.
Reimplemented from gnash::as_object.
Implemented in gnash::Function, gnash::Function2, gnash::builtin_function, gnash::NativeFunction, and gnash::abc::abc_function.
Referenced by gnash::Trigger::call().
as_object* gnash::as_function::construct | ( | as_object & | newobj, |
const as_environment & | env, | ||
FunctionArgs< as_value > & | args | ||
) |
Run this function as a constructor on an object.
This function assigns various constructor properties and runs the constructor. NB: This function does not make the object an 'instance of' the constructor, i.e. it does not assign a __proto__ property. For ActionScript compatibility, callers should ensure this is already done.
newobj | The object to construct. This will be used as the 'this' object in the constructor. |
env | The environment to use for stack, local variables, registers and scope chain. |
args | Arguments for the constructor invocation |
Referenced by gnash::constructInstance().
virtual bool gnash::as_function::isBuiltin | ( | ) | [inline, virtual] |
Return true if this is a built-in class.
Reimplemented in gnash::builtin_function, and gnash::NativeFunction.
Referenced by gnash::abc::Machine::pushCall().
std::string gnash::as_function::stringValue | ( | ) | const [virtual] |
Return the string value of this as_object subclass.
It's "function".
Reimplemented from gnash::as_object.
virtual as_function* gnash::as_function::to_function | ( | ) | [inline, virtual] |
Return this as_object as an as_function.
Reimplemented from gnash::as_object.