Otclient  14/8/2020
LuaInterface Class Reference

Class that manages LUA stuff. More...

#include <luainterface.h>

Public Member Functions

 LuaInterface ()
 
 ~LuaInterface ()
 
void init ()
 
void terminate ()
 
void registerFunctions ()
 Register core script functions. More...
 
void registerSingletonClass (const std::string &className)
 
void registerClass (const std::string &className, const std::string &baseClass="LuaObject")
 
void registerClassStaticFunction (const std::string &className, const std::string &functionName, const LuaCppFunction &function)
 
void registerClassMemberFunction (const std::string &className, const std::string &functionName, const LuaCppFunction &function)
 
void registerClassMemberField (const std::string &className, const std::string &field, const LuaCppFunction &getFunction, const LuaCppFunction &setFunction)
 
void registerGlobalFunction (const std::string &functionName, const LuaCppFunction &function)
 
template<class C , class B = LuaObject>
void registerClass ()
 
template<class C >
void registerClassStaticFunction (const std::string &functionName, const LuaCppFunction &function)
 
template<class C >
void registerClassMemberFunction (const std::string &functionName, const LuaCppFunction &function)
 
template<class C >
void registerClassMemberField (const std::string &field, const LuaCppFunction &getFunction, const LuaCppFunction &setFunction)
 
template<class C , typename F >
void bindSingletonFunction (const std::string &functionName, F C::*function, C *instance)
 
template<class C , typename F >
void bindSingletonFunction (const std::string &className, const std::string &functionName, F C::*function, C *instance)
 
template<class C , typename F >
void bindClassStaticFunction (const std::string &functionName, const F &function)
 
template<typename F >
void bindClassStaticFunction (const std::string &className, const std::string &functionName, const F &function)
 
template<class C , typename F , class FC >
void bindClassMemberFunction (const std::string &functionName, F FC::*function)
 
template<class C , typename F , class FC >
void bindClassMemberFunction (const std::string &className, const std::string &functionName, F FC::*function)
 
template<class C , typename F1 , typename F2 , class FC >
void bindClassMemberField (const std::string &fieldName, F1 FC::*getFunction, F2 FC::*setFunction)
 
template<class C , typename F1 , typename F2 , class FC >
void bindClassMemberField (const std::string &className, const std::string &fieldName, F1 FC::*getFunction, F2 FC::*setFunction)
 
template<class C , typename F , class FC >
void bindClassMemberGetField (const std::string &fieldName, F FC::*getFunction)
 
template<class C , typename F , class FC >
void bindClassMemberGetField (const std::string &className, const std::string &fieldName, F FC::*getFunction)
 
template<class C , typename F , class FC >
void bindClassMemberSetField (const std::string &fieldName, F FC::*setFunction)
 
template<class C , typename F , class FC >
void bindClassMemberSetField (const std::string &className, const std::string &fieldName, F FC::*setFunction)
 
template<typename F >
void bindGlobalFunction (const std::string &functionName, const F &function)
 
bool safeRunScript (const std::string &fileName)
 Loads and runs a script, any errors are printed to stdout and returns false. More...
 
void runScript (const std::string &fileName)
 
void runBuffer (const std::string &buffer, const std::string &source)
 
void loadScript (const std::string &fileName)
 
void loadFunction (const std::string &buffer, const std::string &source="lua function buffer")
 
void evaluateExpression (const std::string &expression, const std::string &source="lua expression")
 
std::string traceback (const std::string &errorMessage="", int level=0)
 
void throwError (const std::string &message)
 
std::string getCurrentSourcePath (int level=0)
 Searches for the source of the current running function. More...
 
int safeCall (int numArgs=0, int numRets=-1)
 Calls a function The function and arguments must be on top of the stack in order, results are pushed onto the stack. More...
 
int signalCall (int numArgs=0, int numRets=-1)
 
int newSandboxEnv ()
 Creates a new environment table The new environment table is redirected to the global environment (aka _G), this allows to access global variables from _G in the new environment and prevents new variables in this new environment to be set on the global environment. More...
 
template<typename... T>
int luaCallGlobalField (const std::string &global, const std::string &field, const T &... args)
 
template<typename... T>
void callGlobalField (const std::string &global, const std::string &field, const T &... args)
 
template<typename R , typename... T>
callGlobalField (const std::string &global, const std::string &field, const T &... args)
 
bool isInCppCallback ()
 
void createLuaState ()
 
void closeLuaState ()
 
void collectGarbage ()
 
void loadBuffer (const std::string &buffer, const std::string &source)
 
int pcall (int numArgs=0, int numRets=0, int errorFuncIndex=0)
 
void call (int numArgs=0, int numRets=0)
 
void error ()
 
int ref ()
 
int weakRef ()
 
void unref (int ref)
 
void useValue ()
 
const char * typeName (int index=-1)
 
std::string functionSourcePath ()
 
void insert (int index)
 
void remove (int index)
 
bool next (int index=-2)
 
void checkStack ()
 
void getStackFunction (int level=0)
 
void getRef (int ref)
 
void getWeakRef (int weakRef)
 
int getGlobalEnvironment ()
 
void setGlobalEnvironment (int env)
 
void resetGlobalEnvironment ()
 
void setMetatable (int index=-2)
 
void getMetatable (int index=-1)
 
void getField (const char *key, int index=-1)
 
void getField (const std::string &key, int index=-1)
 
void setField (const char *key, int index=-2)
 
void setField (const std::string &key, int index=-2)
 
void getTable (int index=-2)
 
void setTable (int index=-3)
 
void clearTable (int index=-1)
 
void getEnv (int index=-1)
 
void setEnv (int index=-2)
 
void getGlobal (const std::string &key)
 
void getGlobalField (const std::string &globalKey, const std::string &fieldKey)
 
void setGlobal (const std::string &key)
 
void rawGet (int index=-1)
 
void rawGeti (int n, int index=-1)
 
void rawSet (int index=-3)
 
void rawSeti (int n, int index=-2)
 
void newTable ()
 
void createTable (int narr, int nrec)
 
void * newUserdata (int size)
 
void pop (int n=1)
 
long popInteger ()
 
double popNumber ()
 
bool popBoolean ()
 
std::string popString ()
 
void * popUserdata ()
 
void * popUpvalueUserdata ()
 
LuaObjectPtr popObject ()
 
void pushNil ()
 
void pushInteger (long v)
 
void pushNumber (double v)
 
void pushBoolean (bool v)
 
void pushCString (const char *v)
 
void pushString (const std::string &v)
 
void pushLightUserdata (void *p)
 
void pushThread ()
 
void pushValue (int index=-1)
 
void pushObject (const LuaObjectPtr &obj)
 
void pushCFunction (LuaCFunction func, int n=0)
 
void pushCppFunction (const LuaCppFunction &func)
 
bool isNil (int index=-1)
 
bool isBoolean (int index=-1)
 
bool isNumber (int index=-1)
 
bool isString (int index=-1)
 
bool isTable (int index=-1)
 
bool isFunction (int index=-1)
 
bool isCFunction (int index=-1)
 
bool isLuaFunction (int index=-1)
 
bool isUserdata (int index=-1)
 
bool toBoolean (int index=-1)
 
int toInteger (int index=-1)
 
double toNumber (int index=-1)
 
const char * toCString (int index=-1)
 
std::string toString (int index=-1)
 
void * toUserdata (int index=-1)
 
LuaObjectPtr toObject (int index=-1)
 
int getTop ()
 
int stackSize ()
 
void clearStack ()
 
bool hasIndex (int index)
 
void loadFiles (std::string directory, bool recursive=false, std::string contains="")
 
template<typename T , typename... Args>
int polymorphicPush (const T &v, const Args &... args)
 Pushes any type onto the stack. More...
 
int polymorphicPush ()
 
template<class T >
castValue (int index=-1)
 
template<class T >
polymorphicPop ()
 Same as castValue but also pops. More...
 

Detailed Description

Class that manages LUA stuff.

Definition at line 32 of file luainterface.h.

Constructor & Destructor Documentation

◆ LuaInterface()

LuaInterface::LuaInterface ( )

Definition at line 33 of file luainterface.cpp.

◆ ~LuaInterface()

LuaInterface::~LuaInterface ( )

Definition at line 42 of file luainterface.cpp.

Member Function Documentation

◆ bindClassMemberField() [1/2]

template<class C , typename F1 , typename F2 , class FC >
void LuaInterface::bindClassMemberField ( const std::string &  className,
const std::string &  fieldName,
F1 FC::*  getFunction,
F2 FC::*  setFunction 
)

Definition at line 398 of file luainterface.h.

Here is the call graph for this function:

◆ bindClassMemberField() [2/2]

template<class C , typename F1 , typename F2 , class FC >
void LuaInterface::bindClassMemberField ( const std::string &  fieldName,
F1 FC::*  getFunction,
F2 FC::*  setFunction 
)

Definition at line 394 of file luainterface.h.

◆ bindClassMemberFunction() [1/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberFunction ( const std::string &  className,
const std::string &  functionName,
F FC::*  function 
)

Definition at line 389 of file luainterface.h.

Here is the call graph for this function:

◆ bindClassMemberFunction() [2/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberFunction ( const std::string &  functionName,
F FC::*  function 
)

Definition at line 385 of file luainterface.h.

Here is the caller graph for this function:

◆ bindClassMemberGetField() [1/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberGetField ( const std::string &  className,
const std::string &  fieldName,
F FC::*  getFunction 
)

Definition at line 407 of file luainterface.h.

Here is the call graph for this function:

◆ bindClassMemberGetField() [2/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberGetField ( const std::string &  fieldName,
F FC::*  getFunction 
)

Definition at line 403 of file luainterface.h.

◆ bindClassMemberSetField() [1/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberSetField ( const std::string &  className,
const std::string &  fieldName,
F FC::*  setFunction 
)

Definition at line 416 of file luainterface.h.

Here is the call graph for this function:

◆ bindClassMemberSetField() [2/2]

template<class C , typename F , class FC >
void LuaInterface::bindClassMemberSetField ( const std::string &  fieldName,
F FC::*  setFunction 
)

Definition at line 412 of file luainterface.h.

◆ bindClassStaticFunction() [1/2]

template<typename F >
void LuaInterface::bindClassStaticFunction ( const std::string &  className,
const std::string &  functionName,
const F &  function 
)

Definition at line 380 of file luainterface.h.

Here is the call graph for this function:

◆ bindClassStaticFunction() [2/2]

template<class C , typename F >
void LuaInterface::bindClassStaticFunction ( const std::string &  functionName,
const F &  function 
)

Definition at line 376 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bindGlobalFunction()

template<typename F >
void LuaInterface::bindGlobalFunction ( const std::string &  functionName,
const F &  function 
)

Definition at line 421 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bindSingletonFunction() [1/2]

template<class C , typename F >
void LuaInterface::bindSingletonFunction ( const std::string &  className,
const std::string &  functionName,
F C::*  function,
C *  instance 
)

Definition at line 371 of file luainterface.h.

Here is the call graph for this function:

◆ bindSingletonFunction() [2/2]

template<class C , typename F >
void LuaInterface::bindSingletonFunction ( const std::string &  functionName,
F C::*  function,
C *  instance 
)

Definition at line 366 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ call()

void LuaInterface::call ( int  numArgs = 0,
int  numRets = 0 
)

Definition at line 744 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callGlobalField() [1/2]

template<typename... T>
void LuaInterface::callGlobalField ( const std::string &  global,
const std::string &  field,
const T &...  args 
)

Definition at line 445 of file luainterface.h.

Here is the call graph for this function:

◆ callGlobalField() [2/2]

template<typename R , typename... T>
R LuaInterface::callGlobalField ( const std::string &  global,
const std::string &  field,
const T &...  args 
)

Definition at line 452 of file luainterface.h.

Here is the call graph for this function:

◆ castValue()

template<class T >
T LuaInterface::castValue ( int  index = -1)

Casts a value from stack to any type

Exceptions
LuaBadValueCastExceptionthrown if the cast fails

Definition at line 426 of file luainterface.h.

Here is the call graph for this function:

◆ checkStack()

void LuaInterface::checkStack ( )
inline

Definition at line 242 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearStack()

void LuaInterface::clearStack ( )
inline

Definition at line 322 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearTable()

void LuaInterface::clearTable ( int  index = -1)

Definition at line 918 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeLuaState()

void LuaInterface::closeLuaState ( )

Definition at line 705 of file luainterface.cpp.

Here is the caller graph for this function:

◆ collectGarbage()

void LuaInterface::collectGarbage ( )

Definition at line 714 of file luainterface.cpp.

Here is the caller graph for this function:

◆ createLuaState()

void LuaInterface::createLuaState ( )

Definition at line 664 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTable()

void LuaInterface::createTable ( int  narr,
int  nrec 
)

Definition at line 989 of file luainterface.cpp.

Here is the caller graph for this function:

◆ error()

void LuaInterface::error ( )

Definition at line 750 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluateExpression()

void LuaInterface::evaluateExpression ( const std::string &  expression,
const std::string &  source = "lua expression" 
)

Evaluates a lua expression and pushes the result value onto the stack

Exceptions
LuaExceptionis thrown on any lua error

Definition at line 362 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ functionSourcePath()

std::string LuaInterface::functionSourcePath ( )

Definition at line 799 of file luainterface.cpp.

Here is the caller graph for this function:

◆ getCurrentSourcePath()

std::string LuaInterface::getCurrentSourcePath ( int  level = 0)

Searches for the source of the current running function.

Definition at line 405 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEnv()

void LuaInterface::getEnv ( int  index = -1)

Definition at line 894 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getField() [1/2]

void LuaInterface::getField ( const char *  key,
int  index = -1 
)

Definition at line 880 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getField() [2/2]

void LuaInterface::getField ( const std::string &  key,
int  index = -1 
)
inline

Definition at line 256 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGlobal()

void LuaInterface::getGlobal ( const std::string &  key)

Definition at line 939 of file luainterface.cpp.

Here is the caller graph for this function:

◆ getGlobalEnvironment()

int LuaInterface::getGlobalEnvironment ( )
inline

Definition at line 248 of file luainterface.h.

Here is the caller graph for this function:

◆ getGlobalField()

void LuaInterface::getGlobalField ( const std::string &  globalKey,
const std::string &  fieldKey 
)

Definition at line 944 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMetatable()

void LuaInterface::getMetatable ( int  index = -1)

Definition at line 874 of file luainterface.cpp.

Here is the call graph for this function:

◆ getRef()

void LuaInterface::getRef ( int  ref)

Definition at line 846 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStackFunction()

void LuaInterface::getStackFunction ( int  level = 0)

Definition at line 837 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTable()

void LuaInterface::getTable ( int  index = -2)

Definition at line 906 of file luainterface.cpp.

Here is the call graph for this function:

◆ getTop()

int LuaInterface::getTop ( )

Definition at line 1250 of file luainterface.cpp.

Here is the caller graph for this function:

◆ getWeakRef()

void LuaInterface::getWeakRef ( int  weakRef)

Definition at line 851 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasIndex()

bool LuaInterface::hasIndex ( int  index)
inline

Definition at line 323 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void LuaInterface::init ( )

Definition at line 46 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert()

void LuaInterface::insert ( int  index)

Definition at line 819 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBoolean()

bool LuaInterface::isBoolean ( int  index = -1)

Definition at line 1156 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCFunction()

bool LuaInterface::isCFunction ( int  index = -1)

Definition at line 1186 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFunction()

bool LuaInterface::isFunction ( int  index = -1)

Definition at line 1180 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInCppCallback()

bool LuaInterface::isInCppCallback ( )
inline

Definition at line 200 of file luainterface.h.

Here is the caller graph for this function:

◆ isLuaFunction()

bool LuaInterface::isLuaFunction ( int  index = -1)
inline

Definition at line 309 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNil()

bool LuaInterface::isNil ( int  index = -1)

Definition at line 1150 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNumber()

bool LuaInterface::isNumber ( int  index = -1)

Definition at line 1162 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isString()

bool LuaInterface::isString ( int  index = -1)

Definition at line 1168 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTable()

bool LuaInterface::isTable ( int  index = -1)

Definition at line 1174 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUserdata()

bool LuaInterface::isUserdata ( int  index = -1)

Definition at line 1192 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadBuffer()

void LuaInterface::loadBuffer ( const std::string &  buffer,
const std::string &  source 
)

Definition at line 730 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFiles()

void LuaInterface::loadFiles ( std::string  directory,
bool  recursive = false,
std::string  contains = "" 
)

Definition at line 1255 of file luainterface.cpp.

Here is the call graph for this function:

◆ loadFunction()

void LuaInterface::loadFunction ( const std::string &  buffer,
const std::string &  source = "lua function buffer" 
)

Loads a function from buffer and pushes it onto stack,

Exceptions
LuaExceptionis thrown on any lua error

Definition at line 338 of file luainterface.cpp.

Here is the call graph for this function:

◆ loadScript()

void LuaInterface::loadScript ( const std::string &  fileName)

Loads a script file and pushes it's main function onto stack,

Exceptions
LuaExceptionis thrown on any lua error

Definition at line 324 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ luaCallGlobalField()

template<typename... T>
int LuaInterface::luaCallGlobalField ( const std::string &  global,
const std::string &  field,
const T &...  args 
)

Definition at line 434 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newSandboxEnv()

int LuaInterface::newSandboxEnv ( )

Creates a new environment table The new environment table is redirected to the global environment (aka _G), this allows to access global variables from _G in the new environment and prevents new variables in this new environment to be set on the global environment.

Definition at line 536 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newTable()

void LuaInterface::newTable ( )

Definition at line 984 of file luainterface.cpp.

Here is the caller graph for this function:

◆ newUserdata()

void * LuaInterface::newUserdata ( int  size)

Definition at line 994 of file luainterface.cpp.

Here is the caller graph for this function:

◆ next()

bool LuaInterface::next ( int  index = -2)

Definition at line 831 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcall()

int LuaInterface::pcall ( int  numArgs = 0,
int  numRets = 0,
int  errorFuncIndex = 0 
)

Definition at line 738 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ polymorphicPop()

template<class T >
T LuaInterface::polymorphicPop ( )
inline

Same as castValue but also pops.

Definition at line 339 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ polymorphicPush() [1/2]

int LuaInterface::polymorphicPush ( )
inline

Definition at line 330 of file luainterface.h.

Here is the caller graph for this function:

◆ polymorphicPush() [2/2]

template<typename T , typename... Args>
int LuaInterface::polymorphicPush ( const T &  v,
const Args &...  args 
)

Pushes any type onto the stack.

Definition at line 358 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pop()

void LuaInterface::pop ( int  n = 1)

Definition at line 999 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popBoolean()

bool LuaInterface::popBoolean ( )

Definition at line 1023 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popInteger()

long LuaInterface::popInteger ( )

Definition at line 1007 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popNumber()

double LuaInterface::popNumber ( )

Definition at line 1015 of file luainterface.cpp.

Here is the call graph for this function:

◆ popObject()

LuaObjectPtr LuaInterface::popObject ( )

Definition at line 1047 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popString()

std::string LuaInterface::popString ( )

Definition at line 1031 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popUpvalueUserdata()

void * LuaInterface::popUpvalueUserdata ( )

Definition at line 1055 of file luainterface.cpp.

◆ popUserdata()

void * LuaInterface::popUserdata ( )

Definition at line 1039 of file luainterface.cpp.

Here is the call graph for this function:

◆ pushBoolean()

void LuaInterface::pushBoolean ( bool  v)

Definition at line 1078 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushCFunction()

void LuaInterface::pushCFunction ( LuaCFunction  func,
int  n = 0 
)

Definition at line 1121 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushCppFunction()

void LuaInterface::pushCppFunction ( const LuaCppFunction func)

Definition at line 1127 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushCString()

void LuaInterface::pushCString ( const char *  v)

Definition at line 1084 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushInteger()

void LuaInterface::pushInteger ( long  v)

Definition at line 1066 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushLightUserdata()

void LuaInterface::pushLightUserdata ( void *  p)

Definition at line 1097 of file luainterface.cpp.

Here is the call graph for this function:

◆ pushNil()

void LuaInterface::pushNil ( )

Definition at line 1060 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushNumber()

void LuaInterface::pushNumber ( double  v)

Definition at line 1072 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushObject()

void LuaInterface::pushObject ( const LuaObjectPtr obj)

Definition at line 1109 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushString()

void LuaInterface::pushString ( const std::string &  v)

Definition at line 1091 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushThread()

void LuaInterface::pushThread ( )

Definition at line 1103 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushValue()

void LuaInterface::pushValue ( int  index = -1)

Definition at line 1143 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawGet()

void LuaInterface::rawGet ( int  index = -1)

Definition at line 960 of file luainterface.cpp.

Here is the call graph for this function:

◆ rawGeti()

void LuaInterface::rawGeti ( int  n,
int  index = -1 
)

Definition at line 966 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawSet()

void LuaInterface::rawSet ( int  index = -3)

Definition at line 972 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawSeti()

void LuaInterface::rawSeti ( int  n,
int  index = -2 
)

Definition at line 978 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ref()

int LuaInterface::ref ( )

Definition at line 756 of file luainterface.cpp.

Here is the caller graph for this function:

◆ registerClass() [1/2]

template<class C , class B = LuaObject>
void LuaInterface::registerClass ( )
inline

Definition at line 66 of file luainterface.h.

◆ registerClass() [2/2]

void LuaInterface::registerClass ( const std::string &  className,
const std::string &  baseClass = "LuaObject" 
)

Definition at line 87 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerClassMemberField() [1/2]

void LuaInterface::registerClassMemberField ( const std::string &  className,
const std::string &  field,
const LuaCppFunction getFunction,
const LuaCppFunction setFunction 
)

Definition at line 167 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerClassMemberField() [2/2]

template<class C >
void LuaInterface::registerClassMemberField ( const std::string &  field,
const LuaCppFunction getFunction,
const LuaCppFunction setFunction 
)
inline

Definition at line 81 of file luainterface.h.

Here is the call graph for this function:

◆ registerClassMemberFunction() [1/2]

void LuaInterface::registerClassMemberFunction ( const std::string &  className,
const std::string &  functionName,
const LuaCppFunction function 
)

Definition at line 157 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerClassMemberFunction() [2/2]

template<class C >
void LuaInterface::registerClassMemberFunction ( const std::string &  functionName,
const LuaCppFunction function 
)
inline

Definition at line 76 of file luainterface.h.

Here is the call graph for this function:

◆ registerClassStaticFunction() [1/2]

void LuaInterface::registerClassStaticFunction ( const std::string &  className,
const std::string &  functionName,
const LuaCppFunction function 
)

Definition at line 150 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerClassStaticFunction() [2/2]

template<class C >
void LuaInterface::registerClassStaticFunction ( const std::string &  functionName,
const LuaCppFunction function 
)
inline

Definition at line 71 of file luainterface.h.

Here is the call graph for this function:

◆ registerFunctions()

void LuaInterface::registerFunctions ( )

Register core script functions.

◆ registerGlobalFunction()

void LuaInterface::registerGlobalFunction ( const std::string &  functionName,
const LuaCppFunction function 
)

Definition at line 187 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerSingletonClass()

void LuaInterface::registerSingletonClass ( const std::string &  className)

Definition at line 79 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

void LuaInterface::remove ( int  index)

Definition at line 825 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetGlobalEnvironment()

void LuaInterface::resetGlobalEnvironment ( )
inline

Definition at line 250 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runBuffer()

void LuaInterface::runBuffer ( const std::string &  buffer,
const std::string &  source 
)

Loads and runs the script from buffer

Exceptions
LuaExceptionis thrown on any lua error

Definition at line 318 of file luainterface.cpp.

Here is the call graph for this function:

◆ runScript()

void LuaInterface::runScript ( const std::string &  fileName)

Loads and runs a script

Exceptions
LuaExceptionis thrown on any lua error

Definition at line 312 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safeCall()

int LuaInterface::safeCall ( int  numArgs = 0,
int  numRets = -1 
)

Calls a function The function and arguments must be on top of the stack in order, results are pushed onto the stack.

Exceptions
LuaExceptionis thrown on any lua error
Returns
number of results

Definition at line 432 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safeRunScript()

bool LuaInterface::safeRunScript ( const std::string &  fileName)

Loads and runs a script, any errors are printed to stdout and returns false.

Definition at line 301 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEnv()

void LuaInterface::setEnv ( int  index = -2)

Definition at line 900 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setField() [1/2]

void LuaInterface::setField ( const char *  key,
int  index = -2 
)

Definition at line 887 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setField() [2/2]

void LuaInterface::setField ( const std::string &  key,
int  index = -2 
)
inline

Definition at line 258 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGlobal()

void LuaInterface::setGlobal ( const std::string &  key)

Definition at line 954 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGlobalEnvironment()

void LuaInterface::setGlobalEnvironment ( int  env)

Definition at line 859 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMetatable()

void LuaInterface::setMetatable ( int  index = -2)

Definition at line 868 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTable()

void LuaInterface::setTable ( int  index = -3)

Definition at line 912 of file luainterface.cpp.

Here is the call graph for this function:

◆ signalCall()

int LuaInterface::signalCall ( int  numArgs = 0,
int  numRets = -1 
)

Same as safeCall but catches exceptions and can also calls a table of functions, if any error occurs it will be reported to stdout and returns 0 results

Parameters
requestedResultsis the number of results requested to pushes onto the stack, if supplied, the call will always pushes that number of results, even if it fails

Definition at line 468 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stackSize()

int LuaInterface::stackSize ( )
inline

Definition at line 321 of file luainterface.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ terminate()

void LuaInterface::terminate ( )

Definition at line 71 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ throwError()

void LuaInterface::throwError ( const std::string &  message)

Throw a lua error if inside a lua call or generates an C++ stdext::exception

Parameters
messageis the error message wich will be displayed before the error traceback
Exceptions
stdext::exceptionis thrown with the error message if the error is not captured by lua

Definition at line 396 of file luainterface.cpp.

Here is the call graph for this function:

◆ toBoolean()

bool LuaInterface::toBoolean ( int  index = -1)

Definition at line 1198 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toCString()

const char * LuaInterface::toCString ( int  index = -1)

Definition at line 1216 of file luainterface.cpp.

Here is the call graph for this function:

◆ toInteger()

int LuaInterface::toInteger ( int  index = -1)

Definition at line 1204 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toNumber()

double LuaInterface::toNumber ( int  index = -1)

Definition at line 1210 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toObject()

LuaObjectPtr LuaInterface::toObject ( int  index = -1)

Definition at line 1239 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

std::string LuaInterface::toString ( int  index = -1)

Definition at line 1222 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toUserdata()

void * LuaInterface::toUserdata ( int  index = -1)

Definition at line 1233 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ traceback()

std::string LuaInterface::traceback ( const std::string &  errorMessage = "",
int  level = 0 
)

Generates a traceback message for the current call stack

Parameters
errorMessageis an additional error message
levelis the level of the traceback, 0 means trace from calling function
Returns
the generated traceback message

Definition at line 380 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ typeName()

const char * LuaInterface::typeName ( int  index = -1)

Definition at line 792 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unref()

void LuaInterface::unref ( int  ref)

Definition at line 786 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ useValue()

void LuaInterface::useValue ( )
inline

Definition at line 233 of file luainterface.h.

Here is the call graph for this function:

◆ weakRef()

int LuaInterface::weakRef ( )

Definition at line 764 of file luainterface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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