diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2025-09-20 14:30:57 +0200 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2025-09-20 14:30:57 +0200 |
| commit | c52571736d852d2636bd285d19c613be5c706cff (patch) | |
| tree | 50a1fc9b867197faa695c728008c8d0c7498b756 /unit_tests/shared.cpp | |
| parent | dc3de6ef8d4bb1a8ce7b2932515a0f6287ab1e76 (diff) | |
| download | lanes-c52571736d852d2636bd285d19c613be5c706cff.tar.gz lanes-c52571736d852d2636bd285d19c613be5c706cff.tar.bz2 lanes-c52571736d852d2636bd285d19c613be5c706cff.zip | |
Improve table and userdata conversions
* add convert_fallback and convert_max_attempts to global settings
* if no __lanesconvert is available, use convert_fallback (can be useful for externally provided full userdata with fixed metatables)
* only try conversion on non-deep and non-clonable userdata
* conversion can be applied recursively, up to convert_max_attempts times
* plus all the relevant unit tests of course
Diffstat (limited to 'unit_tests/shared.cpp')
| -rw-r--r-- | unit_tests/shared.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp index 9f3b08e..825cd48 100644 --- a/unit_tests/shared.cpp +++ b/unit_tests/shared.cpp | |||
| @@ -46,8 +46,14 @@ namespace | |||
| 46 | return 1; | 46 | return 1; |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | // a function that creates a full userdata, using first argument as its metatable | ||
| 49 | lua_CFunction sNewUserData = +[](lua_State* const L_) { | 50 | lua_CFunction sNewUserData = +[](lua_State* const L_) { |
| 50 | std::ignore = luaW_newuserdatauv<int>(L_, UserValueCount{ 0 }); | 51 | lua_settop(L_, 1); // L_: {}|nil |
| 52 | STACK_CHECK_START_ABS(L_, 1); | ||
| 53 | std::ignore = luaW_newuserdatauv<int>(L_, UserValueCount{ 0 }); // L_: {}|nil u | ||
| 54 | lua_insert(L_, 1); // L_: u {}|nil | ||
| 55 | lua_setmetatable(L_, 1); // L_: u | ||
| 56 | STACK_CHECK(L_, 1); | ||
| 51 | return 1; | 57 | return 1; |
| 52 | }; | 58 | }; |
| 53 | 59 | ||
