Skip to content

Commit

Permalink
More build tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Exit-9B committed Nov 12, 2024
1 parent 251b482 commit 43ee592
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 42 deletions.
1 change: 1 addition & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions include/RE/B/BSFixedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CharT> a_view);
BSFixedString(std::basic_string_view<value_type> a_view);

inline BSFixedString(std::convertible_to<std::basic_string_view<CharT>> auto&& a_string) :
BSFixedString(static_cast<std::basic_string_view<CharT>>(a_string))
template <std::convertible_to<std::basic_string_view<value_type>> T>
inline BSFixedString(T&& a_string) :
BSFixedString(static_cast<std::basic_string_view<value_type>>(std::forward<T>(a_string)))
{
}

Expand All @@ -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<CharT> a_view);
BSFixedString& operator=(std::basic_string_view<value_type> a_view);

inline BSFixedString& operator=(std::convertible_to<std::basic_string_view<CharT>> auto&& a_string)
template <std::convertible_to<std::basic_string_view<value_type>> T>
inline BSFixedString& operator=(T&& a_string)
{
return *this = static_cast<std::basic_string_view<CharT>>(a_string);
return *this = static_cast<std::basic_string_view<value_type>>(std::forward<T>(a_string));
}

[[nodiscard]] inline const_reference operator[](size_type a_pos) const noexcept
Expand Down
29 changes: 9 additions & 20 deletions include/RE/F/FormTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,17 @@

namespace RE
{
template <class T>
requires(std::is_class_v<T>)
T* TESForm::As() noexcept
{
return const_cast<T*>(
static_cast<const TESForm*>(this)->As<T>());
}
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 <class T>
requires(requires { T::FORMTYPE; })
const T* TESForm::As() const noexcept
{
if (GetFormType() == T::FORMTYPE) {
return static_cast<const T*>(this);
} else {
return nullptr;
}
}

template <std::derived_from<BaseFormComponent> 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);
Expand Down
25 changes: 18 additions & 7 deletions include/RE/T/TESForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,27 @@ namespace RE
}

template <class T>
requires(std::is_class_v<T>)
[[nodiscard]] T* As() noexcept;
requires(std::is_class_v<T>)
[[nodiscard]] T* As() noexcept
{
return const_cast<T*>(
static_cast<const TESForm*>(this)->As<T>());
}

template <class T>
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<const T*>(this);
} else {
return nullptr;
}
}

template <std::derived_from<BaseFormComponent> T>
requires(!requires { T::FORMTYPE; })
[[nodiscard]] const T* As() const noexcept;
template <class T>
requires(!requires { T::FORMTYPE; })
[[nodiscard]] const T* As() const noexcept;

[[nodiscard]] TESObjectREFR* AsReference() { return AsReference1(); }
[[nodiscard]] const TESObjectREFR* AsReference() const { return AsReference2(); }
Expand Down
2 changes: 1 addition & 1 deletion src/RE/A/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/RE/B/BSFixedString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace RE
}

template <class CharT>
BSFixedString<CharT>::BSFixedString(std::basic_string_view<CharT> a_view)
BSFixedString<CharT>::BSFixedString(std::basic_string_view<value_type> a_view)
{
if (!a_view.empty()) {
ctor(a_view.data());
Expand Down Expand Up @@ -73,7 +73,7 @@ namespace RE
}

template <class CharT>
BSFixedString<CharT>& BSFixedString<CharT>::operator=(std::basic_string_view<CharT> a_view)
BSFixedString<CharT>& BSFixedString<CharT>::operator=(std::basic_string_view<value_type> a_view)
{
try_release();
if (!a_view.empty()) {
Expand Down
12 changes: 12 additions & 0 deletions src/RE/F/FormTraits.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 0 additions & 1 deletion src/RE/I/InventoryEntryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion src/RE/T/TESForm.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/RE/T/TESLeveledList.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "RE/T/TESLeveledList.h"

#include "RE/F/FormTraits.h"
#include "RE/T/TESForm.h"

namespace RE
{
Expand Down
1 change: 0 additions & 1 deletion src/RE/T/TESObjectARMA.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/RE/T/TESObjectREFR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/RE/T/TutorialMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 43ee592

Please sign in to comment.