aboutsummaryrefslogtreecommitdiff
path: root/src/universe.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/universe.h')
-rw-r--r--src/universe.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/universe.h b/src/universe.h
index eb85133..320c400 100644
--- a/src/universe.h
+++ b/src/universe.h
@@ -13,7 +13,7 @@ extern "C" {
13 13
14#include <mutex> 14#include <mutex>
15 15
16// ################################################################################################ 16// #################################################################################################
17 17
18// forwards 18// forwards
19struct DeepPrelude; 19struct DeepPrelude;
@@ -25,7 +25,7 @@ class Lane;
25*/ 25*/
26#define HAVE_LANE_TRACKING() 1 26#define HAVE_LANE_TRACKING() 1
27 27
28// ################################################################################################ 28// #################################################################################################
29 29
30// everything we need to provide to lua_newstate() 30// everything we need to provide to lua_newstate()
31class AllocatorDefinition 31class AllocatorDefinition
@@ -35,6 +35,7 @@ class AllocatorDefinition
35 lua_Alloc m_allocF{ nullptr }; 35 lua_Alloc m_allocF{ nullptr };
36 void* m_allocUD{ nullptr }; 36 void* m_allocUD{ nullptr };
37 37
38 [[nodiscard]] static void* operator new(size_t size_) noexcept = delete; // can't create one outside of a Lua state
38 [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } 39 [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); }
39 // always embedded somewhere else or "in-place constructed" as a full userdata 40 // always embedded somewhere else or "in-place constructed" as a full userdata
40 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 41 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
@@ -72,7 +73,7 @@ class AllocatorDefinition
72 } 73 }
73}; 74};
74 75
75// ################################################################################################ 76// #################################################################################################
76 77
77// mutex-protected allocator for use with Lua states that share a non-threadsafe allocator 78// mutex-protected allocator for use with Lua states that share a non-threadsafe allocator
78class ProtectedAllocator : public AllocatorDefinition 79class ProtectedAllocator : public AllocatorDefinition
@@ -115,7 +116,7 @@ class ProtectedAllocator : public AllocatorDefinition
115 } 116 }
116}; 117};
117 118
118// ################################################################################################ 119// #################################################################################################
119 120
120// everything regarding the Lanes universe is stored in that global structure 121// everything regarding the Lanes universe is stored in that global structure
121// held as a full userdata in the master Lua state that required it for the first time 122// held as a full userdata in the master Lua state that required it for the first time
@@ -183,13 +184,13 @@ class Universe
183 Universe& operator=(Universe&&) = delete; 184 Universe& operator=(Universe&&) = delete;
184}; 185};
185 186
186// ################################################################################################ 187// #################################################################################################
187 188
188[[nodiscard]] Universe* universe_get(lua_State* L); 189[[nodiscard]] Universe* universe_get(lua_State* L);
189[[nodiscard]] Universe* universe_create(lua_State* L); 190[[nodiscard]] Universe* universe_create(lua_State* L);
190void universe_store(lua_State* L, Universe* U); 191void universe_store(lua_State* L, Universe* U);
191 192
192// ################################################################################################ 193// #################################################################################################
193 194
194#if USE_DEBUG_SPEW() 195#if USE_DEBUG_SPEW()
195class DebugSpewIndentScope 196class DebugSpewIndentScope