From c1859c3bab84dd1e712b946f4976702cfd9db5d2 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 28 Oct 2024 17:24:30 +0100 Subject: Renamed _pch.h → _pch.hpp, deep.h → deep.hpp, lanes.h → lanes.hpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/deep.h | 76 -------------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/deep.h (limited to 'src/deep.h') diff --git a/src/deep.h b/src/deep.h deleted file mode 100644 index 0ea2712..0000000 --- a/src/deep.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once - -/* - * public 'deep' API to be used by external modules if they want to implement Lanes-aware userdata - * said modules can either link against lanes, or embed compat.cpp/h deep.cpp/h tools.cpp/h universe.cpp/h - */ - -#include "lanesconf.h" -#include "uniquekey.h" - -// forwards -enum class LookupMode; -class DeepFactory; -class Universe; - -// ################################################################################################# - -// xxh64 of string "kDeepVersion_1" generated at https://www.pelock.com/products/hash-calculator -static constexpr UniqueKey kDeepVersion{ 0x91171AEC6641E9DBull, "kDeepVersion" }; - -// should be used as header for deep userdata -// a deep userdata is a full userdata that stores a single pointer to the actual DeepPrelude-derived object -struct DeepPrelude -{ - UniqueKey const magic{ kDeepVersion }; - // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the factory - DeepFactory& factory; - // data is destroyed when refcount is 0 - std::atomic refcount{ 0 }; - - DeepPrelude(DeepFactory& factory_) - : factory{ factory_ } - { - } - - void push(lua_State* L_) const; -}; - -// ################################################################################################# - -// external C modules should create a single object implementing that interface for each Deep userdata class they want to expose -class DeepFactory -{ - protected: - // protected non-virtual destructor: Lanes won't manage the Factory's lifetime - DeepFactory() = default; - virtual ~DeepFactory() = default; - - public: - // non-copyable, non-movable - DeepFactory(DeepFactory const&) = delete; - DeepFactory(DeepFactory const&&) = delete; - DeepFactory& operator=(DeepFactory const&) = delete; - DeepFactory& operator=(DeepFactory const&&) = delete; - - private: - // NVI: private overrides - virtual void createMetatable(lua_State* L_) const = 0; - virtual void deleteDeepObjectInternal(lua_State* L_, DeepPrelude* o_) const = 0; - [[nodiscard]] virtual DeepPrelude* newDeepObjectInternal(lua_State* L_) const = 0; - [[nodiscard]] virtual std::string_view moduleName() const = 0; - - private: - void storeDeepLookup(lua_State* L_) const; - - public: - // NVI: public interface - static void DeleteDeepObject(lua_State* L_, DeepPrelude* o_); - [[nodiscard]] static bool IsDeepUserdata(lua_State* const L_, StackIndex const idx_); - [[nodiscard]] static DeepFactory* LookupFactory(lua_State* L_, StackIndex index_, LookupMode mode_); - static void PushDeepProxy(DestState L_, DeepPrelude* o_, UserValueCount nuv_, LookupMode mode_, lua_State* errL_); - void pushDeepUserdata(DestState L_, UserValueCount nuv_) const; - [[nodiscard]] DeepPrelude* toDeep(lua_State* L_, StackIndex index_) const; -}; - -// ################################################################################################# -- cgit v1.2.3-55-g6feb