aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2018-11-30 11:13:21 +0100
committerBenoit Germain <bnt.germain@gmail.com>2018-11-30 11:13:21 +0100
commitb33d86abb9997c1c056d2f6e55a9754dffed5f48 (patch)
tree63dc7e24d0abe2a5121a196063c6e8866e1f02bc /src
parentc64ad48fdf3aa9505fcf8505c832d1e397d60e85 (diff)
downloadlanes-b33d86abb9997c1c056d2f6e55a9754dffed5f48.tar.gz
lanes-b33d86abb9997c1c056d2f6e55a9754dffed5f48.tar.bz2
lanes-b33d86abb9997c1c056d2f6e55a9754dffed5f48.zip
Fix clonable userdata uservalue transfer
Diffstat (limited to 'src')
-rw-r--r--src/tools.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tools.c b/src/tools.c
index ff23e36..48e904c 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1907,13 +1907,14 @@ static bool_t inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i
1907 { 1907 {
1908 int const clone_i = lua_gettop( L2); 1908 int const clone_i = lua_gettop( L2);
1909 int uvi = 0; 1909 int uvi = 0;
1910 while( lua_getiuservalue( L, i, uvi + 1) != LUA_TNONE) // ... u uv 1910 while( lua_getiuservalue( L, -1, uvi + 1) != LUA_TNONE) // ... u uv
1911 { 1911 {
1912 luaG_inter_move( U, L, L2, 1, mode_); // ... u // ... mt __lanesclone nil [uv]+ 1912 luaG_inter_move( U, L, L2, 1, mode_); // ... u // ... mt __lanesclone nil [uv]+
1913 ++ uvi; 1913 ++ uvi;
1914 } 1914 }
1915 // when lua_getiuservalue() returned LUA_TNONE, it pushed a nil. pop it now 1915 // when lua_getiuservalue() returned LUA_TNONE, it pushed a nil. pop it now at the same time as the rest
1916 lua_pop( L, 1); // ... u 1916 lua_pop( L, 2); // ... u
1917 STACK_MID( L, 0); // ...
1917 // create the clone userdata with the required number of uservalue slots 1918 // create the clone userdata with the required number of uservalue slots
1918 clone = lua_newuserdatauv( L2, userdata_size, uvi); // ... mt __lanesclone nil [uv]+ u 1919 clone = lua_newuserdatauv( L2, userdata_size, uvi); // ... mt __lanesclone nil [uv]+ u
1919 lua_replace( L2, clone_i); // ... mt __lanesclone u [uv]+ 1920 lua_replace( L2, clone_i); // ... mt __lanesclone u [uv]+
@@ -1927,13 +1928,11 @@ static bool_t inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i
1927 // when we are done, all uservalues are popped from the stack 1928 // when we are done, all uservalues are popped from the stack
1928 STACK_MID( L2, 3); // ... mt __lanesclone u 1929 STACK_MID( L2, 3); // ... mt __lanesclone u
1929 } 1930 }
1930 STACK_MID( L, 1); // u
1931 lua_insert( L2, -3); // ... u mt __lanesclone 1931 lua_insert( L2, -3); // ... u mt __lanesclone
1932 lua_pushlightuserdata( L2, clone); // ... u mt __lanesclone clone 1932 lua_pushlightuserdata( L2, clone); // ... u mt __lanesclone clone
1933 lua_pushlightuserdata( L2, source); // ... u mt __lanesclone clone source 1933 lua_pushlightuserdata( L2, source); // ... u mt __lanesclone clone source
1934 lua_call( L2, 2, 0); // ... u mt 1934 lua_call( L2, 2, 0); // ... u mt
1935 lua_setmetatable( L2, -2); // ... u 1935 lua_setmetatable( L2, -2); // ... u
1936 lua_pop( L, 1); // ...
1937 } 1936 }
1938 else 1937 else
1939 { 1938 {