aboutsummaryrefslogtreecommitdiff
path: root/src/macros_and_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros_and_utils.h')
-rw-r--r--src/macros_and_utils.h27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/macros_and_utils.h b/src/macros_and_utils.h
index 338e389..3e0b425 100644
--- a/src/macros_and_utils.h
+++ b/src/macros_and_utils.h
@@ -31,33 +31,6 @@ inline void STACK_GROW(lua_State* L_, int n_)
31 31
32// ################################################################################################# 32// #################################################################################################
33 33
34// a small helper to extract a full userdata pointer from the stack in a safe way
35template <typename T>
36[[nodiscard]] T* lua_tofulluserdata(lua_State* L_, int index_)
37{
38 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_type(L_, index_) == LUA_TUSERDATA);
39 return static_cast<T*>(lua_touserdata(L_, index_));
40}
41
42template <typename T>
43[[nodiscard]] auto lua_tolightuserdata(lua_State* L_, int index_)
44{
45 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_islightuserdata(L_, index_));
46 if constexpr (std::is_pointer_v<T>) {
47 return static_cast<T>(lua_touserdata(L_, index_));
48 } else {
49 return static_cast<T*>(lua_touserdata(L_, index_));
50 }
51}
52
53template <typename T>
54[[nodiscard]] T* lua_newuserdatauv(lua_State* L_, int nuvalue_)
55{
56 return static_cast<T*>(lua_newuserdatauv(L_, sizeof(T), nuvalue_));
57}
58
59// #################################################################################################
60
61using lua_Duration = std::chrono::template duration<lua_Number>; 34using lua_Duration = std::chrono::template duration<lua_Number>;
62 35
63// ################################################################################################# 36// #################################################################################################