19 template <
class F,
class Tuple, std::size_t... I,
class... Args>
20 inline constexpr decltype(
auto)
CallbackImpl(F&& a_func, Tuple&& a_tuple, std::index_sequence<I...>, Args&&... a_args)
23 std::forward<F>(a_func),
24 std::forward<Args>(a_args)...,
25 std::get<I>(std::forward<Tuple>(a_tuple))...);
28 template <
class F,
class Tuple,
class... Args>
29 inline constexpr decltype(
auto)
CallBack(F&& a_func, Tuple&& a_tuple, Args&&... a_args)
32 std::forward<F>(a_func),
33 std::forward<Tuple>(a_tuple),
35 std::forward<Args>(a_args)...);
38 template <
class... Args, std::size_t... I>
41 return std::forward_as_tuple(
46 template <
class... Args>
49 return MakeTupleImpl<Args...>(a_frame, a_page, std::index_sequence_for<Args...>{});
53 template <
bool IS_LONG,
class F,
class R,
class Base,
class... Args>
78 return static_cast<bool>(
_stub);
84 if constexpr (std::negation_v<is_static_base<base_type>>) {
91 auto page = a_frame.GetPageForFrame();
93 if constexpr (std::is_void_v<result_type>) {
94 if constexpr (IS_LONG) {
96 a_resultValue.SetNone();
99 a_resultValue.SetNone();
102 if constexpr (IS_LONG) {
103 auto result =
Impl::CallBack(
_stub, std::move(args), std::addressof(a_vm), a_stackID, std::move(base));
104 a_resultValue.Pack<
result_type>(std::move(result));
107 a_resultValue.Pack<
result_type>(std::move(result));
120 template <
class F,
class =
void>
123 template <
class R,
class Cls,
class... Args>
124 class NativeFunction<R(Cls, Args...),
std::enable_if_t<BSScript::is_valid_short_sig_v<R, Cls, Args...>>> :
138 template <
class Int,
class R,
class Cls,
class... Args>
139 class NativeFunction<R(BSScript::Internal::VirtualMachine*, Int, Cls, Args...), std::enable_if_t<BSScript::is_valid_long_sig_v<Int, R, Cls, Args...>>> :
153 template <
class Int,
class R,
class Cls,
class... Args>
154 class NativeFunction<R(BSScript::IVirtualMachine*, Int, Cls, Args...), std::enable_if_t<BSScript::is_valid_long_sig_v<Int, R, Cls, Args...>>> :
177 if (a_callableFromTasklets) {
Definition IVirtualMachine.h:39
void SetCallableFromTasklets(const char *a_className, const char *a_stateName, const char *a_fnName, bool a_callable)
void RegisterFunction(std::string_view a_fnName, std::string_view a_className, F a_callback, bool a_callableFromTasklets=false)
Definition NativeFunction.h:174
virtual bool BindNativeMethod(IFunction *a_fn)=0
Definition VirtualMachine.h:46
Definition NativeFunctionBase.h:23
TypeInfo _retType
Definition NativeFunctionBase.h:65
NativeFunctionBase()=delete
Internal::VDescTable _descTable
Definition NativeFunctionBase.h:66
Definition NativeFunction.h:55
NativeFunction(NativeFunction &&)=delete
std::function< function_type > _stub
Definition NativeFunction.h:116
Base base_type
Definition NativeFunction.h:58
NativeFunction(const NativeFunction &)=delete
~NativeFunction() override=default
bool MarshallAndDispatch(Variable &a_baseValue, Internal::VirtualMachine &a_vm, VMStackID a_stackID, Variable &a_resultValue, const StackFrame &a_frame) const override
Definition NativeFunction.h:81
R result_type
Definition NativeFunction.h:57
bool HasStub() const override
Definition NativeFunction.h:76
F function_type
Definition NativeFunction.h:59
NativeFunction(std::string_view a_fnName, std::string_view a_className, function_type a_callback)
Definition NativeFunction.h:65
Definition StackFrame.h:15
Variable & GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const
T Unpack() const
Definition PackUnpack.h:302
typename super::function_type function_type
Definition NativeFunction.h:163
typename super::result_type result_type
Definition NativeFunction.h:161
typename super::base_type base_type
Definition NativeFunction.h:162
typename super::function_type function_type
Definition NativeFunction.h:148
typename super::result_type result_type
Definition NativeFunction.h:146
typename super::base_type base_type
Definition NativeFunction.h:147
typename super::result_type result_type
Definition NativeFunction.h:131
typename super::function_type function_type
Definition NativeFunction.h:133
typename super::base_type base_type
Definition NativeFunction.h:132
Definition NativeFunction.h:121
std::tuple< Args... > MakeTupleImpl(const StackFrame &a_frame, std::uint32_t a_page, std::index_sequence< I... >)
Definition NativeFunction.h:39
std::tuple< Args... > MakeTuple(const StackFrame &a_frame, std::uint32_t a_page)
Definition NativeFunction.h:47
constexpr decltype(auto) CallBack(F &&a_func, Tuple &&a_tuple, Args &&... a_args)
Definition NativeFunction.h:29
constexpr decltype(auto) CallbackImpl(F &&a_func, Tuple &&a_tuple, std::index_sequence< I... >, Args &&... a_args)
Definition NativeFunction.h:20
constexpr bool is_static_base_v
Definition TypeTraits.h:137
Definition AbsorbEffect.h:6
std::uint32_t VMStackID
Definition BSCoreTypes.h:8
Definition ActorValueList.h:28
Definition PackUnpack.h:21
SimpleArray< BSTTuple< BSFixedString, TypeInfo > > entries
Definition VDescTable.h:24
Definition CommonTypeTraits.h:191