diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2021-06-23 12:38:01 +0200 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2021-06-23 12:38:01 +0200 |
commit | d1ef9b97e356805c622e4832ec76289bae391a6e (patch) | |
tree | e00a1a4b1c16bcc02d0e6c75d664d93e76f8d606 /src | |
parent | 5875fe44ba7a240dd101f954c7dc83337a0c2cef (diff) | |
download | lanes-d1ef9b97e356805c622e4832ec76289bae391a6e.tar.gz lanes-d1ef9b97e356805c622e4832ec76289bae391a6e.tar.bz2 lanes-d1ef9b97e356805c622e4832ec76289bae391a6e.zip |
__lanesclone now receives the original as light userdata the first time it is called
Diffstat (limited to 'src')
-rw-r--r-- | src/tools.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools.c b/src/tools.c index 02d51ae..f3ac236 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1760,8 +1760,9 @@ static bool_t copyclone( Universe* U, lua_State* L2, uint_t L2_cache_i, lua_Stat | |||
1760 | void* const source = lua_touserdata( L, i); | 1760 | void* const source = lua_touserdata( L, i); |
1761 | void* clone = NULL; | 1761 | void* clone = NULL; |
1762 | lua_pushvalue( L, -1); // ... mt __lanesclone __lanesclone | 1762 | lua_pushvalue( L, -1); // ... mt __lanesclone __lanesclone |
1763 | // call the cloning function with 0 arguments, should return the number of bytes to allocate for the clone | 1763 | // call the cloning function with 1 argument, should return the number of bytes to allocate for the clone |
1764 | lua_call( L, 0, 1); // ... mt __lanesclone size | 1764 | lua_pushlightuserdata( L, source); // ... mt __lanesclone __lanesclone source |
1765 | lua_call( L, 1, 1); // ... mt __lanesclone size | ||
1765 | STACK_MID( L, 3); | 1766 | STACK_MID( L, 3); |
1766 | userdata_size = (size_t) lua_tointeger( L, -1); // ... mt __lanesclone size | 1767 | userdata_size = (size_t) lua_tointeger( L, -1); // ... mt __lanesclone size |
1767 | lua_pop( L, 1); // ... mt __lanesclone | 1768 | lua_pop( L, 1); // ... mt __lanesclone |
@@ -1899,8 +1900,9 @@ static bool_t inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i | |||
1899 | // __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with | 1900 | // __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with |
1900 | lua_getfield( L2, -1, "__lanesclone"); // ... mt __lanesclone | 1901 | lua_getfield( L2, -1, "__lanesclone"); // ... mt __lanesclone |
1901 | lua_pushvalue( L2, -1); // ... mt __lanesclone __lanesclone | 1902 | lua_pushvalue( L2, -1); // ... mt __lanesclone __lanesclone |
1902 | // call the cloning function with 0 arguments, should return the number of bytes to allocate for the clone | 1903 | // call the cloning function with 1 argument, should return the number of bytes to allocate for the clone |
1903 | lua_call( L2, 0, 1); // ... mt __lanesclone size | 1904 | lua_pushlightuserdata( L2, source); // ... mt __lanesclone __lanesclone source |
1905 | lua_call( L2, 1, 1); // ... mt __lanesclone size | ||
1904 | userdata_size = (size_t) lua_tointeger( L2, -1); // ... mt __lanesclone size | 1906 | userdata_size = (size_t) lua_tointeger( L2, -1); // ... mt __lanesclone size |
1905 | lua_pop( L2, 1); // ... mt __lanesclone | 1907 | lua_pop( L2, 1); // ... mt __lanesclone |
1906 | lua_pushnil( L2); // ... mt __lanesclone nil | 1908 | lua_pushnil( L2); // ... mt __lanesclone nil |