aboutsummaryrefslogtreecommitdiff
path: root/src/universe.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/universe.h')
-rw-r--r--src/universe.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/universe.h b/src/universe.h
index 128c4d9..2fd487e 100644
--- a/src/universe.h
+++ b/src/universe.h
@@ -34,7 +34,7 @@ class AllocatorDefinition
34 void* m_allocUD{ nullptr }; 34 void* m_allocUD{ nullptr };
35 35
36 [[nodiscard]] static void* operator new(size_t size_) noexcept = delete; // can't create one outside of a Lua state 36 [[nodiscard]] static void* operator new(size_t size_) noexcept = delete; // can't create one outside of a Lua state
37 [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } 37 [[nodiscard]] static void* operator new(size_t size_, lua_State* L_) noexcept { return lua_newuserdatauv(L_, size_, 0); }
38 // always embedded somewhere else or "in-place constructed" as a full userdata 38 // always embedded somewhere else or "in-place constructed" as a full userdata
39 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 39 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
40 static void operator delete([[maybe_unused]] void* p_, lua_State* L_) { LUA_ASSERT(L_, !"should never be called"); } 40 static void operator delete([[maybe_unused]] void* p_, lua_State* L_) { LUA_ASSERT(L_, !"should never be called"); }
@@ -50,9 +50,9 @@ class AllocatorDefinition
50 AllocatorDefinition& operator=(AllocatorDefinition const& rhs_) = default; 50 AllocatorDefinition& operator=(AllocatorDefinition const& rhs_) = default;
51 AllocatorDefinition& operator=(AllocatorDefinition&& rhs_) = default; 51 AllocatorDefinition& operator=(AllocatorDefinition&& rhs_) = default;
52 52
53 void initFrom(lua_State* L) 53 void initFrom(lua_State* L_)
54 { 54 {
55 m_allocF = lua_getallocf(L, &m_allocUD); 55 m_allocF = lua_getallocf(L_, &m_allocUD);
56 } 56 }
57 57
58 void* lua_alloc(void* ptr_, size_t osize_, size_t nsize_) 58 void* lua_alloc(void* ptr_, size_t osize_, size_t nsize_)
@@ -89,25 +89,25 @@ class ProtectedAllocator
89 89
90 public: 90 public:
91 // we are not like our base class: we can't be created inside a full userdata (or we would have to install a metatable and __gc handler to destroy ourselves properly) 91 // we are not like our base class: we can't be created inside a full userdata (or we would have to install a metatable and __gc handler to destroy ourselves properly)
92 [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept = delete; 92 [[nodiscard]] static void* operator new(size_t size_, lua_State* L_) noexcept = delete;
93 static void operator delete(void* p_, lua_State* L) = delete; 93 static void operator delete(void* p_, lua_State* L_) = delete;
94 94
95 AllocatorDefinition makeDefinition() 95 AllocatorDefinition makeDefinition()
96 { 96 {
97 return AllocatorDefinition{ protected_lua_Alloc, this }; 97 return AllocatorDefinition{ protected_lua_Alloc, this };
98 } 98 }
99 99
100 void installIn(lua_State* L) 100 void installIn(lua_State* L_)
101 { 101 {
102 lua_setallocf(L, protected_lua_Alloc, this); 102 lua_setallocf(L_, protected_lua_Alloc, this);
103 } 103 }
104 104
105 void removeFrom(lua_State* L) 105 void removeFrom(lua_State* L_)
106 { 106 {
107 // remove the protected allocator, if any 107 // remove the protected allocator, if any
108 if (m_allocF != nullptr) { 108 if (m_allocF != nullptr) {
109 // install the non-protected allocator 109 // install the non-protected allocator
110 lua_setallocf(L, m_allocF, m_allocUD); 110 lua_setallocf(L_, m_allocF, m_allocUD);
111 } 111 }
112 } 112 }
113}; 113};
@@ -182,9 +182,9 @@ class Universe
182 182
183// ################################################################################################# 183// #################################################################################################
184 184
185[[nodiscard]] Universe* universe_get(lua_State* L); 185[[nodiscard]] Universe* universe_get(lua_State* L_);
186[[nodiscard]] Universe* universe_create(lua_State* L); 186[[nodiscard]] Universe* universe_create(lua_State* L_);
187void universe_store(lua_State* L, Universe* U); 187void universe_store(lua_State* L_, Universe* U);
188 188
189// ################################################################################################# 189// #################################################################################################
190 190