Lib
QOLを高める
Classes | Public Member Functions | List of all members
yappy::lua::Lua Class Reference

Lua state manager. More...

#include <script.h>

Inheritance diagram for yappy::lua::Lua:
yappy::util::noncopyable

Classes

struct  doNothing
 

Public Member Functions

 Lua (bool debugEnable, size_t maxHeapSize, size_t initHeapSize=1024 *1024, int instLimit=10 *10000)
 Create new lua_State and open standard libs. More...
 
 ~Lua ()
 Destruct lua_State. More...
 
lua_State * getLuaState () const
 Returns lua_State which this object has. More...
 
void loadTraceLib ()
 
void loadSysLib ()
 
void loadRandLib ()
 
void loadResourceLib (framework::Application *app)
 
void loadGraphLib (framework::Application *app)
 
void loadSoundLib (framework::Application *app)
 
void loadFile (const wchar_t *fileName, bool autoBreak, bool prot=true)
 Load script file and eval it. More...
 
template<class ParamFunc = doNothing, class RetFunc = doNothing>
void callGlobal (const char *funcName, bool autoBreak, ParamFunc pushArgFunc=doNothing(), int narg=0, RetFunc getRetFunc=doNothing(), int nret=0)
 Calls global function. More...
 

Detailed Description

Lua state manager.

Each Lua object manages one lua_State. If debugEnable at the constructor is true, full debug hook will be enabled. This may be heavy. If debugEnable is false, debug hook mask is only instruction count. instLimit is a feature for preventing infinite loop. LuaDebugger set it as hook count, and if COUNT event would happened, hook function raises an lua error.

Definition at line 33 of file script.h.

Constructor & Destructor Documentation

yappy::lua::Lua::Lua ( bool  debugEnable,
size_t  maxHeapSize,
size_t  initHeapSize = 1024 * 1024,
int  instLimit = 10 * 10000 
)

Create new lua_State and open standard libs.

Parameters
[in]debugEnableEnable debug feature.
[in]maxHeapSizeMax memory usage. (only virtual address range will be reserved at first)
[in]initHeapSizeInitial commit size. (physical memory mapped)
[in]instLimitLua bytecode instruction count limit. (no limit if 0)

Definition at line 102 of file script.cpp.

yappy::lua::Lua::~Lua ( )

Destruct lua_State.

Definition at line 144 of file script.cpp.

Member Function Documentation

template<class ParamFunc = doNothing, class RetFunc = doNothing>
void yappy::lua::Lua::callGlobal ( const char *  funcName,
bool  autoBreak,
ParamFunc  pushArgFunc = doNothing(),
int  narg = 0,
RetFunc  getRetFunc = doNothing(),
int  nret = 0 
)
inline

Calls global function.

pushParamFunc and getRetFunc must be able to be called by:

pushParamFunc(lua_State *);
getRetFunc(lua_State *);

(lambda expr is recommended)

[](lua_State *L) {
lua_pushXXX(L, ...);
}
Parameters
[in]funcNameFunction name.
[in]autoBreakBreak by debugger at the first LINE event if true.
[in]pushArgFuncWill be called just before lua_pcall().
[in]nargArguments count.
[in]getRetFuncWill be called just after lua_pcall().
[in]nretReturn values count.

Definition at line 92 of file script.h.

lua_State * yappy::lua::Lua::getLuaState ( ) const

Returns lua_State which this object has.

Returns
lua_State

Definition at line 139 of file script.cpp.

void yappy::lua::Lua::loadFile ( const wchar_t *  fileName,
bool  autoBreak,
bool  prot = true 
)

Load script file and eval it.

Parameters
[in]fileNameScript file name.
[in]autoBreakDebug break at the first line.
[in]protUse pcall() if true. (false is include from Lua only)

Definition at line 207 of file script.cpp.

void yappy::lua::Lua::loadGraphLib ( framework::Application app)

Definition at line 187 of file script.cpp.

void yappy::lua::Lua::loadRandLib ( )

Definition at line 170 of file script.cpp.

void yappy::lua::Lua::loadResourceLib ( framework::Application app)

Definition at line 177 of file script.cpp.

void yappy::lua::Lua::loadSoundLib ( framework::Application app)

Definition at line 197 of file script.cpp.

void yappy::lua::Lua::loadSysLib ( )

Definition at line 160 of file script.cpp.

void yappy::lua::Lua::loadTraceLib ( )

Definition at line 149 of file script.cpp.


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