|
infix
A JIT-Powered FFI Library for C
|
Cookbook Chapter 3: Creating a Stateful Callback. More...
Classes | |
| struct | AppContext |
Typedefs | |
| typedef void(* | item_processor_t) (int) |
Functions | |
| static void | my_stateful_handler (infix_context_t *context, void *ret, void **args) |
| static void | process_list (const int *items, int count, item_processor_t process_func) |
| int | main () |
Cookbook Chapter 3: Creating a Stateful Callback.
This example demonstrates how to create a "closure" or stateful callback. This is essential when a C library's callback mechanism does not provide a void* user_data parameter, but your handler still needs access to application state.
infix_reverse_create_closure is used for this. It takes a generic handler function and a void* pointer to your state, which can be retrieved inside the handler.
| typedef void(* item_processor_t) (int) |
| int main | ( | void | ) |
|
static |
|
static |