diff options
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/state.cpp b/src/state.cpp index 2213297..688ac2a 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -146,7 +146,7 @@ static const luaL_Reg libs[] = | |||
146 | #endif | 146 | #endif |
147 | { LUA_COLIBNAME, luaopen_coroutine}, // Lua 5.2: coroutine is no longer a part of base! | 147 | { LUA_COLIBNAME, luaopen_coroutine}, // Lua 5.2: coroutine is no longer a part of base! |
148 | #else // LUA_VERSION_NUM | 148 | #else // LUA_VERSION_NUM |
149 | { LUA_COLIBNAME, NULL}, // Lua 5.1: part of base package | 149 | { LUA_COLIBNAME, nullptr }, // Lua 5.1: part of base package |
150 | #endif // LUA_VERSION_NUM | 150 | #endif // LUA_VERSION_NUM |
151 | { LUA_DBLIBNAME, luaopen_debug}, | 151 | { LUA_DBLIBNAME, luaopen_debug}, |
152 | #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 |
@@ -156,11 +156,11 @@ static const luaL_Reg libs[] = | |||
156 | { LUA_FFILIBNAME, luaopen_ffi}, | 156 | { LUA_FFILIBNAME, luaopen_ffi}, |
157 | #endif // LUAJIT_FLAVOR() | 157 | #endif // LUAJIT_FLAVOR() |
158 | 158 | ||
159 | { LUA_DBLIBNAME, luaopen_debug}, | 159 | { LUA_DBLIBNAME, luaopen_debug}, |
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) | 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) |
161 | // | 161 | // |
162 | { "base", NULL}, // ignore "base" (already acquired it) | 162 | { "base", nullptr }, // ignore "base" (already acquired it) |
163 | { NULL, NULL } | 163 | { nullptr, nullptr } |
164 | }; | 164 | }; |
165 | 165 | ||
166 | static void open1lib( DEBUGSPEW_PARAM_COMMA( Universe* U) lua_State* L, char const* name_, size_t len_) | 166 | static void open1lib( DEBUGSPEW_PARAM_COMMA( Universe* U) lua_State* L, char const* name_, size_t len_) |
@@ -172,7 +172,7 @@ static void open1lib( DEBUGSPEW_PARAM_COMMA( Universe* U) lua_State* L, char con | |||
172 | { | 172 | { |
173 | lua_CFunction libfunc = libs[i].func; | 173 | lua_CFunction libfunc = libs[i].func; |
174 | name_ = libs[i].name; // note that the provided name_ doesn't necessarily ends with '\0', hence len_ | 174 | name_ = libs[i].name; // note that the provided name_ doesn't necessarily ends with '\0', hence len_ |
175 | if( libfunc != NULL) | 175 | if (libfunc != nullptr) |
176 | { | 176 | { |
177 | bool const isLanesCore{ libfunc == require_lanes_core }; // don't want to create a global for "lanes.core" | 177 | bool const isLanesCore{ libfunc == require_lanes_core }; // don't want to create a global for "lanes.core" |
178 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "opening %.*s library\n" INDENT_END, (int) len_, name_)); | 178 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "opening %.*s library\n" INDENT_END, (int) len_, name_)); |
@@ -224,11 +224,11 @@ void initialize_on_state_create( Universe* U, lua_State* L) | |||
224 | { | 224 | { |
225 | // store C function pointer in an internal variable | 225 | // store C function pointer in an internal variable |
226 | U->on_state_create_func = lua_tocfunction( L, -1); // settings on_state_create | 226 | U->on_state_create_func = lua_tocfunction( L, -1); // settings on_state_create |
227 | if( U->on_state_create_func != NULL) | 227 | if (U->on_state_create_func != nullptr) |
228 | { | 228 | { |
229 | // make sure the function doesn't have upvalues | 229 | // make sure the function doesn't have upvalues |
230 | char const* upname = lua_getupvalue( L, -1, 1); // settings on_state_create upval? | 230 | char const* upname = lua_getupvalue( L, -1, 1); // settings on_state_create upval? |
231 | if( upname != NULL) // should be "" for C functions with upvalues if any | 231 | if (upname != nullptr) // should be "" for C functions with upvalues if any |
232 | { | 232 | { |
233 | (void) luaL_error( L, "on_state_create shouldn't have upvalues"); | 233 | (void) luaL_error( L, "on_state_create shouldn't have upvalues"); |
234 | } | 234 | } |
@@ -254,7 +254,7 @@ lua_State* create_state( Universe* U, lua_State* from_) | |||
254 | // 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... |
255 | L = luaL_newstate(); | 255 | L = luaL_newstate(); |
256 | #else // LUAJIT_FLAVOR() == 64 | 256 | #else // LUAJIT_FLAVOR() == 64 |
257 | if( U->provide_allocator != NULL) // we have a function we can call to obtain an allocator | 257 | if (U->provide_allocator != nullptr) // we have a function we can call to obtain an allocator |
258 | { | 258 | { |
259 | lua_pushcclosure( from_, U->provide_allocator, 0); | 259 | lua_pushcclosure( from_, U->provide_allocator, 0); |
260 | lua_call( from_, 0, 1); | 260 | lua_call( from_, 0, 1); |
@@ -271,7 +271,7 @@ lua_State* create_state( Universe* U, lua_State* from_) | |||
271 | } | 271 | } |
272 | #endif // LUAJIT_FLAVOR() == 64 | 272 | #endif // LUAJIT_FLAVOR() == 64 |
273 | 273 | ||
274 | if( L == NULL) | 274 | if (L == nullptr) |
275 | { | 275 | { |
276 | (void) luaL_error( from_, "luaG_newstate() failed while creating state; out of memory"); | 276 | (void) luaL_error( from_, "luaG_newstate() failed while creating state; out of memory"); |
277 | } | 277 | } |
@@ -280,7 +280,7 @@ lua_State* create_state( Universe* U, lua_State* from_) | |||
280 | 280 | ||
281 | void call_on_state_create( Universe* U, lua_State* L, lua_State* from_, LookupMode mode_) | 281 | void call_on_state_create( Universe* U, lua_State* L, lua_State* from_, LookupMode mode_) |
282 | { | 282 | { |
283 | if( U->on_state_create_func != NULL) | 283 | if (U->on_state_create_func != nullptr) |
284 | { | 284 | { |
285 | STACK_CHECK( L, 0); | 285 | STACK_CHECK( L, 0); |
286 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "calling on_state_create()\n" INDENT_END)); | 286 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "calling on_state_create()\n" INDENT_END)); |
@@ -315,12 +315,12 @@ void call_on_state_create( Universe* U, lua_State* L, lua_State* from_, LookupMo | |||
315 | /* | 315 | /* |
316 | * Like 'luaL_openlibs()' but allows the set of libraries be selected | 316 | * Like 'luaL_openlibs()' but allows the set of libraries be selected |
317 | * | 317 | * |
318 | * NULL no libraries, not even base | 318 | * nullptr no libraries, not even base |
319 | * "" base library only | 319 | * "" base library only |
320 | * "io,string" named libraries | 320 | * "io,string" named libraries |
321 | * "*" all libraries | 321 | * "*" all libraries |
322 | * | 322 | * |
323 | * Base ("unpack", "print" etc.) is always added, unless 'libs' is NULL. | 323 | * Base ("unpack", "print" etc.) is always added, unless 'libs' is nullptr. |
324 | * | 324 | * |
325 | * *NOT* called for keeper states! | 325 | * *NOT* called for keeper states! |
326 | * | 326 | * |
@@ -342,9 +342,9 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
342 | STACK_MID( L, 0); | 342 | STACK_MID( L, 0); |
343 | 343 | ||
344 | // neither libs (not even 'base') nor special init func: we are done | 344 | // neither libs (not even 'base') nor special init func: we are done |
345 | if( libs_ == NULL && U->on_state_create_func == NULL) | 345 | if (libs_ == nullptr && U->on_state_create_func == nullptr) |
346 | { | 346 | { |
347 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "luaG_newstate(NULL)\n" INDENT_END)); | 347 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "luaG_newstate(nullptr)\n" INDENT_END)); |
348 | return L; | 348 | return L; |
349 | } | 349 | } |
350 | 350 | ||
@@ -360,7 +360,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
360 | 360 | ||
361 | // Anything causes 'base' to be taken in | 361 | // Anything causes 'base' to be taken in |
362 | // | 362 | // |
363 | if( libs_ != NULL) | 363 | if (libs_ != nullptr) |
364 | { | 364 | { |
365 | // special "*" case (mainly to help with LuaJIT compatibility) | 365 | // special "*" case (mainly to help with LuaJIT compatibility) |
366 | // as we are called from luaopen_lanes_core() already, and that would deadlock | 366 | // as we are called from luaopen_lanes_core() already, and that would deadlock |
@@ -370,7 +370,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
370 | luaL_openlibs( L); | 370 | luaL_openlibs( L); |
371 | // don't forget lanes.core for regular lane states | 371 | // don't forget lanes.core for regular lane states |
372 | open1lib( DEBUGSPEW_PARAM_COMMA( U) L, "lanes.core", 10); | 372 | open1lib( DEBUGSPEW_PARAM_COMMA( U) L, "lanes.core", 10); |
373 | libs_ = NULL; // done with libs | 373 | libs_ = nullptr; // done with libs |
374 | } | 374 | } |
375 | else | 375 | else |
376 | { | 376 | { |
@@ -417,7 +417,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_) | |||
417 | STACK_CHECK( L, 0); | 417 | STACK_CHECK( L, 0); |
418 | // after all this, register everything we find in our name<->function database | 418 | // after all this, register everything we find in our name<->function database |
419 | 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 |
420 | populate_func_lookup_table( L, -1, NULL); | 420 | populate_func_lookup_table(L, -1, nullptr); |
421 | 421 | ||
422 | #if 0 && USE_DEBUG_SPEW() | 422 | #if 0 && USE_DEBUG_SPEW() |
423 | // dump the lookup database contents | 423 | // dump the lookup database contents |