Colobot
Public Member Functions | List of all members
CBot::CBotExternalCallList Class Reference

Class for mangaging CBot external calls. More...

#include <CBotExternalCall.h>

Public Member Functions

bool AddFunction (const std::string &name, std::unique_ptr< CBotExternalCall > call)
 Add a new function to the list. More...
 
CBotTypResult CompileCall (CBotToken *&p, CBotVar *thisVar, CBotVar **ppVars, CBotCStack *pStack)
 Find and call compile function. More...
 
bool CheckCall (const std::string &name)
 Check if function with given name has been defined. More...
 
int DoCall (CBotToken *token, CBotVar *thisVar, CBotVar **ppVars, CBotStack *pStack, const CBotTypResult &rettype)
 Find and call runtime function. More...
 
bool RestoreCall (CBotToken *token, CBotVar *thisVar, CBotVar **ppVar, CBotStack *pStack)
 Restore execution status after loading saved state. More...
 
void SetUserPtr (void *pUser)
 Set user pointer to pass to compile functions. More...
 
void Clear ()
 Reset the list of registered functions. More...
 

Detailed Description

Class for mangaging CBot external calls.

See also
CBotProgram::AddFunction() for information on how to add your functions to this list

Member Function Documentation

bool CBot::CBotExternalCallList::AddFunction ( const std::string &  name,
std::unique_ptr< CBotExternalCall call 
)

Add a new function to the list.

Parameters
nameFunction name
callFunction to add
Returns
true
CBotTypResult CBot::CBotExternalCallList::CompileCall ( CBotToken *&  p,
CBotVar thisVar,
CBotVar **  ppVars,
CBotCStack pStack 
)

Find and call compile function.

This function sets an error in compilation stack in case of failure

Parameters
pToken representing the function name
thisVar"this" variable for class calls, nullptr for normal calls
ppVarsList of arguments (only types!)
pStackCompilation stack
Returns
CBotTypResult representing the return type of the function (CBotType), or an error (CBotError)
bool CBot::CBotExternalCallList::CheckCall ( const std::string &  name)

Check if function with given name has been defined.

Parameters
nameName to check
Returns
true if function was defined
int CBot::CBotExternalCallList::DoCall ( CBotToken token,
CBotVar thisVar,
CBotVar **  ppVars,
CBotStack pStack,
const CBotTypResult rettype 
)

Find and call runtime function.

This function sets an error in runtime stack in case of failure

Parameters
tokenToken representing the function name
thisVar"this" variable for class calls, nullptr for normal calls
ppVarsList of arguments
pStackRuntime stack
rettypeReturn type of the function, as returned by CompileCall()
Returns
-1 if call failed (no such function), 0 if function requested interruption, 1 on success
bool CBot::CBotExternalCallList::RestoreCall ( CBotToken token,
CBotVar thisVar,
CBotVar **  ppVar,
CBotStack pStack 
)

Restore execution status after loading saved state.

Parameters
tokenToken representing the function name
thisVar"this" variable for class calls, nullptr for normal calls
ppVarList of arguments
pStackRuntime stack
Returns
false on failure (e.g. function doesn't exist)
void CBot::CBotExternalCallList::SetUserPtr ( void *  pUser)

Set user pointer to pass to compile functions.

This is for compile functions only, runtime functions use CBotStack::GetUserPtr()

Parameters
pUserUser pointer
void CBot::CBotExternalCallList::Clear ( )

Reset the list of registered functions.


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