plugify 1.0.0.0
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
plugify::JitCallback Class Reference

Class to create callback objects, that can be passed to functions as callback function pointers. In other words, a pointer to the callback object can be "called", directly. A generic callback handler invoked by this object then allows iterating dynamically over the arguments once called back. More...

#include <callback.hpp>

Collaboration diagram for plugify::JitCallback:
Collaboration graph
[legend]

Classes

struct  Parameters
 Structure to represent function parameters. More...
 
struct  Return
 

Public Types

using CallbackHandler = void(*)(MethodHandle method, MemAddr data, const Parameters *params, size_t count, const Return *ret)
 
using HiddenParam = bool(*)(ValueType)
 

Public Member Functions

 JitCallback (std::weak_ptr< asmjit::JitRuntime > rt)
 Constructor.
 
 JitCallback (const JitCallback &other)=delete
 Copy constructor.
 
 JitCallback (JitCallback &&other) noexcept
 Move constructor.
 
 ~JitCallback ()
 Destructor.
 
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 GetJitFunc (MethodHandle method, CallbackHandler callback, MemAddr data=nullptr, HiddenParam hidden=&ValueUtils::IsHiddenParam)
 Get a dynamically created function based on the method.
 
MemAddr GetFunction () const noexcept
 Get a dynamically created function.
 
MemAddr GetUserData () const noexcept
 Get the user data associated with the object.
 
std::string_view GetError () noexcept
 Get the error message, if any.
 
JitCallbackoperator= (const JitCallback &other)=delete
 Copy assignment operator for JitCallback.
 
JitCallbackoperator= (JitCallback &&other) noexcept
 Move assignment operator for JitCall.
 

Detailed Description

Class to create callback objects, that can be passed to functions as callback function pointers. In other words, a pointer to the callback object can be "called", directly. A generic callback handler invoked by this object then allows iterating dynamically over the arguments once called back.

Definition at line 19 of file callback.hpp.

Member Typedef Documentation

◆ CallbackHandler

using plugify::JitCallback::CallbackHandler = void(*)(MethodHandle method, MemAddr data, const Parameters* params, size_t count, const Return* ret)

Definition at line 145 of file callback.hpp.

◆ HiddenParam

using plugify::JitCallback::HiddenParam = bool(*)(ValueType)

Definition at line 146 of file callback.hpp.

Constructor & Destructor Documentation

◆ JitCallback() [1/3]

plugify::JitCallback::JitCallback ( std::weak_ptr< asmjit::JitRuntime >  rt)
explicit

Constructor.

Parameters
rtWeak pointer to the asmjit::JitRuntime.

◆ JitCallback() [2/3]

plugify::JitCallback::JitCallback ( const JitCallback other)
delete

Copy constructor.

Parameters
otherAnother instance of Callback.

◆ JitCallback() [3/3]

plugify::JitCallback::JitCallback ( JitCallback &&  other)
noexcept

Move constructor.

Parameters
otherAnother instance of Callback.

Member Function Documentation

◆ GetError()

std::string_view plugify::JitCallback::GetError ( )
inlinenoexcept

Get the error message, if any.

Returns
Error message.

Definition at line 196 of file callback.hpp.

◆ GetFunction()

MemAddr plugify::JitCallback::GetFunction ( ) const
inlinenoexcept

Get a dynamically created function.

Returns
Pointer to the already generated function.
Note
The returned pointer can be nullptr if function is not generate.

Definition at line 182 of file callback.hpp.

◆ GetJitFunc() [1/2]

MemAddr plugify::JitCallback::GetJitFunc ( const asmjit::FuncSignature &  sig,
MethodHandle  method,
CallbackHandler  callback,
MemAddr  data,
bool  hidden 
)

Get a dynamically created callback function based on the raw signature.

Parameters
sigFunction signature.
methodHandle to the method.
callbackCallback function.
dataUser data.
hiddenIf true, return will be pass as hidden argument.
Returns
Pointer to the generated function.

◆ GetJitFunc() [2/2]

MemAddr plugify::JitCallback::GetJitFunc ( MethodHandle  method,
CallbackHandler  callback,
MemAddr  data = nullptr,
HiddenParam  hidden = &ValueUtils::IsHiddenParam 
)

Get a dynamically created function based on the method.

Parameters
methodHandle to the method.
callbackCallback function.
dataUser data.
hiddenIf true, return will be pass as hidden argument.
Returns
Pointer to the generated function.

Creates a new callback object, where method is a signature describing the function to be called back, and callback is a pointer to a generic callback handler (see below). The signature is needed in the generic callback handler to correctly retrieve the arguments provided by the caller of the callback. Note that the generic handler's function type/declaration is always the same for any callback. userdata is a pointer to arbitrary user data to be available in the generic callback handler.

◆ GetUserData()

MemAddr plugify::JitCallback::GetUserData ( ) const
inlinenoexcept

Get the user data associated with the object.

This function returns a pointer to the user data associated with the object.

Returns
A void pointer to the user data.
Note
The returned pointer can be nullptr if no user data is set.

Definition at line 190 of file callback.hpp.

◆ operator=() [1/2]

JitCallback & plugify::JitCallback::operator= ( const JitCallback other)
delete

Copy assignment operator for JitCallback.

Parameters
otherThe other JitCallback instance to copy from.
Returns
A reference to this instance after copying.

◆ operator=() [2/2]

JitCallback & plugify::JitCallback::operator= ( JitCallback &&  other)
noexcept

Move assignment operator for JitCall.

Parameters
otherThe other JitCallback instance to move from.
Returns
A reference to this instance after moving.
Note
This operator is marked noexcept to indicate it does not throw exceptions.

Member Data Documentation

◆ _errorCode

const char* plugify::JitCallback::_errorCode {}

Definition at line 220 of file callback.hpp.

◆ _userData

MemAddr plugify::JitCallback::_userData

Definition at line 219 of file callback.hpp.


The documentation for this class was generated from the following file: