infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
501_direct_marshalling.c File Reference

Test suite for the high-performance direct marshalling API. More...

#include "common/compat_c23.h"
#include "common/double_tap.h"
#include "common/infix_config.h"
#include "common/infix_internals.h"
#include <infix/infix.h>
#include <math.h>
#include <string.h>
Include dependency graph for 501_direct_marshalling.c:

Classes

struct  Point
 A simple struct with two doubles, often used to test pass-by-value on registers. More...
struct  Line
struct  EmptyStruct
struct  MockObject
struct  AM_U16x4
struct  AM_U8x4

Macros

#define DBLTAP_IMPLEMENTATION

Typedefs

typedef int(* IntFunc) (int)
typedef struct MockObject MockObject

Enumerations

enum  MockObjectType {
  MOCK_TYPE_INT , MOCK_TYPE_DOUBLE , MOCK_TYPE_FLOAT , MOCK_TYPE_POINT ,
  MOCK_TYPE_STRING , MOCK_TYPE_LINE , MOCK_TYPE_FUNC , MOCK_TYPE_VECTOR
}

Functions

static Point add_points (Point p1, Point p2, int dummy_arg)
static void move_point (Point *p, int32_t dx, int32_t dy)
static double sum_mixed_types (double a, int b, float c, int d, double e, int f, float g)
static const char * check_string (const char *s, int64_t *out_len)
static int64_t sum_small_ints (unsigned char uc, short ss, uint32_t ui, int64_t ll)
static double get_line_length (Line l)
static int takes_empty_struct (EmptyStruct es, int tag)
static int execute_callback (IntFunc func, int value)
static infix_direct_value_t mock_marshaller_int (void *source_obj)
static infix_direct_value_t mock_marshaller_double (void *source_obj)
static infix_direct_value_t mock_marshaller_string (void *source_obj)
static void mock_marshaller_point (void *source_obj, void *dest_buffer, const infix_type *type)
static void mock_writeback_point (void *source_obj, void *c_data_ptr, const infix_type *type)
static void mock_writeback_int64 (void *source_obj, void *c_data_ptr, const infix_type *type)
static void mock_marshaller_line (void *source_obj, void *dest_buffer, const infix_type *type)
static infix_direct_value_t mock_marshaller_func_ptr (void *source_obj)
static int mock_c_callback (int a)
static int am_sum_u16 (AM_U16x4 s)
static int am_sum_u8 (AM_U8x4 s)
static void mock_marshaller_raw (void *source_obj, void *dest_buffer, const infix_type *type)
 ok (infix_register_types(reg, "@Point = { x: double, y: double };" "@Line = { start: @Point, end: @Point };" "@Empty = {};" "@IntFunc = (int)->int;")==INFIX_SUCCESS, "Successfully registered all test types")
 subtest ("Test struct-by-value with add_points")
 subtest ("Test in-out pointer with move_point")
 subtest ("Test mixed types and stack arguments")
 subtest ("Test C strings and pointer out-parameters")
 subtest ("Test various small integer types")
 subtest ("Test nested structs")
 subtest ("Test empty structs")
 subtest ("Test function pointer arguments")
 subtest ("Test SIMD vectors with direct marshalling")
 subtest ("Test trailing-member aggregate arg (fuzzer struct_array_member shapes)")
 infix_registry_destroy (reg)
 done ()

Variables

 TEST
infix_registry_t * reg = infix_registry_create()

Detailed Description

Test suite for the high-performance direct marshalling API.

This test acts as a "mock" language binding to validate the direct marshalling feature. It defines its own simple object system (MockObject) and provides marshaller/write-back handlers to convert between these mock objects and native C types.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Typedef Documentation

◆ IntFunc

typedef int(* IntFunc) (int)

◆ MockObject

typedef struct MockObject MockObject

Enumeration Type Documentation

◆ MockObjectType

Enumerator
MOCK_TYPE_INT 
MOCK_TYPE_DOUBLE 
MOCK_TYPE_FLOAT 
MOCK_TYPE_POINT 
MOCK_TYPE_STRING 
MOCK_TYPE_LINE 
MOCK_TYPE_FUNC 
MOCK_TYPE_VECTOR 

Function Documentation

◆ add_points()

Point add_points ( Point p1,
Point p2,
int dummy_arg )
static

◆ am_sum_u16()

int am_sum_u16 ( AM_U16x4 s)
static

◆ am_sum_u8()

int am_sum_u8 ( AM_U8x4 s)
static

◆ check_string()

const char * check_string ( const char * s,
int64_t * out_len )
static

◆ done()

done ( )

◆ execute_callback()

int execute_callback ( IntFunc func,
int value )
static

◆ get_line_length()

double get_line_length ( Line l)
static

◆ infix_registry_destroy()

infix_registry_destroy ( reg )

◆ mock_c_callback()

int mock_c_callback ( int a)
static

◆ mock_marshaller_double()

infix_direct_value_t mock_marshaller_double ( void * source_obj)
static

◆ mock_marshaller_func_ptr()

infix_direct_value_t mock_marshaller_func_ptr ( void * source_obj)
static

◆ mock_marshaller_int()

infix_direct_value_t mock_marshaller_int ( void * source_obj)
static

◆ mock_marshaller_line()

void mock_marshaller_line ( void * source_obj,
void * dest_buffer,
const infix_type * type )
static

◆ mock_marshaller_point()

void mock_marshaller_point ( void * source_obj,
void * dest_buffer,
const infix_type * type )
static

◆ mock_marshaller_raw()

void mock_marshaller_raw ( void * source_obj,
void * dest_buffer,
const infix_type * type )
static

◆ mock_marshaller_string()

infix_direct_value_t mock_marshaller_string ( void * source_obj)
static

◆ mock_writeback_int64()

void mock_writeback_int64 ( void * source_obj,
void * c_data_ptr,
const infix_type * type )
static

◆ mock_writeback_point()

void mock_writeback_point ( void * source_obj,
void * c_data_ptr,
const infix_type * type )
static

◆ move_point()

void move_point ( Point * p,
int32_t dx,
int32_t dy )
static

◆ ok()

ok ( infix_register_types(reg, "@Point = { x: double, y: double };" "@Line = { start: @Point, end: @Point };" "@Empty = {};" "@IntFunc = (int)->int;") = =INFIX_SUCCESS,
"Successfully registered all test types"  )

◆ subtest() [1/10]

subtest ( "Test C strings and pointer out-parameters" )

◆ subtest() [2/10]

subtest ( "Test empty structs" )

◆ subtest() [3/10]

subtest ( "Test function pointer arguments" )

◆ subtest() [4/10]

subtest ( "Test in-out pointer with move_point" )

◆ subtest() [5/10]

subtest ( "Test mixed types and stack arguments" )

◆ subtest() [6/10]

subtest ( "Test nested structs" )

◆ subtest() [7/10]

subtest ( "Test SIMD vectors with direct marshalling" )

◆ subtest() [8/10]

subtest ( "Test struct-by-value with add_points" )

◆ subtest() [9/10]

subtest ( "Test trailing-member aggregate arg (fuzzer struct_array_member shapes)" )

◆ subtest() [10/10]

subtest ( "Test various small integer types" )

◆ sum_mixed_types()

double sum_mixed_types ( double a,
int b,
float c,
int d,
double e,
int f,
float g )
static

◆ sum_small_ints()

int64_t sum_small_ints ( unsigned char uc,
short ss,
uint32_t ui,
int64_t ll )
static

◆ takes_empty_struct()

int takes_empty_struct ( EmptyStruct es,
int tag )
static

Variable Documentation

◆ reg

◆ TEST

TEST
Initial value:
{
plan(11)
#define plan(count)
Definition double_tap.h:192