ActionScript Function, either builtin or SWF-defined. More...
#include <as_function.h>
Public Member Functions | |
virtual | ~as_function () |
Decrement refcount on the exported interface. | |
as_function * | to_function () |
Cast to a as_function, or return NULL. | |
virtual as_value | call (const fn_call &fn)=0 |
virtual const std::string & | stringValue () const |
Return the string representation for this object. | |
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. | |
Static Public Member Functions | |
static NativeFunction * | getFunctionConstructor () |
Return the built-in Function constructor. | |
Protected Member Functions | |
as_function (Global_as &gl) | |
Construct a function with no interface. |
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] |
Decrement refcount on the exported interface.
gnash::as_function::as_function | ( | Global_as & | gl | ) | [protected] |
Construct a function with no interface.
For SWF>5 the function object will have derive from Function.
References gnash::PropFlags::dontDelete, and gnash::PropFlags::dontEnum.
Function dispatch. // Override from as_object, although as_objects cannot generally be called.
Reimplemented from gnash::as_object.
Implemented in gnash::abc::abc_function, gnash::builtin_function, gnash::Function, gnash::Function2, and gnash::NativeFunction.
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 |
NativeFunction * gnash::as_function::getFunctionConstructor | ( | ) | [static] |
Return the built-in Function constructor.
Referenced by gnash::AVM1Global::createClass(), gnash::AVM1Global::createFunction(), and gnash::VM::getNative().
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.
const std::string & gnash::as_function::stringValue | ( | ) | const [virtual] |
Return the string representation for this object.
This is dependent on the VM version and the type of object, function, or class.
Reimplemented from gnash::as_object.
as_function* gnash::as_function::to_function | ( | ) | [inline, virtual] |
Cast to a as_function, or return NULL.
Reimplemented from gnash::as_object.
Referenced by gnash::getClassConstructor().