2019-03-21 20:18:31 +01:00
|
|
|
#pragma once
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "gta/natives.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class native_call_context : public rage::scrNativeCallContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
native_call_context();
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
private:
|
|
|
|
std::uint64_t m_return_stack[10];
|
|
|
|
std::uint64_t m_arg_stack[100];
|
|
|
|
};
|
|
|
|
|
|
|
|
class native_invoker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit native_invoker() = default;
|
2023-03-01 21:27:15 +00:00
|
|
|
~native_invoker() = default;
|
2019-03-21 20:18:31 +01:00
|
|
|
|
2019-07-29 23:19:21 +02:00
|
|
|
void cache_handlers();
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
void begin_call();
|
|
|
|
void end_call(rage::scrNativeHash hash);
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
template<typename T>
|
|
|
|
void push_arg(T&& value)
|
2019-03-21 20:18:31 +01:00
|
|
|
{
|
|
|
|
m_call_context.push_arg(std::forward<T>(value));
|
|
|
|
}
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
template<typename T>
|
|
|
|
T& get_return_value()
|
2019-03-21 20:18:31 +01:00
|
|
|
{
|
|
|
|
return *m_call_context.get_return_value<T>();
|
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2023-06-06 07:40:40 +00:00
|
|
|
public:
|
2019-03-21 20:18:31 +01:00
|
|
|
native_call_context m_call_context;
|
2019-07-29 23:19:21 +02:00
|
|
|
std::unordered_map<rage::scrNativeHash, rage::scrNativeHandler> m_handler_cache;
|
2022-09-30 20:41:26 +02:00
|
|
|
bool m_handlers_cached = false;
|
2019-03-21 20:18:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline native_invoker g_native_invoker;
|
|
|
|
}
|