feat: added native manager impl
This commit is contained in:
@@ -22,10 +22,6 @@ namespace fxn
|
||||
|
||||
static void DispatchNative(fxn::NativeContext* context, NativeHash hash);
|
||||
|
||||
public:
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
const NativeHandler& GetNativeHandler(const NativeHash hash) const;
|
||||
void RegisterNativeHandler(const NativeHash hash, const NativeHandler handler);
|
||||
@@ -37,42 +33,5 @@ namespace fxn
|
||||
public:
|
||||
bool Invoke(fxn::NativeContext* context);
|
||||
bool Schedule(fxn::NativeContext* context, bool waitForCompletion = true);
|
||||
|
||||
public:
|
||||
template<typename R, typename... Args>
|
||||
R Invoke(const NativeHash hash, Args&&... args)
|
||||
{
|
||||
fxn::NativeContext context(hash);
|
||||
|
||||
(context.PushArgument(std::forward<Args>(args)), ...);
|
||||
|
||||
if (!this->Invoke(&context))
|
||||
{
|
||||
throw std::runtime_error("Failed to invoke native with hash: " + std::to_string(hash));
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<R, void>)
|
||||
{
|
||||
return context.GetResult<R>();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename R, typename... Args>
|
||||
R Schedule(const NativeHash hash, Args&&... args)
|
||||
{
|
||||
fxn::NativeContext context(hash);
|
||||
|
||||
(context.PushArgument(std::forward<Args>(args)), ...);
|
||||
|
||||
if (!this->Schedule(&context, true))
|
||||
{
|
||||
throw std::runtime_error("Failed to schedule native with hash: " + std::to_string(hash));
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<R, void>)
|
||||
{
|
||||
return context.GetResult<R>();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user