sswf::ActionFunction Class Reference

The action to hold an ActionScript function. More...

#include <libsswf.h>

Inheritance diagram for sswf::ActionFunction:

sswf::Action sswf::MemoryManager sswf::ItemBase sswf::MemBuffer List of all members.

Public Types

 ACTION_FUNCTION_LOAD_ARGUMENTS = 0x0004
 Load arguments in registers.
 ACTION_FUNCTION_LOAD_GLOBAL = 0x0100
 Make the 'global' variable ready.
 ACTION_FUNCTION_LOAD_PARENT = 0x0080
 Make the 'parent' variable ready.
 ACTION_FUNCTION_LOAD_ROOT = 0x0040
 Make the 'root' variable ready.
 ACTION_FUNCTION_LOAD_SUPER = 0x0010
 Make the 'super' variable ready.
 ACTION_FUNCTION_LOAD_THIS = 0x0001
 Make 'this' variable ready.
 ACTION_FUNCTION_SUPPRESS_ARGUMENTS = 0x0008
 Ignore all arguments.
 ACTION_FUNCTION_SUPPRESS_SUPER = 0x0020
 Don't bother creating the 'super' variable.
 ACTION_FUNCTION_SUPPRESS_THIS = 0x0002
 Don't create the 'this' variable.
enum  action_function_t {
  ACTION_FUNCTION_LOAD_THIS = 0x0001, ACTION_FUNCTION_SUPPRESS_THIS = 0x0002, ACTION_FUNCTION_LOAD_ARGUMENTS = 0x0004, ACTION_FUNCTION_SUPPRESS_ARGUMENTS = 0x0008,
  ACTION_FUNCTION_LOAD_SUPER = 0x0010, ACTION_FUNCTION_SUPPRESS_SUPER = 0x0020, ACTION_FUNCTION_LOAD_ROOT = 0x0040, ACTION_FUNCTION_LOAD_PARENT = 0x0080,
  ACTION_FUNCTION_LOAD_GLOBAL = 0x0100
}
 List the flags supported by the DeclareFunction2 tag. More...
enum  as_set_prop_flags_t { PROP_FLAG_IS_HIDDEN = 1, PROP_FLAG_CAN_DELETE = 2, PROP_FLAG_CAN_OVERWRITE = 4 }
 List of flags available to call the ASSetPropFlags() function. More...
 PROP_FLAG_CAN_DELETE = 2
 Whether a member can be removed from an object.
 PROP_FLAG_CAN_OVERWRITE = 4
 Whether a member can be overwritten in an object.
 PROP_FLAG_IS_HIDDEN = 1
 Prevent the enumeration actions from showing this member.

Public Member Functions

 ActionFunction (TagBase *tag, action_t action=ACTION_DECLARE_FUNCTION)
 Initializes ActionFunction objects.
void AddAction (Action *action)
 Add an action in the function.
void AddParameter (const char *name, int register_number=-1)
 Add a function parameter.
void SetName (const char *name)
 Define the name of the function.
void SetRegistersCount (unsigned int count)
 Set the maximum number of registers to use with this function.
virtual VectorsSubList (void)
 Get a pointer to the Vectors of sub-actions.

Private Member Functions

virtual ActionDuplicate (void) const
 Duplicate the function action.
virtual ErrorManager::error_code_t SaveData (Data &data, Data &nested_data)
 Save the function header and nested data.

Private Attributes

Vectors f_actions
unsigned short f_flags
char * f_name
Vectors f_parameters
unsigned int f_registers_count

Classes

struct  parameter_t
 Hold the parameters name and register number. More...

Detailed Description

This class is used to create an ActionFunction, meaning a function to be called from within an ActionScript.

See also:
SWF Alexis' Reference—Declare Function

SWF Alexis' Reference—Declare Function (V7)


Member Enumeration Documentation

enum sswf::ActionFunction::action_function_t

These flags can be used to very much optimize ActionScripts.

Each special variable and arguments to functions can be saved in registers for fast retrieval.

See also:
SWF Alexis' Reference—Declare Function (V7)

Enumerator:
ACTION_FUNCTION_LOAD_THIS  Make 'this' variable ready.

The ACTION_FUNCTION_LOAD_THIS loads a register with the value of 'this'. The register depends on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_SUPPRESS_THIS

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_SUPPRESS_THIS  Don't create the 'this' variable.

The ACTION_FUNCTION_SUPPRESS_THIS can be used so 'this' variable is not even created. This can speed things up.

See also:
sswf::ActionFunction::ACTION_FUNCTION_LOAD_THIS

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_LOAD_ARGUMENTS  Load arguments in registers.

The ACTION_FUNCTION_LOAD_ARGUMENTS loads a register with the value of each of the arguments specified when calling this function. The registers depend on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_SUPPRESS_ARGUMENTS

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_SUPPRESS_ARGUMENTS  Ignore all arguments.

The ACTION_FUNCTION_SUPPRESS_ARGUMENTS ensures that the ActionScript interpreter does not spend any time saving the arguments. This useful for virtual functions support.

See also:
sswf::ActionFunction::ACTION_FUNCTION_LOAD_ARGUMENTS

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_LOAD_SUPER  Make the 'super' variable ready.

The ACTION_FUNCTION_LOAD_SUPER loads a register with the value of 'super'. The register depends on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_SUPPRESS_SUPER

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_SUPPRESS_SUPER  Don't bother creating the 'super' variable.

The ACTION_FUNCTION_SUPPRESS_SUPER asks the ActionScript interpreter to not bother creating the super variable. This can speed things up.

See also:
sswf::ActionFunction::ACTION_FUNCTION_LOAD_SUPER

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_LOAD_ROOT  Make the 'root' variable ready.

The ACTION_FUNCTION_LOAD_ROOT loads a register with the value of 'root'. The register depends on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_LOAD_THIS

sswf::ActionFunction::ACTION_FUNCTION_LOAD_PARENT

sswf::ActionFunction::ACTION_FUNCTION_LOAD_GLOBAL

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_LOAD_PARENT  Make the 'parent' variable ready.

ACTION_FUNCTION_LOAD_PARENT = 0x0080, ACTION_FUNCTION_LOAD_GLOBAL = 0x0100

The ACTION_FUNCTION_LOAD_PARENT loads a register with the value of 'parent'. The register depends on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_LOAD_THIS

sswf::ActionFunction::ACTION_FUNCTION_LOAD_ROOT

sswf::ActionFunction::ACTION_FUNCTION_LOAD_GLOBAL

SWF Alexis' Reference—Declare Function (V7)


ACTION_FUNCTION_LOAD_GLOBAL  Make the 'global' variable ready.

The ACTION_FUNCTION_LOAD_THIS loads a register with the value of 'global'. The register depends on what is loaded before.

See also:
sswf::ActionFunction::ACTION_FUNCTION_SUPPRESS_THIS

sswf::ActionFunction::ACTION_FUNCTION_LOAD_ROOT

sswf::ActionFunction::ACTION_FUNCTION_LOAD_PARENT

SWF Alexis' Reference—Declare Function (V7)

enum sswf::ActionFunction::as_set_prop_flags_t

This undocumented function is used to change the properties of an object variable member or function member. The properties are defined by three flags:

See also:
sswf::ActionFunction::PROP_FLAG_IS_HIDDEN

sswf::ActionFunction::PROP_FLAG_CAN_DELETE

sswf::ActionFunction::PROP_FLAG_CAN_OVERWRITE


Enumerator:
PROP_FLAG_IS_HIDDEN  Prevent the enumeration actions from showing this member.

The PROP_FLAG_IS_HIDDEN flag, if set, prevents the enumeration functions from listing to corresponding member.

See also:
sswf::ActionFunction::PROP_FLAG_CAN_DELETE

sswf::ActionFunction::PROP_FLAG_CAN_OVERWRITE


PROP_FLAG_CAN_DELETE  Whether a member can be removed from an object.

The PROP_FLAG_CAN_DELETE flag, if set, lets the user delete requests function. Once deleted, a member loses its property flag setup. If the member is re-created later, it may be required to set this flag again to delete it again.

See also:
sswf::ActionFunction::PROP_FLAG_IS_HIDDEN

sswf::ActionFunction::PROP_FLAG_CAN_OVERWRITE


PROP_FLAG_CAN_OVERWRITE  Whether a member can be overwritten in an object.

The PROP_FLAG_CAN_OVERWRITE flag, if set, means that the corresponding member can be replaced (i.e. set with a different type, or in case of a function, by a different function.)

This flag does not prevent a variable member from being modified.

See also:
sswf::ActionFunction::PROP_FLAG_IS_HIDDEN

sswf::ActionFunction::PROP_FLAG_CAN_DELETE


Constructor & Destructor Documentation

ActionFunction::ActionFunction ( TagBase tag,
action_t  action = ACTION_DECLARE_FUNCTION 
)

This function is used to initialize ActionFunction objects.

In debug mode it will test that the action is valid. It has to be set to either:

ACTION_DECLARE_FUNCTION or ACTION_DECLARE_FUNCTION2

The former can be used for movies version 5 or 6, the latter for movies version 7 or more.

Parameters:
[in] tag The tag holding this action
[in] action The type of function to create


Member Function Documentation

void ActionFunction::AddAction ( Action action  ) 

Most functions include a set of actions to be executed when called. These actions are added using this functions. It is also possible to get a pointer to the sub-actions Vectors and directly add the actions in the Vectors object.

These actions are seen as the function block.

Parameters:
[in] action The action to add to this function
See also:
sswf::ActionFunction::SubList(void)

void ActionFunction::AddParameter ( const char *  name,
int  register_number = -1 
)

This function adds a parameter to the ActionFunction.

The name is mandatory for an ACTION_DECLARE_FUNCTION and optional for an ACTION_DECLARE_FUNCTION2. There are some special parameter names for an ACTION_DECLARE_FUNCTION2 to create or not system registers. The special names are as follow:

The register number is used only by an ACTION_DECLARE_FUNCTION2. By default the register number is set to -1 which means that no register is assigned to that parameter. You can use 0 to have the system automatically assign a register number to your parameter.

According to my testings, the register 255 cannot be used. So you are limited to a register number from 1 to 254. However, don't forget that system parameters must use the first few registers! If the register number you specify is larger than the one defined by the sswf::ActionFunction::SetRegistersCount(unsigned int count) then it is increased as required.

Parameters:
[in] name The name of the parameter
[in] register_number The assigned register for that parameter

Action * ActionFunction::Duplicate ( void   )  const [private, virtual]

This function duplicates a function. This includes all the parameters and actions as well as the name and number of registers used in the list of parameters.

Returns:
A pointer to a new ActionFunction object

Reimplemented from sswf::Action.

ErrorManager::error_code_t ActionFunction::SaveData ( Data data,
Data nested_data 
) [private, virtual]

This function creates the function header which includes its name, all the parameters, whether to create or suppress system registers and the size of the function block.

Note that the function block cannot be larger than about 64Kb.

Parameters:
[in] data The Data buffer where the function is saved
[in] nested_data The Data buffer holding the function block

Reimplemented from sswf::Action.

void ActionFunction::SetName ( const char *  name  ) 

This function saves the specified name as the name of the function.

This is the name you need to use to call the function later.

Note that an object function member has no name.

Parameters:
[in] name The new function name

void ActionFunction::SetRegistersCount ( unsigned int  count  ) 

With an ACTION_DECLARE_FUNCTION2, you can use as many as 255 registers in your function, otherwise you are limited to 4 as before version 7. Also, before version 7, the parameters cannot automatically be assigned to registers and thus this function is not necessary.

Parameters:
[in] count The number of registers you want to use

Vectors * ActionFunction::SubList ( void   )  [virtual]

This function can be used to retrieve a pointer to the sub-actions Vectors object. This can be used to add actions to the function in a way similar to the main block.

Returns:
A pointer to a Vectors object expecting actions

Reimplemented from sswf::Action.


Member Data Documentation

Vectors sswf::ActionFunction::f_actions [private]

unsigned short sswf::ActionFunction::f_flags [private]

char* sswf::ActionFunction::f_name [private]

Vectors sswf::ActionFunction::f_parameters [private]

unsigned int sswf::ActionFunction::f_registers_count [private]


The documentation for this class was generated from the following files:
Generated on Sun May 13 23:29:39 2007 for libsswf by  doxygen 1.4.7