Gnash  0.8.10
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:
gnash::as_object gnash::GcResource gnash::abc::abc_function gnash::NativeFunction gnash::UserFunction gnash::builtin_function gnash::Function gnash::Function2

List of all members.

Public Member Functions

virtual ~as_function ()
virtual as_functionto_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_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.

Protected Member Functions

 as_function (Global_as &gl)
 Construct a function.

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]


gnash::as_function::as_function ( Global_as gl) [protected]

Construct a function.

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

newobjThe object to construct. This will be used as the 'this' object in the constructor.
envThe environment to use for stack, local variables, registers and scope chain.
argsArguments for the constructor invocation
The constructed object. TODO: return void; currently there is a hack to cope with some remaining bogus constructors, which necessitates returning a different object from the passed 'this' pointer.

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.

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