libsswf: sswf::ActionWith Class Reference

# sswf::ActionWith Class Reference

Block including variable member names refering to the With object. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::ActionWith:

List of all members.

## Public Member Functions
| ActionWith (TagBase *tag)
| Initialize the ActionWith object.
void | AddAction (Action *action)
| Add an action to the 'with' block.
virtual Vectors * | SubList (void)
| The sub-list of actions of this ActionWith.
## Private Member Functions
virtual Action * | Duplicate (void) const
| Create a clone of this ActionWith object.
virtual ErrorManager::error_code_t | ParseData (const Data &data)
| Parse the nested actions from the Data buffer.
virtual ErrorManager::error_code_t | SaveData (Data &data, Data &nested_data)
| Save the byte size of the nested data.
## Private Attributes
Vectors | f_actions

## Detailed Description

This action is supposed to be useful to optimize JavaScript code by not having to fully qualify variables by their respective object name.

For instance, the following code:

            obj.a = 1;
            obj.b = 2;
            obj.c = 3;
            obj.d = 4;
            obj.e = 5;

can be simplified using a 'with' instruction as follow:

            with obj {
                    a = 1;
                    b = 2;
                    c = 3;
                    d = 4;
                    e = 5;
            }

See also:
  SWF Alexis' Reference—With

## Constructor & Destructor Documentation

ActionWith::ActionWith | ( | TagBase * | tag | ) |

This function initialize the 'with' object by making the 'with' block empty.

Parameters:

  `[in]` | tag | The tag where the With is inserted

Referenced by Duplicate().

## Member Function Documentation

void ActionWith::AddAction | ( | Action * | action | ) |

The 'with' block is a list of actions which can be grown using this function. Note that you can have several levels of 'with' (i.e. within a 'with' block you can have another 'with' block to a depth of 7 up to version 5 of SWF, and 15 in version 6 of SWF.)

Of course, it can be quite tedious to know what variable reference which object when all the objects have variable and function members of the same name (it should be the inner most object which has a match.)

Note that the action being added is not duplicated.

Parameters:

  `[in]` | action | The pointer to the action to add to this ActionWith

References f_actions, and sswf::Vectors::Set().

Referenced by Duplicate().

Action * ActionWith::Duplicate | ( | void |  | ) | const`[private, virtual]`

This function creates a new ActionWith object and copies all the actions of 'this' ActionWith in it. Finally, it returns a pointer to the newly allocated object.

Returns:
  The newly allocated action pointer

Reimplemented from sswf::Action.

References ActionWith(), AddAction(), sswf::Vectors::Count(), sswf::Action::Duplicate(), f_actions, sswf::Vectors::Get(), and sswf::Action::Tag().

ErrorManager::error_code_t ActionWith::ParseData | ( | const Data & | data | ) | `[private, virtual]`

This function parses the nested actions of the ActionWith object.

Parameters:

  `[in]` | data | The source Data buffer

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

Reimplemented from sswf::Action.

References sswf::ErrorManager::ERROR_CODE_NONE, f_actions, sswf::Data::GetShort(), sswf::Action::ParseList(), and sswf::Action::Tag().

ErrorManager::error_code_t ActionWith::SaveData | ( | Data & | data,
|  | Data & | nested_data |
| ) |  |  | `[private, virtual]`

This function saves the extraneous data for an ActionWith object which is the size of the nested data buffer in bytes.

Parameters:

  `[in]` | data | The Data buffer where the size is to be saved
  `[in]` | nested_data | The Data buffer which holds the sub-actions

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

Reimplemented from sswf::Action.

References sswf::Data::ByteSize(), sswf::ErrorManager::ERROR_CODE_NONE, and sswf::Data::PutShort().

Vectors * ActionWith::SubList | ( | void |  | ) | `[virtual]`

This function returns a direct pointer to the Vectors of this ActioWith object. This Vectors array holds all the actions to execute once the specified frame was loaded.

Do not forget that the actions are limited to a byte size of 65535 in the outer most ActionWith object.

Returns:
  A Vectors pointer to fill with actions

Reimplemented from sswf::Action.

References f_actions.

## Member Data Documentation

Vectors sswf::ActionWith::f_actions`[private]`

Referenced by AddAction(), Duplicate(), ParseData(), and SubList().

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

- libsswf.h
- libsswf_actions.c++