Functions for querying the properties of trampolines and types.
More...
|
c23_nodiscard infix_status | infix_type_print (char *, size_t, const infix_type *, infix_print_dialect_t) |
| Serializes an infix_type object graph into a string representation.
|
|
c23_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 full function signature into a string representation.
|
|
Functions for querying the properties of trampolines and types.
◆ infix_print_dialect_t
Specifies the output format for type-to-string serialization functions.
Enumerator |
---|
INFIX_DIALECT_SIGNATURE | The standard infix signature language format.
|
INFIX_DIALECT_ITANIUM_MANGLING | Itanium C++ ABI name mangling (used by GCC/Clang). (Not yet implemented)
|
INFIX_DIALECT_MSVC_MANGLING | Microsoft C++ ABI name mangling. (Not yet implemented)
|
◆ infix_forward_get_arg_type()
Retrieves the type of a specific argument for a forward trampoline.
- Parameters
-
trampoline | A handle to a forward trampoline. Can be nullptr . |
index | The zero-based index of the argument to retrieve. |
- Returns
- A constant pointer to the argument's
infix_type
. Returns nullptr
if the handle is nullptr
or the index is out of bounds.
◆ infix_forward_get_code()
Retrieves the executable code pointer from a bound forward trampoline.
- Parameters
-
trampoline | A handle to a previously created bound forward trampoline. |
- Returns
- A callable function pointer of type
infix_cif_func
. Returns nullptr
if the handle is invalid or if it points to an unbound trampoline.
◆ infix_forward_get_num_args()
Retrieves the number of arguments for a forward trampoline.
- Parameters
-
trampoline | A handle to a forward trampoline. Can be nullptr . |
- Returns
- The total number of arguments. Returns
0
if the handle is nullptr
.
◆ infix_forward_get_num_fixed_args()
Retrieves the number of fixed (non-variadic) arguments for a forward trampoline.
- Parameters
-
trampoline | A handle to a forward trampoline. Can be nullptr . |
- Returns
- The number of fixed arguments. Returns
0
if the handle is nullptr
.
◆ infix_forward_get_return_type()
Retrieves the return type for a forward trampoline.
- Parameters
-
trampoline | A handle to a forward trampoline. Can be nullptr . |
- Returns
- A constant pointer to the return
infix_type
. Returns nullptr
if the handle is nullptr
.
◆ infix_forward_get_unbound_code()
Retrieves the executable code pointer from an unbound forward trampoline.
- Parameters
-
trampoline | A handle to a previously created unbound forward trampoline. |
- Returns
- A callable function pointer of type
infix_unbound_cif_func
. Returns nullptr
if the handle is invalid or if it points to a bound trampoline.
◆ infix_function_print()
Serializes a full function signature into a string representation.
This is a convenience wrapper around infix_type_print
for serializing function types, with future support for including a function name for C++ name mangling.
- Parameters
-
[out] | buffer | The character buffer to write the string into. |
[in] | buffer_size | The total size of the buffer . |
[in] | function_name | The name of the function (optional, for mangling). Can be nullptr . |
[in] | ret_type | The return type of the function. |
[in] | args | An array of infix_function_argument . |
[in] | num_args | The total number of arguments. |
[in] | num_fixed_args | The number of non-variadic arguments. |
[in] | dialect | The output format to use. |
- Returns
INFIX_SUCCESS
on success.
Serializes a full function signature into a string representation.
◆ infix_reverse_get_arg_type()
Retrieves the type of a specific argument for a reverse trampoline.
- Parameters
-
trampoline | A handle to a reverse trampoline. Can be nullptr . |
index | The zero-based index of the argument to retrieve. |
- Returns
- A constant pointer to the argument's
infix_type
. Returns nullptr
if the handle is nullptr
or the index is out of bounds.
◆ infix_reverse_get_code()
Retrieves the executable code pointer from a reverse trampoline.
- Parameters
-
reverse_trampoline | A handle to a previously created reverse trampoline. |
- Returns
- A callable function pointer. Returns
nullptr
if the handle is invalid.
◆ infix_reverse_get_num_args()
Retrieves the number of arguments for a reverse trampoline.
- Parameters
-
trampoline | A handle to a reverse trampoline. Can be nullptr . |
- Returns
- The total number of arguments. Returns
0
if the handle is nullptr
.
◆ infix_reverse_get_num_fixed_args()
Retrieves the number of fixed (non-variadic) arguments for a reverse trampoline.
- Parameters
-
trampoline | A handle to a reverse trampoline. Can be nullptr . |
- Returns
- The number of fixed arguments. Returns
0
if the handle is nullptr
.
◆ infix_reverse_get_return_type()
Retrieves the return type for a reverse trampoline.
- Parameters
-
trampoline | A handle to a reverse trampoline. Can be nullptr . |
- Returns
- A constant pointer to the return
infix_type
. Returns nullptr
if the handle is nullptr
.
◆ infix_reverse_get_user_data()
Retrieves the user_data stored with a reverse trampoline.
- Parameters
-
reverse_trampoline | A handle to a reverse trampoline context. |
- Returns
- The opaque user_data pointer. Returns
nullptr
if the handle is invalid.
◆ infix_type_get_alignment()
Retrieves the alignment requirement of an infix_type
in bytes.
- Parameters
-
type | A pointer to the infix_type to inspect. Can be nullptr . |
- Returns
- The alignment of the type. Returns
0
if the type is nullptr
.
◆ infix_type_get_arg_name()
Retrieves the name of a function argument by its index.
- Parameters
-
func_type | A pointer to an infix_type of category INFIX_TYPE_REVERSE_TRAMPOLINE . |
index | The zero-based index of the argument to retrieve. |
- Returns
- A constant string for the argument's name, or
nullptr
.
◆ infix_type_get_arg_type()
Retrieves the type of a function argument by its index.
- Parameters
-
func_type | A pointer to an infix_type of category INFIX_TYPE_REVERSE_TRAMPOLINE . |
index | The zero-based index of the argument to retrieve. |
- Returns
- A constant pointer to the argument's
infix_type
. Returns nullptr
if invalid.
◆ infix_type_get_category()
Retrieves the fundamental category of an infix_type
.
- Parameters
-
type | A pointer to the infix_type to inspect. Can be nullptr . |
- Returns
- The
infix_type_category
enum for the type.
◆ infix_type_get_member()
Retrieves a specific member from an aggregate type by its index.
- Parameters
-
type | A pointer to an infix_type . Can be nullptr . |
index | The zero-based index of the member to retrieve. |
- Returns
- A constant pointer to the
infix_struct_member
on success. Returns nullptr
if type
is not a struct/union or the index
is out of bounds.
◆ infix_type_get_member_count()
Retrieves the number of members in an aggregate type (struct or union).
- Parameters
-
type | A pointer to an infix_type . Can be nullptr . |
- Returns
- The number of members if the type is a struct or union;
0
otherwise.
◆ infix_type_get_size()
Retrieves the size of an infix_type
in bytes.
- Parameters
-
type | A pointer to the infix_type to inspect. Can be nullptr . |
- Returns
- The size of the type. Returns
0
if the type is nullptr
.
◆ infix_type_print()
Serializes an infix_type object graph into a string representation.
This function recursively walks an infix_type
graph and writes its string representation into the provided buffer. This is useful for debugging, logging, or generating code.
- Parameters
-
[out] | buffer | The character buffer to write the string into. |
[in] | buffer_size | The total size of the buffer . |
[in] | type | The infix_type to serialize. |
[in] | dialect | The output format to use (e.g., INFIX_DIALECT_SIGNATURE ). |
- Returns
INFIX_SUCCESS
on success. Returns INFIX_ERROR_INVALID_ARGUMENT
if the buffer is too small to hold the entire string.
char buffer[128];
printf("Serialized type: %s\n", buffer);
}
infix_arena_t * arena
Definition 005_layouts.c:57
c23_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:1090
c23_nodiscard infix_status infix_type_print(char *, size_t, const infix_type *, infix_print_dialect_t)
Serializes an infix_type object graph into a string representation.
Definition signature.c:1370
@ INFIX_DIALECT_SIGNATURE
The standard infix signature language format.
Definition infix.h:815
void infix_arena_destroy(infix_arena_t *)
Frees an entire memory arena and all objects allocated within it.
Definition arena.c:68
@ INFIX_SUCCESS
The operation completed successfully.
Definition infix.h:352
Definition infix_internals.h:130
The central structure for describing any data type in the FFI system.
Definition infix.h:161
Serializes an infix_type object graph into a string representation.