diff options
Diffstat (limited to '')
-rw-r--r-- | src/uniquekey.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/uniquekey.h b/src/uniquekey.h index fb98628..777d640 100644 --- a/src/uniquekey.h +++ b/src/uniquekey.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include "compat.h" | 3 | #include "compat.h" |
4 | #include "macros_and_utils.h" | ||
4 | 5 | ||
5 | class UniqueKey | 6 | class UniqueKey |
6 | { | 7 | { |
@@ -38,4 +39,17 @@ class UniqueKey | |||
38 | // unfortunately, converting a scalar to a pointer must go through a C cast | 39 | // unfortunately, converting a scalar to a pointer must go through a C cast |
39 | return lua_touserdata(L, i) == (void*) m_storage; | 40 | return lua_touserdata(L, i) == (void*) m_storage; |
40 | } | 41 | } |
42 | void query_registry(lua_State* const L) const | ||
43 | { | ||
44 | push(L); | ||
45 | lua_rawget(L, LUA_REGISTRYINDEX); | ||
46 | } | ||
47 | template <typename OP> | ||
48 | void set_registry(lua_State* L, OP operation_) const | ||
49 | { | ||
50 | // Note we can't check stack consistency because operation is not always a push (could be insert, replace, whatever) | ||
51 | push(L); // ... key | ||
52 | operation_(L); // ... key value | ||
53 | lua_rawset(L, LUA_REGISTRYINDEX); // ... | ||
54 | } | ||
41 | }; | 55 | }; |