3#include <asmjit/asmjit.h>
4#include <plugify/mem_addr.hpp>
5#include <plugify/method.hpp>
91 return ((int8_t*) &arguments) +
sizeof(uint64_t) * idx;
95 volatile uint64_t arguments;
107 template<
typename T,
typename...Args>
109 std::construct_at((T*)
GetReturnPtr(), std::forward<Args>(args)...);
138 return (int8_t*) &ret;
142 volatile uint64_t ret;
145 using CallbackHandler = void(*)(
MethodHandle method,
MemAddr data,
const Parameters* params,
size_t count,
const Return* ret);
146 using HiddenParam = bool(*)(ValueType);
196 std::string_view
GetError() noexcept {
return !_function && _errorCode ? _errorCode :
""; }
216 std::weak_ptr<asmjit::JitRuntime> _rt;
220 const char* _errorCode{};
Class to create callback objects, that can be passed to functions as callback function pointers....
MemAddr GetJitFunc(const asmjit::FuncSignature &sig, MethodHandle method, CallbackHandler callback, MemAddr data, bool hidden)
Get a dynamically created callback function based on the raw signature.
MemAddr GetFunction() const noexcept
Get a dynamically created function.
JitCallback(std::weak_ptr< asmjit::JitRuntime > rt)
Constructor.
std::string_view GetError() noexcept
Get the error message, if any.
MemAddr GetUserData() const noexcept
Get the user data associated with the object.
JitCallback & operator=(const JitCallback &other)=delete
Copy assignment operator for JitCallback.
MemAddr GetJitFunc(MethodHandle method, CallbackHandler callback, MemAddr data=nullptr, HiddenParam hidden=&ValueUtils::IsHiddenParam)
Get a dynamically created function based on the method.
JitCallback & operator=(JitCallback &&other) noexcept
Move assignment operator for JitCall.
~JitCallback()
Destructor.
JitCallback(JitCallback &&other) noexcept
Move constructor.
JitCallback(const JitCallback &other)=delete
Copy constructor.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
A handle class for the Method structure.
constexpr bool IsHiddenParam(ValueType type) noexcept
Checks if a given ValueType is considered a hidden object parameter.
Structure to represent function parameters.
T GetArgument(size_t idx) const noexcept
Get the value of the argument at the specified index.
void SetArgumentAt(size_t idx, T val, size_t i=0) const noexcept
Set the value of the argument at the specified index and position within a multi-dimensional array.
void SetArgument(size_t idx, T val) const noexcept
Set the value of the argument at the specified index.
int8_t * GetArgumentPtr(size_t idx) const noexcept
Get a pointer to the argument at the specified index.
void ConstructAt(Args &&... args) const noexcept
Constructs an object of type T at the memory location.
int8_t * GetReturnPtr() const noexcept
Get a pointer to the return value.
T GetReturn() const noexcept
Get the return value.
void SetReturn(T val) const noexcept
Set the return value.