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/double_tap.h"
#include "common/infix_config.h"
#include "common/infix_internals.h"
#include <infix/infix.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
 

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
}
 

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)
 
 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")
 
 infix_registry_destroy (reg)
 
 done ()
 

Variables

 TEST
 
infix_registry_treg = 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 

Function Documentation

◆ add_points()

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

◆ check_string()

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

◆ done()

done ( )

◆ execute_callback()

static int execute_callback ( IntFunc  func,
int  value 
)
static

◆ get_line_length()

static double get_line_length ( Line  l)
static

◆ infix_registry_destroy()

infix_registry_destroy ( reg  )

◆ mock_c_callback()

static int mock_c_callback ( int  a)
static

◆ mock_marshaller_double()

static infix_direct_value_t mock_marshaller_double ( void *  source_obj)
static

◆ mock_marshaller_func_ptr()

static infix_direct_value_t mock_marshaller_func_ptr ( void *  source_obj)
static

◆ mock_marshaller_int()

static infix_direct_value_t mock_marshaller_int ( void *  source_obj)
static

◆ mock_marshaller_line()

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

◆ mock_marshaller_point()

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

◆ mock_marshaller_string()

static infix_direct_value_t mock_marshaller_string ( void *  source_obj)
static

◆ mock_writeback_int64()

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

◆ mock_writeback_point()

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

◆ move_point()

static 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/8]

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

◆ subtest() [2/8]

subtest ( "Test empty structs"  )

◆ subtest() [3/8]

subtest ( "Test function pointer arguments"  )

◆ subtest() [4/8]

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

◆ subtest() [5/8]

subtest ( "Test mixed types and stack arguments"  )

◆ subtest() [6/8]

subtest ( "Test nested structs"  )

◆ subtest() [7/8]

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

◆ subtest() [8/8]

subtest ( "Test various small integer types"  )

◆ sum_mixed_types()

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

◆ sum_small_ints()

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

◆ takes_empty_struct()

static int takes_empty_struct ( EmptyStruct  es,
int  tag 
)
static

Variable Documentation

◆ reg

◆ TEST

TEST
Initial value:
{
plan(9)
#define plan(count)
Definition double_tap.h:154