From 69c6796fb1356d78be8fefa93a80b30295b6bb54 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 28 Oct 2024 18:16:00 +0100 Subject: Renamed intercopycontext.h → intercopycontext.hpp, state.h → state.hpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/intercopycontext.cpp | 2 +- src/intercopycontext.h | 79 ------------------------------------------------ src/intercopycontext.hpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ src/keeper.cpp | 4 +-- src/lane.cpp | 2 +- src/lanes.cpp | 4 +-- src/state.cpp | 4 +-- src/state.h | 14 --------- src/state.hpp | 14 +++++++++ src/universe.cpp | 4 +-- 10 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 src/intercopycontext.h create mode 100644 src/intercopycontext.hpp delete mode 100644 src/state.h create mode 100644 src/state.hpp (limited to 'src') diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 3470fe4..672d49e 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. =============================================================================== */ #include "_pch.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "debugspew.hpp" #include "deep.hpp" diff --git a/src/intercopycontext.h b/src/intercopycontext.h deleted file mode 100644 index 2b247d2..0000000 --- a/src/intercopycontext.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include "tools.hpp" - -// forwards -class Universe; - -// ################################################################################################# - -enum class VT -{ - NORMAL, // keep this one first so that it's the value we get when we default-construct - KEY, - METATABLE -}; - -enum class InterCopyResult -{ - Success, - NotEnoughValues, - Error -}; - -// ################################################################################################# - -DECLARE_UNIQUE_TYPE(CacheIndex, StackIndex); -DECLARE_UNIQUE_TYPE(SourceIndex, StackIndex); -class InterCopyContext -{ - public: - Universe* const U; - DestState const L2; - SourceState const L1; - CacheIndex const L2_cache_i; - SourceIndex L1_i; // that one can change when we reuse the context - VT vt; // that one can change when we reuse the context - LookupMode const mode; - std::string_view name; // that one can change when we reuse the context - - private: - [[nodiscard]] std::string_view findLookupName() const; - // when mode == LookupMode::FromKeeper, L1 is a keeper state and L2 is not, therefore L2 is the state where we want to raise the error - // whon mode != LookupMode::FromKeeper, L1 is not a keeper state, therefore L1 is the state where we want to raise the error - lua_State* getErrL() const { return (mode == LookupMode::FromKeeper) ? L2.value() : L1.value(); } - [[nodiscard]] LuaType processConversion() const; - - // for use in copyCachedFunction - void copyFunction() const; - void lookupNativeFunction() const; - - // for use in inter_copy_function - void copyCachedFunction() const; - [[nodiscard]] bool lookupTable() const; - - // for use in inter_copy_table - void interCopyKeyValuePair() const; - [[nodiscard]] bool pushCachedMetatable() const; - [[nodiscard]] bool pushCachedTable() const; - - // for use in inter_copy_userdata - [[nodiscard]] bool tryCopyClonable() const; - [[nodiscard]] bool tryCopyDeep() const; - - // copying a single Lua stack item - [[nodiscard]] bool interCopyBoolean() const; - [[nodiscard]] bool interCopyFunction() const; - [[nodiscard]] bool interCopyLightuserdata() const; - [[nodiscard]] bool interCopyNil() const; - [[nodiscard]] bool interCopyNumber() const; - [[nodiscard]] bool interCopyString() const; - [[nodiscard]] bool interCopyTable() const; - [[nodiscard]] bool interCopyUserdata() const; - - public: - [[nodiscard]] InterCopyResult interCopy(int n_) const; - [[nodiscard]] InterCopyResult interCopyOne() const; - [[nodiscard]] InterCopyResult interCopyPackage() const; - [[nodiscard]] InterCopyResult interMove(int n_) const; -}; diff --git a/src/intercopycontext.hpp b/src/intercopycontext.hpp new file mode 100644 index 0000000..2b247d2 --- /dev/null +++ b/src/intercopycontext.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include "tools.hpp" + +// forwards +class Universe; + +// ################################################################################################# + +enum class VT +{ + NORMAL, // keep this one first so that it's the value we get when we default-construct + KEY, + METATABLE +}; + +enum class InterCopyResult +{ + Success, + NotEnoughValues, + Error +}; + +// ################################################################################################# + +DECLARE_UNIQUE_TYPE(CacheIndex, StackIndex); +DECLARE_UNIQUE_TYPE(SourceIndex, StackIndex); +class InterCopyContext +{ + public: + Universe* const U; + DestState const L2; + SourceState const L1; + CacheIndex const L2_cache_i; + SourceIndex L1_i; // that one can change when we reuse the context + VT vt; // that one can change when we reuse the context + LookupMode const mode; + std::string_view name; // that one can change when we reuse the context + + private: + [[nodiscard]] std::string_view findLookupName() const; + // when mode == LookupMode::FromKeeper, L1 is a keeper state and L2 is not, therefore L2 is the state where we want to raise the error + // whon mode != LookupMode::FromKeeper, L1 is not a keeper state, therefore L1 is the state where we want to raise the error + lua_State* getErrL() const { return (mode == LookupMode::FromKeeper) ? L2.value() : L1.value(); } + [[nodiscard]] LuaType processConversion() const; + + // for use in copyCachedFunction + void copyFunction() const; + void lookupNativeFunction() const; + + // for use in inter_copy_function + void copyCachedFunction() const; + [[nodiscard]] bool lookupTable() const; + + // for use in inter_copy_table + void interCopyKeyValuePair() const; + [[nodiscard]] bool pushCachedMetatable() const; + [[nodiscard]] bool pushCachedTable() const; + + // for use in inter_copy_userdata + [[nodiscard]] bool tryCopyClonable() const; + [[nodiscard]] bool tryCopyDeep() const; + + // copying a single Lua stack item + [[nodiscard]] bool interCopyBoolean() const; + [[nodiscard]] bool interCopyFunction() const; + [[nodiscard]] bool interCopyLightuserdata() const; + [[nodiscard]] bool interCopyNil() const; + [[nodiscard]] bool interCopyNumber() const; + [[nodiscard]] bool interCopyString() const; + [[nodiscard]] bool interCopyTable() const; + [[nodiscard]] bool interCopyUserdata() const; + + public: + [[nodiscard]] InterCopyResult interCopy(int n_) const; + [[nodiscard]] InterCopyResult interCopyOne() const; + [[nodiscard]] InterCopyResult interCopyPackage() const; + [[nodiscard]] InterCopyResult interMove(int n_) const; +}; diff --git a/src/keeper.cpp b/src/keeper.cpp index d7ed77c..af8bd1a 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -40,10 +40,10 @@ #include "_pch.hpp" #include "keeper.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "lane.hpp" #include "linda.hpp" -#include "state.h" +#include "state.hpp" // There is a table at _R[kLindasRegKey] (aka LindasDB) // This table contains entries of the form [Linda*] = {KeysDB...} diff --git a/src/lane.cpp b/src/lane.cpp index 0b86e99..c9e334c 100644 --- a/src/lane.cpp +++ b/src/lane.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. #include "lane.hpp" #include "debugspew.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "threading.hpp" #include "tools.hpp" diff --git a/src/lanes.cpp b/src/lanes.cpp index 82977ca..7dd626b 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -83,11 +83,11 @@ THE SOFTWARE. #include "lanes.hpp" #include "deep.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "keeper.hpp" #include "lane.hpp" #include "nameof.hpp" -#include "state.h" +#include "state.hpp" #include "threading.hpp" #include "tools.hpp" diff --git a/src/state.cpp b/src/state.cpp index e6900d3..c8f1ef8 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -32,9 +32,9 @@ THE SOFTWARE. */ #include "_pch.hpp" -#include "state.h" +#include "state.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "lane.hpp" #include "lanes.hpp" #include "tools.hpp" diff --git a/src/state.h b/src/state.h deleted file mode 100644 index 7401fe9..0000000 --- a/src/state.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "debugspew.hpp" -#include "macros_and_utils.hpp" - -// forwards -enum class LookupMode; -class Universe; - -namespace state { - [[nodiscard]] lua_State* CreateState(Universe* U_, lua_State* from_, std::string_view const& hint_); - [[nodiscard]] lua_State* NewLaneState(Universe* U_, SourceState from_, std::optional const& libs_); - LUAG_FUNC(supported_libs); -} // namespace state diff --git a/src/state.hpp b/src/state.hpp new file mode 100644 index 0000000..7401fe9 --- /dev/null +++ b/src/state.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "debugspew.hpp" +#include "macros_and_utils.hpp" + +// forwards +enum class LookupMode; +class Universe; + +namespace state { + [[nodiscard]] lua_State* CreateState(Universe* U_, lua_State* from_, std::string_view const& hint_); + [[nodiscard]] lua_State* NewLaneState(Universe* U_, SourceState from_, std::optional const& libs_); + LUAG_FUNC(supported_libs); +} // namespace state diff --git a/src/universe.cpp b/src/universe.cpp index 9f28f6a..1aafbff 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -32,10 +32,10 @@ THE SOFTWARE. #include "universe.hpp" #include "deep.hpp" -#include "intercopycontext.h" +#include "intercopycontext.hpp" #include "keeper.hpp" #include "lane.hpp" -#include "state.h" +#include "state.hpp" extern LUAG_FUNC(linda); -- cgit v1.2.3-55-g6feb