From 91155c74fc10fa98ad6257d5309bfd13d4a61cf0 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 7 Nov 2018 11:40:59 +0100 Subject: Little bugfix for __lanesclone support Don't fall back to the light userdata demotion when cloning succeeded (cloning still doesn't work yet) --- src/deep.c | 8 ++++---- src/tools.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/deep.c b/src/deep.c index fe7a21f..6a735b8 100644 --- a/src/deep.c +++ b/src/deep.c @@ -519,13 +519,13 @@ void* luaG_todeep( lua_State* L, luaG_IdFunction idfunc, int index) * the id function of the copied value, or NULL for non-deep userdata * (not copied) */ -luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_) +bool_t copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_) { char const* errmsg; luaG_IdFunction idfunc = get_idfunc( L, index, mode_); if( idfunc == NULL) { - return NULL; // not a deep userdata + return FALSE; // not a deep userdata } errmsg = push_deep_proxy( U, L2, *(DeepPrelude**) lua_touserdata( L, index), mode_); @@ -535,5 +535,5 @@ luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, L lua_State* errL = (mode_ == eLM_FromKeeper) ? L2 : L; luaL_error( errL, errmsg); } - return idfunc; -} + return TRUE; +} \ No newline at end of file diff --git a/src/tools.c b/src/tools.c index 98938f0..2f9de7b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -47,7 +47,7 @@ THE SOFTWARE. #include "uniquekey.h" // functions implemented in deep.c -extern luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_); +extern bool_t copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_); extern void push_registry_subtable( lua_State* L, void* key_); char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; @@ -1582,7 +1582,7 @@ static void inter_copy_keyvaluepair( Universe* U, lua_State* L2, uint_t L2_cache * Copies a value from 'L' state (at index 'i') to 'L2' state. Does not remove * the original value. * -* NOTE: Both the states must be solely in the current OS thread's posession. +* NOTE: Both the states must be solely in the current OS thread's possession. * * 'i' is an absolute index (no -1, ...) * @@ -1648,7 +1648,7 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu lua_pushlightuserdata( L2, lua_touserdata( L, i)); break; - /* The following types are not allowed as table keys */ + /* The following types are not allowed as table keys */ case LUA_TUSERDATA: if( vt == VT_KEY) @@ -1658,8 +1658,11 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu } // Allow only deep userdata entities to be copied across DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "USERDATA\n" INDENT_END)); - if( !copydeep( U, L, L2, i, mode_)) + if( copydeep( U, L, L2, i, mode_)) { + break; + } + if( lua_getmetatable( L, i)) // ... mt? { lua_getfield( L, -1, "__lanesclone"); // ... mt clone? @@ -1691,6 +1694,7 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu } } lua_pop( L, 2); // ... + break; } // Not a deep or clonable full userdata @@ -1703,7 +1707,6 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu { (void) luaL_error( L, "can't copy non-deep full userdata across lanes"); } - } break; case LUA_TNIL: -- cgit v1.2.3-55-g6feb