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 6
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
335 const char * name;
337 size_t offset;
338 uint8_t bit_width;
339 uint8_t bit_offset;
341};
// end of type_system group
370#ifndef infix_malloc
371#define infix_malloc malloc
372#endif
374#ifndef infix_calloc
375#define infix_calloc calloc
376#endif
378#ifndef infix_realloc
379#define infix_realloc realloc
380#endif
382#ifndef infix_free
383#define infix_free free
384#endif
386#ifndef infix_memcpy
387#define infix_memcpy memcpy
388#endif
390#ifndef infix_memset
391#define infix_memset memset
392#endif
// end of memory_management group
409typedef void (*infix_unbound_cif_func)(void *, void *, void **);
418typedef void (*infix_cif_func)(void *, void **);
430typedef void (*infix_closure_handler_fn)(infix_context_t *, void *, void **);
// end of registry_api group // end of registry_introspection_api group
648 const char *,
649 void *,
665 const char *,
666 void *,
712 const char *,
770 const char *,
771 void *,
852 const char *, infix_arena_t **, infix_type **, infix_function_argument **, size_t *, size_t *, infix_registry_t *);
867 infix_arena_t **,
868 const char *,
// end of high_level_api group
908infix_read_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
919infix_write_global(infix_library_t *, const char *, const char *, void *, infix_registry_t *);
// end of exports_api group
941infix_forward_create_manual(infix_forward_t **, infix_type *, infix_type **, size_t, size_t, void *);
977 infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, infix_closure_handler_fn, void *);
1025 infix_type **,
1027 size_t);
1049 infix_type **,
1051 size_t);
1088 infix_type **,
1089 const char *,
// end of manual_api group (continued) // end of type_system group
1161INFIX_API INFIX_NODISCARD void * infix_arena_calloc(infix_arena_t *, size_t, size_t, size_t);
// end of memory_management group (continued)
1202 size_t,
1203 const char *,
1204 const infix_type *,
1206 size_t,
1207 size_t,
1332INFIX_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
1437typedef void (*infix_direct_cif_func)(void *, void **);
1438
1446typedef union {
1447 uint64_t u64;
1448 int64_t i64;
1449 double f64;
1450 void * ptr;
1452
1462typedef infix_direct_value_t (*infix_marshaller_fn)(void * source_object);
1463
1478typedef void (*infix_aggregate_marshaller_fn)(void * source_object, void * dest_buffer, const infix_type * type);
1479
1492typedef void (*infix_writeback_fn)(void * source_object, void * c_data_ptr, const infix_type * type);
1493
1508
1528 const char * signature,
1529 void * target_function,
// end of direct_marshalling_api group
1541#ifdef __cplusplus
1542}
1543#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:1437
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:1478
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:1462
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:1492
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:1360
infix_error_category_t
Enumerates the high-level categories of errors that can occur.
Definition infix.h:1350
@ INFIX_CODE_PROTECTION_FAILURE
Definition infix.h:1371
@ INFIX_CODE_SUCCESS
Definition infix.h:1362
@ INFIX_CODE_LAYOUT_FAILED
Definition infix.h:1389
@ INFIX_CODE_LIBRARY_NOT_FOUND
Definition infix.h:1392
@ INFIX_CODE_INVALID_MEMBER_TYPE
Definition infix.h:1388
@ INFIX_CODE_MISSING_REGISTRY
Definition infix.h:1365
@ INFIX_CODE_UNRESOLVED_NAMED_TYPE
Definition infix.h:1387
@ INFIX_CODE_INVALID_ALIGNMENT
Definition infix.h:1372
@ INFIX_CODE_INTEGER_OVERFLOW
Definition infix.h:1379
@ INFIX_CODE_TYPE_TOO_LARGE
Definition infix.h:1386
@ INFIX_CODE_EMPTY_SIGNATURE
Definition infix.h:1382
@ INFIX_CODE_UNEXPECTED_TOKEN
Definition infix.h:1375
@ INFIX_CODE_MISSING_RETURN_TYPE
Definition infix.h:1378
@ INFIX_CODE_EMPTY_MEMBER_NAME
Definition infix.h:1381
@ INFIX_CODE_EXECUTABLE_MEMORY_FAILURE
Definition infix.h:1370
@ INFIX_CODE_UNKNOWN
Definition infix.h:1363
@ INFIX_CODE_SYMBOL_NOT_FOUND
Definition infix.h:1393
@ INFIX_CODE_RECURSION_DEPTH_EXCEEDED
Definition infix.h:1380
@ INFIX_CODE_UNSUPPORTED_ABI
Definition infix.h:1385
@ INFIX_CODE_UNTERMINATED_AGGREGATE
Definition infix.h:1376
@ INFIX_CODE_LIBRARY_LOAD_FAILED
Definition infix.h:1394
@ INFIX_CODE_NATIVE_EXCEPTION
Definition infix.h:1366
@ INFIX_CODE_NULL_POINTER
Definition infix.h:1364
@ INFIX_CODE_INVALID_KEYWORD
Definition infix.h:1377
@ INFIX_CODE_OUT_OF_MEMORY
Definition infix.h:1369
@ INFIX_CATEGORY_ABI
Definition infix.h:1355
@ INFIX_CATEGORY_ALLOCATION
Definition infix.h:1353
@ INFIX_CATEGORY_GENERAL
Definition infix.h:1352
@ INFIX_CATEGORY_PARSER
Definition infix.h:1354
@ INFIX_CATEGORY_NONE
Definition infix.h:1351
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:282
void * _current_entry
Definition infix.h:520
struct infix_type_t::@0::@1 pointer_info
Metadata for INFIX_TYPE_POINTER.
size_t position
Definition infix.h:1403
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:295
struct infix_type_t::@0::@7 vector_info
Metadata for INFIX_TYPE_VECTOR.
infix_error_category_t category
Definition infix.h:1401
const infix_registry_t * registry
Definition infix.h:518
bool is_incomplete
Definition infix.h:280
uint64_t u64
Used for all unsigned integer types up to 64 bits.
Definition infix.h:1447
infix_type * type
Definition infix.h:348
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:1085
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:418
size_t num_elements
Definition infix.h:300
infix_arena_t * arena
Definition infix.h:281
size_t size
Definition infix.h:277
void(* infix_unbound_cif_func)(void *, void *, void **)
A function pointer type for an unbound forward trampoline.
Definition infix.h:409
size_t alignment
Definition infix.h:278
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:1450
uint8_t bit_offset
Definition infix.h:339
infix_writeback_fn writeback_handler
For "out" or "in-out" parameters. Called after the C function returns.
Definition infix.h:1506
infix_struct_member * members
Definition infix.h:293
bool is_bitfield
Definition infix.h:340
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:1026
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:275
infix_function_argument * args
Definition infix.h:306
size_t num_elements
Definition infix.h:321
struct infix_type_t * element_type
Definition infix.h:320
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:326
infix_status
Enumerates the possible status codes returned by infix API functions.
Definition infix.h:434
const char * name
Definition infix.h:347
const char * name
Definition infix.h:325
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:335
infix_type_category category
Definition infix.h:276
int minor
Definition infix.h:150
size_t _bucket_index
Definition infix.h:519
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:289
infix_marshaller_fn scalar_marshaller
For "in" parameters of a scalar type (int, float, pointer).
Definition infix.h:1502
infix_type * type
Definition infix.h:336
struct infix_type_t * element_type
Definition infix.h:299
int patch
Definition infix.h:151
bool is_flexible
Definition infix.h:301
struct infix_type_t * return_type
Definition infix.h:305
size_t offset
Definition infix.h:337
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:1504
double f64
Used for float and double.
Definition infix.h:1449
struct infix_type_t * base_type
Definition infix.h:316
long system_error_code
Definition infix.h:1404
uint8_t bit_width
Definition infix.h:338
infix_error_code_t code
Definition infix.h:1402
int64_t i64
Used for all signed integer types up to 64 bits.
Definition infix.h:1448
size_t num_members
Definition infix.h:294
struct infix_type_t * underlying_type
Definition infix.h:312
struct infix_type_t::@0::@8 named_reference
Metadata for INFIX_TYPE_NAMED_REFERENCE.
size_t num_fixed_args
Definition infix.h:308
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:430
infix_primitive_type_id primitive_id
Metadata for INFIX_TYPE_PRIMITIVE.
Definition infix.h:286
size_t num_args
Definition infix.h:307
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:279
@ INFIX_ERROR_ALLOCATION_FAILED
Definition infix.h:436
@ INFIX_ERROR_LAYOUT_FAILED
Definition infix.h:439
@ INFIX_ERROR_
Definition infix.h:441
@ INFIX_ERROR_PROTECTION_FAILED
Definition infix.h:440
@ INFIX_ERROR_UNSUPPORTED_ABI
Definition infix.h:438
@ INFIX_SUCCESS
Definition infix.h:435
@ INFIX_ERROR_INVALID_ARGUMENT
Definition infix.h:437
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:2009
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:1962
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:1308
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:1175
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:1176
@ INFIX_DIALECT_ITANIUM_MANGLING
Definition infix.h:1177
@ INFIX_DIALECT_MSVC_MANGLING
Definition infix.h:1178
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:2169
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:1333
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: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:1272
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:1285
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:1248
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:1324
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:1360
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:1297
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:1261
INFIX_API INFIX_NODISCARD infix_type_category infix_type_get_category(const infix_type *)
Gets the fundamental category of a type.
Definition types.c:1240
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:1352
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: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:1369
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:264
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:1316
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: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:1344
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:1254
@ INFIX_PRIMITIVE_UINT16
Definition infix.h:247
@ INFIX_PRIMITIVE_UINT32
Definition infix.h:249
@ INFIX_PRIMITIVE_LONG_DOUBLE
Definition infix.h:258
@ INFIX_PRIMITIVE_FLOAT
Definition infix.h:256
@ INFIX_PRIMITIVE_DOUBLE
Definition infix.h:257
@ 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_FLOAT16
Definition infix.h:255
@ 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:264
@ INFIX_AGGREGATE_UNION
Definition infix.h:264
#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:143
A struct containing all the necessary handlers for a single function argument.
Definition infix.h:1500
Provides detailed, thread-local information about the last error that occurred.
Definition infix.h:1400
Internal definition of a forward trampoline handle.
Definition infix_internals.h:90
Describes a single argument to a C function.
Definition infix.h:346
Internal definition of a dynamic library handle.
Definition infix_internals.h:225
An iterator for traversing a type registry.
Definition infix.h:517
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:334
A semi-opaque structure that describes a C type.
Definition infix.h:274
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:1446