aboutsummaryrefslogtreecommitdiff
path: root/src/tools.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2018-11-07 11:40:59 +0100
committerBenoit Germain <bnt.germain@gmail.com>2018-11-07 11:40:59 +0100
commit91155c74fc10fa98ad6257d5309bfd13d4a61cf0 (patch)
treeaa7524e8284fb1a0c35e89e30660cdab8d96cf29 /src/tools.c
parent8306532f0ec891dfa5e8ca09e710b3cb60e5b760 (diff)
downloadlanes-91155c74fc10fa98ad6257d5309bfd13d4a61cf0.tar.gz
lanes-91155c74fc10fa98ad6257d5309bfd13d4a61cf0.tar.bz2
lanes-91155c74fc10fa98ad6257d5309bfd13d4a61cf0.zip
Little bugfix for __lanesclone support
Don't fall back to the light userdata demotion when cloning succeeded (cloning still doesn't work yet)
Diffstat (limited to 'src/tools.c')
-rw-r--r--src/tools.c13
1 files changed, 8 insertions, 5 deletions
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.
47#include "uniquekey.h" 47#include "uniquekey.h"
48 48
49// functions implemented in deep.c 49// functions implemented in deep.c
50extern luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_); 50extern bool_t copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_);
51extern void push_registry_subtable( lua_State* L, void* key_); 51extern void push_registry_subtable( lua_State* L, void* key_);
52 52
53char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; 53char 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
1582* Copies a value from 'L' state (at index 'i') to 'L2' state. Does not remove 1582* Copies a value from 'L' state (at index 'i') to 'L2' state. Does not remove
1583* the original value. 1583* the original value.
1584* 1584*
1585* NOTE: Both the states must be solely in the current OS thread's posession. 1585* NOTE: Both the states must be solely in the current OS thread's possession.
1586* 1586*
1587* 'i' is an absolute index (no -1, ...) 1587* 'i' is an absolute index (no -1, ...)
1588* 1588*
@@ -1648,7 +1648,7 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu
1648 lua_pushlightuserdata( L2, lua_touserdata( L, i)); 1648 lua_pushlightuserdata( L2, lua_touserdata( L, i));
1649 break; 1649 break;
1650 1650
1651 /* The following types are not allowed as table keys */ 1651 /* The following types are not allowed as table keys */
1652 1652
1653 case LUA_TUSERDATA: 1653 case LUA_TUSERDATA:
1654 if( vt == VT_KEY) 1654 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
1658 } 1658 }
1659 // Allow only deep userdata entities to be copied across 1659 // Allow only deep userdata entities to be copied across
1660 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "USERDATA\n" INDENT_END)); 1660 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "USERDATA\n" INDENT_END));
1661 if( !copydeep( U, L, L2, i, mode_)) 1661 if( copydeep( U, L, L2, i, mode_))
1662 { 1662 {
1663 break;
1664 }
1665
1663 if( lua_getmetatable( L, i)) // ... mt? 1666 if( lua_getmetatable( L, i)) // ... mt?
1664 { 1667 {
1665 lua_getfield( L, -1, "__lanesclone"); // ... mt clone? 1668 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
1691 } 1694 }
1692 } 1695 }
1693 lua_pop( L, 2); // ... 1696 lua_pop( L, 2); // ...
1697 break;
1694 } 1698 }
1695 1699
1696 // Not a deep or clonable full userdata 1700 // 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
1703 { 1707 {
1704 (void) luaL_error( L, "can't copy non-deep full userdata across lanes"); 1708 (void) luaL_error( L, "can't copy non-deep full userdata across lanes");
1705 } 1709 }
1706 }
1707 break; 1710 break;
1708 1711
1709 case LUA_TNIL: 1712 case LUA_TNIL: