infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches

A lower-level, programmatic API for creating trampolines from infix_type objects. More...

Collaboration diagram for Manual API:

Modules

 Type System
 The core data structures and APIs for describing C types and function signatures.
 

Functions

c23_nodiscard infix_status infix_forward_create_manual (infix_forward_t **, infix_type *, infix_type **, size_t, size_t, void *)
 Creates a bound forward trampoline from infix_type objects.
 
c23_nodiscard infix_status infix_forward_create_unbound_manual (infix_forward_t **, infix_type *, infix_type **, size_t, size_t)
 Creates an unbound forward trampoline from infix_type objects.
 
c23_nodiscard infix_status infix_reverse_create_callback_manual (infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, void *)
 Creates a type-safe reverse 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 *)
 Creates a generic reverse trampoline (closure) from infix_type objects.
 
void infix_forward_destroy (infix_forward_t *)
 Destroys a forward trampoline and frees all associated memory.
 
void infix_reverse_destroy (infix_reverse_t *)
 Destroys a reverse trampoline and frees all associated memory.
 

Detailed Description

A lower-level, programmatic API for creating trampolines from infix_type objects.

This API is intended for performance-critical applications or language bindings that need to construct type information dynamically without the overhead of string parsing. All infix_type objects passed to these functions must be allocated from an infix_arena_t.

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 
)

Creates a bound forward trampoline from infix_type objects.

Parameters
[out]out_trampolineReceives the created trampoline handle.
[in]return_typeThe infix_type for the function's return value.
[in]arg_typesAn array of infix_type* for the function's arguments.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]target_functionThe address of the C function to call.
Returns
INFIX_SUCCESS on success.

Creates a bound forward trampoline from infix_type objects.

This is the lower-level, programmatic way to create a bound forward trampoline. It bypasses the signature string parser, making it suitable for performance-critical applications or language bindings that construct type information dynamically.

All infix_type objects passed to this function must be fully resolved and have a valid layout. They should be allocated from a user-managed infix_arena_t.

Parameters
[out]out_trampolineReceives the created trampoline handle.
[in]return_typeThe infix_type for the function's return value.
[in]arg_typesAn array of infix_type* for the function's arguments.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]target_functionThe address of the C function to call.
Returns
INFIX_SUCCESS on success.

◆ 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 
)

Creates an unbound forward trampoline from infix_type objects.

Parameters
[out]out_trampolineReceives the created trampoline handle.
[in]return_typeThe infix_type for the function's return value.
[in]arg_typesAn array of infix_type* for the function's arguments.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
Returns
INFIX_SUCCESS on success.

Creates an unbound forward trampoline from infix_type objects.

This is the lower-level, programmatic way to create an unbound forward trampoline. It bypasses the signature string parser.

Parameters
[out]out_trampolineReceives the created trampoline handle.
[in]return_typeThe infix_type for the function's return value.
[in]arg_typesAn array of infix_type* for the function's arguments.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
Returns
INFIX_SUCCESS on success.

◆ infix_forward_destroy()

void infix_forward_destroy ( infix_forward_t trampoline)

Destroys a forward trampoline and frees all associated memory.

Parameters
[in]trampolineThe trampoline to destroy. Safe to call with nullptr.

This function safely releases all resources owned by the trampoline, including its JIT-compiled executable code and its private memory arena which stores the deep-copied type information.

Parameters
[in]trampolineThe trampoline to destroy. Safe to call with 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 
)

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

Parameters
[out]out_contextReceives the created context handle.
[in]return_typeThe function's return type.
[in]arg_typesAn array of argument types.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]user_callback_fnA pointer to the type-safe C handler function.
Returns
INFIX_SUCCESS on success.

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

Parameters
[out]out_contextReceives the created context handle.
[in]return_typeThe function's return type.
[in]arg_typesAn array of argument types.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]user_callback_fnA pointer to the type-safe C handler function.
Returns
INFIX_SUCCESS on success.

◆ 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 
)

Creates a generic reverse trampoline (closure) from infix_type objects.

Parameters
[out]out_contextReceives the created context handle.
[in]return_typeThe function's return type.
[in]arg_typesAn array of argument types.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]user_callback_fnA pointer to the generic infix_closure_handler_fn.
[in]user_dataA void* pointer to application-specific state.
Returns
INFIX_SUCCESS on success.

Creates a generic reverse trampoline (closure) from infix_type objects.

Parameters
[out]out_contextReceives the created context handle.
[in]return_typeThe function's return type.
[in]arg_typesAn array of argument types.
[in]num_argsThe number of arguments.
[in]num_fixed_argsThe number of non-variadic arguments.
[in]user_callback_fnA pointer to the generic infix_closure_handler_fn.
[in]user_dataA void* pointer to application-specific state.
Returns
INFIX_SUCCESS on success.

◆ infix_reverse_destroy()

void infix_reverse_destroy ( infix_reverse_t reverse_trampoline)

Destroys a reverse trampoline and frees all associated memory.

Parameters
[in]reverse_trampolineThe reverse trampoline context to destroy. Safe to call with nullptr.

This function safely releases all resources owned by the reverse trampoline, including its JIT-compiled stub, its private memory arena, the cached forward trampoline (if any), and the special read-only memory region for the context itself.

Parameters
[in]reverse_trampolineThe reverse trampoline context to destroy. Safe to call with nullptr.