infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
infix.h
Go to the documentation of this file.
1
76#pragma once
83#define INFIX_MAJOR 0
84#define INFIX_MINOR 1
85#define INFIX_PATCH 4
87#if defined(__has_c_attribute)
88#define _INFIX_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
89#else
90#define _INFIX_HAS_C_ATTRIBUTE(x) 0
91#endif
92
103#if defined(_WIN32) || defined(__CYGWIN__)
104#if defined(INFIX_BUILDING_DLL)
105#define INFIX_API __declspec(dllexport)
106#elif defined(INFIX_USING_DLL)
107#define INFIX_API __declspec(dllimport)
108#else
109#define INFIX_API
110#endif
111#elif defined(__GNUC__) || defined(__clang__)
112#define INFIX_API __attribute__((visibility("default")))
113#else
114#define INFIX_API
115#endif
116
133#if _INFIX_HAS_C_ATTRIBUTE(nodiscard) && !defined(__GNUC__) && !defined(__clang__)
134#define INFIX_NODISCARD [[nodiscard]]
135#elif defined(__GNUC__) || defined(__clang__)
136#define INFIX_NODISCARD __attribute__((warn_unused_result))
137#elif defined(_MSC_VER)
138#define INFIX_NODISCARD _Check_return_
139#else
140#define INFIX_NODISCARD
141#endif
142
148typedef struct {
149 int major;
150 int minor;
151 int patch;
153
155// Define the POSIX source macro to ensure function declarations for shm_open,
156// ftruncate, etc., are visible on all POSIX-compliant systems.
157// This must be defined before any system headers are included.
158#ifndef _DEFAULT_SOURCE
159#define _DEFAULT_SOURCE
160#endif
161// Define the POSIX source macro to ensure function declarations for posix_memalign
162// are visible. This must be defined before any system headers are included.
163#if !defined(_POSIX_C_SOURCE)
164#define _POSIX_C_SOURCE 200809L
165#endif
166#include <stdbool.h>
167#include <stddef.h>
168#include <stdint.h>
169
170#ifdef __cplusplus
171extern "C" {
172#endif
184
204// Opaque and Semi-Opaque Type Forward Declarations
334 const char * name;
336 size_t offset;
337 uint8_t bit_width;
338 uint8_t bit_offset;
340};
// end of type_system group
369#ifndef infix_malloc
370#define infix_malloc malloc
371#endif
373#ifndef infix_calloc
374#define infix_calloc calloc
375#endif
377#ifndef infix_realloc
378#define infix_realloc realloc
379#endif
381#ifndef infix_free
382#define infix_free free
383#endif
385#ifndef infix_memcpy
386#define infix_memcpy memcpy
387#endif
389#ifndef infix_memset
390#define infix_memset memset
391#endif
// end of memory_management group
408typedef void (*infix_unbound_cif_func)(void *, void *, void **);
417typedef void (*infix_cif_func)(void *, void **);
429typedef void (*infix_closure_handler_fn)(infix_context_t *, void *, void **);
// end of registry_api group // end of registry_introspection_api group
647 const char *,
648 void *,
694 const char *,
752 const char *,
753 void *,
834 const char *, infix_arena_t **, infix_type **, infix_function_argument **, size_t *, size_t *, infix_registry_t *);
849 infix_arena_t **,
850 const char *,
// end of high_level_api group
890infix_read_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
901infix_write_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
// end of exports_api group
923infix_forward_create_manual(infix_forward_t **, infix_type *, infix_type **, size_t, size_t, void *);
959 infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, infix_closure_handler_fn, void *);
1007 infix_type **,
1009 size_t);
1031 infix_type **,
1033 size_t);
1070 infix_type **,
1071 const char *,
// end of manual_api group (continued) // end of type_system group
1143INFIX_API INFIX_NODISCARD void * infix_arena_calloc(infix_arena_t *, size_t, size_t, size_t);
// end of memory_management group (continued)
1184 size_t,
1185 const char *,
1186 const infix_type *,
1188 size_t,
1189 size_t,
1314INFIX_API INFIX_NODISCARD const char * infix_type_get_arg_name(const infix_type *, size_t);
// end addtogroup type_system // end of introspection_api group // end of error_api group
1418typedef void (*infix_direct_cif_func)(void *, void **);
1419
1427typedef union {
1428 uint64_t u64;
1429 int64_t i64;
1430 double f64;
1431 void * ptr;
1433
1443typedef infix_direct_value_t (*infix_marshaller_fn)(void * source_object);
1444
1459typedef void (*infix_aggregate_marshaller_fn)(void * source_object, void * dest_buffer, const infix_type * type);
1460
1473typedef void (*infix_writeback_fn)(void * source_object, void * c_data_ptr, const infix_type * type);
1474
1489
1509 const char * signature,
1510 void * target_function,
// end of direct_marshalling_api group
1522#ifdef __cplusplus
1523}
1524#endif
infix_arena_t * arena
Definition 005_layouts.c:62
infix_registry_t * registry
Definition 008_registry_introspection.c:33
infix_direct_arg_handler_t handlers[2]
Definition 901_call_overhead.c:104
void(* infix_direct_cif_func)(void *, void **)
A function pointer for a direct marshalling forward trampoline.
Definition infix.h:1418
void(* infix_aggregate_marshaller_fn)(void *source_object, void *dest_buffer, const infix_type *type)
A function pointer for a custom marshaller for aggregate types (structs/unions).
Definition infix.h:1459
INFIX_API INFIX_NODISCARD infix_direct_cif_func infix_forward_get_direct_code(infix_forward_t *trampoline)
Gets the callable function pointer from a direct marshalling trampoline.
Definition trampoline.c:288
infix_direct_value_t(* infix_marshaller_fn)(void *source_object)
A function pointer for a custom marshaller for scalar types.
Definition infix.h:1443
INFIX_API INFIX_NODISCARD infix_status infix_forward_create_direct(infix_forward_t **out_trampoline, const char *signature, void *target_function, infix_direct_arg_handler_t *handlers, infix_registry_t *registry)
Creates a forward trampoline with direct, JIT-bound marshalling.
Definition trampoline.c:1008
void(* infix_writeback_fn)(void *source_object, void *c_data_ptr, const infix_type *type)
A function pointer for a "write-back" handler for out/in-out parameters.
Definition infix.h:1473
INFIX_API infix_error_details_t infix_get_last_error(void)
Retrieves detailed information about the last error that occurred on the current thread.
Definition error.c:279
infix_error_code_t
Enumerates specific error codes.
Definition infix.h:1342
infix_error_category_t
Enumerates the high-level categories of errors that can occur.
Definition infix.h:1332
@ INFIX_CODE_PROTECTION_FAILURE
Definition infix.h:1352
@ INFIX_CODE_SUCCESS
Definition infix.h:1344
@ INFIX_CODE_LAYOUT_FAILED
Definition infix.h:1370
@ INFIX_CODE_LIBRARY_NOT_FOUND
Definition infix.h:1373
@ INFIX_CODE_INVALID_MEMBER_TYPE
Definition infix.h:1369
@ INFIX_CODE_MISSING_REGISTRY
Definition infix.h:1347
@ INFIX_CODE_UNRESOLVED_NAMED_TYPE
Definition infix.h:1368
@ INFIX_CODE_INVALID_ALIGNMENT
Definition infix.h:1353
@ INFIX_CODE_INTEGER_OVERFLOW
Definition infix.h:1360
@ INFIX_CODE_TYPE_TOO_LARGE
Definition infix.h:1367
@ INFIX_CODE_EMPTY_SIGNATURE
Definition infix.h:1363
@ INFIX_CODE_UNEXPECTED_TOKEN
Definition infix.h:1356
@ INFIX_CODE_MISSING_RETURN_TYPE
Definition infix.h:1359
@ INFIX_CODE_EMPTY_MEMBER_NAME
Definition infix.h:1362
@ INFIX_CODE_EXECUTABLE_MEMORY_FAILURE
Definition infix.h:1351
@ INFIX_CODE_UNKNOWN
Definition infix.h:1345
@ INFIX_CODE_SYMBOL_NOT_FOUND
Definition infix.h:1374
@ INFIX_CODE_RECURSION_DEPTH_EXCEEDED
Definition infix.h:1361
@ INFIX_CODE_UNSUPPORTED_ABI
Definition infix.h:1366
@ INFIX_CODE_UNTERMINATED_AGGREGATE
Definition infix.h:1357
@ INFIX_CODE_LIBRARY_LOAD_FAILED
Definition infix.h:1375
@ INFIX_CODE_NULL_POINTER
Definition infix.h:1346
@ INFIX_CODE_INVALID_KEYWORD
Definition infix.h:1358
@ INFIX_CODE_OUT_OF_MEMORY
Definition infix.h:1350
@ INFIX_CATEGORY_ABI
Definition infix.h:1337
@ INFIX_CATEGORY_ALLOCATION
Definition infix.h:1335
@ INFIX_CATEGORY_GENERAL
Definition infix.h:1334
@ INFIX_CATEGORY_PARSER
Definition infix.h:1336
@ INFIX_CATEGORY_NONE
Definition infix.h:1333
INFIX_API INFIX_NODISCARD infix_status infix_read_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *)
Reads the value of a global variable from a library into a buffer.
Definition loader.c:150
INFIX_API INFIX_NODISCARD void * infix_library_get_symbol(infix_library_t *, const char *)
Retrieves the address of a symbol (function or variable) from a loaded library.
Definition loader.c:124
INFIX_API INFIX_NODISCARD infix_library_t * infix_library_open(const char *)
Opens a dynamic library and returns a handle to it.
Definition loader.c:46
INFIX_API void infix_library_close(infix_library_t *)
Closes a dynamic library handle.
Definition loader.c:93
INFIX_API INFIX_NODISCARD infix_status infix_write_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *)
Writes data from a buffer into a global variable in a library.
Definition loader.c:192
size_t source_offset
Definition infix.h:281
void * _current_entry
Definition infix.h:519
struct infix_type_t::@0::@1 pointer_info
Metadata for INFIX_TYPE_POINTER.
size_t position
Definition infix.h:1384
int major
Definition infix.h:149
union infix_type_t::@0 meta
A union containing metadata specific to the type's category.
bool is_packed
Definition infix.h:294
struct infix_type_t::@0::@7 vector_info
Metadata for INFIX_TYPE_VECTOR.
infix_error_category_t category
Definition infix.h:1382
const infix_registry_t * registry
Definition infix.h:517
bool is_incomplete
Definition infix.h:279
uint64_t u64
Used for all unsigned integer types up to 64 bits.
Definition infix.h:1428
infix_type * type
Definition infix.h:347
INFIX_API INFIX_NODISCARD infix_status infix_signature_parse(const char *, infix_arena_t **, infix_type **, infix_function_argument **, size_t *, size_t *, infix_registry_t *)
Parses a full function signature string into its constituent parts.
Definition signature.c:1087
struct infix_type_t::@0::@4 func_ptr_info
Metadata for INFIX_TYPE_REVERSE_TRAMPOLINE.
void(* infix_cif_func)(void *, void **)
A function pointer type for a bound forward trampoline.
Definition infix.h:417
size_t num_elements
Definition infix.h:299
infix_arena_t * arena
Definition infix.h:280
size_t size
Definition infix.h:276
void(* infix_unbound_cif_func)(void *, void *, void **)
A function pointer type for an unbound forward trampoline.
Definition infix.h:408
size_t alignment
Definition infix.h:277
INFIX_API INFIX_NODISCARD infix_status infix_reverse_create_callback(infix_reverse_t **, const char *, void *, infix_registry_t *)
Creates a type-safe reverse trampoline (callback).
Definition trampoline.c:1052
void * ptr
Used for all pointer types.
Definition infix.h:1431
uint8_t bit_offset
Definition infix.h:338
infix_writeback_fn writeback_handler
For "out" or "in-out" parameters. Called after the C function returns.
Definition infix.h:1487
infix_struct_member * members
Definition infix.h:292
bool is_bitfield
Definition infix.h:339
struct infix_type_t::@0::@6 complex_info
Metadata for INFIX_TYPE_COMPLEX.
INFIX_API INFIX_NODISCARD infix_status infix_type_from_signature(infix_type **, infix_arena_t **, const char *, infix_registry_t *)
Parses a signature string representing a single data type.
Definition signature.c:1028
const char * name
Definition infix.h:274
infix_function_argument * args
Definition infix.h:305
size_t num_elements
Definition infix.h:320
struct infix_type_t * element_type
Definition infix.h:319
INFIX_API INFIX_NODISCARD infix_status infix_reverse_create_closure(infix_reverse_t **, const char *, infix_closure_handler_fn, void *, infix_registry_t *)
Creates a generic reverse trampoline (closure) for stateful callbacks.
Definition trampoline.c:1080
infix_aggregate_category_t aggregate_category
Definition infix.h:325
infix_status
Enumerates the possible status codes returned by infix API functions.
Definition infix.h:433
const char * name
Definition infix.h:346
const char * name
Definition infix.h:324
INFIX_API INFIX_NODISCARD infix_status infix_forward_create_in_arena(infix_forward_t **, infix_arena_t *, const char *, void *, infix_registry_t *)
Creates a "bound" forward trampoline within a user-provided arena.
Definition trampoline.c:918
const char * name
Definition infix.h:334
infix_type_category category
Definition infix.h:275
int minor
Definition infix.h:150
size_t _bucket_index
Definition infix.h:518
struct infix_type_t::@0::@2 aggregate_info
Metadata for INFIX_TYPE_STRUCT and INFIX_TYPE_UNION.
struct infix_type_t::@0::@3 array_info
Metadata for INFIX_TYPE_ARRAY.
struct infix_type_t * pointee_type
Definition infix.h:288
infix_marshaller_fn scalar_marshaller
For "in" parameters of a scalar type (int, float, pointer).
Definition infix.h:1483
infix_type * type
Definition infix.h:335
struct infix_type_t * element_type
Definition infix.h:298
int patch
Definition infix.h:151
bool is_flexible
Definition infix.h:300
struct infix_type_t * return_type
Definition infix.h:304
size_t offset
Definition infix.h:336
struct infix_type_t::@0::@5 enum_info
Metadata for INFIX_TYPE_ENUM.
infix_aggregate_marshaller_fn aggregate_marshaller
For "in" parameters of an aggregate type (struct, union).
Definition infix.h:1485
double f64
Used for float and double.
Definition infix.h:1430
struct infix_type_t * base_type
Definition infix.h:315
long system_error_code
Definition infix.h:1385
uint8_t bit_width
Definition infix.h:337
infix_error_code_t code
Definition infix.h:1383
int64_t i64
Used for all signed integer types up to 64 bits.
Definition infix.h:1429
size_t num_members
Definition infix.h:293
struct infix_type_t * underlying_type
Definition infix.h:311
struct infix_type_t::@0::@8 named_reference
Metadata for INFIX_TYPE_NAMED_REFERENCE.
size_t num_fixed_args
Definition infix.h:307
INFIX_API INFIX_NODISCARD infix_status infix_forward_create_unbound(infix_forward_t **, const char *, infix_registry_t *)
Creates an "unbound" forward trampoline from a signature string.
Definition trampoline.c:1003
void(* infix_closure_handler_fn)(infix_context_t *, void *, void **)
A function pointer type for a generic closure handler.
Definition infix.h:429
infix_primitive_type_id primitive_id
Metadata for INFIX_TYPE_PRIMITIVE.
Definition infix.h:285
size_t num_args
Definition infix.h:306
INFIX_API INFIX_NODISCARD infix_status infix_forward_create(infix_forward_t **, const char *, void *, infix_registry_t *)
Creates a "bound" forward trampoline from a signature string.
Definition trampoline.c:997
bool is_arena_allocated
Definition infix.h:278
@ INFIX_ERROR_ALLOCATION_FAILED
Definition infix.h:435
@ INFIX_ERROR_LAYOUT_FAILED
Definition infix.h:438
@ INFIX_ERROR_
Definition infix.h:440
@ INFIX_ERROR_PROTECTION_FAILED
Definition infix.h:439
@ INFIX_ERROR_UNSUPPORTED_ABI
Definition infix.h:437
@ INFIX_SUCCESS
Definition infix.h:434
@ INFIX_ERROR_INVALID_ARGUMENT
Definition infix.h:436
INFIX_API INFIX_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.
Definition signature.c:1892
INFIX_API INFIX_NODISCARD void * infix_reverse_get_code(const infix_reverse_t *)
Gets the native, callable C function pointer from a reverse trampoline.
Definition trampoline.c:902
INFIX_API INFIX_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.
Definition signature.c:1845
INFIX_API INFIX_NODISCARD size_t infix_forward_get_num_args(const infix_forward_t *)
Gets the total number of arguments for a forward trampoline.
Definition types.c:1337
INFIX_API INFIX_NODISCARD infix_unbound_cif_func infix_forward_get_unbound_code(infix_forward_t *)
Gets the callable function pointer from an unbound forward trampoline.
Definition trampoline.c:278
infix_print_dialect_t
Specifies the output format for printing types and function signatures.
Definition infix.h:1157
INFIX_API INFIX_NODISCARD infix_cif_func infix_forward_get_code(infix_forward_t *)
Gets the callable function pointer from a bound forward trampoline.
Definition trampoline.c:283
INFIX_API INFIX_NODISCARD void * infix_reverse_get_user_data(const infix_reverse_t *)
Gets the user-provided data pointer from a closure context.
Definition trampoline.c:912
@ INFIX_DIALECT_SIGNATURE
Definition infix.h:1158
@ INFIX_DIALECT_ITANIUM_MANGLING
Definition infix.h:1159
@ INFIX_DIALECT_MSVC_MANGLING
Definition infix.h:1160
INFIX_API void infix_reverse_destroy(infix_reverse_t *)
Destroys a reverse trampoline and frees all associated memory.
Definition trampoline.c:884
INFIX_API INFIX_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.
Definition trampoline.c:594
INFIX_API INFIX_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.
Definition trampoline.c:620
INFIX_API INFIX_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.
Definition trampoline.c:865
INFIX_API INFIX_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.
Definition trampoline.c:843
INFIX_API void infix_forward_destroy(infix_forward_t *)
Destroys a forward trampoline and frees all associated memory.
Definition trampoline.c:636
INFIX_API INFIX_NODISCARD void * infix_arena_alloc(infix_arena_t *, size_t, size_t)
Allocates a block of memory from an arena.
Definition arena.c:117
INFIX_API INFIX_NODISCARD infix_arena_t * infix_arena_create(size_t)
Creates a new memory arena.
Definition arena.c:52
INFIX_API INFIX_NODISCARD void * infix_arena_calloc(infix_arena_t *, size_t, size_t, size_t)
Allocates and zero-initializes a block of memory from an arena.
Definition arena.c:188
INFIX_API void infix_arena_destroy(infix_arena_t *)
Destroys an arena and frees all memory allocated from it.
Definition arena.c:83
INFIX_API void infix_registry_destroy(infix_registry_t *)
Destroys a type registry and frees all associated memory.
Definition type_registry.c:310
INFIX_API INFIX_NODISCARD infix_status infix_register_types(infix_registry_t *, const char *)
Parses a string of type definitions and adds them to a registry.
Definition type_registry.c:522
INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_create(void)
Creates a new, empty named type registry.
Definition type_registry.c:197
INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_clone(const infix_registry_t *)
Creates a deep copy of an existing type registry.
Definition type_registry.c:264
INFIX_API INFIX_NODISCARD const infix_type * infix_registry_lookup_type(const infix_registry_t *, const char *)
Retrieves the canonical infix_type object for a given name from the registry.
Definition type_registry.c:888
INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_create_in_arena(infix_arena_t *arena)
Creates a new named type registry that allocates from a user-provided arena.
Definition type_registry.c:235
INFIX_API INFIX_NODISCARD infix_status infix_registry_print(char *, size_t, const infix_registry_t *)
Serializes all defined types within a registry into a single, human-readable string.
Definition signature.c:2052
INFIX_API INFIX_NODISCARD bool infix_registry_iterator_next(infix_registry_iterator_t *)
Advances the iterator to the next defined type in the registry.
Definition type_registry.c:799
INFIX_API INFIX_NODISCARD infix_registry_iterator_t infix_registry_iterator_begin(const infix_registry_t *)
Initializes an iterator for traversing the types in a registry.
Definition type_registry.c:782
INFIX_API INFIX_NODISCARD const infix_type * infix_registry_iterator_get_type(const infix_registry_iterator_t *)
Gets the infix_type object of the type at the iterator's current position.
Definition type_registry.c:856
INFIX_API INFIX_NODISCARD bool infix_registry_is_defined(const infix_registry_t *, const char *)
Checks if a type with the given name is fully defined in the registry.
Definition type_registry.c:872
INFIX_API INFIX_NODISCARD const char * infix_registry_iterator_get_name(const infix_registry_iterator_t *)
Gets the name of the type at the iterator's current position.
Definition type_registry.c:842
INFIX_API INFIX_NODISCARD infix_status infix_type_create_pointer_to(infix_arena_t *, infix_type **, infix_type *)
Creates a new pointer type that points to a specific type.
Definition types.c:431
INFIX_API infix_struct_member infix_type_create_member(const char *, infix_type *, size_t)
A factory function to create an infix_struct_member.
Definition types.c:197
INFIX_API INFIX_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 packed struct type with a user-specified layout.
Definition types.c:750
INFIX_API INFIX_NODISCARD infix_status infix_type_create_complex(infix_arena_t *, infix_type **, infix_type *)
Creates a new _Complex number type.
Definition types.c:576
INFIX_API INFIX_NODISCARD const infix_type * infix_forward_get_arg_type(const infix_forward_t *, size_t)
Gets the type of a specific argument for a forward trampoline.
Definition types.c:1362
infix_primitive_type_id
Enumerates the supported primitive C types.
Definition infix.h:243
INFIX_API INFIX_NODISCARD infix_type * infix_type_create_void(void)
Creates a static descriptor for the void type.
Definition types.c:189
INFIX_API INFIX_NODISCARD const infix_struct_member * infix_type_get_member(const infix_type *, size_t)
Gets a specific member from a struct or union type.
Definition types.c:1301
INFIX_API INFIX_NODISCARD infix_status infix_type_create_union(infix_arena_t *, infix_type **, infix_struct_member *, size_t)
Creates a new union type from an array of members.
Definition types.c:644
INFIX_API INFIX_NODISCARD const char * infix_type_get_arg_name(const infix_type *, size_t)
Gets the name of a specific argument from a function type.
Definition types.c:1314
INFIX_API infix_struct_member infix_type_create_bitfield_member(const char *, infix_type *, size_t, uint8_t)
A factory function to create a bitfield infix_struct_member.
Definition types.c:208
INFIX_API INFIX_NODISCARD size_t infix_type_get_size(const infix_type *)
Gets the size of a type in bytes.
Definition types.c:1277
INFIX_API INFIX_NODISCARD const infix_type * infix_forward_get_return_type(const infix_forward_t *)
Gets the return type for a forward trampoline.
Definition types.c:1353
INFIX_API INFIX_NODISCARD infix_status infix_type_create_named_reference(infix_arena_t *, infix_type **, const char *, infix_aggregate_category_t)
Creates a placeholder for a named type to be resolved by a registry.
Definition types.c:807
INFIX_API INFIX_NODISCARD const infix_type * infix_reverse_get_return_type(const infix_reverse_t *)
Gets the return type for a reverse trampoline.
Definition types.c:1389
INFIX_API INFIX_NODISCARD const infix_type * infix_type_get_arg_type(const infix_type *, size_t)
Gets the type of a specific argument from a function type.
Definition types.c:1326
INFIX_API INFIX_NODISCARD size_t infix_type_get_member_count(const infix_type *)
Gets the number of members in a struct or union type.
Definition types.c:1290
INFIX_API INFIX_NODISCARD infix_type_category infix_type_get_category(const infix_type *)
Gets the fundamental category of a type.
Definition types.c:1269
INFIX_API INFIX_NODISCARD infix_type * infix_type_create_primitive(infix_primitive_type_id)
Creates a static descriptor for a primitive C type.
Definition types.c:135
INFIX_API INFIX_NODISCARD infix_type * infix_type_create_pointer(void)
Creates a static descriptor for a generic pointer (void*).
Definition types.c:184
INFIX_API INFIX_NODISCARD size_t infix_reverse_get_num_fixed_args(const infix_reverse_t *)
Gets the number of fixed (non-variadic) arguments for a reverse trampoline.
Definition types.c:1381
infix_type_category
Enumerates the fundamental categories of types that infix can represent.
Definition infix.h:227
INFIX_API INFIX_NODISCARD infix_status infix_type_create_vector(infix_arena_t *, infix_type **, infix_type *, size_t)
Creates a new SIMD vector type.
Definition types.c:606
INFIX_API INFIX_NODISCARD const infix_type * infix_reverse_get_arg_type(const infix_reverse_t *, size_t)
Gets the type of a specific argument for a reverse trampoline.
Definition types.c:1398
INFIX_API INFIX_NODISCARD const char * infix_type_get_name(const infix_type *)
Gets the semantic alias of a type, if one exists.
Definition types.c:1259
INFIX_API INFIX_NODISCARD infix_status infix_type_create_struct(infix_arena_t *, infix_type **, infix_struct_member *, size_t)
Creates a new struct type from an array of members, calculating layout automatically.
Definition types.c:691
infix_aggregate_category_t
Specifies whether a named type reference refers to a struct or a union.
Definition infix.h:263
INFIX_API INFIX_NODISCARD size_t infix_forward_get_num_fixed_args(const infix_forward_t *)
Gets the number of fixed (non-variadic) arguments for a forward trampoline.
Definition types.c:1345
infix_reverse_t infix_context_t
An alias for infix_reverse_t, used to clarify its role as a context object in closure handlers.
Definition infix.h:217
INFIX_API INFIX_NODISCARD infix_status infix_type_create_enum(infix_arena_t *, infix_type **, infix_type *)
Creates a new enum type with a specified underlying integer type.
Definition types.c:542
INFIX_API INFIX_NODISCARD size_t infix_reverse_get_num_args(const infix_reverse_t *)
Gets the total number of arguments for a reverse trampoline.
Definition types.c:1373
INFIX_API infix_status infix_type_create_flexible_array(infix_arena_t *, infix_type **, infix_type *)
Creates a flexible array member type ([?:type]).
Definition types.c:499
INFIX_API INFIX_NODISCARD infix_status infix_type_create_array(infix_arena_t *, infix_type **, infix_type *, size_t)
Creates a new fixed-size array type.
Definition types.c:461
INFIX_API INFIX_NODISCARD size_t infix_type_get_alignment(const infix_type *)
Gets the alignment requirement of a type in bytes.
Definition types.c:1283
@ INFIX_PRIMITIVE_UINT16
Definition infix.h:247
@ INFIX_PRIMITIVE_UINT32
Definition infix.h:249
@ INFIX_PRIMITIVE_LONG_DOUBLE
Definition infix.h:257
@ INFIX_PRIMITIVE_FLOAT
Definition infix.h:255
@ INFIX_PRIMITIVE_DOUBLE
Definition infix.h:256
@ INFIX_PRIMITIVE_SINT16
Definition infix.h:248
@ INFIX_PRIMITIVE_SINT64
Definition infix.h:252
@ INFIX_PRIMITIVE_SINT32
Definition infix.h:250
@ INFIX_PRIMITIVE_UINT8
Definition infix.h:245
@ INFIX_PRIMITIVE_UINT128
Definition infix.h:253
@ INFIX_PRIMITIVE_BOOL
Definition infix.h:244
@ INFIX_PRIMITIVE_UINT64
Definition infix.h:251
@ INFIX_PRIMITIVE_SINT128
Definition infix.h:254
@ INFIX_PRIMITIVE_SINT8
Definition infix.h:246
@ INFIX_TYPE_UNION
Definition infix.h:231
@ INFIX_TYPE_PRIMITIVE
Definition infix.h:228
@ INFIX_TYPE_COMPLEX
Definition infix.h:235
@ INFIX_TYPE_ARRAY
Definition infix.h:232
@ INFIX_TYPE_VECTOR
Definition infix.h:236
@ INFIX_TYPE_VOID
Definition infix.h:238
@ INFIX_TYPE_POINTER
Definition infix.h:229
@ INFIX_TYPE_NAMED_REFERENCE
Definition infix.h:237
@ INFIX_TYPE_REVERSE_TRAMPOLINE
Definition infix.h:233
@ INFIX_TYPE_ENUM
Definition infix.h:234
@ INFIX_TYPE_STRUCT
Definition infix.h:230
@ INFIX_AGGREGATE_STRUCT
Definition infix.h:263
@ INFIX_AGGREGATE_UNION
Definition infix.h:263
#define INFIX_NODISCARD
A compatibility macro for the C23 [[nodiscard]] attribute.
Definition infix.h:140
#define INFIX_API
Symbol visibility macro.
Definition infix.h:114
INFIX_API INFIX_NODISCARD infix_version_t infix_get_version(void)
Retrieves the version of the infix library linked at runtime.
Definition platform.c:34
Internal definition of a memory arena.
Definition infix_internals.h:138
A struct containing all the necessary handlers for a single function argument.
Definition infix.h:1481
Provides detailed, thread-local information about the last error that occurred.
Definition infix.h:1381
Internal definition of a forward trampoline handle.
Definition infix_internals.h:88
Describes a single argument to a C function.
Definition infix.h:345
Internal definition of a dynamic library handle.
Definition infix_internals.h:195
An iterator for traversing a type registry.
Definition infix.h:516
Internal definition of a named type registry.
Definition infix_internals.h:165
Internal definition of a reverse trampoline (callback/closure) handle.
Definition infix_internals.h:114
Describes a single member of a C struct or union.
Definition infix.h:333
A semi-opaque structure that describes a C type.
Definition infix.h:273
A structure representing the semantic version of the library.
Definition infix.h:148
A union to hold any primitive value returned by a scalar marshaller.
Definition infix.h:1427