aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-24 18:03:06 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-24 18:03:06 +0200
commit5e3f33bd66ef5b21568fde7866ca4ba9a7496180 (patch)
treed2692b78cb20655de5ebf842de72fd2b806d12db /src/linda.cpp
parent0a481b9aef3726763c572ad3ce6d44ea14dd35ba (diff)
downloadlanes-5e3f33bd66ef5b21568fde7866ca4ba9a7496180.tar.gz
lanes-5e3f33bd66ef5b21568fde7866ca4ba9a7496180.tar.bz2
lanes-5e3f33bd66ef5b21568fde7866ca4ba9a7496180.zip
Lindas now accept deep user data as valid keys
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index 4edc029..079ab9d 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -46,6 +46,7 @@ namespace {
46 46
47 static void CheckKeyTypes(lua_State* const L_, int const start_, int const end_) 47 static void CheckKeyTypes(lua_State* const L_, int const start_, int const end_)
48 { 48 {
49 STACK_CHECK_START_REL(L_, 0);
49 for (int const _i : std::ranges::iota_view{ start_, end_ + 1 }) { 50 for (int const _i : std::ranges::iota_view{ start_, end_ + 1 }) {
50 switch (LuaType const _t{ luaG_type(L_, _i) }) { 51 switch (LuaType const _t{ luaG_type(L_, _i) }) {
51 case LuaType::BOOLEAN: 52 case LuaType::BOOLEAN:
@@ -53,6 +54,12 @@ namespace {
53 case LuaType::STRING: 54 case LuaType::STRING:
54 break; 55 break;
55 56
57 case LuaType::USERDATA:
58 if (!DeepFactory::IsDeepUserdata(L_, _i)) {
59 raise_luaL_error(L_, "argument #%d: can't use non-deep userdata as a key", _i);
60 }
61 break;
62
56 case LuaType::LIGHTUSERDATA: 63 case LuaType::LIGHTUSERDATA:
57 { 64 {
58 static constexpr std::array<std::reference_wrapper<UniqueKey const>, 3> kKeysToCheck{ kLindaBatched, kCancelError, kNilSentinel }; 65 static constexpr std::array<std::reference_wrapper<UniqueKey const>, 3> kKeysToCheck{ kLindaBatched, kCancelError, kNilSentinel };
@@ -69,6 +76,7 @@ namespace {
69 raise_luaL_error(L_, "argument #%d: invalid key type (not a boolean, string, number or light userdata)", _i); 76 raise_luaL_error(L_, "argument #%d: invalid key type (not a boolean, string, number or light userdata)", _i);
70 } 77 }
71 } 78 }
79 STACK_CHECK(L_, 0);
72 } 80 }
73 81
74 // ############################################################################################# 82 // #############################################################################################