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 /deep_test | |
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 'deep_test')
-rw-r--r-- | deep_test/deep_test.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/deep_test/deep_test.c b/deep_test/deep_test.c index 9585a3c..61c81c5 100644 --- a/deep_test/deep_test.c +++ b/deep_test/deep_test.c | |||
@@ -166,8 +166,12 @@ static int clonable_lanesclone( lua_State* L) | |||
166 | { | 166 | { |
167 | switch( lua_gettop( L)) | 167 | switch( lua_gettop( L)) |
168 | { | 168 | { |
169 | case 0: | 169 | case 1: |
170 | lua_pushinteger( L, sizeof( struct s_MyClonableUserdata)); | 170 | { |
171 | // in case we need it to compute the amount of memory we need | ||
172 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); | ||
173 | lua_pushinteger( L, sizeof( struct s_MyClonableUserdata)); | ||
174 | } | ||
171 | return 1; | 175 | return 1; |
172 | 176 | ||
173 | case 2: | 177 | case 2: |
@@ -175,8 +179,8 @@ static int clonable_lanesclone( lua_State* L) | |||
175 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); | 179 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); |
176 | struct s_MyClonableUserdata* from = lua_touserdata( L, 2); | 180 | struct s_MyClonableUserdata* from = lua_touserdata( L, 2); |
177 | *self = *from; | 181 | *self = *from; |
178 | return 0; | ||
179 | } | 182 | } |
183 | return 0; | ||
180 | 184 | ||
181 | default: | 185 | default: |
182 | (void) luaL_error( L, "Lanes called clonable_lanesclone with unexpected parameters"); | 186 | (void) luaL_error( L, "Lanes called clonable_lanesclone with unexpected parameters"); |
@@ -223,7 +227,7 @@ extern int __declspec(dllexport) luaopen_deep_test(lua_State* L) | |||
223 | { | 227 | { |
224 | luaL_newlib( L, deep_module); // M | 228 | luaL_newlib( L, deep_module); // M |
225 | 229 | ||
226 | // preregister the metatables for the types we can instanciate so that Lanes can know about them | 230 | // preregister the metatables for the types we can instantiate so that Lanes can know about them |
227 | if( luaL_newmetatable( L, "clonable")) // M mt | 231 | if( luaL_newmetatable( L, "clonable")) // M mt |
228 | { | 232 | { |
229 | luaL_setfuncs( L, clonable_mt, 0); | 233 | luaL_setfuncs( L, clonable_mt, 0); |