|
infix
A JIT-Powered FFI Library for C
|
Unit test for FFI calls involving C99 _Complex types.
More...
#include "common/double_tap.h"#include "types.h"#include <complex.h>#include <infix/infix.h>#include <math.h>Macros | |
| #define | DBLTAP_IMPLEMENTATION |
Typedefs | |
| typedef double _Complex | complex_double_t |
Functions | |
| complex_double_t | c_add (complex_double_t a, complex_double_t b) |
| complex_double_t | c_mul (complex_double_t a, complex_double_t b) |
| complex_double_t | callback_c_add (complex_double_t a, complex_double_t b) |
| void | execute_complex_callback (complex_double_t(*func_ptr)(complex_double_t, complex_double_t), complex_double_t val_a, complex_double_t val_b, complex_double_t expected_val) |
| A C harness to call a complex-number callback and verify the result. | |
| if (!ok(status==INFIX_SUCCESS, "Successfully created infix_type for double _Complex")) | |
| subtest ("Forward call with _Complex arguments and return") | |
| subtest ("Reverse call (callback) with _Complex types") | |
| subtest ("Round trip signature parsing") | |
| infix_arena_destroy (arena) | |
Variables | |
| TEST | |
| infix_arena_t * | arena = infix_arena_create(4096) |
| infix_type * | complex_double_type = NULL |
| infix_status | status |
Unit test for FFI calls involving C99 _Complex types.
This test verifies that infix correctly handles the C99 _Complex number types, which are not supported by all compilers (notably MSVC). The entire test is conditionally compiled to run only on platforms that support this feature.
A _Complex double is typically treated by the ABI as a struct of two doubles: struct { double real; double imag; }. Therefore, this test is an important validation of the aggregate classification and handling logic for a specific, standardized C type.
The test covers:
c[double] signature is parsed correctly._Complex double arguments to a C function and receiving a _Complex double return value._Complex double signature and verifying that it can be called correctly from C.| #define DBLTAP_IMPLEMENTATION |
| typedef double _Complex complex_double_t |
| complex_double_t c_add | ( | complex_double_t | a, |
| complex_double_t | b | ||
| ) |
| complex_double_t c_mul | ( | complex_double_t | a, |
| complex_double_t | b | ||
| ) |
| complex_double_t callback_c_add | ( | complex_double_t | a, |
| complex_double_t | b | ||
| ) |
| void execute_complex_callback | ( | complex_double_t(*)(complex_double_t, complex_double_t) | func_ptr, |
| complex_double_t | val_a, | ||
| complex_double_t | val_b, | ||
| complex_double_t | expected_val | ||
| ) |
A C harness to call a complex-number callback and verify the result.
| if | ( | ! | okstatus==INFIX_SUCCESS, "Successfully created infix_type for double _Complex" | ) |
| infix_arena_destroy | ( | arena | ) |
| subtest | ( | "Forward call with _Complex arguments and return" | ) |
| subtest | ( | "Reverse call (callback) with _Complex types" | ) |
| subtest | ( | "Round trip signature parsing" | ) |
| infix_arena_t* arena = infix_arena_create(4096) |
| infix_type* complex_double_type = NULL |
| infix_status status |