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/_pch.cpp | 2 +- src/_pch.h | 66 ----------------------------------------- src/_pch.hpp | 66 +++++++++++++++++++++++++++++++++++++++++ src/cancel.cpp | 2 +- src/compat.cpp | 2 +- src/deep.cpp | 4 +-- src/deep.h | 76 ------------------------------------------------ src/deep.hpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ src/intercopycontext.cpp | 4 +-- src/keeper.cpp | 2 +- src/lane.cpp | 2 +- src/lanes.cpp | 6 ++-- src/lanes.h | 20 ------------- src/lanes.hpp | 20 +++++++++++++ src/linda.cpp | 2 +- src/linda.h | 2 +- src/lindafactory.cpp | 2 +- src/lindafactory.h | 2 +- src/nameof.cpp | 2 +- src/state.cpp | 4 +-- src/threading.cpp | 2 +- src/tools.cpp | 2 +- src/tracker.cpp | 2 +- src/universe.cpp | 4 +-- 24 files changed, 186 insertions(+), 186 deletions(-) delete mode 100644 src/_pch.h create mode 100644 src/_pch.hpp delete mode 100644 src/deep.h create mode 100644 src/deep.hpp delete mode 100644 src/lanes.h create mode 100644 src/lanes.hpp (limited to 'src') diff --git a/src/_pch.cpp b/src/_pch.cpp index 4082771..9961a2c 100644 --- a/src/_pch.cpp +++ b/src/_pch.cpp @@ -1 +1 @@ -#include "_pch.h" \ No newline at end of file +#include "_pch.hpp" \ No newline at end of file diff --git a/src/_pch.h b/src/_pch.h deleted file mode 100644 index 1c7b7dc..0000000 --- a/src/_pch.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __PROSPERO__ -#include -#endif // __PROSPERO__ -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - -// warning level /Wall triggers a bunch of warnings in Lua headers. we can't do anything about that, so suppress them -#pragma warning(push) -#pragma warning(disable : 4820) // 'n' bytes padding added after data member 'x' - -#endif // _MSC_VER - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus -#include "lua.h" -#include "lualib.h" -#include "lauxlib.h" -#ifdef __cplusplus -} -#endif // __cplusplus - -#ifdef _MSC_VER - -#pragma warning(pop) - -#pragma warning(disable : 4061) // enumerator 'x' in switch of 'y' is not explicitly handled by a case label -#pragma warning(disable : 4514) // 'x': unreferenced inline function has been removed -#pragma warning(disable : 4623) // 'x': default constructor was implicitly defined as deleted -#pragma warning(disable : 4623) // 'x': default constructor was implicitly defined as deleted -#pragma warning(disable : 4625) // 'x': copy constructor was implicitly defined as deleted -#pragma warning(disable : 4626) // 'x': assignment operator was implicitly defined as deleted -#pragma warning(disable : 4820) // 'n' bytes padding added after data member 'x' -#pragma warning(disable : 5026) // 'x': move constructor was implicitly defined as deleted -#pragma warning(disable : 5027) // 'x': move assignment operator was implicitly defined as deleted -#pragma warning(disable : 5039) // 'x': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. -#pragma warning(disable : 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified -#pragma warning(disable : 5220) // 'x': a non-static data member with a volatile qualified type no longer implies that compiler generated copy/move constructors and copy/move assignment operators are not trivial -#pragma warning(disable : 5246) // 'x': the initialization of a subobject should be wrapped in braces - -#endif // _MSC_VER diff --git a/src/_pch.hpp b/src/_pch.hpp new file mode 100644 index 0000000..1c7b7dc --- /dev/null +++ b/src/_pch.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef __PROSPERO__ +#include +#endif // __PROSPERO__ +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER + +// warning level /Wall triggers a bunch of warnings in Lua headers. we can't do anything about that, so suppress them +#pragma warning(push) +#pragma warning(disable : 4820) // 'n' bytes padding added after data member 'x' + +#endif // _MSC_VER + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +#ifdef __cplusplus +} +#endif // __cplusplus + +#ifdef _MSC_VER + +#pragma warning(pop) + +#pragma warning(disable : 4061) // enumerator 'x' in switch of 'y' is not explicitly handled by a case label +#pragma warning(disable : 4514) // 'x': unreferenced inline function has been removed +#pragma warning(disable : 4623) // 'x': default constructor was implicitly defined as deleted +#pragma warning(disable : 4623) // 'x': default constructor was implicitly defined as deleted +#pragma warning(disable : 4625) // 'x': copy constructor was implicitly defined as deleted +#pragma warning(disable : 4626) // 'x': assignment operator was implicitly defined as deleted +#pragma warning(disable : 4820) // 'n' bytes padding added after data member 'x' +#pragma warning(disable : 5026) // 'x': move constructor was implicitly defined as deleted +#pragma warning(disable : 5027) // 'x': move assignment operator was implicitly defined as deleted +#pragma warning(disable : 5039) // 'x': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. +#pragma warning(disable : 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified +#pragma warning(disable : 5220) // 'x': a non-static data member with a volatile qualified type no longer implies that compiler generated copy/move constructors and copy/move assignment operators are not trivial +#pragma warning(disable : 5246) // 'x': the initialization of a subobject should be wrapped in braces + +#endif // _MSC_VER diff --git a/src/cancel.cpp b/src/cancel.cpp index ebb0c67..fda6dd5 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. =============================================================================== ]]-- */ -#include "_pch.h" +#include "_pch.hpp" #include "cancel.h" #include "debugspew.h" diff --git a/src/compat.cpp b/src/compat.cpp index 04ac819..3dc7b56 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -1,4 +1,4 @@ -#include "_pch.h" +#include "_pch.hpp" #include "compat.h" #include "macros_and_utils.h" diff --git a/src/deep.cpp b/src/deep.cpp index 278d25f..10d5fd5 100644 --- a/src/deep.cpp +++ b/src/deep.cpp @@ -31,8 +31,8 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" -#include "deep.h" +#include "_pch.hpp" +#include "deep.hpp" #include "tools.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; -}; - -// ################################################################################################# diff --git a/src/deep.hpp b/src/deep.hpp new file mode 100644 index 0000000..0ea2712 --- /dev/null +++ b/src/deep.hpp @@ -0,0 +1,76 @@ +#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; +}; + +// ################################################################################################# diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 06cafbd..073daff 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp @@ -23,11 +23,11 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "intercopycontext.h" #include "debugspew.h" -#include "deep.h" +#include "deep.hpp" #include "keeper.h" #include "lane.h" #include "linda.h" diff --git a/src/keeper.cpp b/src/keeper.cpp index 8ab9681..517bd1c 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -37,7 +37,7 @@ =============================================================================== ]]-- */ -#include "_pch.h" +#include "_pch.hpp" #include "keeper.h" #include "intercopycontext.h" diff --git a/src/lane.cpp b/src/lane.cpp index aaddf85..3a22a79 100644 --- a/src/lane.cpp +++ b/src/lane.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "lane.h" #include "debugspew.h" diff --git a/src/lanes.cpp b/src/lanes.cpp index 8c4ef61..5271a3c 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -79,10 +79,10 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" -#include "lanes.h" +#include "_pch.hpp" +#include "lanes.hpp" -#include "deep.h" +#include "deep.hpp" #include "intercopycontext.h" #include "keeper.h" #include "lane.h" diff --git a/src/lanes.h b/src/lanes.h deleted file mode 100644 index a3731e4..0000000 --- a/src/lanes.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "lanesconf.h" - -#define LANES_VERSION_MAJOR 4 -#define LANES_VERSION_MINOR 0 -#define LANES_VERSION_PATCH 0 - -#define LANES_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH >= PATCH)))) -#define LANES_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR < MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR < MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH < PATCH)))) -#define LANES_VERSION_LESS_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR < MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR < MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH <= PATCH)))) -#define LANES_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH > PATCH)))) -#define LANES_VERSION_GREATER_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH >= PATCH)))) - -LANES_API int luaopen_lanes_core(lua_State* L_); - -// Call this to work with embedded Lanes instead of calling luaopen_lanes_core() -LANES_API void luaopen_lanes_embedded(lua_State* L_, lua_CFunction luaopen_lanes_); -using luaopen_lanes_embedded_t = void (*)(lua_State* L_, lua_CFunction luaopen_lanes_); -static_assert(std::is_same_v, "signature changed: check all uses of luaopen_lanes_embedded_t"); diff --git a/src/lanes.hpp b/src/lanes.hpp new file mode 100644 index 0000000..a3731e4 --- /dev/null +++ b/src/lanes.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "lanesconf.h" + +#define LANES_VERSION_MAJOR 4 +#define LANES_VERSION_MINOR 0 +#define LANES_VERSION_PATCH 0 + +#define LANES_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH >= PATCH)))) +#define LANES_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR < MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR < MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH < PATCH)))) +#define LANES_VERSION_LESS_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR < MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR < MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH <= PATCH)))) +#define LANES_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH > PATCH)))) +#define LANES_VERSION_GREATER_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR > MAJOR) || (LANES_VERSION_MAJOR == MAJOR && (LANES_VERSION_MINOR > MINOR || (LANES_VERSION_MINOR == MINOR && LANES_VERSION_PATCH >= PATCH)))) + +LANES_API int luaopen_lanes_core(lua_State* L_); + +// Call this to work with embedded Lanes instead of calling luaopen_lanes_core() +LANES_API void luaopen_lanes_embedded(lua_State* L_, lua_CFunction luaopen_lanes_); +using luaopen_lanes_embedded_t = void (*)(lua_State* L_, lua_CFunction luaopen_lanes_); +static_assert(std::is_same_v, "signature changed: check all uses of luaopen_lanes_embedded_t"); diff --git a/src/linda.cpp b/src/linda.cpp index 67526a7..aeca8d6 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "linda.h" #include "lane.h" diff --git a/src/linda.h b/src/linda.h index 02b0514..583089d 100644 --- a/src/linda.h +++ b/src/linda.h @@ -1,7 +1,7 @@ #pragma once #include "cancel.h" -#include "deep.h" +#include "deep.hpp" #include "universe.h" struct Keeper; diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp index 11e2cff..1233edf 100644 --- a/src/lindafactory.cpp +++ b/src/lindafactory.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "lindafactory.h" #include "linda.h" diff --git a/src/lindafactory.h b/src/lindafactory.h index 06eab44..ac42c10 100644 --- a/src/lindafactory.h +++ b/src/lindafactory.h @@ -1,6 +1,6 @@ #pragma once -#include "deep.h" +#include "deep.hpp" // ################################################################################################# diff --git a/src/nameof.cpp b/src/nameof.cpp index ef03820..1e2752d 100644 --- a/src/nameof.cpp +++ b/src/nameof.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "nameof.h" #include "tools.h" diff --git a/src/state.cpp b/src/state.cpp index 2e551ed..cf28e2c 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -31,12 +31,12 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "state.h" #include "intercopycontext.h" #include "lane.h" -#include "lanes.h" +#include "lanes.hpp" #include "tools.h" #include "universe.h" diff --git a/src/threading.cpp b/src/threading.cpp index ad3d3e4..bc0bc23 100644 --- a/src/threading.cpp +++ b/src/threading.cpp @@ -34,7 +34,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #if defined(__linux__) diff --git a/src/tools.cpp b/src/tools.cpp index 34b9faf..80a9f0b 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "tools.h" diff --git a/src/tracker.cpp b/src/tracker.cpp index 16c9c55..83c2261 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "tracker.h" #include "lane.h" diff --git a/src/universe.cpp b/src/universe.cpp index 5ee2255..96ef34d 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -28,10 +28,10 @@ THE SOFTWARE. =============================================================================== */ -#include "_pch.h" +#include "_pch.hpp" #include "universe.h" -#include "deep.h" +#include "deep.hpp" #include "intercopycontext.h" #include "keeper.h" #include "lane.h" -- cgit v1.2.3-55-g6feb