aboutsummaryrefslogtreecommitdiff
path: root/src/deep.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/deep.cpp')
-rw-r--r--src/deep.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/deep.cpp b/src/deep.cpp
index dd682e4..f091d4d 100644
--- a/src/deep.cpp
+++ b/src/deep.cpp
@@ -113,7 +113,7 @@ static inline luaG_IdFunction* get_idfunc( lua_State* L, int index, LookupMode m
113 // when looking inside a keeper, we are 100% sure the object is a deep userdata 113 // when looking inside a keeper, we are 100% sure the object is a deep userdata
114 if( mode_ == eLM_FromKeeper) 114 if( mode_ == eLM_FromKeeper)
115 { 115 {
116 DeepPrelude** proxy = (DeepPrelude**) lua_touserdata( L, index); 116 DeepPrelude** const proxy{ lua_touserdata<DeepPrelude*>(L, index) };
117 // we can (and must) cast and fetch the internally stored idfunc 117 // we can (and must) cast and fetch the internally stored idfunc
118 return (*proxy)->idfunc; 118 return (*proxy)->idfunc;
119 } 119 }
@@ -133,7 +133,7 @@ static inline luaG_IdFunction* get_idfunc( lua_State* L, int index, LookupMode m
133 // replace metatable with the idfunc pointer, if it is actually a deep userdata 133 // replace metatable with the idfunc pointer, if it is actually a deep userdata
134 get_deep_lookup( L); // deep ... idfunc|nil 134 get_deep_lookup( L); // deep ... idfunc|nil
135 135
136 luaG_IdFunction* const ret{ static_cast<luaG_IdFunction*>(lua_touserdata(L, -1)) }; // nullptr if not a userdata 136 luaG_IdFunction* const ret{ lua_touserdata<luaG_IdFunction>(L, -1) }; // nullptr if not a userdata
137 lua_pop( L, 1); 137 lua_pop( L, 1);
138 STACK_CHECK( L, 0); 138 STACK_CHECK( L, 0);
139 return ret; 139 return ret;
@@ -161,7 +161,7 @@ void free_deep_prelude( lua_State* L, DeepPrelude* prelude_)
161 */ 161 */
162static int deep_userdata_gc( lua_State* L) 162static int deep_userdata_gc( lua_State* L)
163{ 163{
164 DeepPrelude** proxy = (DeepPrelude**) lua_touserdata( L, 1); 164 DeepPrelude** const proxy{ lua_touserdata<DeepPrelude*>(L, 1) };
165 DeepPrelude* p = *proxy; 165 DeepPrelude* p = *proxy;
166 166
167 // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded 167 // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded
@@ -418,17 +418,15 @@ int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction* idfunc, int nuv_)
418*/ 418*/
419void* luaG_todeep( lua_State* L, luaG_IdFunction* idfunc, int index) 419void* luaG_todeep( lua_State* L, luaG_IdFunction* idfunc, int index)
420{ 420{
421 DeepPrelude** proxy;
422
423 STACK_CHECK_START_REL(L, 0); 421 STACK_CHECK_START_REL(L, 0);
424 // ensure it is actually a deep userdata 422 // ensure it is actually a deep userdata
425 if( get_idfunc( L, index, eLM_LaneBody) != idfunc) 423 if( get_idfunc( L, index, eLM_LaneBody) != idfunc)
426 { 424 {
427 return nullptr; // no metatable, or wrong kind 425 return nullptr; // no metatable, or wrong kind
428 } 426 }
427 STACK_CHECK(L, 0);
429 428
430 proxy = (DeepPrelude**) lua_touserdata( L, index); 429 DeepPrelude** const proxy{ lua_touserdata<DeepPrelude*>(L, index) };
431 STACK_CHECK( L, 0);
432 430
433 return *proxy; 431 return *proxy;
434} 432}
@@ -464,7 +462,7 @@ bool copydeep(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, L
464 lua_pop( L, 1); // ... u [uv]* 462 lua_pop( L, 1); // ... u [uv]*
465 STACK_CHECK( L, nuv); 463 STACK_CHECK( L, nuv);
466 464
467 errmsg = push_deep_proxy(L2, *(DeepPrelude**) lua_touserdata( L, i), nuv, mode_); // u 465 errmsg = push_deep_proxy(L2, *lua_touserdata<DeepPrelude*>(L, i), nuv, mode_); // u
468 466
469 // transfer all uservalues of the source in the destination 467 // transfer all uservalues of the source in the destination
470 { 468 {