BS_NMSP::ObjectDefinition Class Reference

Base class for script object definitions. More...

#include <bsObjectDefinition.h>

Inheritance diagram for BS_NMSP::ObjectDefinition:

BS_NMSP::ControllerDefinition BS_NMSP::EmitterDefinition

List of all members.

Classes

struct  MemberVariable
 Member variable compile information. More...
struct  State
 State compile information. More...

Public Member Functions

 ObjectDefinition (const String &name, const String &type)
 Constructor.
virtual ~ObjectDefinition ()
 Destructor.
const String & getName () const
 Get the name of this ObjectDefinition.
const String & getType () const
 Get the type of this ObjectDefinition.
void appendConstructionCode (const BytecodeBlock &code)
 Add code onto the scripted constructor: this will typically be for setting member variables.
void finaliseConstructor ()
 Finalises the constructor.
void setMaxLocalVariables (int count)
 Set the maximum number of local variables that any state, function or event uses.
int getMaxLocalVariables () const
 Get the maximum number of local variables that any state, function or event uses.
int addMemberVariable (const String &name, bool readOnly, bstype initialValue=bsvalue0)
 Add a member variable.
MemberVariablegetMemberVariable (int index)
 Get a member variable.
int getMemberVariableIndex (const String &name) const
 Get the index that the named variable uses.
int getNumMemberVariables () const
 Get the number of member variables.
void setNumUserMembers (int count)
 Set the number of user member variable.
int getNumUserMembers () const
 Get the number of user member variable.
StateaddState (const String &name)
 Add the named state.
StategetState (int index)
 Get a state.
int getStateIndex (const String &name) const
 Get the index that the named state uses.
int getNumStates () const
 Get the number of states.
void setInitialState (int state)
 Set the index of the initial state.
ScriptRecordcreateScriptRecord (ScriptMachine *machine)
 Create a ScriptRecord for an instance to use.

Protected Attributes

int mMaxLocals
 Maximum number of local variables.
BytecodeBlock mConstructor
 Temporary storage for constructor for setting member variables.
uint32 * mConstructCode
 Constructor code.
size_t mConstructSize
 Constructor code size.
std::vector< MemberVariablemMemberVariables
 Member variables.
int mNumUserMembers
 Number of user variables.
std::vector< StatemStates
 States.
int mInitialState
 Starting state for this ObjectDefinition.


Detailed Description

Base class for script object definitions.

Constructor & Destructor Documentation

BS_NMSP::ObjectDefinition::ObjectDefinition ( const String &  name,
const String &  type 
)

Constructor.

Parameters:
name name of definition.
type type, will generally be either "Emitter" or "Controller".


Member Function Documentation

int BS_NMSP::ObjectDefinition::addMemberVariable ( const String &  name,
bool  readOnly,
bstype  initialValue = bsvalue0 
)

Add a member variable.

Parameters:
name variable name.
readOnly whether the variable can be modified in script, or not.
initialValue initial value.
Returns:
BS_OK or BS_TooManyMemberVariables.

State& BS_NMSP::ObjectDefinition::addState ( const String &  name  ) 

Add the named state.

This function does not check to see if the state already exists.

Parameters:
name name of the state.
Returns:
the newly-created state.

void BS_NMSP::ObjectDefinition::appendConstructionCode ( const BytecodeBlock &  code  ) 

Add code onto the scripted constructor: this will typically be for setting member variables.

Parameters:
code bytecode.

ScriptRecord* BS_NMSP::ObjectDefinition::createScriptRecord ( ScriptMachine *  machine  ) 

Create a ScriptRecord for an instance to use.

Parameters:
machine pointer to an active ScriptMachine.
Returns:
ScriptRecord object.

int BS_NMSP::ObjectDefinition::getMaxLocalVariables (  )  const

Get the maximum number of local variables that any state, function or event uses.

Returns:
number of variables.

MemberVariable& BS_NMSP::ObjectDefinition::getMemberVariable ( int  index  ) 

Get a member variable.

This function assumes that the index is valid!

Parameters:
index variable index.
Returns:
Member variable structure.

int BS_NMSP::ObjectDefinition::getMemberVariableIndex ( const String &  name  )  const

Get the index that the named variable uses.

Parameters:
name name of the variable.
Returns:
variable index, or BS_NotFound if it does not exist.

const String& BS_NMSP::ObjectDefinition::getName (  )  const

Get the name of this ObjectDefinition.

Returns:
the name.

int BS_NMSP::ObjectDefinition::getNumMemberVariables (  )  const

Get the number of member variables.

Returns:
number of variables.

int BS_NMSP::ObjectDefinition::getNumStates (  )  const

Get the number of states.

Returns:
number of states.

int BS_NMSP::ObjectDefinition::getNumUserMembers (  )  const

Get the number of user member variable.

Returns:
number of variables.

State& BS_NMSP::ObjectDefinition::getState ( int  index  ) 

Get a state.

This function assumes that the index is valid!

Parameters:
index state index.
Returns:
State structure.

int BS_NMSP::ObjectDefinition::getStateIndex ( const String &  name  )  const

Get the index that the named state uses.

Parameters:
name name of the state.
Returns:
state index, or BS_NotFound if it does not exist.

const String& BS_NMSP::ObjectDefinition::getType (  )  const

Get the type of this ObjectDefinition.

Returns:
the type.

void BS_NMSP::ObjectDefinition::setInitialState ( int  state  ) 

Set the index of the initial state.

Parameters:
state initial state.

void BS_NMSP::ObjectDefinition::setMaxLocalVariables ( int  count  ) 

Set the maximum number of local variables that any state, function or event uses.

Parameters:
count number of variables.

void BS_NMSP::ObjectDefinition::setNumUserMembers ( int  count  ) 

Set the number of user member variable.

Parameters:
count number of variables.


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

Generated on Wed Mar 31 12:49:05 2010 for bulletscript by  doxygen 1.5.9