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

Cookbook Chapter 7: Dynamic Struct Marshalling. More...

#include <infix/infix.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for Ch07_DynamicMarshalling.c:

Classes

struct  UserProfile
 

Functions

static void marshal_ordered_data (void *dest, const char *sig, void **src)
 A generic marshalling function that packs data into a struct.
 
int main ()
 

Detailed Description

Cookbook Chapter 7: Dynamic Struct Marshalling.

This example demonstrates a powerful use of the introspection API: dynamically packing data from an arbitrary source into a C-compatible struct layout at runtime. This is a core task for any language binding or data serialization layer.

The infix_type_from_signature function is used to parse a signature string into a detailed infix_type graph. This graph contains all the size, alignment, and member offset information needed to correctly write data into a C-compatible memory buffer.

Function Documentation

◆ main()

int main ( void  )

◆ marshal_ordered_data()

static void marshal_ordered_data ( void *  dest,
const char *  sig,
void **  src 
)
static

A generic marshalling function that packs data into a struct.

Parameters
destA pointer to the destination C struct buffer.
sigThe infix signature of the destination struct.
srcAn array of void* pointers, where each pointer points to the source data for the corresponding member, in order.