|
infix
A JIT-Powered FFI Library for C
|
Cookbook Chapter 7: Dynamic Struct Marshalling. More...
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 () |
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.
| int main | ( | void | ) |
|
static |
A generic marshalling function that packs data into a struct.
| dest | A pointer to the destination C struct buffer. |
| sig | The infix signature of the destination struct. |
| src | An array of void* pointers, where each pointer points to the source data for the corresponding member, in order. |