infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Manual Type-Creation API

Advanced functions for manually building infix_type objects. More...

Collaboration diagram for Manual Type-Creation API:

Functions

c23_nodiscard infix_status infix_forward_create_manual (infix_forward_t **, infix_type *, infix_type **, size_t, size_t, void *)
 Generates a bound forward-call trampoline for a given function signature.
 
c23_nodiscard infix_status infix_forward_create_unbound_manual (infix_forward_t **, infix_type *, infix_type **, size_t, size_t)
 Generates an unbound forward-call trampoline for a given function signature.
 
c23_nodiscard infix_status infix_reverse_create_callback_manual (infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, void *)
 Generates a type-safe reverse-call trampoline (callback) from infix_type objects.
 
c23_nodiscard infix_status infix_reverse_create_closure_manual (infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, infix_closure_handler_fn, void *)
 Generates a generic reverse-call trampoline (closure) from infix_type objects.
 
void infix_forward_destroy (infix_forward_t *)
 Frees a forward trampoline and its associated executable memory.
 
void infix_reverse_destroy (infix_reverse_t *)
 Frees a reverse trampoline, its JIT-compiled stub, and its context.
 

Detailed Description

Advanced functions for manually building infix_type objects.

Function Documentation

◆ infix_forward_create_manual()

c23_nodiscard infix_status infix_forward_create_manual ( infix_forward_t **  out_trampoline,
infix_type return_type,
infix_type **  arg_types,
size_t  num_args,
size_t  num_fixed_args,
void *  target_function 
)

Generates a bound forward-call trampoline for a given function signature.

Parameters
[out]out_trampolineOn success, will point to the handle for the new trampoline.
return_typeThe infix_type of the function's return value.
arg_typesAn array of infix_type* for each argument.
num_argsThe total number of arguments.
num_fixed_argsFor variadic functions, the number of non-variadic arguments.
target_functionA pointer to the native C function to be bound to the trampoline.
Returns
INFIX_SUCCESS on success, or an error code on failure.
Note
The function pointer returned by infix_forward_get_code should be used.

◆ infix_forward_create_unbound_manual()

c23_nodiscard infix_status infix_forward_create_unbound_manual ( infix_forward_t **  out_trampoline,
infix_type return_type,
infix_type **  arg_types,
size_t  num_args,
size_t  num_fixed_args 
)

Generates an unbound forward-call trampoline for a given function signature.

Parameters
[out]out_trampolineOn success, will point to the handle for the new trampoline.
return_typeThe infix_type of the function's return value.
arg_typesAn array of infix_type* for each argument.
num_argsThe total number of arguments.
num_fixed_argsFor variadic functions, the number of non-variadic arguments.
Returns
INFIX_SUCCESS on success, or an error code on failure.
Note
The function pointer returned by infix_forward_get_unbound_code must be used.

Generates an unbound forward-call trampoline for a given function signature.

Creates a trampoline where the target function pointer is not hardcoded.

Parameters
[out]out_trampolineOn success, will point to the handle for the new trampoline.
return_typeThe infix_type of the function's return value.
arg_typesAn array of infix_type* for each argument.
num_argsThe total number of arguments.
num_fixed_argsFor variadic functions, the number of non-variadic arguments.
Returns
INFIX_SUCCESS on success, or an error code on failure.
Note
The returned trampoline must be freed with infix_forward_destroy.

◆ infix_forward_destroy()

void infix_forward_destroy ( infix_forward_t trampoline)

Frees a forward trampoline and its associated executable memory.

Parameters
trampolineThe trampoline to free. Can be nullptr.

◆ infix_reverse_create_callback_manual()

c23_nodiscard infix_status infix_reverse_create_callback_manual ( infix_reverse_t **  out_context,
infix_type return_type,
infix_type **  arg_types,
size_t  num_args,
size_t  num_fixed_args,
void *  user_callback_fn 
)

Generates a type-safe reverse-call trampoline (callback) from infix_type objects.

Parameters
[out]out_contextOn success, will point to the new reverse trampoline context.
return_typeThe return type of the callback.
arg_typesAn array of infix_type pointers for the callback's arguments.
num_argsThe total number of arguments in arg_types.
num_fixed_argsThe number of fixed arguments.
user_callback_fnA function pointer to your type-safe C callback handler.
Returns
INFIX_SUCCESS on success, or an error code on failure.
Note
See infix_reverse_create_callback for details on the handler's signature.

◆ infix_reverse_create_closure_manual()

c23_nodiscard infix_status infix_reverse_create_closure_manual ( infix_reverse_t **  out_context,
infix_type return_type,
infix_type **  arg_types,
size_t  num_args,
size_t  num_fixed_args,
infix_closure_handler_fn  user_callback_fn,
void *  user_data 
)

Generates a generic reverse-call trampoline (closure) from infix_type objects.

Parameters
[out]out_contextOn success, will point to the new reverse trampoline context.
return_typeThe return type of the callback.
arg_typesAn array of infix_type pointers for the callback's arguments.
num_argsThe total number of arguments in arg_types.
num_fixed_argsThe number of fixed arguments.
user_callback_fnA function pointer to your generic infix_closure_handler_fn.
user_dataA user-defined pointer for passing state to the handler.
Returns
INFIX_SUCCESS on success.

◆ infix_reverse_destroy()

void infix_reverse_destroy ( infix_reverse_t reverse_trampoline)

Frees a reverse trampoline, its JIT-compiled stub, and its context.

Parameters
reverse_trampolineThe reverse trampoline to free. Can be nullptr.