diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2018-11-07 11:40:59 +0100 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2018-11-07 11:40:59 +0100 |
| commit | 91155c74fc10fa98ad6257d5309bfd13d4a61cf0 (patch) | |
| tree | aa7524e8284fb1a0c35e89e30660cdab8d96cf29 | |
| parent | 8306532f0ec891dfa5e8ca09e710b3cb60e5b760 (diff) | |
| download | lanes-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)
| -rw-r--r-- | src/deep.c | 8 | ||||
| -rw-r--r-- | src/tools.c | 13 |
2 files changed, 12 insertions, 9 deletions
| @@ -519,13 +519,13 @@ void* luaG_todeep( lua_State* L, luaG_IdFunction idfunc, int index) | |||
| 519 | * the id function of the copied value, or NULL for non-deep userdata | 519 | * the id function of the copied value, or NULL for non-deep userdata |
| 520 | * (not copied) | 520 | * (not copied) |
| 521 | */ | 521 | */ |
| 522 | luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_) | 522 | bool_t copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_) |
| 523 | { | 523 | { |
| 524 | char const* errmsg; | 524 | char const* errmsg; |
| 525 | luaG_IdFunction idfunc = get_idfunc( L, index, mode_); | 525 | luaG_IdFunction idfunc = get_idfunc( L, index, mode_); |
| 526 | if( idfunc == NULL) | 526 | if( idfunc == NULL) |
| 527 | { | 527 | { |
| 528 | return NULL; // not a deep userdata | 528 | return FALSE; // not a deep userdata |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | errmsg = push_deep_proxy( U, L2, *(DeepPrelude**) lua_touserdata( L, index), mode_); | 531 | 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 | |||
| 535 | lua_State* errL = (mode_ == eLM_FromKeeper) ? L2 : L; | 535 | lua_State* errL = (mode_ == eLM_FromKeeper) ? L2 : L; |
| 536 | luaL_error( errL, errmsg); | 536 | luaL_error( errL, errmsg); |
| 537 | } | 537 | } |
| 538 | return idfunc; | 538 | return TRUE; |
| 539 | } | 539 | } \ 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. | |||
| 47 | #include "uniquekey.h" | 47 | #include "uniquekey.h" |
| 48 | 48 | ||
| 49 | // functions implemented in deep.c | 49 | // functions implemented in deep.c |
| 50 | extern luaG_IdFunction copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_); | 50 | extern bool_t copydeep( Universe* U, lua_State* L, lua_State* L2, int index, LookupMode mode_); |
| 51 | extern void push_registry_subtable( lua_State* L, void* key_); | 51 | extern void push_registry_subtable( lua_State* L, void* key_); |
| 52 | 52 | ||
| 53 | char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; | 53 | 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 | |||
| 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: |
