Skip to content

Commit

Permalink
chore: resubmit #219 (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee authored Jul 24, 2024
1 parent 6b9f20f commit 2fb815a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
14 changes: 7 additions & 7 deletions include/RE/I/IFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "RE/B/BSFixedString.h"
#include "RE/B/BSIntrusiveRefCounted.h"
#include "RE/T/TypeInfo.h"

namespace RE::BSScript
{
Expand All @@ -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
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/RE/I/IVirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ namespace RE
virtual bool GetScriptStructType(const BSFixedString& a_structTypeName, BSTSmartPointer<StructTypeInfo>& a_structType) = 0; // 16
virtual bool GetScriptStructTypeNoLoad(const BSFixedString& a_structTypeName, BSTSmartPointer<StructTypeInfo>& a_structType) const = 0; // 17
virtual bool GetChildStructTypes(const BSFixedString& a_parentObjectName, /*BSTObjectArena<BSFixedString>&*/ void* a_structTypes) const = 0; // 18
virtual bool CreateObject(const BSFixedString& a_objectTypeName, const /*BSTScrapHashMap<BSFixedString, Variable>&*/ void* a_properties, BSTSmartPointer<Object>& a_newObj) = 0; // 19
virtual bool CreateObject(const BSFixedString& a_objectTypeName, BSTSmartPointer<Object>& a_newObj) = 0; // 1A
virtual bool CreateObject(const BSFixedString& a_objectTypeName, const /*BSTScrapHashMap<BSFixedString, Variable>&*/ void* a_properties, BSTSmartPointer<Object>& 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<Struct>& a_newStruct) = 0; // 1B
virtual bool CreateArray(TypeInfo::RawType a_elementType, const BSFixedString& a_elementObjectTypeName, std::uint32_t a_elementCount, BSTSmartPointer<Array>& a_newArray) = 0; // 1C
virtual bool CreateArray(const TypeInfo& a_type, std::uint32_t a_elementCount, BSTSmartPointer<Array>& a_newArray) = 0; // 1D
Expand Down
3 changes: 2 additions & 1 deletion include/RE/N/NativeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeFunction*(NativeFunction*, const char*, const char*, bool, std::uint32_t)>;
Expand All @@ -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
Expand Down
22 changes: 10 additions & 12 deletions include/RE/N/NativeFunctionBase.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "RE/I/IFunction.h"
#include "RE/t/TypeInfo.h"

namespace RE::BSScript
{
Expand All @@ -11,6 +12,7 @@ namespace RE::BSScript

class StackFrame;
class Variable;
class IVirtualMachine;

namespace NF_util
{
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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_t> 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
{
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion include/RE/T/TESQuest.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include "RE/T/TESForm.h"

namespace RE
{
class TESQuest
class TESQuest : public TESForm
{
public:
SF_RTTI_VTABLE(TESQuest);
Expand Down

0 comments on commit 2fb815a

Please sign in to comment.