3 #include <asmjit/asmjit.h>
4 #include <plugify/mem_addr.hpp>
5 #include <plugify/method.hpp>
85 return ((int8_t*) &arguments) +
sizeof(uint64_t) * idx;
89 volatile uint64_t arguments;
101 template<
typename T,
typename...Args>
103 std::construct_at((T*)
GetReturnPtr(), std::forward<Args>(args)...);
132 return (int8_t*) &ret;
136 volatile uint64_t ret;
139 using CallbackHandler = void(*)(
MethodRef method,
MemAddr data,
const Parameters* params, uint8_t count,
const Return* ret);
140 using HiddenParam = bool(*)(ValueType);
190 std::string_view
GetError() noexcept {
return !_function && _errorCode ? _errorCode :
""; }
193 std::weak_ptr<asmjit::JitRuntime> _rt;
197 const char* _errorCode{};
Class to create callback objects, that can be passed to functions as callback function pointers....
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()
Destructor.
JitCallback(JitCallback &&other) noexcept
Move constructor.
MemAddr GetJitFunc(MethodRef method, CallbackHandler callback, MemAddr data=nullptr, HiddenParam hidden=&ValueUtils::IsHiddenParam)
Get a dynamically created function based on the method reference.
MemAddr GetJitFunc(const asmjit::FuncSignature &sig, MethodRef method, CallbackHandler callback, MemAddr data, bool hidden)
Get a dynamically created callback function based on the raw signature.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
A reference 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.
int8_t * GetArgumentPtr(uint8_t idx) const noexcept
Get a pointer to the argument at the specified index.
void SetArgumentAt(uint8_t idx, T val, uint8_t i=0) const noexcept
Set the value of the argument at the specified index and position within a multi-dimensional array.
T GetArgument(uint8_t idx) const noexcept
Get the value of the argument at the specified index.
void SetArgument(uint8_t idx, T val) const noexcept
Set the value of the argument at the specified index.
void ConstructAt(Args &&... args) const noexcept
Constructs an object of type T at the memory location.
T GetReturn() const noexcept
Get the return value.
int8_t * GetReturnPtr() const noexcept
Get a pointer to the return value.
void SetReturn(T val) const noexcept
Set the return value.