|
int | int_callback_handler (int a, int b) |
| A simple callback handler that multiplies two integers.
|
|
float | float_callback_handler (float a, float b) |
| A callback handler that adds two floats.
|
|
void | void_callback_handler (int check_val) |
| A callback handler with a void return type that checks its argument.
|
|
void | int_closure_handler (infix_context_t *context, void *return_value, void **args) |
|
void | float_closure_handler (infix_context_t *context, void *return_value, void **args) |
|
void | void_closure_handler (infix_context_t *context, void *return_value, void **args) |
|
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)") |
|
Tests reverse trampolines (callbacks) with primitive type signatures.
Copyright (c) 2025 Sanko Robinson
This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.
SPDX-License-Identifier: (Artistic-2.0 OR MIT)
The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
SPDX-License-Identifier: CC-BY-4.0
This test suite is the cornerstone for verifying the reverse FFI (callback) functionality. It ensures that the library can correctly generate native, callable function pointers for user-defined handlers that operate on primitive C types.
For each signature, the test performs these steps:
- Defines a C "handler" function (e.g.,
int_callback_handler
).
- Creates the
infix_type
definitions for the handler's public signature.
- Calls the appropriate
infix_reverse_create_*_manual
function to create a native function pointer.
- Defines a C "harness" function that takes a function pointer of the native type as an argument.
- Calls the harness, passing it the generated function pointer.
- Inside the harness, the generated function pointer is called. This triggers the JIT-compiled assembly stub, which marshals the arguments and invokes the original C handler via the correct path (type-safe or generic).
- The test asserts that the value returned by the callback is correct.