diff options
Diffstat (limited to 'src/deep.h')
-rw-r--r-- | src/deep.h | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -36,19 +36,20 @@ enum DeepOp | |||
36 | eDO_module, | 36 | eDO_module, |
37 | }; | 37 | }; |
38 | 38 | ||
39 | using luaG_IdFunction = void*( lua_State* L, DeepOp op_); | 39 | using luaG_IdFunction = void*(*)( lua_State* L, DeepOp op_); |
40 | 40 | ||
41 | // ################################################################################################ | 41 | // ################################################################################################ |
42 | 42 | ||
43 | // xxh64 of string "DEEP_VERSION_3" generated at https://www.pelock.com/products/hash-calculator | 43 | // xxh64 of string "DEEP_VERSION_3" generated at https://www.pelock.com/products/hash-calculator |
44 | static constexpr UniqueKey DEEP_VERSION{ 0xB2CC0FD9C0AE9674ull }; | 44 | static constexpr UniqueKey DEEP_VERSION{ 0xB2CC0FD9C0AE9674ull }; |
45 | 45 | ||
46 | // should be used as header for full userdata | 46 | // should be used as header for deep userdata |
47 | // a deep userdata is a full userdata that stores a single pointer to the actual DeepPrelude-derived object | ||
47 | struct DeepPrelude | 48 | struct DeepPrelude |
48 | { | 49 | { |
49 | UniqueKey const magic{ DEEP_VERSION }; | 50 | UniqueKey const magic{ DEEP_VERSION }; |
50 | // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the idfunc | 51 | // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the idfunc |
51 | luaG_IdFunction* idfunc { nullptr }; | 52 | luaG_IdFunction idfunc { nullptr }; |
52 | // data is destroyed when refcount is 0 | 53 | // data is destroyed when refcount is 0 |
53 | std::atomic<int> m_refcount{ 0 }; | 54 | std::atomic<int> m_refcount{ 0 }; |
54 | }; | 55 | }; |
@@ -56,5 +57,5 @@ struct DeepPrelude | |||
56 | char const* push_deep_proxy(lua_State* L, DeepPrelude* prelude, int nuv_, LookupMode mode_); | 57 | char const* push_deep_proxy(lua_State* L, DeepPrelude* prelude, int nuv_, LookupMode mode_); |
57 | void free_deep_prelude( lua_State* L, DeepPrelude* prelude_); | 58 | void free_deep_prelude( lua_State* L, DeepPrelude* prelude_); |
58 | 59 | ||
59 | LANES_API int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction* idfunc, int nuv_); | 60 | LANES_API int luaG_newdeepuserdata( lua_State* L, luaG_IdFunction idfunc, int nuv_); |
60 | LANES_API void* luaG_todeep( lua_State* L, luaG_IdFunction* idfunc, int index); | 61 | LANES_API DeepPrelude* luaG_todeep(lua_State* L, luaG_IdFunction idfunc, int index); |