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

Functions for inspecting the properties of trampolines and infix_type objects at runtime. More...

Collaboration diagram for Introspection API:

Modules

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

Enumerations

enum  infix_print_dialect_t { INFIX_DIALECT_SIGNATURE , INFIX_DIALECT_ITANIUM_MANGLING , INFIX_DIALECT_MSVC_MANGLING }
 Specifies the output format for printing types and function signatures. More...
 

Functions

c23_nodiscard infix_status infix_type_print (char *, size_t, const infix_type *, infix_print_dialect_t)
 Serializes an infix_type object graph back into a signature string.
 
c23_nodiscard infix_status infix_function_print (char *, size_t, const char *, const infix_type *, const infix_function_argument *, size_t, size_t, infix_print_dialect_t)
 Serializes a function signature's components into a string.
 
c23_nodiscard infix_unbound_cif_func infix_forward_get_unbound_code (infix_forward_t *)
 Gets the callable function pointer from an unbound forward trampoline.
 
c23_nodiscard infix_cif_func infix_forward_get_code (infix_forward_t *)
 Gets the callable function pointer from a bound forward trampoline.
 
c23_nodiscard void * infix_reverse_get_code (const infix_reverse_t *)
 Gets the native, callable C function pointer from a reverse trampoline.
 
c23_nodiscard void * infix_reverse_get_user_data (const infix_reverse_t *)
 Gets the user-provided data pointer from a closure context.
 
c23_nodiscard size_t infix_forward_get_num_args (const infix_forward_t *)
 Gets the total number of arguments for a forward trampoline.
 

Detailed Description

Functions for inspecting the properties of trampolines and infix_type objects at runtime.

This API is essential for building dynamic language bindings, serializers, or any tool that needs to understand the memory layout and signature of C data structures and functions.

Enumeration Type Documentation

◆ infix_print_dialect_t

Specifies the output format for printing types and function signatures.

Enumerator
INFIX_DIALECT_SIGNATURE 

The standard, human-readable infix signature format.

INFIX_DIALECT_ITANIUM_MANGLING 

(Not yet implemented) Itanium C++ ABI name mangling.

INFIX_DIALECT_MSVC_MANGLING 

(Not yet implemented) MSVC C++ name mangling.

Function Documentation

◆ infix_forward_get_code()

c23_nodiscard infix_cif_func infix_forward_get_code ( infix_forward_t trampoline)

Gets the callable function pointer from a bound forward trampoline.

Parameters
[in]trampolineThe bound infix_forward_t handle.
Returns
A callable infix_cif_func pointer on success, or nullptr if the trampoline is nullptr or if it is an unbound trampoline.

◆ infix_forward_get_num_args()

c23_nodiscard size_t infix_forward_get_num_args ( const infix_forward_t trampoline)

Gets the total number of arguments for a forward trampoline.

Parameters
[in]trampolineThe trampoline handle.
Returns
The number of arguments, or 0 if trampoline is nullptr.

◆ infix_forward_get_unbound_code()

c23_nodiscard infix_unbound_cif_func infix_forward_get_unbound_code ( infix_forward_t trampoline)

Gets the callable function pointer from an unbound forward trampoline.

Parameters
[in]trampolineThe unbound infix_forward_t handle.
Returns
A callable infix_unbound_cif_func pointer on success, or nullptr if the trampoline is nullptr or if it is a bound trampoline.

◆ infix_function_print()

c23_nodiscard infix_status infix_function_print ( char *  buffer,
size_t  buffer_size,
const char *  function_name,
const infix_type ret_type,
const infix_function_argument args,
size_t  num_args,
size_t  num_fixed_args,
infix_print_dialect_t  dialect 
)

Serializes a function signature's components into a string.

Parameters
[out]bufferThe output buffer.
[in]buffer_sizeThe size of the output buffer.
[in]function_nameOptional name for dialects that support it.
[in]ret_typeThe return type.
[in]argsThe array of arguments.
[in]num_argsThe total number of arguments.
[in]num_fixed_argsThe number of fixed arguments.
[in]dialectThe output dialect.
Returns
INFIX_SUCCESS on success, or INFIX_ERROR_INVALID_ARGUMENT if the buffer is too small.
Parameters
[out]bufferThe output buffer.
[in]buffer_sizeThe size of the output buffer.
[in]function_nameOptional name for dialects that support it (currently unused).
[in]ret_typeThe return type.
[in]argsThe array of arguments.
[in]num_argsThe total number of arguments.
[in]num_fixed_argsThe number of fixed arguments.
[in]dialectThe output dialect.
Returns
INFIX_SUCCESS on success, or INFIX_ERROR_INVALID_ARGUMENT if the buffer is too small.

◆ infix_reverse_get_code()

c23_nodiscard void * infix_reverse_get_code ( const infix_reverse_t reverse_trampoline)

Gets the native, callable C function pointer from a reverse trampoline.

Parameters
[in]reverse_trampolineThe infix_reverse_t context handle.
Returns
A void* that can be cast to the appropriate C function pointer type and called. The returned pointer is valid for the lifetime of the context handle.

◆ infix_reverse_get_user_data()

c23_nodiscard void * infix_reverse_get_user_data ( const infix_reverse_t reverse_trampoline)

Gets the user-provided data pointer from a closure context.

Parameters
[in]reverse_trampolineThe infix_reverse_t context handle created with infix_reverse_create_closure.
Returns
The void* user_data that was provided during creation.

◆ infix_type_print()

c23_nodiscard infix_status infix_type_print ( char *  buffer,
size_t  buffer_size,
const infix_type type,
infix_print_dialect_t  dialect 
)

Serializes an infix_type object graph back into a signature string.

Parameters
[out]bufferThe output buffer to write the string into.
[in]buffer_sizeThe size of the output buffer.
[in]typeThe infix_type to print.
[in]dialectThe desired output format dialect.
Returns
INFIX_SUCCESS on success, or INFIX_ERROR_INVALID_ARGUMENT if the buffer is too small.