gnash::as_function Class Reference

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

#include <as_function.h>

Inheritance diagram for gnash::as_function:

gnash::as_object gnash::ref_counted gnash::builtin_function gnash::swf_function

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 operator() (const fn_call &fn)=0
 Dispatch.
as_value call (const fn_call &fn)
 Alias for operator().
boost::intrusive_ptr< as_objectconstructInstance (as_environment &env, unsigned nargs, unsigned first_arg_index)
 Construct an instance of this class.
boost::intrusive_ptr< as_objectgetPrototype ()
void extends (as_function &superclass)
 Make this function a subclass of the given as_function.
virtual bool isBuiltin ()
 Return true if this is a built-in class.
std::string get_text_value () const

Static Public Member Functions

static boost::intrusive_ptr
< builtin_function
getFunctionConstructor ()
 Return the built-in Function constructor.

Protected Member Functions

 as_function ()
 Construct a function with a default interface.
 as_function (as_object *iface)
 Construct a function with given interface (possibly none).


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 an '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 it's __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 (  )  [protected]

Construct a function with a default interface.

The default interface will have derive from Object and have 'this' set as it's 'constructor' member.

gnash::as_function::as_function ( as_object iface  )  [protected]

Construct a function with given interface (possibly none).

Parameters:
iface The interface exported by this class (its 'prototype' member). If NULL, no prototype will be set (this is used for some corner cases like TextField in SWF5 or below). If not NULL, a 'constructor' member will be added to the prototype, pointing to 'this'.


Member Function Documentation

as_function* gnash::as_function::to_function (  )  [inline, virtual]

Cast to a as_function, or return NULL.

Reimplemented from gnash::as_object.

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

Dispatch.

Implemented in gnash::builtin_function, and gnash::swf_function.

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

Alias for operator().

boost::intrusive_ptr< as_object > gnash::as_function::constructInstance ( as_environment env,
unsigned  nargs,
unsigned  first_arg_index 
)

Construct an instance of this class.

Post-conditions:

Parameters:
env The environment to use for stack, local variables, registers and scope chain.
nargs Number of arguments passed to this constructor
first_arg_index Index of the as_environment stack element to use as first argument.

boost::intrusive_ptr< as_object > gnash::as_function::getPrototype (  ) 

Get this function's "prototype" member (exported interface).

void gnash::as_function::extends ( as_function superclass  ) 

Make this function a subclass of the given as_function.

virtual bool gnash::as_function::isBuiltin (  )  [inline, virtual]

Return true if this is a built-in class.

Reimplemented in gnash::builtin_function.

std::string gnash::as_function::get_text_value (  )  const [inline, virtual]

TODO: check if a user-defined 'toString' will be used when available.

Reimplemented from gnash::as_object.

boost::intrusive_ptr< builtin_function > gnash::as_function::getFunctionConstructor (  )  [static]

Return the built-in Function constructor.


The documentation for this class was generated from the following files:
Generated on Thu Mar 6 18:25:10 2008 for Gnash by  doxygen 1.5.4