aboutsummaryrefslogtreecommitdiff
path: root/src/macros_and_utils.h
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-07 11:46:25 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-07 11:46:25 +0200
commitee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3 (patch)
tree68c0d74ac40c6ee098abf606e3d660a862acf04f /src/macros_and_utils.h
parent35d7a6bb691d7e0564cda324b3d724caf4901545 (diff)
downloadlanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.tar.gz
lanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.tar.bz2
lanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.zip
Boyscouting some luaG_ functions
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// #################################################################################################