aboutsummaryrefslogtreecommitdiff
path: root/src/deep.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/deep.cpp')
-rw-r--r--src/deep.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/deep.cpp b/src/deep.cpp
index c0aa25b..ee08cdd 100644
--- a/src/deep.cpp
+++ b/src/deep.cpp
@@ -106,7 +106,7 @@ static void get_deep_lookup( lua_State* L)
106 106
107/* 107/*
108* Return the registered ID function for 'index' (deep userdata proxy), 108* Return the registered ID function for 'index' (deep userdata proxy),
109* or NULL if 'index' is not a deep userdata proxy. 109* or nullptr if 'index' is not a deep userdata proxy.
110*/ 110*/
111static inline luaG_IdFunction get_idfunc( lua_State* L, int index, LookupMode mode_) 111static inline luaG_IdFunction get_idfunc( lua_State* L, int index, LookupMode mode_)
112{ 112{
@@ -128,13 +128,13 @@ static inline luaG_IdFunction get_idfunc( lua_State* L, int index, LookupMode mo
128 128
129 if( !lua_getmetatable( L, index)) // deep ... metatable? 129 if( !lua_getmetatable( L, index)) // deep ... metatable?
130 { 130 {
131 return NULL; // no metatable: can't be a deep userdata object! 131 return nullptr; // no metatable: can't be a deep userdata object!
132 } 132 }
133 133
134 // replace metatable with the idfunc pointer, if it is actually a deep userdata 134 // replace metatable with the idfunc pointer, if it is actually a deep userdata
135 get_deep_lookup( L); // deep ... idfunc|nil 135 get_deep_lookup( L); // deep ... idfunc|nil
136 136
137 ret = (luaG_IdFunction) lua_touserdata( L, -1); // NULL if not a userdata 137 ret = (luaG_IdFunction) lua_touserdata( L, -1); // nullptr if not a userdata
138 lua_pop( L, 1); 138 lua_pop( L, 1);
139 STACK_END( L, 0); 139 STACK_END( L, 0);
140 return ret; 140 return ret;
@@ -189,14 +189,14 @@ static int deep_userdata_gc( lua_State* L)
189 luaL_error( L, "Bad idfunc(eDO_delete): should not push anything"); 189 luaL_error( L, "Bad idfunc(eDO_delete): should not push anything");
190 } 190 }
191 } 191 }
192 *proxy = NULL; // make sure we don't use it any more, just in case 192 *proxy = nullptr; // make sure we don't use it any more, just in case
193 return 0; 193 return 0;
194} 194}
195 195
196 196
197/* 197/*
198 * Push a proxy userdata on the stack. 198 * Push a proxy userdata on the stack.
199 * returns NULL if ok, else some error string related to bad idfunc behavior or module require problem 199 * returns nullptr if ok, else some error string related to bad idfunc behavior or module require problem
200 * (error cannot happen with mode_ == eLM_ToKeeper) 200 * (error cannot happen with mode_ == eLM_ToKeeper)
201 * 201 *
202 * Initializes necessary structures if it's the first time 'idfunc' is being 202 * Initializes necessary structures if it's the first time 'idfunc' is being
@@ -214,7 +214,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in
214 if ( !lua_isnil( L, -1)) 214 if ( !lua_isnil( L, -1))
215 { 215 {
216 lua_remove( L, -2); // proxy 216 lua_remove( L, -2); // proxy
217 return NULL; 217 return nullptr;
218 } 218 }
219 else 219 else
220 { 220 {
@@ -293,7 +293,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in
293 return "Bad idfunc(eOP_module): should not push anything"; 293 return "Bad idfunc(eOP_module): should not push anything";
294 } 294 }
295 } 295 }
296 if( NULL != modname) // we actually got a module name 296 if (nullptr != modname) // we actually got a module name
297 { 297 {
298 // L.registry._LOADED exists without having registered the 'package' library. 298 // L.registry._LOADED exists without having registered the 'package' library.
299 lua_getglobal( L, "require"); // DPC proxy metatable require() 299 lua_getglobal( L, "require"); // DPC proxy metatable require()
@@ -352,7 +352,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in
352 lua_remove( L, -2); // proxy 352 lua_remove( L, -2); // proxy
353 ASSERT_L( lua_isuserdata( L, -1)); 353 ASSERT_L( lua_isuserdata( L, -1));
354 STACK_END( L, 0); 354 STACK_END( L, 0);
355 return NULL; 355 return nullptr;
356} 356}
357 357
358/* 358/*
@@ -386,7 +386,7 @@ int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction idfunc, int nuv_)
386 { 386 {
387 int const oldtop = lua_gettop( L); 387 int const oldtop = lua_gettop( L);
388 DeepPrelude* prelude = (DeepPrelude*) idfunc( L, eDO_new); 388 DeepPrelude* prelude = (DeepPrelude*) idfunc( L, eDO_new);
389 if( prelude == NULL) 389 if (prelude == nullptr)
390 { 390 {
391 return luaL_error( L, "idfunc(eDO_new) failed to create deep userdata (out of memory)"); 391 return luaL_error( L, "idfunc(eDO_new) failed to create deep userdata (out of memory)");
392 } 392 }
@@ -408,7 +408,7 @@ int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction idfunc, int nuv_)
408 return luaL_error( L, "Bad idfunc(eDO_new): should not push anything on the stack"); 408 return luaL_error( L, "Bad idfunc(eDO_new): should not push anything on the stack");
409 } 409 }
410 errmsg = push_deep_proxy( universe_get( L), L, prelude, nuv_, eLM_LaneBody); // proxy 410 errmsg = push_deep_proxy( universe_get( L), L, prelude, nuv_, eLM_LaneBody); // proxy
411 if( errmsg != NULL) 411 if (errmsg != nullptr)
412 { 412 {
413 return luaL_error( L, errmsg); 413 return luaL_error( L, errmsg);
414 } 414 }
@@ -432,7 +432,7 @@ void* luaG_todeep( lua_State* L, luaG_IdFunction idfunc, int index)
432 // ensure it is actually a deep userdata 432 // ensure it is actually a deep userdata
433 if( get_idfunc( L, index, eLM_LaneBody) != idfunc) 433 if( get_idfunc( L, index, eLM_LaneBody) != idfunc)
434 { 434 {
435 return NULL; // no metatable, or wrong kind 435 return nullptr; // no metatable, or wrong kind
436 } 436 }
437 437
438 proxy = (DeepPrelude**) lua_touserdata( L, index); 438 proxy = (DeepPrelude**) lua_touserdata( L, index);
@@ -446,7 +446,7 @@ void* luaG_todeep( lua_State* L, luaG_IdFunction idfunc, int index)
446 * Copy deep userdata between two separate Lua states (from L to L2) 446 * Copy deep userdata between two separate Lua states (from L to L2)
447 * 447 *
448 * Returns: 448 * Returns:
449 * the id function of the copied value, or NULL for non-deep userdata 449 * the id function of the copied value, or nullptr for non-deep userdata
450 * (not copied) 450 * (not copied)
451 */ 451 */
452bool copydeep( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, LookupMode mode_, char const* upName_) 452bool copydeep( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, LookupMode mode_, char const* upName_)
@@ -455,7 +455,7 @@ bool copydeep( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint
455 luaG_IdFunction idfunc = get_idfunc( L, i, mode_); 455 luaG_IdFunction idfunc = get_idfunc( L, i, mode_);
456 int nuv = 0; 456 int nuv = 0;
457 457
458 if( idfunc == NULL) 458 if (idfunc == nullptr)
459 { 459 {
460 return false; // not a deep userdata 460 return false; // not a deep userdata
461 } 461 }
@@ -490,7 +490,7 @@ bool copydeep( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint
490 STACK_END( L2, 1); 490 STACK_END( L2, 1);
491 STACK_END( L, 0); 491 STACK_END( L, 0);
492 492
493 if( errmsg != NULL) 493 if (errmsg != nullptr)
494 { 494 {
495 // raise the error in the proper state (not the keeper) 495 // raise the error in the proper state (not the keeper)
496 lua_State* errL = (mode_ == eLM_FromKeeper) ? L2 : L; 496 lua_State* errL = (mode_ == eLM_FromKeeper) ? L2 : L;