sswf::ActionBranch Class Reference

An action to change the execution pointer. More...

#include <libsswf.h>

Inheritance diagram for sswf::ActionBranch:

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

Public Member Functions

 ActionBranch (TagBase *tag, action_t action=ACTION_BRANCH_ALWAYS)
 Initialize an branch action.
void SetLabel (const char *label)
 Set the label this branch needs to branch to.

Private Member Functions

virtual ActionDuplicate (void) const
 Duplicate an ActionBranch object.
virtual ErrorManager::error_code_t Save2ndPass (const Vectors &list, Data &data)
 Save the real branch offset.
virtual ErrorManager::error_code_t SaveData (Data &data, Data &nested_data)
 Save a branch offset placeholder.

Private Attributes

char * f_label

Detailed Description

The ActionBranch class is used to create a branch or jump from one place to another in your ActionScript. Depending on the type of Branch that you define, it will always be taken, or it will be taken only when the current value on the stack is true.

By default, if you do not specify the type of branch, it will always branch.

See also:
SWF Alexis' Reference—Branch Always

SWF Alexis' Reference—Branch If True


Constructor & Destructor Documentation

ActionBranch::ActionBranch ( TagBase tag,
action_t  action = ACTION_BRANCH_ALWAYS 
)

This function initializes an ActionBranch object. You can specify which action whether you want the branch to be conditional or not.

Parameters:
[in] tag The tag in which this action is being created
[in] action The branch to be created, one of: ACTION_BRANCH_ALWAYS or ACTION_BRANCH_IF_TRUE


Member Function Documentation

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

This function creates a new ActionBranch and copies the label from this ActionBranch to the new one.

Returns:
The ActionBranch copy

Reimplemented from sswf::Action.

ErrorManager::error_code_t ActionBranch::Save2ndPass ( const Vectors list,
Data data 
) [private, virtual]

This function searches the whole list of actions for the label specified in the branch. If the label cannot be found, this is an error and the function fails.

When the label is found, the offset to that label is read and used to compute the offset we need to save in the branch byte codes.

If the branch cannot be generated because the offset is out of bounds (i.e. smaller than 0x8000 or larger than 0x7FFF) then an error is generated and the function fails.

Parameters:
[in] list The list of actions where the label is searched
[in] data The Data buffer where the resulting offset is saved

Reimplemented from sswf::Action.

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

This function saves 2 bytes which represent the offset where the branch needs to go.

Since at this time we cannot be sure of the exact offset (forward offset are not yet known), we just save an offset of zero. The Save2ndPass() will save the real offset.

Parameters:
[in] data The Data buffer where the offset is saved
[in] nested_data Branches have no nested data

Reimplemented from sswf::Action.

void ActionBranch::SetLabel ( const char *  label  ) 

This function defines the label this branch needs to branch to. This label will be searched in the same block the ActionBranch is inserted in. (note that their is no 'if' block in byte code ActionScript.)

There should be an ActionLabel for each different label defined in ActionBranch objects.

Parameters:
[in] label The label to branch to


Member Data Documentation

char* sswf::ActionBranch::f_label [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