|
Lines 35-46
Link Here
|
| 35 |
|
35 |
|
| 36 |
// include Lua libs and tolua++ |
36 |
// include Lua libs and tolua++ |
| 37 |
extern "C" { |
37 |
extern "C" { |
| 38 |
#include "lua.h" |
38 |
#include "tolua++.h" |
| 39 |
#include "lualib.h" |
39 |
#include "lualib.h" |
| 40 |
#include "lauxlib.h" |
|
|
| 41 |
} |
40 |
} |
| 42 |
|
41 |
|
| 43 |
#include "tolua++.h" |
|
|
| 44 |
|
42 |
|
| 45 |
// prototype for bindings initialisation function |
43 |
// prototype for bindings initialisation function |
| 46 |
int tolua_CEGUI_open(lua_State* tolua_S); |
44 |
int tolua_CEGUI_open(lua_State* tolua_S); |
|
Lines 55-65
Link Here
|
| 55 |
*************************************************************************/ |
53 |
*************************************************************************/ |
| 56 |
LuaScriptModule::LuaScriptModule() |
54 |
LuaScriptModule::LuaScriptModule() |
| 57 |
{ |
55 |
{ |
|
|
56 |
#ifdef LUA51 |
| 57 |
static const luaL_Reg lualibs[] = { |
| 58 |
{"", luaopen_base}, |
| 59 |
{LUA_LOADLIBNAME, luaopen_package}, |
| 60 |
{LUA_TABLIBNAME, luaopen_table}, |
| 61 |
{LUA_IOLIBNAME, luaopen_io}, |
| 62 |
{LUA_OSLIBNAME, luaopen_os}, |
| 63 |
{LUA_STRLIBNAME, luaopen_string}, |
| 64 |
{LUA_MATHLIBNAME, luaopen_math}, |
| 65 |
#if defined(DEBUG) || defined (_DEBUG) |
| 66 |
{LUA_DBLIBNAME, luaopen_debug}, |
| 67 |
#endif |
| 68 |
{NULL, NULL} |
| 69 |
}; |
| 70 |
#endif /* LUA51 */ |
| 71 |
|
| 58 |
// create a lua state |
72 |
// create a lua state |
| 59 |
d_ownsState = true; |
73 |
d_ownsState = true; |
| 60 |
d_state = lua_open(); |
74 |
d_state = lua_open(); |
| 61 |
|
75 |
|
| 62 |
// init all standard libraries |
76 |
// init all standard libraries |
|
|
77 |
#ifdef LUA51 |
| 78 |
const luaL_Reg *lib = lualibs; |
| 79 |
for (; lib->func; lib++) |
| 80 |
{ |
| 81 |
lua_pushcfunction(d_state, lib->func); |
| 82 |
lua_pushstring(d_state, lib->name); |
| 83 |
lua_call(d_state, 1, 0); |
| 84 |
} |
| 85 |
#else /* LUA51 */ |
| 63 |
luaopen_base(d_state); |
86 |
luaopen_base(d_state); |
| 64 |
luaopen_io(d_state); |
87 |
luaopen_io(d_state); |
| 65 |
luaopen_string(d_state); |
88 |
luaopen_string(d_state); |
|
Lines 68-74
Link Here
|
| 68 |
#if defined(DEBUG) || defined (_DEBUG) |
91 |
#if defined(DEBUG) || defined (_DEBUG) |
| 69 |
luaopen_debug(d_state); |
92 |
luaopen_debug(d_state); |
| 70 |
#endif |
93 |
#endif |
| 71 |
|
94 |
#endif /* LUA51 */ |
| 72 |
setModuleIdentifierString(); |
95 |
setModuleIdentifierString(); |
| 73 |
} |
96 |
} |
| 74 |
|
97 |
|