Public Member Functions | Static Public Member Functions | Protected Member Functions

gnash::as_function Class Reference

ActionScript Function, either builtin or SWF-defined. More...

#include <as_function.h>

Inheritance diagram for gnash::as_function:
Inheritance graph
Collaboration diagram for gnash::as_function:
Collaboration graph

List of all members.

Public Member Functions

virtual ~as_function ()
 Decrement refcount on the exported interface.
as_functionto_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_objectconstruct (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 NativeFunctiongetFunctionConstructor ()
 Return the built-in Function constructor.

Protected Member Functions

 as_function (Global_as &gl)
 Construct a function with no interface.

Detailed Description

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).

Constructor & Destructor Documentation

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.

Member Function Documentation

virtual as_value gnash::as_function::call ( const fn_call fn  )  [pure virtual]

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
The constructed object. TODO: return void; currently there is a hack to cope with some remaining bogus constructors (Microphone and Camera), which necessitates returning a different object from the passed 'this' pointer.
NativeFunction * gnash::as_function::getFunctionConstructor (  )  [static]
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().

The documentation for this class was generated from the following files: