From 8f75e0ff26645ced3669f600aa5e9133bb7b49af Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 10 Apr 2024 09:01:42 +0200 Subject: C++ migration: fixed a few std::ignore --- src/cancel.cpp | 13 +-- src/compat.cpp | 9 +- src/deep.cpp | 15 ++-- src/keeper.cpp | 6 +- src/lanes.cpp | 14 +-- src/lanes_private.h | 2 +- src/tools.cpp | 251 ++++++++++++++++++++++++++-------------------------- 7 files changed, 154 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/cancel.cpp b/src/cancel.cpp index 2f3c22e..3a01ac2 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp @@ -213,7 +213,7 @@ CancelOp which_cancel_op(char const* op_string_) lua_remove(L, idx_); // argument is processed, remove it if (op == CancelOp::Invalid) { - std::ignore = luaL_error(L, "invalid hook option %s", str); + std::ignore = luaL_error(L, "invalid hook option %s", str); // doesn't return } return op; } @@ -260,6 +260,7 @@ LUAG_FUNC(thread_cancel) wake_lane = lua_toboolean(L, 2); lua_remove(L, 2); // argument is processed, remove it } + STACK_CHECK_START_REL(L, 0); switch (thread_cancel(lane, op, hook_count, wait_timeout, wake_lane)) { default: // should never happen unless we added a case and forgot to handle it @@ -267,15 +268,15 @@ LUAG_FUNC(thread_cancel) break; case CancelResult::Timeout: - lua_pushboolean(L, 0); - lua_pushstring(L, "timeout"); + lua_pushboolean(L, 0); // false + lua_pushstring(L, "timeout"); // false "timeout" break; case CancelResult::Cancelled: - lua_pushboolean(L, 1); - std::ignore = push_thread_status(L, lane); + lua_pushboolean(L, 1); // true + push_thread_status(L, lane); // true status break; } - // should never happen, only here to prevent the compiler from complaining of "not all control paths returning a value" + STACK_CHECK(L, 2); return 2; } diff --git a/src/compat.cpp b/src/compat.cpp index 9807390..73d0f6b 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -15,7 +15,7 @@ // ################################################################################################ // ################################################################################################ -[[nodiscard]] static int luaL_getsubtable(lua_State* L, int idx, const char* fname) +static int luaL_getsubtable(lua_State* L, int idx, const char* fname) { lua_getfield(L, idx, fname); if (lua_istable(L, -1)) @@ -38,7 +38,7 @@ void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int g lua_pushcfunction(L, openf); lua_pushstring(L, modname); /* argument to open function */ lua_call(L, 1, 1); /* open module */ - std::ignore = luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); lua_pushvalue(L, -2); /* make copy of module (call result) */ lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ lua_pop(L, 1); /* remove _LOADED table */ @@ -93,7 +93,8 @@ int lua_getiuservalue(lua_State* L, int idx, int n) // ################################################################################################ -// pop stack top, sets it a uservalue #n of full userdata at idx +// Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index. +// Returns 0 if the userdata does not have that value. int lua_setiuservalue(lua_State* L, int idx, int n) { if( n > 1 @@ -106,7 +107,7 @@ int lua_setiuservalue(lua_State* L, int idx, int n) return 0; } - std::ignore = lua_setuservalue(L, idx); + lua_setuservalue(L, idx); return 1; // I guess anything non-0 is ok } diff --git a/src/deep.cpp b/src/deep.cpp index a3806aa..418724e 100644 --- a/src/deep.cpp +++ b/src/deep.cpp @@ -470,11 +470,10 @@ bool copydeep(Universe* U, Dest L2, int L2_cache_i, Source L, int i, LookupMode int const clone_i = lua_gettop( L2); while( nuv) { - std::ignore = inter_copy_one(U - , L2, L2_cache_i - , L, lua_absindex( L, -1) - , VT::NORMAL, mode_, upName_ - ); // u uv + if (!inter_copy_one(U, L2, L2_cache_i, L, lua_absindex(L, -1), VT::NORMAL, mode_, upName_)) // u uv + { + return luaL_error(L, "Cannot copy upvalue type '%s'", luaL_typename(L, -1)); + } lua_pop( L, 1); // ... u [uv]* // this pops the value from the stack lua_setiuservalue(L2, clone_i, nuv); // u @@ -482,14 +481,14 @@ bool copydeep(Universe* U, Dest L2, int L2_cache_i, Source L, int i, LookupMode } } - STACK_CHECK( L2, 1); - STACK_CHECK( L, 0); + STACK_CHECK(L2, 1); + STACK_CHECK(L, 0); if (errmsg != nullptr) { // raise the error in the proper state (not the keeper) lua_State* const errL{ (mode_ == LookupMode::FromKeeper) ? L2 : L }; - std::ignore = luaL_error(errL, errmsg); + std::ignore = luaL_error(errL, errmsg); // doesn't return } return true; } \ No newline at end of file diff --git a/src/keeper.cpp b/src/keeper.cpp index 19fbd06..37fcba5 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -656,7 +656,7 @@ void init_keepers(Universe* U, lua_State* L) lua_pop(L, 1); // if (nb_keepers < 1) { - std::ignore = luaL_error(L, "Bad number of keepers (%d)", nb_keepers); + std::ignore = luaL_error(L, "Bad number of keepers (%d)", nb_keepers); // doesn't return } STACK_CHECK(L, 0); @@ -671,7 +671,7 @@ void init_keepers(Universe* U, lua_State* L) U->keepers = static_cast(U->internal_allocator.alloc(bytes)); if (U->keepers == nullptr) { - std::ignore = luaL_error(L, "init_keepers() failed while creating keeper array; out of memory"); + std::ignore = luaL_error(L, "init_keepers() failed while creating keeper array; out of memory"); // doesn't return } U->keepers->Keepers::Keepers(); U->keepers->gc_threshold = keepers_gc_threshold; @@ -688,7 +688,7 @@ void init_keepers(Universe* U, lua_State* L) lua_State* const K{ create_state(U, L) }; if (K == nullptr) { - std::ignore = luaL_error(L, "init_keepers() failed while creating keeper states; out of memory"); + std::ignore = luaL_error(L, "init_keepers() failed while creating keeper states; out of memory"); // doesn't return } U->keepers->keeper_array[i].L = K; diff --git a/src/lanes.cpp b/src/lanes.cpp index 2a5ebfd..f549359 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -540,7 +540,7 @@ static void selfdestruct_add(Lane* lane_) if (lane != SELFDESTRUCT_END) { // this causes a leak because we don't call U's destructor (which could be bad if the still running lanes are accessing it) - std::ignore = luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); + std::ignore = luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); // doesn't return } } @@ -1374,13 +1374,12 @@ LUAG_FUNC(lane_new) // ################################################################################################# -int push_thread_status(lua_State* L, Lane* lane_) +void push_thread_status(lua_State* L, Lane* lane_) { char const* const str{ thread_status_string(lane_) }; ASSERT_L(str); - lua_pushstring(L, str); - return 1; + std::ignore = lua_pushstring(L, str); } // ################################################################################################# @@ -1583,11 +1582,12 @@ LUAG_FUNC(thread_index) } if (lua_type(L, KEY) == LUA_TSTRING) { - char const * const keystr = lua_tostring(L, KEY); + char const* const keystr{ lua_tostring(L, KEY) }; lua_settop(L, 2); // keep only our original arguments on the stack if (strcmp( keystr, "status") == 0) { - return push_thread_status(L, lane); // push the string representing the status + push_thread_status(L, lane); // push the string representing the status + return 1; } // return UD.metatable[key] lua_getmetatable(L, UD); // UD KEY mt @@ -1634,7 +1634,7 @@ LUAG_FUNC(threads) lua_newtable(L); // {} {} lua_pushstring(L, lane->debug_name); // {} {} "name" lua_setfield(L, -2, "name"); // {} {} - std::ignore = push_thread_status(L, lane); // {} {} "status" + push_thread_status(L, lane); // {} {} "status" lua_setfield(L, -2, "status"); // {} {} lua_rawseti(L, -2, ++index); // {} lane = lane->tracking_next; diff --git a/src/lanes_private.h b/src/lanes_private.h index ba40e44..18e55fd 100644 --- a/src/lanes_private.h +++ b/src/lanes_private.h @@ -103,4 +103,4 @@ static constexpr UniqueKey LANE_POINTER_REGKEY{ 0xB3022205633743BCull }; // used return *(static_cast(luaL_checkudata(L, i_, "Lane"))); } -[[nodiscard]] int push_thread_status(lua_State* L, Lane* s); +void push_thread_status(lua_State* L, Lane* lane_); diff --git a/src/tools.cpp b/src/tools.cpp index 4083a57..9207df6 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -1393,50 +1393,49 @@ static void copy_cached_func(Universe* U, Dest L2, int L2_cache_i, Source L, int [[nodiscard]] static bool push_cached_metatable(Universe* U, Dest L2, int L2_cache_i, Source L, int i, LookupMode mode_, char const* upName_) { STACK_CHECK_START_REL(L, 0); - if( lua_getmetatable( L, i)) // ... mt + if (!lua_getmetatable(L, i)) // ... mt { - lua_Integer const mt_id = get_mt_id( U, L, -1); // Unique id for the metatable + STACK_CHECK( L, 0); + return false; + } + STACK_CHECK(L, 1); - STACK_CHECK_START_REL(L2, 0); - STACK_GROW( L2, 4); - // do we already know this metatable? - push_registry_subtable( L2, REG_MTID); // _R[REG_MTID] - lua_pushinteger( L2, mt_id); // _R[REG_MTID] id - lua_rawget( L2, -2); // _R[REG_MTID] mt? - - STACK_CHECK( L2, 2); - - if( lua_isnil( L2, -1)) - { // L2 did not know the metatable - lua_pop( L2, 1); // _R[REG_MTID] - if (inter_copy_one(U, L2, L2_cache_i, L, lua_gettop( L), VT::METATABLE, mode_, upName_)) // _R[REG_MTID] mt - { - STACK_CHECK( L2, 2); - // mt_id -> metatable - lua_pushinteger( L2, mt_id); // _R[REG_MTID] mt id - lua_pushvalue( L2, -2); // _R[REG_MTID] mt id mt - lua_rawset( L2, -4); // _R[REG_MTID] mt - - // metatable -> mt_id - lua_pushvalue( L2, -1); // _R[REG_MTID] mt mt - lua_pushinteger( L2, mt_id); // _R[REG_MTID] mt mt id - lua_rawset( L2, -4); // _R[REG_MTID] mt - } - else - { - (void) luaL_error( L, "Error copying a metatable"); - } - STACK_CHECK( L2, 2); + lua_Integer const mt_id{ get_mt_id(U, L, -1) }; // Unique id for the metatable + + STACK_CHECK_START_REL(L2, 0); + STACK_GROW(L2, 4); + // do we already know this metatable? + push_registry_subtable(L2, REG_MTID); // _R[REG_MTID] + lua_pushinteger(L2, mt_id); // _R[REG_MTID] id + lua_rawget(L2, -2); // _R[REG_MTID] mt|nil + STACK_CHECK(L2, 2); + + if (lua_isnil(L2, -1)) + { // L2 did not know the metatable + lua_pop(L2, 1); // _R[REG_MTID] + if (!inter_copy_one(U, L2, L2_cache_i, L, lua_gettop(L), VT::METATABLE, mode_, upName_)) // _R[REG_MTID] mt? + { + std::ignore = luaL_error(L, "Error copying a metatable"); // doesn't return } - lua_remove( L2, -2); // mt - lua_pop( L, 1); // ... - STACK_CHECK( L2, 1); - STACK_CHECK( L, 0); - return true; + STACK_CHECK(L2, 2); // _R[REG_MTID] mt + // mt_id -> metatable + lua_pushinteger(L2, mt_id); // _R[REG_MTID] mt id + lua_pushvalue(L2, -2); // _R[REG_MTID] mt id mt + lua_rawset(L2, -4); // _R[REG_MTID] mt + + // metatable -> mt_id + lua_pushvalue(L2, -1); // _R[REG_MTID] mt mt + lua_pushinteger(L2, mt_id); // _R[REG_MTID] mt mt id + lua_rawset(L2, -4); // _R[REG_MTID] mt + STACK_CHECK(L2, 2); } - STACK_CHECK( L, 0); - return false; + lua_remove(L2, -2); // mt + + lua_pop(L, 1); // ... + STACK_CHECK(L2, 1); + STACK_CHECK(L, 0); + return true; } // ################################################################################################# @@ -1599,11 +1598,10 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; // assign uservalues while( uvi > 0) { - std::ignore = inter_copy_one(U - , L2, L2_cache_i - , L, lua_absindex(L, -1) - , VT::NORMAL, mode_, upName_ - ); // ... u uv + if (!inter_copy_one(U, L2, L2_cache_i, L, lua_absindex(L, -1), VT::NORMAL, mode_, upName_)) // ... u uv + { + std::ignore = luaL_error(L, "Cannot copy upvalue type '%s'", luaL_typename(L, -1)); // doesn't return + } lua_pop( L, 1); // ... mt __lanesclone [uv]* // this pops the value from the stack lua_setiuservalue( L2, -2, uvi); // ... u @@ -1644,39 +1642,39 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; // try clonable userdata first if( copyclone( U, L2, L2_cache_i, L, i, mode_, upName_)) { - STACK_CHECK( L, 0); - STACK_CHECK( L2, 1); + STACK_CHECK(L, 0); + STACK_CHECK(L2, 1); return true; } - STACK_CHECK( L, 0); - STACK_CHECK( L2, 0); + STACK_CHECK(L, 0); + STACK_CHECK(L2, 0); // Allow only deep userdata entities to be copied across - DEBUGSPEW_CODE( fprintf( stderr, "USERDATA\n")); - if( copydeep( U, L2, L2_cache_i, L, i, mode_, upName_)) + DEBUGSPEW_CODE(fprintf(stderr, "USERDATA\n")); + if (copydeep(U, L2, L2_cache_i, L, i, mode_, upName_)) { - STACK_CHECK( L, 0); - STACK_CHECK( L2, 1); + STACK_CHECK(L, 0); + STACK_CHECK(L2, 1); return true; } - STACK_CHECK( L, 0); - STACK_CHECK( L2, 0); + STACK_CHECK(L, 0); + STACK_CHECK(L2, 0); // Not a deep or clonable full userdata - if( U->demoteFullUserdata) // attempt demotion to light userdata + if (U->demoteFullUserdata) // attempt demotion to light userdata { - void* lud = lua_touserdata( L, i); - lua_pushlightuserdata( L2, lud); + void* lud = lua_touserdata(L, i); + lua_pushlightuserdata(L2, lud); } else // raise an error { - (void) luaL_error( L, "can't copy non-deep full userdata across lanes"); + std::ignore = luaL_error(L, "can't copy non-deep full userdata across lanes"); // doesn't return } - STACK_CHECK( L2, 1); - STACK_CHECK( L, 0); + STACK_CHECK(L2, 1); + STACK_CHECK(L, 0); return true; } @@ -1689,91 +1687,90 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; return false; } - STACK_CHECK_START_REL(L, 0); // L (source) // L2 (destination) + STACK_CHECK_START_REL(L, 0); // L (source) // L2 (destination) STACK_CHECK_START_REL(L2, 0); - DEBUGSPEW_CODE( fprintf( stderr, "FUNCTION %s\n", upName_)); + DEBUGSPEW_CODE(fprintf(stderr, "FUNCTION %s\n", upName_)); - if( lua_tocfunction( L, source_i_) == userdata_clone_sentinel) // we are actually copying a clonable full userdata from a keeper + if (lua_tocfunction(L, source_i_) == userdata_clone_sentinel) // we are actually copying a clonable full userdata from a keeper { // clone the full userdata again // let's see if we already restored this userdata - lua_getupvalue( L, source_i_, 2); // ... u - void* source = lua_touserdata( L, -1); - lua_pushlightuserdata( L2, source); // ... source - lua_rawget( L2, L2_cache_i); // ... u? - if( !lua_isnil( L2, -1)) + lua_getupvalue(L, source_i_, 2); // ... u + void* source = lua_touserdata(L, -1); + lua_pushlightuserdata(L2, source); // ... source + lua_rawget(L2, L2_cache_i); // ... u? + if (!lua_isnil(L2, -1)) { - lua_pop( L, 1); // ... - STACK_CHECK( L, 0); - STACK_CHECK( L2, 1); + lua_pop(L, 1); // ... + STACK_CHECK(L, 0); + STACK_CHECK(L2, 1); return true; } - lua_pop( L2, 1); // ... + lua_pop(L2, 1); // ... // this function has 2 upvalues: the fqn of its metatable, and the userdata itself - std::ignore = lookup_table( L2, L, source_i_, mode_, upName_); // ... mt + std::ignore = lookup_table(L2, L, source_i_, mode_, upName_); // ... mt // originally 'source_i_' slot was the proxy closure, but from now on it indexes the actual userdata we extracted from it - source_i_ = lua_gettop( L); - source = lua_touserdata( L, -1); + source_i_ = lua_gettop(L); + source = lua_touserdata(L, -1); void* clone{ nullptr }; // get the number of bytes to allocate for the clone - size_t const userdata_size { lua_rawlen(L, -1) }; + size_t const userdata_size{ lua_rawlen(L, -1) }; { // extract uservalues (don't transfer them yet) int uvi = 0; - while( lua_getiuservalue( L, source_i_, ++ uvi) != LUA_TNONE) {} // ... u uv + while (lua_getiuservalue(L, source_i_, ++uvi) != LUA_TNONE) {} // ... u uv // when lua_getiuservalue() returned LUA_TNONE, it pushed a nil. pop it now - lua_pop( L, 1); // ... u [uv]* - -- uvi; - STACK_CHECK( L, uvi + 1); + lua_pop(L, 1); // ... u [uv]* + --uvi; + STACK_CHECK(L, uvi + 1); // create the clone userdata with the required number of uservalue slots - clone = lua_newuserdatauv( L2, userdata_size, uvi); // ... mt u + clone = lua_newuserdatauv(L2, userdata_size, uvi); // ... mt u // add it in the cache - lua_pushlightuserdata( L2, source); // ... mt u source - lua_pushvalue( L2, -2); // ... mt u source u - lua_rawset( L2, L2_cache_i); // ... mt u + lua_pushlightuserdata(L2, source); // ... mt u source + lua_pushvalue(L2, -2); // ... mt u source u + lua_rawset(L2, L2_cache_i); // ... mt u // set metatable - lua_pushvalue( L2, -2); // ... mt u mt - lua_setmetatable( L2, -2); // ... mt u + lua_pushvalue(L2, -2); // ... mt u mt + lua_setmetatable(L2, -2); // ... mt u // transfer and assign uservalues - while( uvi > 0) + while (uvi > 0) { - std::ignore = inter_copy_one(U - , L2, L2_cache_i - , L, lua_absindex(L, -1) - , vt_, mode_, upName_ - ); // ... mt u uv - lua_pop( L, 1); // ... u [uv]* + if (!inter_copy_one(U, L2, L2_cache_i, L, lua_absindex(L, -1), vt_, mode_, upName_)) // ... mt u uv + { + std::ignore = luaL_error(L, "Cannot copy upvalue type '%s'", luaL_typename(L, -1)); // doesn't return + } + lua_pop(L, 1); // ... u [uv]* // this pops the value from the stack - lua_setiuservalue( L2, -2, uvi); // ... mt u + lua_setiuservalue(L2, -2, uvi); // ... mt u -- uvi; } // when we are done, all uservalues are popped from the stack, we can pop the source as well - lua_pop( L, 1); // ... - STACK_CHECK( L, 0); - STACK_CHECK( L2, 2); // ... mt u + lua_pop(L, 1); // ... + STACK_CHECK(L, 0); + STACK_CHECK(L2, 2); // ... mt u } // perform the custom cloning part - lua_insert( L2, -2); // ... u mt + lua_insert(L2, -2); // ... u mt // __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with - lua_getfield(L2, -1, "__lanesclone"); // ... u mt __lanesclone - lua_remove( L2, -2); // ... u __lanesclone - lua_pushlightuserdata( L2, clone); // ... u __lanesclone clone - lua_pushlightuserdata( L2, source); // ... u __lanesclone clone source - lua_pushinteger( L2, userdata_size); // ... u __lanesclone clone source size + lua_getfield(L2, -1, "__lanesclone"); // ... u mt __lanesclone + lua_remove(L2, -2); // ... u __lanesclone + lua_pushlightuserdata(L2, clone); // ... u __lanesclone clone + lua_pushlightuserdata(L2, source); // ... u __lanesclone clone source + lua_pushinteger(L2, userdata_size); // ... u __lanesclone clone source size // clone:__lanesclone(dest, source, size) - lua_call( L2, 3, 0); // ... u + lua_call(L2, 3, 0); // ... u } else // regular function { DEBUGSPEW_CODE(fprintf( stderr, "FUNCTION %s\n", upName_)); DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); - copy_cached_func( U, L2, L2_cache_i, L, source_i_, mode_, upName_); // ... f + copy_cached_func(U, L2, L2_cache_i, L, source_i_, mode_, upName_); // ... f DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_sub(1, std::memory_order_relaxed)); } - STACK_CHECK( L2, 1); - STACK_CHECK( L, 0); + STACK_CHECK(L2, 1); + STACK_CHECK(L, 0); return true; } @@ -1788,15 +1785,15 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; STACK_CHECK_START_REL(L, 0); STACK_CHECK_START_REL(L2, 0); - DEBUGSPEW_CODE( fprintf( stderr, "TABLE %s\n", upName_)); + DEBUGSPEW_CODE(fprintf(stderr, "TABLE %s\n", upName_)); /* - * First, let's try to see if this table is special (aka is it some table that we registered in our lookup databases during module registration?) - * Note that this table CAN be a module table, but we just didn't register it, in which case we'll send it through the table cloning mechanism - */ - if( lookup_table( L2, L, i, mode_, upName_)) + * First, let's try to see if this table is special (aka is it some table that we registered in our lookup databases during module registration?) + * Note that this table CAN be a module table, but we just didn't register it, in which case we'll send it through the table cloning mechanism + */ + if (lookup_table(L2, L, i, mode_, upName_)) { - ASSERT_L( lua_istable( L2, -1) || (lua_tocfunction( L2, -1) == table_lookup_sentinel)); // from lookup datables // can also be table_lookup_sentinel if this is a table we know + ASSERT_L(lua_istable(L2, -1) || (lua_tocfunction(L2, -1) == table_lookup_sentinel)); // from lookup data. can also be table_lookup_sentinel if this is a table we know return true; } @@ -1809,33 +1806,33 @@ static constexpr UniqueKey CLONABLES_CACHE_KEY{ 0xD04EE018B3DEE8F5ull }; * Note: Even metatables need to go through this test; to detect * loops such as those in required module tables (getmetatable(lanes).lanes == lanes) */ - if( push_cached_table( L2, L2_cache_i, L, i)) + if (push_cached_table(L2, L2_cache_i, L, i)) { - ASSERT_L( lua_istable( L2, -1)); // from cache + ASSERT_L(lua_istable(L2, -1)); // from cache return true; } - ASSERT_L( lua_istable( L2, -1)); + ASSERT_L(lua_istable(L2, -1)); - STACK_GROW( L, 2); - STACK_GROW( L2, 2); + STACK_GROW(L, 2); + STACK_GROW(L2, 2); - lua_pushnil( L); // start iteration - while( lua_next( L, i)) + lua_pushnil(L); // start iteration + while (lua_next(L, i)) { // need a function to prevent overflowing the stack with verboseErrors-induced alloca() inter_copy_keyvaluepair(U, L2, L2_cache_i, L, vt_, mode_, upName_); - lua_pop( L, 1); // pop value (next round) + lua_pop(L, 1); // pop value (next round) } - STACK_CHECK( L, 0); - STACK_CHECK( L2, 1); + STACK_CHECK(L, 0); + STACK_CHECK(L2, 1); // Metatables are expected to be immutable, and copied only once. - if( push_cached_metatable( U, L2, L2_cache_i, L, i, mode_, upName_)) // ... t mt? + if (push_cached_metatable(U, L2, L2_cache_i, L, i, mode_, upName_)) // ... t mt? { - lua_setmetatable( L2, -2); // ... t + lua_setmetatable(L2, -2); // ... t } - STACK_CHECK( L2, 1); - STACK_CHECK( L, 0); + STACK_CHECK(L2, 1); + STACK_CHECK(L, 0); return true; } -- cgit v1.2.3-55-g6feb