|
infix
A JIT-Powered FFI Library for C
|
APIs for defining, storing, and reusing complex types by name. More...
Functions | |
| INFIX_API INFIX_NODISCARD infix_registry_t * | infix_registry_create (void) |
| Creates a new, empty named type registry. | |
| INFIX_API INFIX_NODISCARD infix_registry_t * | infix_registry_clone (const infix_registry_t *) |
| Creates a deep copy of an existing type registry. | |
| INFIX_API void | infix_registry_destroy (infix_registry_t *) |
| Destroys a type registry and frees all associated memory. | |
| 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. | |
APIs for defining, storing, and reusing complex types by name.
| INFIX_API INFIX_NODISCARD infix_status infix_register_types | ( | infix_registry_t * | registry, |
| const char * | definitions | ||
| ) |
Parses a string of type definitions and adds them to a registry.
This is the primary way to populate a registry. Definitions are separated by semicolons. The parser supports forward declarations (@Name;) and out-of-order definitions, making it easy to define mutually recursive types.
| [in] | registry | The registry to populate. |
| [in] | definitions | A semicolon-separated string of definitions. |
INFIX_SUCCESS on success, or an error code on failure. This function uses a robust three-pass approach to handle complex dependencies, including out-of-order and mutually recursive definitions.
@Name = ...) or forward-declared (@Name;). It creates an entry for each name in the registry's hash table. Critically, if a forward declaration is found, a placeholder infix_type is created immediately to ensure subsequent lookups succeed.| [in] | registry | The registry to populate. |
| [in] | definitions | A semicolon-separated string of definitions. |
INFIX_SUCCESS on success, or an error code on failure. | INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_clone | ( | const infix_registry_t * | src | ) |
Creates a deep copy of an existing type registry.
This copies all defined types and their dependency graphs into a new registry with its own arena. This is essential for thread safety in languages that spawn threads by cloning interpreter state (like Perl).
| [in] | registry | The registry to clone. |
nullptr on failure.Creates a deep copy of an existing type registry.
| src | The source registry to clone. |
| INFIX_API INFIX_NODISCARD infix_registry_t * infix_registry_create | ( | void | ) |
Creates a new, empty named type registry.
A registry acts as a dictionary for infix types, allowing you to define complex structs, unions, or aliases once and refer to them by name (e.g., @MyStruct) in any signature string. This is essential for managing complex, recursive, or mutually-dependent types.
nullptr on allocation failure. The returned handle must be freed with infix_registry_destroy. | INFIX_API void infix_registry_destroy | ( | infix_registry_t * | registry | ) |
Destroys a type registry and frees all associated memory.
This includes freeing the registry handle itself, its internal hash table, and all infix_type objects that were created as part of a definition.
| [in] | registry | The registry to destroy. Safe to call with nullptr. |
This includes freeing the registry handle itself and its internal arena, which in turn frees the hash table, all entry structs, and all canonical infix_type objects that were created as part of a type definition.
| [in] | registry | The registry to destroy. Safe to call with nullptr. |