Sheep
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
Public Member Functions | List of all members
Sheep::IExecutionContext Class Referenceabstract

#include <sheepcpp.h>

Public Member Functions

virtual void Release ()=0
 
virtual int Execute ()=0
 
virtual int Suspend ()=0
 
virtual ExecutionContextState GetState ()=0
 Gets the current state of the context.
 
virtual IVirtualMachineGetParentVirtualMachine ()=0
 Gets the parent Sheep::IVirtualMachine that owns this context.
 
virtual int GetNumVariables ()=0
 Gets the number of global variables within the script associated with the Context.
 
virtual const char * GetVariableName (int index)=0
 Gets the name of the given variable, or null if the index is invalid.
 
virtual SymbolType GetVariableType (int index)=0
 Gets the type of variable at the specified index.
 
virtual int SetVariableInt (int index, int value)=0
 
virtual int SetVariableFloat (int index, float value)=0
 
virtual int SetVariableString (int index, const char *value)=0
 
virtual int GetVariableInt (int index, int *result)=0
 
virtual int GetVariableFloat (int index, float *result)=0
 
virtual int GetVariableString (int index, const char **result)=0
 
virtual int PopIntFromStack (int *result)=0
 
virtual int PopFloatFromStack (float *result)=0
 
virtual int PopStringFromStack (const char **result)=0
 
virtual int PushIntOntoStack (int value)=0
 
virtual int PushFloatOntoStack (float value)=0
 

Detailed Description

Represents a currently executing Sheep script.

It is created using Sheep::IVirtualMachine::PrepareScriptForExecution() and is executed or resumed using Sheep::IExecutionContext::Execute().

Member Function Documentation

virtual int Sheep::IExecutionContext::Execute ( )
pure virtual

Executes a prepared Sheep::IExecutionContext (see IVirtualMachine::PrepareScriptForExecution()), or resumes a suspended context.

Returns
SHEEP_SUCCESS if the script completed successfully, SHEEP_SUSPENDED if the script was suspended (most likely by a "wait"), SHEEP_ERR_INVALID_OPERATION if context is not in a valid state.
virtual int Sheep::IExecutionContext::GetVariableFloat ( int  index,
float *  result 
)
pure virtual

Gets the value of a float variable

Parameters
indexThe index of the variable
resultA pointer to a float to where the value will be written
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid or result is null, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not a float
virtual int Sheep::IExecutionContext::GetVariableInt ( int  index,
int *  result 
)
pure virtual

Gets the value of an integer variable

Parameters
indexThe index of the variable
resultA pointer to an integer to where the value will be written
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid or result is null, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not an integer
virtual int Sheep::IExecutionContext::GetVariableString ( int  index,
const char **  result 
)
pure virtual

Gets the value of a string variable

Parameters
indexThe index of the variable
resultA pointer to a character array to where the value will be written
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid or result is null, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not a string
virtual int Sheep::IExecutionContext::PopFloatFromStack ( float *  result)
pure virtual

Pops a float from the top of the stack

Parameters
resultA pointer to a float where the value on top of the stack will be written. May be null.
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_EMPTY_STACK if the stack is empty, or SHEEP_ERR_WRONG_TYPE_ON_STACK if the item on top of the stack is not a float.
virtual int Sheep::IExecutionContext::PopIntFromStack ( int *  result)
pure virtual

Pops an integer from the top of the stack

Parameters
resultA pointer to an integer where the value on top of the stack will be written. May be null.
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_EMPTY_STACK if the stack is empty, or SHEEP_ERR_WRONG_TYPE_ON_STACK if the item on top of the stack is not an integer.
virtual int Sheep::IExecutionContext::PopStringFromStack ( const char **  result)
pure virtual

Pops a string from the top of the stack

Parameters
resultA pointer to an character array where the value on top of the stack will be written. May be null.
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_EMPTY_STACK if the stack is empty, or SHEEP_ERR_WRONG_TYPE_ON_STACK if the item on top of the stack is not a string.
virtual int Sheep::IExecutionContext::PushFloatOntoStack ( float  value)
pure virtual

Pushes a float onto the stack

Parameters
valueAn float that will be pushed onto the top of the stack
Returns
SHEEP_SUCCESS if successful, or SHEEP_ERR_NO_CONTEXT_AVAILABLE if there is not a currently executing Sheep::IExecutionContext
virtual int Sheep::IExecutionContext::PushIntOntoStack ( int  value)
pure virtual

Pushes an integer onto the stack

Parameters
valueAn integer that will be pushed onto the top of the stack
Returns
SHEEP_SUCCESS if successful, or SHEEP_ERR_NO_CONTEXT_AVAILABLE if there is not a currently executing Sheep::IExecutionContext
virtual void Sheep::IExecutionContext::Release ( )
pure virtual

Releases the Execution Context, decreasing its reference count by 1.

Once the reference count reaches 0 the Context is destroyed.

virtual int Sheep::IExecutionContext::SetVariableFloat ( int  index,
float  value 
)
pure virtual

Sets the value of a float variable

Parameters
indexThe index of the variable
valueThe value to assign to the variable
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not a float
virtual int Sheep::IExecutionContext::SetVariableInt ( int  index,
int  value 
)
pure virtual

Sets the value of an integer variable

Parameters
indexThe index of the variable
valueThe value to assign to the variable
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not an integer
virtual int Sheep::IExecutionContext::SetVariableString ( int  index,
const char *  value 
)
pure virtual

Sets the value of a string variable

Parameters
indexThe index of the variable
valueThe value to assign to the variable
Returns
SHEEP_SUCCESS if successful, SHEEP_ERR_INVALID_ARGUMENT if index is invalid, or SHEEP_ERR_VARIABLE_INCORRECT_TYPE if the specified variable is not a string
virtual int Sheep::IExecutionContext::Suspend ( )
pure virtual

Suspends the context

Returns
SHEEP_SUCCESS if the context was successfully suspended, or SHEEP_ERR_INVALID_OPERATION if the context is not in the ExecutionContextState::Executing state

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