Skip to content

Commit

Permalink
replace msvc::function usage with std::function
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 committed May 9, 2024
1 parent 8ae1a5f commit 0cb3d92
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 106 deletions.
1 change: 0 additions & 1 deletion CommonLibF4/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ set(SOURCES
include/RE/Scaleform/Render/Render_Types2D.h
include/RE/Scaleform/Render/Render_Viewport.h
include/RE/VTABLE_IDs.h
include/RE/msvc/functional.h
include/RE/msvc/memory.h
include/RE/msvc/typeinfo.h
include/REL/Relocation.h
Expand Down
32 changes: 16 additions & 16 deletions CommonLibF4/include/RE/Bethesda/ActorValueInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,21 @@ namespace RE
using DerivationFunction_t = float(const ActorValueOwner* a_actor, const ActorValueInfo& a_info);

// members
msvc::function<ModifiedCallback_t> modifiedCallback; // 048
BSStringT<char> formEditorID; // 068
ActorValueInfo* dependentActorValues[15]; // 078
msvc::function<DerivationFunction_t> derivationFunction; // 0F0
const char* enumNames[10]; // 110
BGSLocalizedString abbreviation; // 160
std::int32_t oldActorValue; // 168
stl::enumeration<ActorValue::Flags, std::int32_t> flags; // 16C
stl::enumeration<ActorValue::AVType, std::int32_t> avType; // 170
std::uint32_t numDependentActorValues; // 174
std::uint32_t enumCount; // 178
std::int32_t fullCacheIndex; // 17C
std::int32_t permanentCacheIndex; // 180
float defaultValue; // 184
std::uint32_t sortIndex; // 188
std::function<ModifiedCallback_t> modifiedCallback; // 048
BSStringT<char> formEditorID; // 088
ActorValueInfo* dependentActorValues[15]; // 098
std::function<DerivationFunction_t> derivationFunction; // 110
const char* enumNames[10]; // 150
BGSLocalizedString abbreviation; // 1A0
std::int32_t oldActorValue; // 1A8
stl::enumeration<ActorValue::Flags, std::int32_t> flags; // 1AC
stl::enumeration<ActorValue::AVType, std::int32_t> avType; // 1B0
std::uint32_t numDependentActorValues; // 1B4
std::uint32_t enumCount; // 1B8
std::int32_t fullCacheIndex; // 1BC
std::int32_t permanentCacheIndex; // 1C0
float defaultValue; // 1C4
std::uint32_t sortIndex; // 1C8
};
static_assert(sizeof(ActorValueInfo) == 0x190);
static_assert(sizeof(ActorValueInfo) == 0x1D0);
}
9 changes: 8 additions & 1 deletion CommonLibF4/include/RE/Bethesda/BSScript/IVirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace RE
{
template <class F>
using BSTThreadScrapFunction = msvc::function<F>;
using BSTThreadScrapFunction = std::function<F>;

namespace BSScript
{
Expand Down Expand Up @@ -140,6 +140,13 @@ namespace RE
std::optional<bool> a_taskletCallable = std::nullopt,
bool a_isLatent = false);

template <class... Args>
bool DispatchStaticCall(
const BSFixedString& a_objName,
const BSFixedString& a_funcName,
const BSTSmartPointer<IStackCallbackFunctor>& a_callback,
Args... a_args);

template <class... Args>
bool DispatchMethodCall(
std::uint64_t a_objHandle,
Expand Down
61 changes: 19 additions & 42 deletions CommonLibF4/include/RE/Bethesda/BSScriptUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1255,48 +1255,23 @@ namespace RE::BSScript
(std::make_index_sequence<size>{});
return result;
}
}

class FunctionArgsBase
{
public:
FunctionArgsBase() = delete;
FunctionArgsBase(IVirtualMachine* a_vm) :
vm(a_vm)
{}

bool operator()(BSScrapArray<Variable>& a_args)
{
args->ReplaceArray(a_args, *vm);
template <class... Args>
bool IVirtualMachine::DispatchStaticCall(
const BSFixedString& a_objName,
const BSFixedString& a_funcName,
const BSTSmartPointer<IStackCallbackFunctor>& a_callback,
Args... a_args)
{
return DispatchStaticCall(
a_objName,
a_funcName,
[&](BSScrapArray<Variable>& a_out) {
a_out = detail::PackVariables(a_args...);
return true;
}

protected:
ArrayWrapper<Variable>* args; // 00
IVirtualMachine* vm; // 08
};
static_assert(sizeof(FunctionArgsBase) == 0x10);

inline BSTThreadScrapFunction<bool(BSScrapArray<Variable>&)>
CreateThreadScrapFunction(FunctionArgsBase& a_args)
{
using func_t = decltype(&detail::CreateThreadScrapFunction);
REL::Relocation<func_t> func{ REL::ID(69733) };
return func(a_args);
}

template <class... Args>
class FunctionArgs :
public FunctionArgsBase
{
public:
FunctionArgs() = delete;
FunctionArgs(IVirtualMachine* a_vm, Args... a_args) :
FunctionArgsBase(a_vm)
{
auto scrap = PackVariables(a_args...);
args = new ArrayWrapper<Variable>(scrap, *vm);
}
};
},
a_callback);
}

template <class... Args>
Expand All @@ -1307,12 +1282,14 @@ namespace RE::BSScript
const BSTSmartPointer<IStackCallbackFunctor>& a_callback,
Args... a_args)
{
auto args = detail::FunctionArgs{ this, a_args... };
return DispatchMethodCall(
a_objHandle,
a_objName,
a_funcName,
detail::CreateThreadScrapFunction(args),
[&](BSScrapArray<Variable>& a_out) {
a_out = detail::PackVariables(a_args...);
return true;
},
a_callback);
}
}
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/GameScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace RE
{
template <class F>
using BSTThreadScrapFunction = msvc::function<F>;
using BSTThreadScrapFunction = std::function<F>;

namespace BSScript
{
Expand Down
45 changes: 0 additions & 45 deletions CommonLibF4/include/RE/msvc/functional.h

This file was deleted.

0 comments on commit 0cb3d92

Please sign in to comment.