CommonLibSSE (powerof3)
NativeFunctionBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/I/IFunction.h"
5 #include "RE/T/TypeInfo.h"
6 #include "RE/V/VDescTable.h"
7 
8 namespace RE
9 {
10  namespace BSScript
11  {
12  namespace Internal
13  {
14  class VirtualMachine;
15  }
16 
17  class StackFrame;
18  class Variable;
19 
20  namespace NF_util
21  {
23  {
24  public:
25  inline static constexpr auto RTTI = RTTI_BSScript__NF_util__NativeFunctionBase;
26  inline static constexpr auto VTABLE = VTABLE_BSScript__NF_util__NativeFunctionBase;
27 
28  NativeFunctionBase() = delete;
29  explicit NativeFunctionBase(std::string_view a_fnName, std::string_view a_className, bool a_isStatic, std::uint16_t a_numParams);
30  ~NativeFunctionBase() override = default; // 00
31 
32  // override (IFunction)
33  const BSFixedString& GetName() const override; // 01
34  const BSFixedString& GetObjectTypeName() const override; // 02
35  const BSFixedString& GetStateName() const override; // 03
36  TypeInfo GetReturnType() const override; // 04
37  std::uint32_t GetParamCount() const override; // 05
38  void GetParam(std::uint32_t a_idx, BSFixedString& a_nameOut, TypeInfo& a_typeOut) const override; // 06
39  std::uint32_t GetStackFrameSize() const override; // 07
40  bool GetIsNative() const override; // 08
41  bool GetIsStatic() const override; // 09
42  bool GetIsEmpty() const override; // 0A
43  FunctionType GetFunctionType() const override; // 0B
44  std::uint32_t GetUserFlags() const override; // 0C
45  const BSFixedString& GetDocString() const override; // 0D
46  void InsertLocals(StackFrame* a_frame) override; // 0E
47  CallResult Call(const BSTSmartPointer<Stack>& a_stack, ErrorLogger* a_logger, Internal::VirtualMachine* a_vm, bool a_arg4) override; // 0F
48  const BSFixedString& GetSourceFilename() const override; // 10
49  bool TranslateIPToLineNumber(std::uint32_t a_taskletExecutionOffset, std::uint32_t& a_lineNumberOut) const override; // 11
50  bool GetVarNameForStackIndex(std::uint32_t a_idx, BSFixedString& a_nameOut) const override; // 12
51  bool CanBeCalledFromTasklets() const override; // 13
52  void SetCallableFromTasklets(bool a_callable) override; // 14
53 
54  // add
55  virtual bool HasStub() const = 0; // 15
56  virtual bool MarshallAndDispatch(Variable& a_baseValue, Internal::VirtualMachine& a_vm, VMStackID a_stackID, Variable& a_resultValue, const StackFrame& a_frame) const = 0; // 16
57 
58  const bool GetIsLatent() const;
59 
60  protected:
61  // members
67  bool _isStatic; // 40
68  bool _isCallableFromTasklet{ false }; // 41
69  bool _isLatent{ false }; // 42
70  std::uint8_t _pad43{ 0 }; // 43
71  std::uint32_t _userFlags{ 0 }; // 44
73  };
74  static_assert(sizeof(NativeFunctionBase) == 0x50);
75  }
76  }
77 }
Definition: ErrorLogger.h:13
Definition: IFunction.h:23
CallResult
Definition: IFunction.h:36
FunctionType
Definition: IFunction.h:29
Definition: VirtualMachine.h:46
Definition: NativeFunctionBase.h:23
std::uint32_t GetParamCount() const override
TypeInfo _retType
Definition: NativeFunctionBase.h:65
bool _isLatent
Definition: NativeFunctionBase.h:69
bool CanBeCalledFromTasklets() const override
const BSFixedString & GetName() const override
BSFixedString _name
Definition: NativeFunctionBase.h:62
std::uint32_t GetUserFlags() const override
bool _isCallableFromTasklet
Definition: NativeFunctionBase.h:68
static constexpr auto RTTI
Definition: NativeFunctionBase.h:25
const BSFixedString & GetStateName() const override
bool TranslateIPToLineNumber(std::uint32_t a_taskletExecutionOffset, std::uint32_t &a_lineNumberOut) const override
void GetParam(std::uint32_t a_idx, BSFixedString &a_nameOut, TypeInfo &a_typeOut) const override
BSFixedString _docString
Definition: NativeFunctionBase.h:72
CallResult Call(const BSTSmartPointer< Stack > &a_stack, ErrorLogger *a_logger, Internal::VirtualMachine *a_vm, bool a_arg4) override
NativeFunctionBase(std::string_view a_fnName, std::string_view a_className, bool a_isStatic, std::uint16_t a_numParams)
const BSFixedString & GetSourceFilename() const override
void InsertLocals(StackFrame *a_frame) override
static constexpr auto VTABLE
Definition: NativeFunctionBase.h:26
bool GetVarNameForStackIndex(std::uint32_t a_idx, BSFixedString &a_nameOut) const override
FunctionType GetFunctionType() const override
Internal::VDescTable _descTable
Definition: NativeFunctionBase.h:66
BSFixedString _stateName
Definition: NativeFunctionBase.h:64
const BSFixedString & GetDocString() const override
void SetCallableFromTasklets(bool a_callable) override
std::uint32_t GetStackFrameSize() const override
std::uint8_t _pad43
Definition: NativeFunctionBase.h:70
BSFixedString _objName
Definition: NativeFunctionBase.h:63
TypeInfo GetReturnType() const override
bool _isStatic
Definition: NativeFunctionBase.h:67
const BSFixedString & GetObjectTypeName() const override
std::uint32_t _userFlags
Definition: NativeFunctionBase.h:71
virtual bool MarshallAndDispatch(Variable &a_baseValue, Internal::VirtualMachine &a_vm, VMStackID a_stackID, Variable &a_resultValue, const StackFrame &a_frame) const =0
Definition: StackFrame.h:15
Definition: TypeInfo.h:10
Definition: Variable.h:15
Definition: BSTSmartPointer.h:37
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 1 > VTABLE_BSScript__NF_util__NativeFunctionBase
Definition: Offsets_VTABLE.h:9476
std::uint32_t VMStackID
Definition: BSCoreTypes.h:8
constexpr REL::ID RTTI_BSScript__NF_util__NativeFunctionBase(static_cast< std::uint64_t >(689174))
Definition: VDescTable.h:15