#include <libsswf.h>
Public Member Functions | |
ActionTry (TagBase *tag) | |
Initialize the ActionTry action. | |
void | AddCatchAction (Action *action) |
Add an action to the catch block. | |
void | AddFinallyAction (Action *action) |
Add an action to the finally block. | |
void | AddTryAction (Action *action) |
Add an action to the try block. | |
void | SetIdentifier (const char *variable_name) |
Request the error to be saved in a named variable. | |
void | SetIdentifier (int register_number) |
Request the error to be saved in a register. | |
Vectors * | SubListCatch (void) |
Retrieve the Vectors to the catch action block. | |
Vectors * | SubListFinally (void) |
Retrieve the Vectors to the finally action block. | |
Vectors * | SubListTry (void) |
Retrieve the Vectors to the try action block. | |
Private Member Functions | |
virtual Action * | Duplicate (void) const |
Create a clone of this action. | |
virtual int | GetMaxRegister (void) const |
Defines the maximum register number in use. | |
virtual ErrorManager::error_code_t | ParseData (const Data &data) |
Parse the data buffer for a Try action. | |
virtual ErrorManager::error_code_t | SaveData (Data &data, Data &nested_data) |
Save the ActionTry extraneous data. | |
virtual unsigned char | Version (void) const |
The version required to save this action. | |
Private Attributes | |
Vectors | f_actions_catch |
Vectors | f_actions_finally |
Vectors | f_actions_try |
bool | f_has_catch |
bool | f_has_finally |
int | f_register |
char * | f_variable_name |
It is necessary to at least have one of the 'catch' or 'finally' blocks. The 'try' block is mandatory.
ActionTry::ActionTry | ( | TagBase * | tag | ) |
This constructor marks the Try action as not having any catch or finally blocks, no name and no register.
Use the AddTryAction() or SubListTry() to add actions to the try block.
Use the AddCatchAction() or SubListCatch() to add actions to the catch block.
Use the AddFinallyAction() or SubListFinally() to add actions to the finally block.
Use the SetIdentifier(int register_number) function with an integer to define a register number for the catch variable.
Use the SetIdentifier(const char *name) function with a string to define the name of a variable to use as the catch variable.
[in] | tag | The tag in which this action is inserted |
References f_has_catch, f_has_finally, f_register, and f_variable_name.
Referenced by Duplicate().
void ActionTry::AddCatchAction | ( | Action * | action | ) |
This function adds the specified action to the catch block. The catch block can be empty, in which case you must have a non-empty finally block.
The action passed is not duplicated.
This function has the side effect of marking the action as having a catch block, unless the pointer is null.
[in] | action | The pointer to the action to add to the catch block or NULL |
References f_actions_catch, f_has_catch, and sswf::Vectors::Set().
Referenced by Duplicate().
void ActionTry::AddFinallyAction | ( | Action * | action | ) |
This function adds the specified action to the finally block. The finally block can be empty, in which case you must have a non-empty catch block.
The action passed is not duplicated.
This function has the side effect of marking the action as having a finally block, unless the pointer is null.
[in] | action | The pointer to the action to add to the finally block or NULL |
References f_actions_finally, f_has_finally, and sswf::Vectors::Set().
Referenced by Duplicate().
void ActionTry::AddTryAction | ( | Action * | action | ) |
This function adds the specified action to the try block. There should be at least one action in the try block.
The action is not duplicated.
[in] | action | The pointer to the action to add to the try block or NULL |
References f_actions_try, and sswf::Vectors::Set().
Referenced by Duplicate().
Action * ActionTry::Duplicate | ( | void | ) | const [private, virtual] |
This function creates a new ActionTry object, it copies the register number, variable name, has catch & finally flags and then copy the lists of actions (try, catch and finally blocks.)
Reimplemented from sswf::Action.
References ActionTry(), AddCatchAction(), AddFinallyAction(), AddTryAction(), sswf::Vectors::Count(), sswf::Action::Duplicate(), f_actions_catch, f_actions_finally, f_actions_try, f_has_catch, f_has_finally, f_register, f_variable_name, sswf::Vectors::Get(), SetIdentifier(), and sswf::Action::Tag().
int ActionTry::GetMaxRegister | ( | void | ) | const [private, virtual] |
This function overwrites the default sswf::Action::GetMaxRegister() function in order to retrieve the largest register in use in any of the sub-action blocks (try, catch, finally).
Reimplemented from sswf::Action.
References f_actions_catch, f_actions_finally, f_actions_try, and sswf::Action::GetMaximumRegister().
ErrorManager::error_code_t ActionTry::ParseData | ( | const Data & | data | ) | [private, virtual] |
This function parses a Try, Catch and Finalize group of actions.
[in] | data | The data buffer to parse for the Try, Catch, Finalize blocks |
Reimplemented from sswf::Action.
References sswf::ErrorManager::ERROR_CODE_NONE, f_actions_catch, f_actions_finally, f_actions_try, f_has_catch, f_has_finally, f_register, f_variable_name, sswf::Data::GetBits(), sswf::Data::GetByte(), sswf::Data::GetShort(), sswf::Data::GetString(), sswf::Action::ParseList(), and sswf::Action::Tag().
ErrorManager::error_code_t ActionTry::SaveData | ( | Data & | data, | |
Data & | nested_data | |||
) | [private, virtual] |
The SaveData() function saves the try, catch and finally blocks in the nested_data and the try header in the Data buffers.
Note that the maximum size for any one sub-block is 65535 bytes. A larger sub-block will generate an error and the save will fail.
This function should not be called until at least one of the catch or finally block has been created.
[in] | data | The Data buffer where the ActionTry header is saved |
[in] | nested_data | This buffer is used to save the try, catch and finally blocks |
Reimplemented from sswf::Action.
References sswf::Data::Append(), sswf::assert(), sswf::Data::ByteSize(), sswf::ErrorManager::ERROR_CODE_ACTION_OVERFLOW, sswf::ErrorManager::ERROR_CODE_INTERNAL_ERROR, sswf::ErrorManager::ERROR_CODE_NONE, f_actions_catch, f_actions_finally, f_actions_try, f_has_catch, f_has_finally, f_register, f_variable_name, sswf::Data::GetSize(), sswf::ErrorManager::KeepFirst(), sswf::Action::OnError(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::Action::SaveList(), sswf::Action::SaveString(), sswf::Data::SetSize(), and sswf::Data::WriteBits().
void ActionTry::SetIdentifier | ( | const char * | name | ) |
This function defines the name to use as the catch variable. When a register number from 0 to 254 was defined with SetIdentifier(), this variable name is ignored.
[in] | name | The name of the variable to use within the catch block to access the error |
References f_variable_name, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().
void ActionTry::SetIdentifier | ( | int | register_number | ) |
The catch block, when called, receives an error variable. This variable can be saved in a register. To archive this, set the register number that you want to use for this catch block.
This function has priority over the SetIdentifier(const char *name) function. This means the register number will be used instead of the register name if defined.
The register number can be any number between 0 and 254.
If the register number is set to -1, then it is ignored.
[in] | register_number | The register to use in the catch block to access the error |
References f_register.
Referenced by Duplicate().
Vectors * ActionTry::SubListCatch | ( | void | ) |
This function can be used to retrieve a direct pointer to the Vectors holding the action block for the 'catch' block.
References f_actions_catch, and f_has_catch.
Vectors * ActionTry::SubListFinally | ( | void | ) |
This function can be used to retrieve a direct pointer to the Vectors holding the action block for the 'finally' block.
References f_actions_finally, and f_has_finally.
Vectors * ActionTry::SubListTry | ( | void | ) |
This function can be used to retrieve a direct pointer to the Vectors holding the action block for the 'try' block.
References f_actions_try.
unsigned char ActionTry::Version | ( | void | ) | const [private, virtual] |
This function goes through all the sub-action lists to determine the minimum version necessary to save it.
The ActionTry itself requires version 7, but actions in the sub-lists may require a higher version.
Reimplemented from sswf::Action.
References f_actions_catch, f_actions_finally, f_actions_try, and sswf::Action::MinimumListVersion().
Vectors sswf::ActionTry::f_actions_catch [private] |
Referenced by AddCatchAction(), Duplicate(), GetMaxRegister(), ParseData(), SaveData(), SubListCatch(), and Version().
Vectors sswf::ActionTry::f_actions_finally [private] |
Referenced by AddFinallyAction(), Duplicate(), GetMaxRegister(), ParseData(), SaveData(), SubListFinally(), and Version().
Vectors sswf::ActionTry::f_actions_try [private] |
Referenced by AddTryAction(), Duplicate(), GetMaxRegister(), ParseData(), SaveData(), SubListTry(), and Version().
bool sswf::ActionTry::f_has_catch [private] |
Referenced by ActionTry(), AddCatchAction(), Duplicate(), ParseData(), SaveData(), and SubListCatch().
bool sswf::ActionTry::f_has_finally [private] |
Referenced by ActionTry(), AddFinallyAction(), Duplicate(), ParseData(), SaveData(), and SubListFinally().
int sswf::ActionTry::f_register [private] |
Referenced by ActionTry(), Duplicate(), ParseData(), SaveData(), and SetIdentifier().
char* sswf::ActionTry::f_variable_name [private] |
Referenced by ActionTry(), Duplicate(), ParseData(), SaveData(), and SetIdentifier().