diff --git a/CommonLibSF/include/RE/S/Stack.h b/CommonLibSF/include/RE/S/Stack.h index a92966ee..38759640 100644 --- a/CommonLibSF/include/RE/S/Stack.h +++ b/CommonLibSF/include/RE/S/Stack.h @@ -4,104 +4,101 @@ #include "RE/B/BSTSmartPointer.h" #include "RE/V/Variable.h" -namespace RE +namespace RE::BSScript { - namespace BSScript + class IProfilePolicy; + class IStackCallbackFunctor; + class MemoryPage; // stub + class Object; + class StackFrame; + + struct IMemoryPagePolicy; + + namespace Internal { - class IProfilePolicy; - class IStackCallbackFunctor; - class MemoryPage; // stub - class Object; - class StackFrame; + class CodeTasklet; + } - struct IMemoryPagePolicy; + namespace UnlinkedTypes + { + struct Object; // stub + } - namespace Internal + class Stack : + public BSIntrusiveRefCounted // 00 + { + public: + enum class StackType { - class CodeTasklet; - } + kNormal, + kPropInit, + kInitEvent + }; - namespace UnlinkedTypes + enum class FreezeState { - struct Object; // stub - } + kUnfrozen, + kFreezing, + kFrozen + }; - class Stack : - public BSIntrusiveRefCounted // 00 + enum class State { - public: - enum class StackType - { - kNormal, - kPropInit, - kInitEvent - }; - - enum class FreezeState - { - kUnfrozen, - kFreezing, - kFrozen - }; - - enum class State - { - kRunning, - kFinished, - kWaitingOnMemory, - kWaitingOnLatentFunction, - kWaitingInOtherStackForCall, - kWaitingInOtherStackForReturn, - kWaitingInOtherStackForReturnNoPop, - kRetryReturnNoPop, - kRetryCall, - kWaitingOnGuard, - kWaitingOnOtherStackForGuard, - }; + kRunning, + kFinished, + kWaitingOnMemory, + kWaitingOnLatentFunction, + kWaitingInOtherStackForCall, + kWaitingInOtherStackForReturn, + kWaitingInOtherStackForReturnNoPop, + kRetryReturnNoPop, + kRetryCall, + kWaitingOnGuard, + kWaitingOnOtherStackForGuard, + }; - struct MemoryPageData - { - public: - // members - BSTAutoPointer page; // 00 - std::uint32_t availableMemoryInBytes; // 08 - }; - static_assert(sizeof(MemoryPageData) == 0x10); + struct MemoryPageData + { + public: + // members + BSTAutoPointer page; // 00 + std::uint32_t availableMemoryInBytes; // 08 + }; + static_assert(sizeof(MemoryPageData) == 0x10); - [[nodiscard]] std::uint32_t GetPageForFrame(const StackFrame* a_frame) const - { - using func_t = decltype(&Stack::GetPageForFrame); - REL::Relocation func{ ID::BSScript::Stack::GetPageForFrame }; - return func(this, a_frame); - } + [[nodiscard]] std::uint32_t GetPageForFrame(const StackFrame* a_frame) const + { + using func_t = decltype(&Stack::GetPageForFrame); + REL::Relocation func{ ID::BSScript::Stack::GetPageForFrame }; + return func(this, a_frame); + } - [[nodiscard]] Variable& GetStackFrameVariable(const StackFrame* a_frame, std::uint32_t a_index, std::uint32_t a_pageHint) - { - using func_t = decltype(&Stack::GetStackFrameVariable); - REL::Relocation func{ ID::BSScript::Stack::GetStackFrameVariable }; - return func(this, a_frame, a_index, a_pageHint); - } + [[nodiscard]] Variable& GetStackFrameVariable(const StackFrame* a_frame, std::uint32_t a_index, std::uint32_t a_pageHint) + { + using func_t = decltype(&Stack::GetStackFrameVariable); + REL::Relocation func{ ID::BSScript::Stack::GetStackFrameVariable }; + return func(this, a_frame, a_index, a_pageHint); + } - // members - IMemoryPagePolicy* policy; // 08 - void* unk10; // 10 -- something to do with guards, guardPolicy maybe? - IProfilePolicy* profilePolicy; // 18 - void* unk20; // 20 - /*BSTSmallArray*/ char pages[0x40]; // 28 - StackFrame* top; // 68 - BSTSmartPointer owningTasklet; // 70 - BSTSmartPointer callback; // 78 - BSTSmartPointer objToUnbind; // 80 - BSTSmartPointer nextStack; // 88 - Variable returnValue; // 90 - std::uint64_t unk98; // A0 - std::uint64_t unkA0; // A8 - std::uint32_t frames; // B0 - std::uint32_t stackID; // B4 - stl::enumeration state; // B8 - stl::enumeration freezeState; // BC - stl::enumeration stackType; // C0 - }; - static_assert(sizeof(Stack) == 0xC8); - } + // members + IMemoryPagePolicy* policy; // 08 + void* unk10; // 10 -- something to do with guards, guardPolicy maybe? + IProfilePolicy* profilePolicy; // 18 + void* unk20; // 20 + /*BSTSmallArray*/ char pages[0x40]; // 28 + StackFrame* top; // 68 + BSTSmartPointer owningTasklet; // 70 + BSTSmartPointer callback; // 78 + BSTSmartPointer objToUnbind; // 80 + BSTSmartPointer nextStack; // 88 + Variable returnValue; // 90 + std::uint64_t unk98; // A0 + std::uint64_t unkA0; // A8 + std::uint32_t frames; // B0 + std::uint32_t stackID; // B4 + stl::enumeration state; // B8 + stl::enumeration freezeState; // BC + stl::enumeration stackType; // C0 + }; + static_assert(sizeof(Stack) == 0xC8); } diff --git a/CommonLibSF/include/RE/S/StackFrame.h b/CommonLibSF/include/RE/S/StackFrame.h index 16abc3b5..708d0790 100644 --- a/CommonLibSF/include/RE/S/StackFrame.h +++ b/CommonLibSF/include/RE/S/StackFrame.h @@ -1,35 +1,31 @@ #pragma once -#include "RE/B/BSFixedString.h" #include "RE/B/BSTSmartPointer.h" #include "RE/V/Variable.h" -namespace RE +namespace RE::BSScript { - namespace BSScript - { - class IFunction; - class ObjectTypeInfo; - class Stack; - class Variable; + class IFunction; + class ObjectTypeInfo; + class Stack; + class Variable; - class StackFrame - { - public: - [[nodiscard]] std::uint32_t GetPageForFrame() const; - [[nodiscard]] Variable& GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const; + class StackFrame + { + public: + [[nodiscard]] std::uint32_t GetPageForFrame() const; + [[nodiscard]] Variable& GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const; - // members - Stack* parent; // 00 - StackFrame* previousFrame; // 08 - BSTSmartPointer owningFunction; // 10 - BSTSmartPointer owningObjectType; // 18 - Variable self; // 20 - std::uint32_t index; // 30 - std::uint32_t ip; // 34 - std::uint32_t size; // 38 - bool instructionsValid; // 3C - }; - static_assert(sizeof(StackFrame) == 0x40); - } + // members + Stack* parent; // 00 + StackFrame* previousFrame; // 08 + BSTSmartPointer owningFunction; // 10 + BSTSmartPointer owningObjectType; // 18 + Variable self; // 20 + std::uint32_t index; // 30 + std::uint32_t ip; // 34 + std::uint32_t size; // 38 + bool instructionsValid; // 3C + }; + static_assert(sizeof(StackFrame) == 0x40); } diff --git a/CommonLibSF/src/RE/S/StackFrame.cpp b/CommonLibSF/src/RE/S/StackFrame.cpp index d09d440c..d03bde14 100644 --- a/CommonLibSF/src/RE/S/StackFrame.cpp +++ b/CommonLibSF/src/RE/S/StackFrame.cpp @@ -7,6 +7,7 @@ namespace RE::BSScript { return parent->GetPageForFrame(this); } + Variable& StackFrame::GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const { return parent->GetStackFrameVariable(this, a_index, a_pageHint); diff --git a/CommonLibSF/test/test.cpp b/CommonLibSF/test/test.cpp index 3d255489..4d0c81b1 100644 --- a/CommonLibSF/test/test.cpp +++ b/CommonLibSF/test/test.cpp @@ -1 +1 @@ -#include "RE/Starfield.h" \ No newline at end of file +#include "RE/Starfield.h"