diff options
Diffstat (limited to 'src/uniquekey.h')
-rw-r--r-- | src/uniquekey.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/uniquekey.h b/src/uniquekey.h index da699b0..6265a56 100644 --- a/src/uniquekey.h +++ b/src/uniquekey.h | |||
@@ -68,7 +68,7 @@ class RegistryUniqueKey | |||
68 | } | 68 | } |
69 | // --------------------------------------------------------------------------------------------- | 69 | // --------------------------------------------------------------------------------------------- |
70 | template <typename T> | 70 | template <typename T> |
71 | T* readLightUserDataValue(lua_State* const L_) const | 71 | [[nodiscard]] T* readLightUserDataValue(lua_State* const L_) const |
72 | { | 72 | { |
73 | STACK_GROW(L_, 1); | 73 | STACK_GROW(L_, 1); |
74 | STACK_CHECK_START_REL(L_, 0); | 74 | STACK_CHECK_START_REL(L_, 0); |
@@ -79,7 +79,7 @@ class RegistryUniqueKey | |||
79 | return value; | 79 | return value; |
80 | } | 80 | } |
81 | // --------------------------------------------------------------------------------------------- | 81 | // --------------------------------------------------------------------------------------------- |
82 | bool readBoolValue(lua_State* const L_) const | 82 | [[nodiscard]] bool readBoolValue(lua_State* const L_) const |
83 | { | 83 | { |
84 | STACK_GROW(L_, 1); | 84 | STACK_GROW(L_, 1); |
85 | STACK_CHECK_START_REL(L_, 0); | 85 | STACK_CHECK_START_REL(L_, 0); |
@@ -89,6 +89,24 @@ class RegistryUniqueKey | |||
89 | STACK_CHECK(L_, 0); | 89 | STACK_CHECK(L_, 0); |
90 | return value; | 90 | return value; |
91 | } | 91 | } |
92 | // --------------------------------------------------------------------------------------------- | ||
93 | // equivalent to luaL_getsubtable | ||
94 | [[nodiscard]] bool getSubTable(lua_State* const L_, int narr_, int nrec_) const | ||
95 | { | ||
96 | STACK_CHECK_START_REL(L_, 0); | ||
97 | pushValue(L_); // L_: {}|nil | ||
98 | if (!lua_isnil(L_, -1)) { | ||
99 | LUA_ASSERT(L_, lua_istable(L_, -1)); | ||
100 | STACK_CHECK(L_, 1); | ||
101 | return true; // table already exists | ||
102 | } | ||
103 | lua_pop(L_, 1); // L_: | ||
104 | // store a newly created table in the registry, but leave it on the stack too | ||
105 | lua_createtable(L_, narr_, nrec_); // L_: {} | ||
106 | setValue(L_, [](lua_State* L_) { lua_pushvalue(L_, -2); }); // L_: {} | ||
107 | STACK_CHECK(L_, 1); | ||
108 | return false; | ||
109 | } | ||
92 | }; | 110 | }; |
93 | 111 | ||
94 | // ################################################################################################# | 112 | // ################################################################################################# |