From 43ee5921b4466511ccb54ddf8e2c3953353557f3 Mon Sep 17 00:00:00 2001 From: Parapets Date: Tue, 12 Nov 2024 13:02:59 +0000 Subject: [PATCH] More build tweaks --- cmake/sourcelist.cmake | 1 + include/RE/B/BSFixedString.h | 14 ++++++++------ include/RE/F/FormTraits.h | 29 +++++++++-------------------- include/RE/T/TESForm.h | 25 ++++++++++++++++++------- src/RE/A/Actor.cpp | 2 +- src/RE/B/BSFixedString.cpp | 4 ++-- src/RE/F/FormTraits.cpp | 12 ++++++++++++ src/RE/I/InventoryEntryData.cpp | 1 - src/RE/T/TESForm.cpp | 5 ++++- src/RE/T/TESLeveledList.cpp | 2 +- src/RE/T/TESObjectARMA.cpp | 1 - src/RE/T/TESObjectREFR.cpp | 2 +- src/RE/T/TutorialMenu.cpp | 1 - 13 files changed, 57 insertions(+), 42 deletions(-) create mode 100644 src/RE/F/FormTraits.cpp diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index 8772833f5..86e27c1e3 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -1468,6 +1468,7 @@ set(SOURCES src/RE/E/ExtraSoul.cpp src/RE/E/ExtraTextDisplayData.cpp src/RE/E/ExtraUniqueID.cpp + src/RE/F/FormTraits.cpp src/RE/F/FxDelegate.cpp src/RE/F/FxDelegateArgs.cpp src/RE/G/GAtomic.cpp diff --git a/include/RE/B/BSFixedString.h b/include/RE/B/BSFixedString.h index ce86c687c..e8db113cf 100644 --- a/include/RE/B/BSFixedString.h +++ b/include/RE/B/BSFixedString.h @@ -23,10 +23,11 @@ namespace RE BSFixedString(const BSFixedString& a_rhs); BSFixedString(BSFixedString&& a_rhs) noexcept; BSFixedString(const_pointer a_string); - BSFixedString(std::basic_string_view a_view); + BSFixedString(std::basic_string_view a_view); - inline BSFixedString(std::convertible_to> auto&& a_string) : - BSFixedString(static_cast>(a_string)) + template > T> + inline BSFixedString(T&& a_string) : + BSFixedString(static_cast>(std::forward(a_string))) { } @@ -35,11 +36,12 @@ namespace RE BSFixedString& operator=(const BSFixedString& a_rhs); BSFixedString& operator=(BSFixedString&& a_rhs) noexcept; BSFixedString& operator=(const_pointer a_string); - BSFixedString& operator=(std::basic_string_view a_view); + BSFixedString& operator=(std::basic_string_view a_view); - inline BSFixedString& operator=(std::convertible_to> auto&& a_string) + template > T> + inline BSFixedString& operator=(T&& a_string) { - return *this = static_cast>(a_string); + return *this = static_cast>(std::forward(a_string)); } [[nodiscard]] inline const_reference operator[](size_type a_pos) const noexcept diff --git a/include/RE/F/FormTraits.h b/include/RE/F/FormTraits.h index 78303c78f..83a1aeec7 100644 --- a/include/RE/F/FormTraits.h +++ b/include/RE/F/FormTraits.h @@ -142,28 +142,17 @@ namespace RE { - template - requires(std::is_class_v) - T* TESForm::As() noexcept - { - return const_cast( - static_cast(this)->As()); - } + extern template const TESBoundObject* TESForm::As() const noexcept; + extern template const TESContainer* TESForm::As() const noexcept; + extern template const TESEnchantableForm* TESForm::As() const noexcept; + extern template const TESFullName* TESForm::As() const noexcept; + extern template const TESLeveledList* TESForm::As() const noexcept; + extern template const TESModel* TESForm::As() const noexcept; + extern template const TESWeightForm* TESForm::As() const noexcept; template - requires(requires { T::FORMTYPE; }) - const T* TESForm::As() const noexcept - { - if (GetFormType() == T::FORMTYPE) { - return static_cast(this); - } else { - return nullptr; - } - } - - template T> - requires(!requires { T::FORMTYPE; }) - const T* TESForm::As() const noexcept + requires(!requires { T::FORMTYPE; }) + const T* TESForm::As() const noexcept { switch (GetFormType()) { SKSE_FORMTRAITS(TESForm); diff --git a/include/RE/T/TESForm.h b/include/RE/T/TESForm.h index 97199b30b..c4613f77c 100644 --- a/include/RE/T/TESForm.h +++ b/include/RE/T/TESForm.h @@ -207,16 +207,27 @@ namespace RE } template - requires(std::is_class_v) - [[nodiscard]] T* As() noexcept; + requires(std::is_class_v) + [[nodiscard]] T* As() noexcept + { + return const_cast( + static_cast(this)->As()); + } template - requires(requires { T::FORMTYPE; }) - [[nodiscard]] const T* As() const noexcept; + requires(requires { T::FORMTYPE; }) + [[nodiscard]] const T* As() const noexcept + { + if (GetFormType() == T::FORMTYPE) { + return static_cast(this); + } else { + return nullptr; + } + } - template T> - requires(!requires { T::FORMTYPE; }) - [[nodiscard]] const T* As() const noexcept; + template + requires(!requires { T::FORMTYPE; }) + [[nodiscard]] const T* As() const noexcept; [[nodiscard]] TESObjectREFR* AsReference() { return AsReference1(); } [[nodiscard]] const TESObjectREFR* AsReference() const { return AsReference2(); } diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index 0933b9418..1ca5bb9d8 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -8,7 +8,6 @@ #include "RE/B/BSFaceGenNiNode.h" #include "RE/E/ExtraCanTalkToPlayer.h" #include "RE/E/ExtraFactionChanges.h" -#include "RE/F/FormTraits.h" #include "RE/H/HighProcessData.h" #include "RE/I/InventoryEntryData.h" #include "RE/M/MiddleHighProcessData.h" @@ -19,6 +18,7 @@ #include "RE/P/ProcessLists.h" #include "RE/T/TESFaction.h" #include "RE/T/TESNPC.h" +#include "RE/T/TESObjectARMO.h" #include "RE/T/TESObjectMISC.h" #include "RE/T/TESRace.h" #include "RE/T/TESWorldSpace.h" diff --git a/src/RE/B/BSFixedString.cpp b/src/RE/B/BSFixedString.cpp index ff28a86e0..c06b03787 100644 --- a/src/RE/B/BSFixedString.cpp +++ b/src/RE/B/BSFixedString.cpp @@ -27,7 +27,7 @@ namespace RE } template - BSFixedString::BSFixedString(std::basic_string_view a_view) + BSFixedString::BSFixedString(std::basic_string_view a_view) { if (!a_view.empty()) { ctor(a_view.data()); @@ -73,7 +73,7 @@ namespace RE } template - BSFixedString& BSFixedString::operator=(std::basic_string_view a_view) + BSFixedString& BSFixedString::operator=(std::basic_string_view a_view) { try_release(); if (!a_view.empty()) { diff --git a/src/RE/F/FormTraits.cpp b/src/RE/F/FormTraits.cpp new file mode 100644 index 000000000..f09055c22 --- /dev/null +++ b/src/RE/F/FormTraits.cpp @@ -0,0 +1,12 @@ +#include "RE/F/FormTraits.h" + +namespace RE +{ + template const TESBoundObject* TESForm::As() const noexcept; + template const TESContainer* TESForm::As() const noexcept; + template const TESEnchantableForm* TESForm::As() const noexcept; + template const TESFullName* TESForm::As() const noexcept; + template const TESLeveledList* TESForm::As() const noexcept; + template const TESModel* TESForm::As() const noexcept; + template const TESWeightForm* TESForm::As() const noexcept; +} diff --git a/src/RE/I/InventoryEntryData.cpp b/src/RE/I/InventoryEntryData.cpp index 590ae36b9..685294b90 100644 --- a/src/RE/I/InventoryEntryData.cpp +++ b/src/RE/I/InventoryEntryData.cpp @@ -7,7 +7,6 @@ #include "RE/E/ExtraTextDisplayData.h" #include "RE/E/ExtraWorn.h" #include "RE/E/ExtraWornLeft.h" -#include "RE/F/FormTraits.h" #include "RE/G/GameSettingCollection.h" #include "RE/T/TESBoundObject.h" #include "RE/T/TESEnchantableForm.h" diff --git a/src/RE/T/TESForm.cpp b/src/RE/T/TESForm.cpp index e92c0a62d..95c0225d1 100644 --- a/src/RE/T/TESForm.cpp +++ b/src/RE/T/TESForm.cpp @@ -1,13 +1,16 @@ #include "RE/T/TESForm.h" #include "RE/B/BGSDefaultObjectManager.h" -#include "RE/F/FormTraits.h" #include "RE/I/IObjectHandlePolicy.h" #include "RE/I/InventoryEntryData.h" +#include "RE/T/TESBoundObject.h" +#include "RE/T/TESForm.h" #include "RE/T/TESFullName.h" #include "RE/T/TESGlobal.h" #include "RE/T/TESModel.h" +#include "RE/T/TESNPC.h" #include "RE/T/TESObjectREFR.h" +#include "RE/T/TESWeightForm.h" #include "RE/V/VirtualMachine.h" namespace RE diff --git a/src/RE/T/TESLeveledList.cpp b/src/RE/T/TESLeveledList.cpp index dbb50f892..a122bf093 100644 --- a/src/RE/T/TESLeveledList.cpp +++ b/src/RE/T/TESLeveledList.cpp @@ -1,6 +1,6 @@ #include "RE/T/TESLeveledList.h" -#include "RE/F/FormTraits.h" +#include "RE/T/TESForm.h" namespace RE { diff --git a/src/RE/T/TESObjectARMA.cpp b/src/RE/T/TESObjectARMA.cpp index 4cc238f24..37d545ccb 100644 --- a/src/RE/T/TESObjectARMA.cpp +++ b/src/RE/T/TESObjectARMA.cpp @@ -1,6 +1,5 @@ #include "RE/T/TESObjectARMA.h" -#include "RE/F/FormTraits.h" #include "RE/T/TESNPC.h" #include "RE/T/TESObjectARMO.h" #include "RE/T/TESObjectREFR.h" diff --git a/src/RE/T/TESObjectREFR.cpp b/src/RE/T/TESObjectREFR.cpp index 0126b43c8..762f25552 100644 --- a/src/RE/T/TESObjectREFR.cpp +++ b/src/RE/T/TESObjectREFR.cpp @@ -12,7 +12,6 @@ #include "RE/E/ExtraOwnership.h" #include "RE/E/ExtraReferenceHandle.h" #include "RE/E/ExtraTextDisplayData.h" -#include "RE/F/FormTraits.h" #include "RE/I/InventoryChanges.h" #include "RE/I/InventoryEntryData.h" #include "RE/M/Misc.h" @@ -24,6 +23,7 @@ #include "RE/T/TESEnchantableForm.h" #include "RE/T/TESFaction.h" #include "RE/T/TESNPC.h" +#include "RE/T/TESObjectCELL.h" #include "SKSE/Logger.h" namespace RE diff --git a/src/RE/T/TutorialMenu.cpp b/src/RE/T/TutorialMenu.cpp index 14f66ad51..8cc685da4 100644 --- a/src/RE/T/TutorialMenu.cpp +++ b/src/RE/T/TutorialMenu.cpp @@ -3,7 +3,6 @@ #include "RE/B/BGSMessage.h" #include "RE/B/BSTArray.h" #include "RE/C/CRC.h" -#include "RE/F/FormTraits.h" #include "RE/I/INISettingCollection.h" #include "RE/T/TESFile.h" #include "RE/T/TESFormUIData.h"