diff options
Diffstat (limited to 'src/state.c')
-rw-r--r-- | src/state.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/state.c b/src/state.c index a2de5cb..ef70842 100644 --- a/src/state.c +++ b/src/state.c | |||
@@ -41,6 +41,7 @@ THE SOFTWARE. | |||
41 | #endif // __APPLE__ | 41 | #endif // __APPLE__ |
42 | 42 | ||
43 | #include "compat.h" | 43 | #include "compat.h" |
44 | #include "macros_and_utils.h" | ||
44 | #include "universe.h" | 45 | #include "universe.h" |
45 | #include "tools.h" | 46 | #include "tools.h" |
46 | #include "lanes.h" | 47 | #include "lanes.h" |
@@ -148,12 +149,12 @@ static const luaL_Reg libs[] = | |||
148 | { LUA_COLIBNAME, NULL}, // Lua 5.1: part of base package | 149 | { LUA_COLIBNAME, NULL}, // Lua 5.1: part of base package |
149 | #endif // LUA_VERSION_NUM | 150 | #endif // LUA_VERSION_NUM |
150 | { LUA_DBLIBNAME, luaopen_debug}, | 151 | { LUA_DBLIBNAME, luaopen_debug}, |
151 | #if LUAJIT_FLAVOR != 0 // building against LuaJIT headers, add some LuaJIT-specific libs | 152 | #if LUAJIT_FLAVOR() != 0 // building against LuaJIT headers, add some LuaJIT-specific libs |
152 | //#pragma message( "supporting JIT base libs") | 153 | //#pragma message( "supporting JIT base libs") |
153 | { LUA_BITLIBNAME, luaopen_bit}, | 154 | { LUA_BITLIBNAME, luaopen_bit}, |
154 | { LUA_JITLIBNAME, luaopen_jit}, | 155 | { LUA_JITLIBNAME, luaopen_jit}, |
155 | { LUA_FFILIBNAME, luaopen_ffi}, | 156 | { LUA_FFILIBNAME, luaopen_ffi}, |
156 | #endif // LUAJIT_FLAVOR | 157 | #endif // LUAJIT_FLAVOR() |
157 | 158 | ||
158 | { LUA_DBLIBNAME, luaopen_debug}, | 159 | { LUA_DBLIBNAME, luaopen_debug}, |
159 | { "lanes.core", require_lanes_core}, // So that we can open it like any base library (possible since we have access to the init function) | 160 | { "lanes.core", require_lanes_core}, // So that we can open it like any base library (possible since we have access to the init function) |
@@ -249,10 +250,10 @@ void initialize_on_state_create( Universe* U, lua_State* L) | |||
249 | lua_State* create_state( Universe* U, lua_State* from_) | 250 | lua_State* create_state( Universe* U, lua_State* from_) |
250 | { | 251 | { |
251 | lua_State* L; | 252 | lua_State* L; |
252 | #if LUAJIT_FLAVOR == 64 | 253 | #if LUAJIT_FLAVOR() == 64 |
253 | // for some reason, LuaJIT 64 bits does not support creating a state with lua_newstate... | 254 | // for some reason, LuaJIT 64 bits does not support creating a state with lua_newstate... |
254 | L = luaL_newstate(); | 255 | L = luaL_newstate(); |
255 | #else // LUAJIT_FLAVOR == 64 | 256 | #else // LUAJIT_FLAVOR() == 64 |
256 | if( U->provide_allocator != NULL) // we have a function we can call to obtain an allocator | 257 | if( U->provide_allocator != NULL) // we have a function we can call to obtain an allocator |
257 | { | 258 | { |
258 | lua_pushcclosure( from_, U->provide_allocator, 0); | 259 | lua_pushcclosure( from_, U->provide_allocator, 0); |
@@ -268,7 +269,7 @@ lua_State* create_state( Universe* U, lua_State* from_) | |||
268 | // reuse the allocator provided when the master state was created | 269 | // reuse the allocator provided when the master state was created |
269 | L = lua_newstate( U->protected_allocator.definition.allocF, U->protected_allocator.definition.allocUD); | 270 | L = lua_newstate( U->protected_allocator.definition.allocF, U->protected_allocator.definition.allocUD); |
270 | } | 271 | } |
271 | #endif // LUAJIT_FLAVOR == 64 | 272 | #endif // LUAJIT_FLAVOR() == 64 |
272 | 273 | ||
273 | if( L == NULL) | 274 | if( L == NULL) |
274 | { | 275 | { |
@@ -418,7 +419,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
418 | lua_pushglobaltable( L); // Lua 5.2 no longer has LUA_GLOBALSINDEX: we must push globals table on the stack | 419 | lua_pushglobaltable( L); // Lua 5.2 no longer has LUA_GLOBALSINDEX: we must push globals table on the stack |
419 | populate_func_lookup_table( L, -1, NULL); | 420 | populate_func_lookup_table( L, -1, NULL); |
420 | 421 | ||
421 | #if 0 && USE_DEBUG_SPEW | 422 | #if 0 && USE_DEBUG_SPEW() |
422 | // dump the lookup database contents | 423 | // dump the lookup database contents |
423 | lua_getfield( L, LUA_REGISTRYINDEX, LOOKUP_REGKEY); // {} | 424 | lua_getfield( L, LUA_REGISTRYINDEX, LOOKUP_REGKEY); // {} |
424 | lua_pushnil( L); // {} nil | 425 | lua_pushnil( L); // {} nil |
@@ -432,7 +433,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
432 | lua_pop( L, 1); // {} k | 433 | lua_pop( L, 1); // {} k |
433 | } | 434 | } |
434 | lua_pop( L, 1); // {} | 435 | lua_pop( L, 1); // {} |
435 | #endif // USE_DEBUG_SPEW | 436 | #endif // USE_DEBUG_SPEW() |
436 | 437 | ||
437 | lua_pop( L, 1); | 438 | lua_pop( L, 1); |
438 | STACK_END( L, 0); | 439 | STACK_END( L, 0); |