diff options
Diffstat (limited to 'src/tools.c')
-rw-r--r-- | src/tools.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/tools.c b/src/tools.c index b5f2f4b..e743393 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1886,9 +1886,28 @@ static bool_t inter_copy_one_( lua_State* L2, uint_t L2_cache_i, lua_State* L, u | |||
1886 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "USERDATA\n" INDENT_END)); | 1886 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "USERDATA\n" INDENT_END)); |
1887 | if( !luaG_copydeep( L, L2, i)) | 1887 | if( !luaG_copydeep( L, L2, i)) |
1888 | { | 1888 | { |
1889 | // Cannot copy it full; copy as light userdata | 1889 | // Not a deep full userdata |
1890 | // | 1890 | bool_t demote = FALSE; |
1891 | lua_pushlightuserdata( L2, lua_touserdata( L, i)); | 1891 | lua_getfield( L, LUA_REGISTRYINDEX, CONFIG_REGKEY); |
1892 | if( lua_istable( L, -1)) // should not happen, but who knows... | ||
1893 | { | ||
1894 | lua_getfield( L, -1, "demote_full_userdata"); | ||
1895 | demote = lua_toboolean( L, -1); | ||
1896 | lua_pop( L, 2); | ||
1897 | } | ||
1898 | else | ||
1899 | { | ||
1900 | lua_pop( L, 1); | ||
1901 | } | ||
1902 | if( demote) // attempt demotion to light userdata | ||
1903 | { | ||
1904 | void* lud = lua_touserdata( L, i); | ||
1905 | lua_pushlightuserdata( L2, lud); | ||
1906 | } | ||
1907 | else // raise an error | ||
1908 | { | ||
1909 | (void) luaL_error( L, "can't copy non-deep full userdata across lanes"); | ||
1910 | } | ||
1892 | } | 1911 | } |
1893 | break; | 1912 | break; |
1894 | 1913 | ||