Loading...
Searching...
No Matches
CBot::CBotExternalCallList Class Reference

Class for mangaging CBot external calls. More...

`#include <src/CBot/CBotExternalCall.h>`

## Public Member Functions

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

## 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

## AddFunction()

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

Add a new function to the list.

Parameters

  name | Function name
  call | Function to add

Returns
  true

## CompileCall()

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

  p | Token representing the function name
  thisVar | "this" variable for class calls, nullptr for normal calls
  ppVars | List of arguments (only types!)
  pStack | Compilation stack

Returns
  CBotTypResult representing the return type of the function (::CBotType), or an error (::CBotError)

## CheckCall()

bool CBot::CBotExternalCallList::CheckCall | ( | const std::string & | name | ) |

Check if function with given name has been defined.

Parameters

  name | Name to check

Returns
  true if function was defined

## DoCall()

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

  token | Token representing the function name
  thisVar | "this" variable for class calls, nullptr for normal calls
  ppVars | List of arguments
  pStack | Runtime stack
  rettype | Return type of the function, as returned by CompileCall()

Returns
  -1 if call failed (no such function), 0 if function requested interruption, 1 on success

## RestoreCall()

bool CBot::CBotExternalCallList::RestoreCall | ( | CBotToken * | token,
|  | CBotVar * | thisVar,
|  | CBotVar ** | ppVar,
|  | CBotStack * | pStack )

Restore execution status after loading saved state.

Parameters

  token | Token representing the function name
  thisVar | "this" variable for class calls, nullptr for normal calls
  ppVar | List of arguments
  pStack | Runtime stack

Returns
  false on failure (e.g. function doesn't exist)

## SetUserPtr()

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

  pUser | User pointer

## Clear()

void CBot::CBotExternalCallList::Clear | ( |  | ) |

Reset the list of registered functions.

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

- src/CBot/CBotExternalCall.h
- src/CBot/CBotExternalCall.cpp