aboutsummaryrefslogtreecommitdiff
path: root/src/tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.cpp')
-rw-r--r--src/tools.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/tools.cpp b/src/tools.cpp
index 8242c82..88e7e2b 100644
--- a/src/tools.cpp
+++ b/src/tools.cpp
@@ -48,7 +48,7 @@ THE SOFTWARE.
48#include "uniquekey.h" 48#include "uniquekey.h"
49 49
50// functions implemented in deep.c 50// functions implemented in deep.c
51extern bool copydeep( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, LookupMode mode_, char const* upName_); 51extern bool copydeep(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, LookupMode mode_, char const* upName_);
52extern void push_registry_subtable( lua_State* L, UniqueKey key_); 52extern void push_registry_subtable( lua_State* L, UniqueKey key_);
53 53
54DEBUGSPEW_CODE( char const* debugspew_indent = "----+----!----+----!----+----!----+----!----+----!----+----!----+----!----+"); 54DEBUGSPEW_CODE( char const* debugspew_indent = "----+----!----+----!----+----!----+----!----+----!----+----!----+----!----+");
@@ -287,12 +287,12 @@ static int dummy_writer( lua_State* L, void const* p, size_t sz, void* ud)
287 * +-----------------+----------+------------+----------+ 287 * +-----------------+----------+------------+----------+
288 */ 288 */
289 289
290typedef enum 290enum FuncSubType
291{ 291{
292 FST_Bytecode, 292 FST_Bytecode,
293 FST_Native, 293 FST_Native,
294 FST_FastJIT 294 FST_FastJIT
295} FuncSubType; 295} ;
296 296
297FuncSubType luaG_getfuncsubtype( lua_State *L, int _i) 297FuncSubType luaG_getfuncsubtype( lua_State *L, int _i)
298{ 298{
@@ -694,7 +694,7 @@ static int userdata_clone_sentinel( lua_State* L)
694/* 694/*
695 * retrieve the name of a function/table in the lookup database 695 * retrieve the name of a function/table in the lookup database
696 */ 696 */
697static char const* find_lookup_name( lua_State* L, uint_t i, LookupMode mode_, char const* upName_, size_t* len_) 697static char const* find_lookup_name(lua_State* L, int i, LookupMode mode_, char const* upName_, size_t* len_)
698{ 698{
699 DEBUGSPEW_CODE( Universe* const U = universe_get( L)); 699 DEBUGSPEW_CODE( Universe* const U = universe_get( L));
700 char const* fqn; 700 char const* fqn;
@@ -766,7 +766,7 @@ static char const* find_lookup_name( lua_State* L, uint_t i, LookupMode mode_, c
766/* 766/*
767 * Push a looked-up table, or nothing if we found nothing 767 * Push a looked-up table, or nothing if we found nothing
768 */ 768 */
769static bool lookup_table( lua_State* L2, lua_State* L, uint_t i, LookupMode mode_, char const* upName_) 769static bool lookup_table(lua_State* L2, lua_State* L, int i, LookupMode mode_, char const* upName_)
770{ 770{
771 // get the name of the table we want to send 771 // get the name of the table we want to send
772 size_t len; 772 size_t len;
@@ -842,7 +842,7 @@ static bool lookup_table( lua_State* L2, lua_State* L, uint_t i, LookupMode mode
842 * Returns true if the table was cached (no need to fill it!); false if 842 * Returns true if the table was cached (no need to fill it!); false if
843 * it's a virgin. 843 * it's a virgin.
844 */ 844 */
845static bool push_cached_table( lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i) 845static bool push_cached_table(lua_State* L2, int L2_cache_i, lua_State* L, int i)
846{ 846{
847 bool not_found_in_cache; // L2 847 bool not_found_in_cache; // L2
848 void const* p{ lua_topointer(L, i) }; 848 void const* p{ lua_topointer(L, i) };
@@ -1071,7 +1071,7 @@ int luaG_nameof( lua_State* L)
1071/* 1071/*
1072 * Push a looked-up native/LuaJIT function. 1072 * Push a looked-up native/LuaJIT function.
1073 */ 1073 */
1074static void lookup_native_func( lua_State* L2, lua_State* L, uint_t i, LookupMode mode_, char const* upName_) 1074static void lookup_native_func(lua_State* L2, lua_State* L, int i, LookupMode mode_, char const* upName_)
1075{ 1075{
1076 // get the name of the function we want to send 1076 // get the name of the function we want to send
1077 size_t len; 1077 size_t len;
@@ -1186,7 +1186,7 @@ static int buf_writer( lua_State* L, void const* b, size_t size, void* ud)
1186 return 0; 1186 return 0;
1187} 1187}
1188 1188
1189static void copy_func( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, LookupMode mode_, char const* upName_) 1189static void copy_func(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, LookupMode mode_, char const* upName_)
1190{ 1190{
1191 int n, needToPush; 1191 int n, needToPush;
1192 luaL_Buffer B; 1192 luaL_Buffer B;
@@ -1199,7 +1199,7 @@ static void copy_func( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State*
1199 1199
1200 // 'lua_dump()' needs the function at top of stack 1200 // 'lua_dump()' needs the function at top of stack
1201 // if already on top of the stack, no need to push again 1201 // if already on top of the stack, no need to push again
1202 needToPush = (i != (uint_t)lua_gettop( L)); 1202 needToPush = (i != lua_gettop( L));
1203 if( needToPush) 1203 if( needToPush)
1204 { 1204 {
1205 lua_pushvalue( L, i); // ... f 1205 lua_pushvalue( L, i); // ... f
@@ -1338,7 +1338,7 @@ static void copy_func( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State*
1338 * 1338 *
1339 * Always pushes a function to 'L2'. 1339 * Always pushes a function to 'L2'.
1340 */ 1340 */
1341static void copy_cached_func( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, LookupMode mode_, char const* upName_) 1341static void copy_cached_func(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, LookupMode mode_, char const* upName_)
1342{ 1342{
1343 FuncSubType funcSubType; 1343 FuncSubType funcSubType;
1344 /*lua_CFunction cfunc =*/ luaG_tocfunction( L, i, &funcSubType); // nullptr for LuaJIT-fast && bytecode functions 1344 /*lua_CFunction cfunc =*/ luaG_tocfunction( L, i, &funcSubType); // nullptr for LuaJIT-fast && bytecode functions
@@ -1391,7 +1391,7 @@ static void copy_cached_func( Universe* U, lua_State* L2, uint_t L2_cache_i, lua
1391 } 1391 }
1392} 1392}
1393 1393
1394static bool push_cached_metatable( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum eLookupMode mode_, char const* upName_) 1394static bool push_cached_metatable(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, LookupMode mode_, char const* upName_)
1395{ 1395{
1396 STACK_CHECK( L, 0); 1396 STACK_CHECK( L, 0);
1397 if( lua_getmetatable( L, i)) // ... mt 1397 if( lua_getmetatable( L, i)) // ... mt
@@ -1440,10 +1440,10 @@ static bool push_cached_metatable( Universe* U, lua_State* L2, uint_t L2_cache_i
1440 return false; 1440 return false;
1441} 1441}
1442 1442
1443static void inter_copy_keyvaluepair( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, enum e_vt vt, LookupMode mode_, char const* upName_) 1443static void inter_copy_keyvaluepair(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, enum e_vt vt, LookupMode mode_, char const* upName_)
1444{ 1444{
1445 uint_t val_i = lua_gettop( L); 1445 int val_i = lua_gettop(L);
1446 uint_t key_i = val_i - 1; 1446 int key_i = val_i - 1;
1447 1447
1448 // Only basic key types are copied over; others ignored 1448 // Only basic key types are copied over; others ignored
1449 if( inter_copy_one( U, L2, 0 /*key*/, L, key_i, VT_KEY, mode_, upName_)) 1449 if( inter_copy_one( U, L2, 0 /*key*/, L, key_i, VT_KEY, mode_, upName_))
@@ -1510,7 +1510,7 @@ static void inter_copy_keyvaluepair( Universe* U, lua_State* L2, uint_t L2_cache
1510*/ 1510*/
1511static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; 1511static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull };
1512 1512
1513static bool copyclone( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t source_i_, LookupMode mode_, char const* upName_) 1513static bool copyclone(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int source_i_, LookupMode mode_, char const* upName_)
1514{ 1514{
1515 void* const source = lua_touserdata( L, source_i_); 1515 void* const source = lua_touserdata( L, source_i_);
1516 source_i_ = lua_absindex( L, source_i_); 1516 source_i_ = lua_absindex( L, source_i_);
@@ -1623,7 +1623,7 @@ static bool copyclone( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State*
1623 return true; 1623 return true;
1624} 1624}
1625 1625
1626static bool inter_copy_userdata( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum e_vt vt, LookupMode mode_, char const* upName_) 1626static bool inter_copy_userdata(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, enum e_vt vt, LookupMode mode_, char const* upName_)
1627{ 1627{
1628 STACK_CHECK( L, 0); 1628 STACK_CHECK( L, 0);
1629 STACK_CHECK( L2, 0); 1629 STACK_CHECK( L2, 0);
@@ -1671,7 +1671,7 @@ static bool inter_copy_userdata( Universe* U, lua_State* L2, uint_t L2_cache_i,
1671 return true; 1671 return true;
1672} 1672}
1673 1673
1674static bool inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t source_i_, enum e_vt vt, LookupMode mode_, char const* upName_) 1674static bool inter_copy_function(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int source_i_, enum e_vt vt, LookupMode mode_, char const* upName_)
1675{ 1675{
1676 if( vt == VT_KEY) 1676 if( vt == VT_KEY)
1677 { 1677 {
@@ -1764,7 +1764,7 @@ static bool inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i,
1764 return true; 1764 return true;
1765} 1765}
1766 1766
1767static bool inter_copy_table( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum e_vt vt, LookupMode mode_, char const* upName_) 1767static bool inter_copy_table(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, enum e_vt vt, LookupMode mode_, char const* upName_)
1768{ 1768{
1769 if( vt == VT_KEY) 1769 if( vt == VT_KEY)
1770 { 1770 {
@@ -1834,7 +1834,7 @@ static bool inter_copy_table( Universe* U, lua_State* L2, uint_t L2_cache_i, lua
1834* 1834*
1835* Returns true if value was pushed, false if its type is non-supported. 1835* Returns true if value was pushed, false if its type is non-supported.
1836*/ 1836*/
1837bool inter_copy_one( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L, uint_t i, enum e_vt vt, LookupMode mode_, char const* upName_) 1837bool inter_copy_one(Universe* U, lua_State* L2, int L2_cache_i, lua_State* L, int i, enum e_vt vt, LookupMode mode_, char const* upName_)
1838{ 1838{
1839 bool ret{ true }; 1839 bool ret{ true };
1840 int val_type = lua_type( L, i); 1840 int val_type = lua_type( L, i);
@@ -1957,11 +1957,11 @@ bool inter_copy_one( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_State* L
1957* 1957*
1958* Note: Parameters are in this order ('L' = from first) to be same as 'lua_xmove'. 1958* Note: Parameters are in this order ('L' = from first) to be same as 'lua_xmove'.
1959*/ 1959*/
1960int luaG_inter_copy( Universe* U, lua_State* L, lua_State* L2, uint_t n, LookupMode mode_) 1960int luaG_inter_copy(Universe* U, lua_State* L, lua_State* L2, int n, LookupMode mode_)
1961{ 1961{
1962 uint_t top_L = lua_gettop( L); // ... {}n 1962 int top_L = lua_gettop(L); // ... {}n
1963 uint_t top_L2 = lua_gettop( L2); // ... 1963 int top_L2 = lua_gettop(L2); // ...
1964 uint_t i, j; 1964 int i, j;
1965 char tmpBuf[16]; 1965 char tmpBuf[16];
1966 char const* pBuf = U->verboseErrors ? tmpBuf : "?"; 1966 char const* pBuf = U->verboseErrors ? tmpBuf : "?";
1967 bool copyok{ true }; 1967 bool copyok{ true };
@@ -2020,7 +2020,7 @@ int luaG_inter_copy( Universe* U, lua_State* L, lua_State* L2, uint_t n, LookupM
2020} 2020}
2021 2021
2022 2022
2023int luaG_inter_move( Universe* U, lua_State* L, lua_State* L2, uint_t n, LookupMode mode_) 2023int luaG_inter_move(Universe* U, lua_State* L, lua_State* L2, int n, LookupMode mode_)
2024{ 2024{
2025 int ret = luaG_inter_copy( U, L, L2, n, mode_); 2025 int ret = luaG_inter_copy( U, L, L2, n, mode_);
2026 lua_pop( L, (int) n); 2026 lua_pop( L, (int) n);