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 7
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 defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L && _INFIX_HAS_C_ATTRIBUTE(nodiscard) && \
134 !defined(__GNUC__) && !defined(__clang__)
135#define INFIX_NODISCARD [[nodiscard]]
136#elif defined(__GNUC__) || defined(__clang__)
137#define INFIX_NODISCARD __attribute__((warn_unused_result))
138#elif defined(_MSC_VER)
139#define INFIX_NODISCARD _Check_return_
140#else
141#define INFIX_NODISCARD
142#endif
143
149typedef struct {
150 int major;
151 int minor;
152 int patch;
154
156// Define the POSIX source macro to ensure function declarations for shm_open,
157// ftruncate, etc., are visible on all POSIX-compliant systems.
158// This must be defined before any system headers are included.
159#ifndef _DEFAULT_SOURCE
160#define _DEFAULT_SOURCE
161#endif
162// Define the POSIX source macro to ensure function declarations for posix_memalign
163// are visible. This must be defined before any system headers are included.
164#if !defined(_POSIX_C_SOURCE)
165#define _POSIX_C_SOURCE 200809L
166#endif
167#include <stdbool.h>
168#include <stddef.h>
169#include <stdint.h>
170
171#ifdef __cplusplus
172extern "C" {
173#endif
185
205// Opaque and Semi-Opaque Type Forward Declarations
336 const char * name;
338 size_t offset;
339 uint8_t bit_width;
340 uint8_t bit_offset;
342};
// end of type_system group
371#ifndef infix_malloc
372#define infix_malloc malloc
373#endif
375#ifndef infix_calloc
376#define infix_calloc calloc
377#endif
379#ifndef infix_realloc
380#define infix_realloc realloc
381#endif
383#ifndef infix_free
384#define infix_free free
385#endif
387#ifndef infix_memcpy
388#define infix_memcpy memcpy
389#endif
391#ifndef infix_memset
392#define infix_memset memset
393#endif
// end of memory_management group
410typedef void (*infix_unbound_cif_func)(void *, void *, void **);
419typedef void (*infix_cif_func)(void *, void **);
431typedef void (*infix_closure_handler_fn)(infix_context_t *, void *, void **);
// end of registry_api group // end of registry_introspection_api group
649 const char *,
650 void *,
666 const char *,
667 void *,
713 const char *,
771 const char *,
772 void *,
853 const char *, infix_arena_t **, infix_type **, infix_function_argument **, size_t *, size_t *, infix_registry_t *);
868 infix_arena_t **,
869 const char *,
// end of high_level_api group
909infix_read_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
920infix_write_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
// end of exports_api group
942infix_forward_create_manual(infix_forward_t **, infix_type *, infix_type **, size_t, size_t, void *);
978 infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, infix_closure_handler_fn, void *);
1026 infix_type **,
1028 size_t);
1050 infix_type **,
1052 size_t);
1089 infix_type **,
1090 const char *,
// end of manual_api group (continued) // end of type_system group
1162INFIX_API INFIX_NODISCARD void * infix_arena_calloc(infix_arena_t *, size_t, size_t, size_t);
// end of memory_management group (continued)
1203 size_t,
1204 const char *,
1205 const infix_type *,
1207 size_t,
1208 size_t,
1333INFIX_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
1438typedef void (*infix_direct_cif_func)(void *, void **);
1439
1447typedef union {
1448 uint64_t u64;
1449 int64_t i64;
1450 double f64;
1451 void * ptr;
1453
1463typedef infix_direct_value_t (*infix_marshaller_fn)(void * source_object);
1464
1479typedef void (*infix_aggregate_marshaller_fn)(void * source_object, void * dest_buffer, const infix_type * type);
1480
1493typedef void (*infix_writeback_fn)(void * source_object, void * c_data_ptr, const infix_type * type);
1494
1509
1529 const char * signature,
1530 void * target_function,
// end of direct_marshalling_api group
1542#ifdef __cplusplus
1543}
1544#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:1438
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:1479
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:1463
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:1115
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:1493
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:281
infix_error_code_t
Enumerates specific error codes.
Definition infix.h:1361
infix_error_category_t
Enumerates the high-level categories of errors that can occur.
Definition infix.h:1351
@ INFIX_CODE_PROTECTION_FAILURE
Definition infix.h:1372
@ INFIX_CODE_SUCCESS
Definition infix.h:1363
@ INFIX_CODE_LAYOUT_FAILED
Definition infix.h:1390
@ INFIX_CODE_LIBRARY_NOT_FOUND
Definition infix.h:1393
@ INFIX_CODE_INVALID_MEMBER_TYPE
Definition infix.h:1389
@ INFIX_CODE_MISSING_REGISTRY
Definition infix.h:1366
@ INFIX_CODE_UNRESOLVED_NAMED_TYPE
Definition infix.h:1388
@ INFIX_CODE_INVALID_ALIGNMENT
Definition infix.h:1373
@ INFIX_CODE_INTEGER_OVERFLOW
Definition infix.h:1380
@ INFIX_CODE_TYPE_TOO_LARGE
Definition infix.h:1387
@ INFIX_CODE_EMPTY_SIGNATURE
Definition infix.h:1383
@ INFIX_CODE_UNEXPECTED_TOKEN
Definition infix.h:1376
@ INFIX_CODE_MISSING_RETURN_TYPE
Definition infix.h:1379
@ INFIX_CODE_EMPTY_MEMBER_NAME
Definition infix.h:1382
@ INFIX_CODE_EXECUTABLE_MEMORY_FAILURE
Definition infix.h:1371
@ INFIX_CODE_UNKNOWN
Definition infix.h:1364
@ INFIX_CODE_SYMBOL_NOT_FOUND
Definition infix.h:1394
@ INFIX_CODE_RECURSION_DEPTH_EXCEEDED
Definition infix.h:1381
@ INFIX_CODE_UNSUPPORTED_ABI
Definition infix.h:1386
@ INFIX_CODE_UNTERMINATED_AGGREGATE
Definition infix.h:1377
@ INFIX_CODE_LIBRARY_LOAD_FAILED
Definition infix.h:1395
@ INFIX_CODE_NATIVE_EXCEPTION
Definition infix.h:1367
@ INFIX_CODE_NULL_POINTER
Definition infix.h:1365
@ INFIX_CODE_INVALID_KEYWORD
Definition infix.h:1378
@ INFIX_CODE_OUT_OF_MEMORY
Definition infix.h:1370
@ INFIX_CATEGORY_ABI
Definition infix.h:1356
@ INFIX_CATEGORY_ALLOCATION
Definition infix.h:1354
@ INFIX_CATEGORY_GENERAL
Definition infix.h:1353
@ INFIX_CATEGORY_PARSER
Definition infix.h:1355
@ INFIX_CATEGORY_NONE
Definition infix.h:1352
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:283
void * _current_entry
Definition infix.h:521
struct infix_type_t::@0::@1 pointer_info
Metadata for INFIX_TYPE_POINTER.
size_t position
Definition infix.h:1404
int major
Definition infix.h:150
union infix_type_t::@0 meta
A union containing metadata specific to the type's category.
bool is_packed
Definition infix.h:296
struct infix_type_t::@0::@7 vector_info
Metadata for INFIX_TYPE_VECTOR.
infix_error_category_t category
Definition infix.h:1402
const infix_registry_t * registry
Definition infix.h:519
bool is_incomplete
Definition infix.h:281
uint64_t u64
Used for all unsigned integer types up to 64 bits.
Definition infix.h:1448
infix_type * type
Definition infix.h:349
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:1112
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:419
size_t num_elements
Definition infix.h:301
infix_arena_t * arena
Definition infix.h:282
size_t size
Definition infix.h:278
void(* infix_unbound_cif_func)(void *, void *, void **)
A function pointer type for an unbound forward trampoline.
Definition infix.h:410
size_t alignment
Definition infix.h:279
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:1159
void * ptr
Used for all pointer types.
Definition infix.h:1451
uint8_t bit_offset
Definition infix.h:340
infix_writeback_fn writeback_handler
For "out" or "in-out" parameters. Called after the C function returns.
Definition infix.h:1507
infix_struct_member * members
Definition infix.h:294
bool is_bitfield
Definition infix.h:341
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:1053
INFIX_API INFIX_NODISCARD infix_status infix_forward_create_safe(infix_forward_t **, const char *, void *, infix_registry_t *)
Creates a "safe" bound forward trampoline that catches native exceptions.
Definition trampoline.c:1071
const char * name
Definition infix.h:276
infix_function_argument * args
Definition infix.h:307
size_t num_elements
Definition infix.h:322
struct infix_type_t * element_type
Definition infix.h:321
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:1187
infix_aggregate_category_t aggregate_category
Definition infix.h:327
infix_status
Enumerates the possible status codes returned by infix API functions.
Definition infix.h:435
const char * name
Definition infix.h:348
const char * name
Definition infix.h:326
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:992
const char * name
Definition infix.h:336
infix_type_category category
Definition infix.h:277
int minor
Definition infix.h:151
size_t _bucket_index
Definition infix.h:520
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:290
infix_marshaller_fn scalar_marshaller
For "in" parameters of a scalar type (int, float, pointer).
Definition infix.h:1503
infix_type * type
Definition infix.h:337
struct infix_type_t * element_type
Definition infix.h:300
int patch
Definition infix.h:152
bool is_flexible
Definition infix.h:302
struct infix_type_t * return_type
Definition infix.h:306
size_t offset
Definition infix.h:338
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:1505
double f64
Used for float and double.
Definition infix.h:1450
struct infix_type_t * base_type
Definition infix.h:317
long system_error_code
Definition infix.h:1405
uint8_t bit_width
Definition infix.h:339
infix_error_code_t code
Definition infix.h:1403
int64_t i64
Used for all signed integer types up to 64 bits.
Definition infix.h:1449
size_t num_members
Definition infix.h:295
struct infix_type_t * underlying_type
Definition infix.h:313
struct infix_type_t::@0::@8 named_reference
Metadata for INFIX_TYPE_NAMED_REFERENCE.
size_t num_fixed_args
Definition infix.h:309
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:1110
void(* infix_closure_handler_fn)(infix_context_t *, void *, void **)
A function pointer type for a generic closure handler.
Definition infix.h:431
infix_primitive_type_id primitive_id
Metadata for INFIX_TYPE_PRIMITIVE.
Definition infix.h:287
size_t num_args
Definition infix.h:308
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:1104
bool is_arena_allocated
Definition infix.h:280
@ INFIX_ERROR_ALLOCATION_FAILED
Definition infix.h:437
@ INFIX_ERROR_LAYOUT_FAILED
Definition infix.h:440
@ INFIX_ERROR_
Definition infix.h:442
@ INFIX_ERROR_PROTECTION_FAILED
Definition infix.h:441
@ INFIX_ERROR_UNSUPPORTED_ABI
Definition infix.h:439
@ INFIX_SUCCESS
Definition infix.h:436
@ INFIX_ERROR_INVALID_ARGUMENT
Definition infix.h:438
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:2050
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:976
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:2003
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:1313
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:1176
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:986
@ INFIX_DIALECT_SIGNATURE
Definition infix.h:1177
@ INFIX_DIALECT_ITANIUM_MANGLING
Definition infix.h:1178
@ INFIX_DIALECT_MSVC_MANGLING
Definition infix.h:1179
INFIX_API void infix_reverse_destroy(infix_reverse_t *)
Destroys a reverse trampoline and frees all associated memory.
Definition trampoline.c:958
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:662
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:688
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:939
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:917
INFIX_API void infix_forward_destroy(infix_forward_t *)
Destroys a forward trampoline and frees all associated memory.
Definition trampoline.c:720
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:307
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:523
INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_create(void)
Creates a new, empty named type registry.
Definition type_registry.c:196
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:261
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:938
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:233
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:2210
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:849
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:832
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:906
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:922
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:892
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:393
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:208
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:719
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:542
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:1338
infix_primitive_type_id
Enumerates the supported primitive C types.
Definition infix.h:244
INFIX_API INFIX_NODISCARD infix_type * infix_type_create_void(void)
Creates a static descriptor for the void type.
Definition types.c:200
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:1277
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:612
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:1290
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:219
INFIX_API INFIX_NODISCARD size_t infix_type_get_size(const infix_type *)
Gets the size of a type in bytes.
Definition types.c:1253
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:1329
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:777
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:1365
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:1302
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:1266
INFIX_API INFIX_NODISCARD infix_type_category infix_type_get_category(const infix_type *)
Gets the fundamental category of a type.
Definition types.c:1245
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:144
INFIX_API INFIX_NODISCARD infix_type * infix_type_create_pointer(void)
Creates a static descriptor for a generic pointer (void*).
Definition types.c:195
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:1357
infix_type_category
Enumerates the fundamental categories of types that infix can represent.
Definition infix.h:228
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:573
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:1374
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:1230
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:660
infix_aggregate_category_t
Specifies whether a named type reference refers to a struct or a union.
Definition infix.h:265
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:1321
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:218
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:507
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:1349
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:463
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:424
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:1259
@ INFIX_PRIMITIVE_UINT16
Definition infix.h:248
@ INFIX_PRIMITIVE_UINT32
Definition infix.h:250
@ INFIX_PRIMITIVE_LONG_DOUBLE
Definition infix.h:259
@ INFIX_PRIMITIVE_FLOAT
Definition infix.h:257
@ INFIX_PRIMITIVE_DOUBLE
Definition infix.h:258
@ INFIX_PRIMITIVE_SINT16
Definition infix.h:249
@ INFIX_PRIMITIVE_SINT64
Definition infix.h:253
@ INFIX_PRIMITIVE_SINT32
Definition infix.h:251
@ INFIX_PRIMITIVE_UINT8
Definition infix.h:246
@ INFIX_PRIMITIVE_UINT128
Definition infix.h:254
@ INFIX_PRIMITIVE_BOOL
Definition infix.h:245
@ INFIX_PRIMITIVE_UINT64
Definition infix.h:252
@ INFIX_PRIMITIVE_FLOAT16
Definition infix.h:256
@ INFIX_PRIMITIVE_SINT128
Definition infix.h:255
@ INFIX_PRIMITIVE_SINT8
Definition infix.h:247
@ INFIX_TYPE_UNION
Definition infix.h:232
@ INFIX_TYPE_PRIMITIVE
Definition infix.h:229
@ INFIX_TYPE_COMPLEX
Definition infix.h:236
@ INFIX_TYPE_ARRAY
Definition infix.h:233
@ INFIX_TYPE_VECTOR
Definition infix.h:237
@ INFIX_TYPE_VOID
Definition infix.h:239
@ INFIX_TYPE_POINTER
Definition infix.h:230
@ INFIX_TYPE_NAMED_REFERENCE
Definition infix.h:238
@ INFIX_TYPE_REVERSE_TRAMPOLINE
Definition infix.h:234
@ INFIX_TYPE_ENUM
Definition infix.h:235
@ INFIX_TYPE_STRUCT
Definition infix.h:231
@ INFIX_AGGREGATE_STRUCT
Definition infix.h:265
@ INFIX_AGGREGATE_UNION
Definition infix.h:265
#define INFIX_NODISCARD
A compatibility macro for the C23 [[nodiscard]] attribute.
Definition infix.h:141
#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:143
A struct containing all the necessary handlers for a single function argument.
Definition infix.h:1501
Provides detailed, thread-local information about the last error that occurred.
Definition infix.h:1401
Internal definition of a forward trampoline handle.
Definition infix_internals.h:90
Describes a single argument to a C function.
Definition infix.h:347
Internal definition of a dynamic library handle.
Definition infix_internals.h:225
An iterator for traversing a type registry.
Definition infix.h:518
Internal definition of a named type registry.
Definition infix_internals.h:188
Internal definition of a reverse trampoline (callback/closure) handle.
Definition infix_internals.h:119
Describes a single member of a C struct or union.
Definition infix.h:335
A semi-opaque structure that describes a C type.
Definition infix.h:275
A structure representing the semantic version of the library.
Definition infix.h:149
A union to hold any primitive value returned by a scalar marshaller.
Definition infix.h:1447