From 2fb815a65c36a47d58ccbc22e643e29723bb5440 Mon Sep 17 00:00:00 2001 From: Angad <66992519+ThirdEyeSqueegee@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:03:09 -0700 Subject: [PATCH] chore: resubmit #219 (#258) --- include/RE/I/IFunction.h | 14 +++++++------- include/RE/I/IVirtualMachine.h | 2 +- include/RE/N/NativeFunction.h | 3 ++- include/RE/N/NativeFunctionBase.h | 22 ++++++++++------------ include/RE/T/TESQuest.h | 4 +++- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/RE/I/IFunction.h b/include/RE/I/IFunction.h index b8c00153..3f418853 100644 --- a/include/RE/I/IFunction.h +++ b/include/RE/I/IFunction.h @@ -2,6 +2,7 @@ #include "RE/B/BSFixedString.h" #include "RE/B/BSIntrusiveRefCounted.h" +#include "RE/T/TypeInfo.h" namespace RE::BSScript { @@ -10,10 +11,9 @@ namespace RE::BSScript class VirtualMachine; } - class VMClassInfo; - class VMClassRegistry; - class VMState; - class VMValue; + class StackFrame; + class Variable; + class IVirtualMachine; class IFunction { @@ -30,7 +30,7 @@ namespace RE::BSScript virtual BSFixedString* GetName(void) = 0; virtual BSFixedString* GetClassName(void) = 0; virtual BSFixedString* GetStateName(void) = 0; - virtual std::uint64_t* GetReturnType(std::uint64_t* a_dst) = 0; + virtual TypeInfo* GetReturnType(TypeInfo* a_typeInfo) = 0; virtual std::uint64_t GetNumParams(void) = 0; virtual std::uint64_t* GetParam(std::uint32_t a_idx, BSFixedString* a_nameOut, std::uint64_t* a_typeOut) = 0; virtual std::uint64_t GetNumParams2(void) = 0; @@ -41,11 +41,11 @@ namespace RE::BSScript virtual std::uint32_t GetUserFlags(void) = 0; virtual BSFixedString* GetDocString(void) = 0; virtual void Unk_0E(std::uint32_t a_unk) = 0; - virtual std::uint32_t Invoke(std::uint64_t a_unk0, std::uint64_t a_unk1, VMClassRegistry* a_registry, VMState* a_unk3) = 0; + virtual std::uint32_t Invoke(std::uint64_t a_unk0, std::uint64_t a_unk1, IVirtualMachine* a_vm, StackFrame* a_frame) = 0; virtual BSFixedString* Unk_10(void) = 0; // file/line number? virtual bool TranslateIPToLineNumber(std::uint32_t a_instructionPointer, std::uint32_t* r_lineNumber) = 0; virtual std::uint64_t* Unk_12(std::uint64_t* a_out) = 0; // new, might be type reflection - virtual Unk13 Unk_13(Unk13* a_out) = 0; // new, might be type reflection + virtual Unk13* Unk_13(Unk13* a_out) = 0; // new, might be type reflection virtual bool GetParamInfo(std::uint32_t a_idx, void* a_out) = 0; // param list stuff virtual void* Unk_15(std::uint64_t a_arg0, std::uint64_t a_arg1) = 0; // param list stuff, loop virtual bool GetUnk41(void) = 0; diff --git a/include/RE/I/IVirtualMachine.h b/include/RE/I/IVirtualMachine.h index 71f91fd9..1f07a5c2 100644 --- a/include/RE/I/IVirtualMachine.h +++ b/include/RE/I/IVirtualMachine.h @@ -90,8 +90,8 @@ namespace RE virtual bool GetScriptStructType(const BSFixedString& a_structTypeName, BSTSmartPointer& a_structType) = 0; // 16 virtual bool GetScriptStructTypeNoLoad(const BSFixedString& a_structTypeName, BSTSmartPointer& a_structType) const = 0; // 17 virtual bool GetChildStructTypes(const BSFixedString& a_parentObjectName, /*BSTObjectArena&*/ void* a_structTypes) const = 0; // 18 - virtual bool CreateObject(const BSFixedString& a_objectTypeName, const /*BSTScrapHashMap&*/ void* a_properties, BSTSmartPointer& a_newObj) = 0; // 19 virtual bool CreateObject(const BSFixedString& a_objectTypeName, BSTSmartPointer& a_newObj) = 0; // 1A + virtual bool CreateObject(const BSFixedString& a_objectTypeName, const /*BSTScrapHashMap&*/ void* a_properties, BSTSmartPointer& a_newObj) = 0; // 19 -- this is intended; not the right order, but the compiler appears to swap the two for some reason virtual bool CreateStruct(const BSFixedString& a_structTypeName, BSTSmartPointer& a_newStruct) = 0; // 1B virtual bool CreateArray(TypeInfo::RawType a_elementType, const BSFixedString& a_elementObjectTypeName, std::uint32_t a_elementCount, BSTSmartPointer& a_newArray) = 0; // 1C virtual bool CreateArray(const TypeInfo& a_type, std::uint32_t a_elementCount, BSTSmartPointer& a_newArray) = 0; // 1D diff --git a/include/RE/N/NativeFunction.h b/include/RE/N/NativeFunction.h index ea243a8e..0c042e37 100644 --- a/include/RE/N/NativeFunction.h +++ b/include/RE/N/NativeFunction.h @@ -8,6 +8,7 @@ namespace RE::BSScript { public: NativeFunction() = delete; + NativeFunction(const char* a_name, const char* a_className, bool a_isStatic, std::uint32_t a_numParams) { using func_t = std::add_pointer_t; @@ -23,7 +24,7 @@ namespace RE::BSScript } virtual bool HasCallback(void) override { return _callback != 0; } - virtual bool Run(VMValue* a_baseValue, VMClassRegistry* a_registry, std::uint32_t a_arg2, VMValue* a_resultValue, VMState* a_state) = 0; + virtual bool Run(Variable* a_selfValue, IVirtualMachine* a_vm, std::uint32_t a_arg2, Variable* a_resultValue, StackFrame* a_frame) = 0; protected: void* _callback; // 50 diff --git a/include/RE/N/NativeFunctionBase.h b/include/RE/N/NativeFunctionBase.h index e4528dc1..f5e4732a 100644 --- a/include/RE/N/NativeFunctionBase.h +++ b/include/RE/N/NativeFunctionBase.h @@ -1,6 +1,7 @@ #pragma once #include "RE/I/IFunction.h" +#include "RE/t/TypeInfo.h" namespace RE::BSScript { @@ -11,6 +12,7 @@ namespace RE::BSScript class StackFrame; class Variable; + class IVirtualMachine; namespace NF_util { @@ -30,12 +32,7 @@ namespace RE::BSScript public: // members BSFixedString name; // 00 - - union - { - std::uint64_t type; // 08 - shared with VMValue::type - VMClassInfo* typePtr; // 08 - }; + TypeInfo type; // 08 }; // members @@ -48,7 +45,7 @@ namespace RE::BSScript virtual BSFixedString* GetName(void) override { return &_name; } virtual BSFixedString* GetClassName(void) override { return &_className; } virtual BSFixedString* GetStateName(void) override { return &_stateName; } - virtual std::uint64_t* GetReturnType(std::uint64_t* a_dst) override + virtual TypeInfo* GetReturnType(TypeInfo* a_dst) { *a_dst = _retType; return a_dst; @@ -68,11 +65,11 @@ namespace RE::BSScript virtual std::uint32_t GetUserFlags(void) override { return _userFlags; } virtual BSFixedString* GetDocString(void) override { return &_docString; } virtual void Unk_0E(std::uint32_t a_unk) override { (void)a_unk; } // always nop? - virtual std::uint32_t Invoke(std::uint64_t a_unk0, std::uint64_t a_unk1, VMClassRegistry* a_registry, VMState* a_unk3) override + virtual std::uint32_t Invoke(std::uint64_t a_unk0, std::uint64_t a_unk1, IVirtualMachine* a_vm, StackFrame* a_frame) override { using func_t = decltype(&NativeFunctionBase::Invoke); REL::Relocation func{ ID::BSScript::Internal::NF_util::NativeFunctionBase::Invoke }; - return func(this, a_unk0, a_unk1, a_registry, a_unk3); + return func(this, a_unk0, a_unk1, a_vm, a_frame); } virtual BSFixedString* Unk_10(void) override { @@ -93,10 +90,11 @@ namespace RE::BSScript return a_out; } - virtual Unk13 Unk_13(Unk13* a_out) override + virtual Unk13* Unk_13(Unk13* a_out) override { a_out->unk00 = 0; a_out->unk08 = 0; + return a_out; // a_out[8] = 0; // as std::uint8_t? } virtual bool GetParamInfo(std::uint32_t a_idx, void* a_out) override @@ -114,13 +112,13 @@ namespace RE::BSScript virtual bool GetUnk41(void) override { return _isCallableFromTasklet; } virtual void SetUnk41(bool a_arg) override { _isCallableFromTasklet = a_arg; } virtual bool HasCallback() = 0; - virtual void Run() = 0; + virtual bool Run(Variable* a_selfValue, IVirtualMachine* a_vm, std::uint32_t a_arg2, Variable* a_resultValue, StackFrame* a_frame) = 0; protected: BSFixedString _name; // 10 BSFixedString _className; // 18 BSFixedString _stateName{ "" }; // 20 - std::uint64_t _retType; // 28 TypeInfo + TypeInfo _retType; // 28 ParameterInfo _params; // 30 bool _isStatic; // 40 bool _isCallableFromTasklet{}; // 41 diff --git a/include/RE/T/TESQuest.h b/include/RE/T/TESQuest.h index abc3a5b0..932861b4 100644 --- a/include/RE/T/TESQuest.h +++ b/include/RE/T/TESQuest.h @@ -1,8 +1,10 @@ #pragma once +#include "RE/T/TESForm.h" + namespace RE { - class TESQuest + class TESQuest : public TESForm { public: SF_RTTI_VTABLE(TESQuest);