infix
A JIT-Powered FFI Library for C
|
Structures and functions for describing C data types. More...
Files | |
file | types.c |
Implements the public API for creating and managing type descriptions. | |
Classes | |
struct | infix_type_t |
The central structure for describing any data type in the FFI system. More... | |
struct | infix_struct_member_t |
Describes a single member of an aggregate type (struct or union). More... | |
struct | infix_function_argument_t |
Describes a single argument to a function, pairing an optional name with its type. More... | |
Typedefs | |
typedef struct infix_type_t | infix_type |
The central structure for describing any data type in the FFI system. | |
typedef struct infix_struct_member_t | infix_struct_member |
Describes a single member of an aggregate type (struct or union). | |
typedef struct infix_function_argument_t | infix_function_argument |
Describes a single argument of a function type, including its optional name. | |
typedef struct infix_forward_t | infix_forward_t |
An opaque handle to a JIT-compiled forward-call trampoline. | |
typedef struct infix_reverse_t | infix_reverse_t |
An opaque handle to the context of a reverse-call trampoline (callback). | |
typedef infix_reverse_t | infix_context_t |
A clear alias for infix_reverse_t , intended for use in callback handler signatures. | |
typedef struct infix_arena_t | infix_arena_t |
An opaque handle to a memory arena for fast, temporary allocations. | |
typedef struct infix_library_t | infix_library_t |
An opaque handle to a shared library. | |
typedef struct infix_registry_t | infix_registry_t |
An opaque handle to a named type registry. | |
Enumerations | |
enum | infix_type_category { INFIX_TYPE_PRIMITIVE , INFIX_TYPE_POINTER , INFIX_TYPE_STRUCT , INFIX_TYPE_UNION , INFIX_TYPE_ARRAY , INFIX_TYPE_REVERSE_TRAMPOLINE , INFIX_TYPE_ENUM , INFIX_TYPE_COMPLEX , INFIX_TYPE_VECTOR , INFIX_TYPE_NAMED_REFERENCE , INFIX_TYPE_VOID } |
Enumerates the fundamental categories of types supported by the FFI system. More... | |
enum | infix_primitive_type_id { INFIX_PRIMITIVE_BOOL , INFIX_PRIMITIVE_UINT8 , INFIX_PRIMITIVE_SINT8 , INFIX_PRIMITIVE_UINT16 , INFIX_PRIMITIVE_SINT16 , INFIX_PRIMITIVE_UINT32 , INFIX_PRIMITIVE_SINT32 , INFIX_PRIMITIVE_UINT64 , INFIX_PRIMITIVE_SINT64 , INFIX_PRIMITIVE_UINT128 , INFIX_PRIMITIVE_SINT128 , INFIX_PRIMITIVE_FLOAT , INFIX_PRIMITIVE_DOUBLE , INFIX_PRIMITIVE_LONG_DOUBLE } |
Enumerates the specific primitive C types supported by the FFI system. More... | |
enum | infix_aggregate_category_t { INFIX_AGGREGATE_STRUCT , INFIX_AGGREGATE_UNION } |
Distinguishes between struct and union for named references. More... | |
Functions | |
c23_nodiscard infix_type * | infix_type_create_primitive (infix_primitive_type_id) |
Creates an infix_type descriptor for a primitive C type. | |
c23_nodiscard infix_type * | infix_type_create_pointer (void) |
Creates an infix_type descriptor for a generic void* pointer. | |
c23_nodiscard infix_status | infix_type_create_pointer_to (infix_arena_t *, infix_type **, infix_type *) |
Creates an infix_type for a pointer to a specific type from an arena. | |
c23_nodiscard infix_type * | infix_type_create_void (void) |
Creates an infix_type descriptor for the void type. | |
c23_nodiscard infix_status | infix_type_create_struct (infix_arena_t *, infix_type **, infix_struct_member *, size_t) |
Creates a new infix_type for a struct from an arena. | |
c23_nodiscard infix_status | infix_type_create_packed_struct (infix_arena_t *, infix_type **, size_t, size_t, infix_struct_member *, size_t) |
Creates a new infix_type for a packed struct from an arena. | |
c23_nodiscard infix_status | infix_type_create_union (infix_arena_t *, infix_type **, infix_struct_member *, size_t) |
Creates a new infix_type for a union from an arena. | |
c23_nodiscard infix_status | infix_type_create_array (infix_arena_t *, infix_type **, infix_type *, size_t) |
Creates a new infix_type for a fixed-size array from an arena. | |
c23_nodiscard infix_status | infix_type_create_enum (infix_arena_t *, infix_type **, infix_type *) |
Creates a new infix_type for an enum from an arena. | |
c23_nodiscard infix_status | infix_type_create_named_reference (infix_arena_t *, infix_type **, const char *, infix_aggregate_category_t) |
Creates a new infix_type for a named reference from an arena. | |
c23_nodiscard infix_status | infix_type_create_complex (infix_arena_t *, infix_type **, infix_type *) |
Creates a new infix_type for a _Complex number from an arena. | |
c23_nodiscard infix_status | infix_type_create_vector (infix_arena_t *, infix_type **, infix_type *, size_t) |
Creates a new infix_type for a SIMD vector from an arena. | |
infix_struct_member | infix_type_create_member (const char *, infix_type *, size_t) |
A factory function to create an infix_struct_member . | |
Structures and functions for describing C data types.
typedef struct infix_arena_t infix_arena_t |
An opaque handle to a memory arena for fast, temporary allocations.
typedef infix_reverse_t infix_context_t |
A clear alias for infix_reverse_t
, intended for use in callback handler signatures.
typedef struct infix_forward_t infix_forward_t |
An opaque handle to a JIT-compiled forward-call trampoline.
typedef struct infix_function_argument_t infix_function_argument |
Describes a single argument of a function type, including its optional name.
typedef struct infix_library_t infix_library_t |
An opaque handle to a shared library.
typedef struct infix_registry_t infix_registry_t |
An opaque handle to a named type registry.
typedef struct infix_reverse_t infix_reverse_t |
An opaque handle to the context of a reverse-call trampoline (callback).
typedef struct infix_struct_member_t infix_struct_member |
Describes a single member of an aggregate type (struct or union).
typedef struct infix_type_t infix_type |
The central structure for describing any data type in the FFI system.
Enumerates the specific primitive C types supported by the FFI system.
enum infix_type_category |
Enumerates the fundamental categories of types supported by the FFI system.
c23_nodiscard infix_status infix_type_create_array | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_type * | element_type, | ||
size_t | num_elements | ||
) |
Creates a new infix_type
for a fixed-size array from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
element_type | An infix_type describing the type of each element in the array. | |
num_elements | The number of elements in the array. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_status infix_type_create_complex | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_type * | base_type | ||
) |
Creates a new infix_type
for a _Complex
number from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
base_type | The floating-point infix_type of the real and imaginary parts. |
INFIX_SUCCESS
on success. c23_nodiscard infix_status infix_type_create_enum | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_type * | underlying_type | ||
) |
Creates a new infix_type
for an enum from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, will point to the newly created infix_type . |
underlying_type | The integer infix_type that this enum is based on. |
INFIX_SUCCESS
on success, or an error code on failure. infix_struct_member infix_type_create_member | ( | const char * | name, |
infix_type * | type, | ||
size_t | offset | ||
) |
A factory function to create an infix_struct_member
.
name | The member's name (for debugging; can be nullptr ). |
type | A pointer to the member's infix_type . |
offset | The byte offset of the member, obtained via the offsetof macro. |
infix_struct_member
. c23_nodiscard infix_status infix_type_create_named_reference | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
const char * | name, | ||
infix_aggregate_category_t | agg_cat | ||
) |
Creates a new infix_type
for a named reference from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, will point to the newly created infix_type . |
name | The name of the type being referenced. | |
aggregate_category | Distinguishes between struct and union for the reference. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_status infix_type_create_packed_struct | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
size_t | total_size, | ||
size_t | alignment, | ||
infix_struct_member * | members, | ||
size_t | num_members | ||
) |
Creates a new infix_type
for a packed struct from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
total_size | The exact size of the packed struct in bytes. | |
alignment | The alignment of the packed struct in bytes (often 1). | |
members | An array of infix_struct_member describing each member. | |
num_members | The number of elements in the members array. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_type * infix_type_create_pointer | ( | void | ) |
Creates an infix_type
descriptor for a generic void*
pointer.
infix_type
descriptor for a pointer. c23_nodiscard infix_status infix_type_create_pointer_to | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_type * | pointee_type | ||
) |
Creates an infix_type
for a pointer to a specific type from an arena.
arena | The arena from which to allocate memory for the new pointer type. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
pointee_type | An infix_type describing the type the pointer points to. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_type * infix_type_create_primitive | ( | infix_primitive_type_id | id | ) |
Creates an infix_type
descriptor for a primitive C type.
id | The enumerator for the desired primitive type (e.g., INFIX_PRIMITIVE_SINT32 ). |
infix_type
descriptor. c23_nodiscard infix_status infix_type_create_struct | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_struct_member * | members, | ||
size_t | num_members | ||
) |
Creates a new infix_type
for a struct from an arena.
arena | The arena from which to allocate memory for the new type. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
members | An array of infix_struct_member describing each member. | |
num_members | The number of elements in the members array. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_status infix_type_create_union | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_struct_member * | members, | ||
size_t | num_members | ||
) |
Creates a new infix_type
for a union from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
members | An array of infix_struct_member describing each member of the union. | |
num_members | The number of elements in the members array. |
INFIX_SUCCESS
on success, or an error code on failure. c23_nodiscard infix_status infix_type_create_vector | ( | infix_arena_t * | arena, |
infix_type ** | out_type, | ||
infix_type * | element_type, | ||
size_t | num_elements | ||
) |
Creates a new infix_type
for a SIMD vector from an arena.
arena | The arena from which to allocate. | |
[out] | out_type | On success, this will point to the newly created infix_type . |
element_type | The primitive infix_type of the vector's elements. | |
num_elements | The number of elements in the vector. |
INFIX_SUCCESS
on success. c23_nodiscard infix_type * infix_type_create_void | ( | void | ) |
Creates an infix_type
descriptor for the void
type.
infix_type
for void
.