|
| int | int_callback_handler (int a, int b) |
| | A type-safe handler for an int(int, int) callback.
|
| |
| float | float_callback_handler (float a, float b) |
| | A type-safe handler for a float(float, float) callback.
|
| |
| void | void_callback_handler (int check_val) |
| | A type-safe handler for a void(int) callback.
|
| |
| void | int_closure_handler (infix_context_t *context, void *return_value, void **args) |
| | A generic closure handler for an int(int, int) signature.
|
| |
| void | float_closure_handler (infix_context_t *context, void *return_value, void **args) |
| | A generic closure handler for a float(float, float) signature.
|
| |
| void | void_closure_handler (infix_context_t *context, void *return_value, void **args) |
| | A generic closure handler for a void(int) signature.
|
| |
| void | execute_int_callback (int(*func_ptr)(int, int), int x, int y) |
| |
| void | execute_float_callback (float(*func_ptr)(float, float), float a, float b) |
| |
| void | execute_void_callback (void(*func_ptr)(int), int val) |
| |
| | subtest ("Callback with signature: int(int, int)") |
| |
| | subtest ("Callback with signature: float(float, float)") |
| |
| | subtest ("Callback with signature: void(int)") |
| |
Unit test for reverse trampolines (callbacks) with primitive C types.
This test file is the reverse-call counterpart to 001_primitives.c. It verifies that infix can correctly generate a callable C function pointer from a user-provided handler function for all basic primitive types.
For each primitive type, it tests two distinct reverse trampoline models:
- Type-Safe Callback (
infix_reverse_create_callback_manual):** The user provides a C handler with a native, type-safe signature (e.g., int handler(int, int)). This is the high-level, convenient API.
- **Generic Closure (
infix_reverse_create_closure_manual):** The user provides a generic handler (infix_closure_handler_fn) that receives arguments as a `void` array. This is the low-level, more flexible API, typically used for language bindings.
The test creates a JIT-compiled function pointer for each model and passes it to a C "harness" function. The harness calls the pointer, and the test verifies that the user-provided handler was invoked correctly and that the return value was transmitted back to the harness.