plugify  1.0.0.0
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(*)(MethodRef method, MemAddr data, const Parameters *params, uint8_t count, const Return *ret)
 
using HiddenParam = bool(*)(ValueType)
 

Public Member Functions

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

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.

Constructor & Destructor Documentation

◆ JitCallback() [1/2]

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

Constructor.

Parameters
rtWeak pointer to the asmjit::JitRuntime.

◆ JitCallback() [2/2]

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 190 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 176 of file callback.hpp.

◆ GetJitFunc() [1/2]

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

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

Parameters
sigFunction signature.
methodReference 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 ( MethodRef  method,
CallbackHandler  callback,
MemAddr  data = nullptr,
HiddenParam  hidden = &ValueUtils::IsHiddenParam 
)

Get a dynamically created function based on the method reference.

Parameters
methodReference 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 184 of file callback.hpp.


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