.TH "bud/bud_reconcile.h" 3 "bud" \" -*- nroff -*- .ad l .nh .SH NAME bud/bud_reconcile.h \- Host-agnostic reactive VDOM reconciler, hooks, and component runtime\&. .SH SYNOPSIS .br .PP \fR#include 'bud\&.h'\fP .br \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBbud_host_ops\fP" .br .RI "Host realization vtable (DOM, liblamina, or custom renderer)\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBbud_use_state\fP(T, init_val)" .br .RI "Typed state hook macro: \fRint *count = \fBbud_use_state(int, 0)\fP;\fP\&. " .ti -1c .RI "#define \fBbud_set\fP(ptr, next_val)" .br .RI "Typed state setter macro: \fR\fBbud_set\fP(count, *count + 1);\fP\&. " .ti -1c .RI "#define \fBbud_use_ref\fP(T, init_val)" .br .RI "Typed ref hook macro: \fRint *r = \fBbud_use_ref(int, 0)\fP;\fP\&. " .ti -1c .RI "#define \fBbud_comp\fP(fn, props_type, \&.\&.\&.)" .br .RI "Convenience constructor for a keyed or unkeyed component VNode\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct \fBbud_mount\fP \fBbud_mount\fP" .br .RI "Opaque mounted reconciler instance\&. " .ti -1c .RI "typedef void(* \fBbud_effect_cleanup_fn\fP) (void *user)" .br .RI "Cleanup callback returned by a \fBbud_effect_fn\fP\&. " .ti -1c .RI "typedef \fBbud_effect_cleanup_fn\fP(* \fBbud_effect_fn\fP) (void *user)" .br .RI "Post-commit effect callback; may return an optional cleanup callback\&. " .ti -1c .RI "typedef struct bud_host_ops \fBbud_host_ops\fP" .br .RI "Host realization vtable (DOM, liblamina, or custom renderer)\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBbud_mount\fP * \fBbud_mount_new\fP (const \fBbud_host_ops\fP *ops, void *host_ctx, void *root_host)" .br .RI "Create a new reconciler mount targeting root_host\&. " .ti -1c .RI "int \fBbud_mount_update\fP (\fBbud_mount\fP *mount, const \fBbud_node\fP *root_vnode)" .br .RI "Reconcile root_vnode into the mount and run post-commit effects\&. " .ti -1c .RI "int \fBbud_mount_flush\fP (\fBbud_mount\fP *mount)" .br .RI "Re-render only dirty component subtrees (sorted parent-first) and run effects\&. " .ti -1c .RI "int \fBbud_mount_is_dirty\fP (const \fBbud_mount\fP *mount)" .br .RI "Non-zero when at least one mounted component cell is dirty\&. " .ti -1c .RI "void * \fBbud_mount_root_host\fP (const \fBbud_mount\fP *mount)" .br .RI "Return the root host container handle passed to bud_mount_new\&. " .ti -1c .RI "void \fBbud_mount_unmount\fP (\fBbud_mount\fP *mount)" .br .RI "Unmount all cells (invoking effect cleanups and destroying host nodes)\&. " .ti -1c .RI "void \fBbud_mount_free\fP (\fBbud_mount\fP *mount)" .br .RI "Unmount and free the \fBbud_mount\fP handle\&. " .ti -1c .RI "void * \fBbud_use_state_raw\fP (size_t size, const void *init)" .br .RI "Allocate or retrieve stable state storage for the current component cell\&. " .ti -1c .RI "int \fBbud_set_state_raw\fP (void *state_ptr, const void *next_val, size_t size)" .br .RI "Update state value obtained from bud_use_state_raw and mark owner dirty\&. " .ti -1c .RI "void * \fBbud_use_ref_raw\fP (size_t size, const void *init)" .br .RI "Allocate or retrieve stable mutable ref storage (mutations do not re-render)\&. " .ti -1c .RI "void \fBbud_use_effect\fP (\fBbud_effect_fn\fP fn, void *user, const void *deps, size_t deps_size)" .br .RI "Schedule a post-commit effect with optional byte-compared dependency snapshot\&. " .in -1c .SS "Variables" .in +1c .ti -1c .RI "const char \fBbud_deps_always_sentinel\fP" .br .RI "Sentinel deps pointer meaning run effect after every commit\&. " .in -1c .SH "Detailed Description" .PP Host-agnostic reactive VDOM reconciler, hooks, and component runtime\&. Reconciles \fBbud_node\fP trees (including lazy BUD_NODE_COMPONENT nodes) into any concrete UI host implementing \fBbud_host_ops\fP (browser DOM via WASM, native desktop / WebGL via liblamina, or test mocks)\&. Pure C, zero host deps\&. .SH "Typedef Documentation" .PP .SS "typedef struct bud_host_ops bud_host_ops" .PP Host realization vtable (DOM, liblamina, or custom renderer)\&. Ownership contract: .IP "\(bu" 2 insert_before inserts or moves child before \fRbefore\fP (or appends if NULL) without destroying child\&. .IP "\(bu" 2 remove_child detaches child from parent without freeing it\&. .IP "\(bu" 2 destroy_node frees a detached host node and any host-side metadata\&. .IP "\(bu" 2 clear_children (optional) destroys all children of parent in O(1) when no mounted subtree holds active effect cleanups\&. .PP .SH "Function Documentation" .PP .SS "int bud_mount_flush (\fBbud_mount\fP * mount)" .PP Re-render only dirty component subtrees (sorted parent-first) and run effects\&. .PP \fBParameters\fP .RS 4 \fImount\fP Target mount\&. .RE .PP \fBReturns\fP .RS 4 Number of component cells re-rendered, or -1 on error\&. .RE .PP .SS "\fBbud_mount\fP * bud_mount_new (const \fBbud_host_ops\fP * ops, void * host_ctx, void * root_host)" .PP Create a new reconciler mount targeting root_host\&. .PP \fBParameters\fP .RS 4 \fIops\fP Host vtable (copied internally; must remain valid functions)\&. .br \fIhost_ctx\fP Opaque context forwarded to every host callback\&. .br \fIroot_host\fP Concrete root container handle in the host\&. .RE .PP \fBReturns\fP .RS 4 Mounted reconciler handle, or NULL on allocation failure\&. .RE .PP .SS "int bud_mount_update (\fBbud_mount\fP * mount, const \fBbud_node\fP * root_vnode)" .PP Reconcile root_vnode into the mount and run post-commit effects\&. Borrows root_vnode (caller retains ownership and may free or SSR-render it)\&. Pass NULL to unmount all children from root_host\&. .PP \fBParameters\fP .RS 4 \fImount\fP Target mount\&. .br \fIroot_vnode\fP Root virtual node tree (or NULL to clear)\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on error\&. .RE .PP .SS "int bud_set_state_raw (void * state_ptr, const void * next_val, size_t size)" .PP Update state value obtained from bud_use_state_raw and mark owner dirty\&. Performs byte-level equality bailout: if the value is unchanged, the owning component cell is not marked dirty\&. .PP \fBParameters\fP .RS 4 \fIstate_ptr\fP Stable pointer previously returned by bud_use_state_raw\&. .br \fInext_val\fP Pointer to new value bytes\&. .br \fIsize\fP Byte size of value (must match state slot size)\&. .RE .PP \fBReturns\fP .RS 4 1 if state changed and owner was dirtied, 0 if unchanged, -1 on error\&. .RE .PP .SS "void bud_use_effect (\fBbud_effect_fn\fP fn, void * user, const void * deps, size_t deps_size)" .PP Schedule a post-commit effect with optional byte-compared dependency snapshot\&. .PP \fBParameters\fP .RS 4 \fIfn\fP Effect callback invoked after commit; may return cleanup fn\&. .br \fIuser\fP User pointer passed to fn (and to its returned cleanup fn)\&. .br \fIdeps\fP Pointer to dependency struct/value, NULL (once on mount), or BUD_DEPS_ALWAYS\&. .br \fIdeps_size\fP Byte size of deps (0 when deps is NULL)\&. .RE .PP .SS "void * bud_use_state_raw (size_t size, const void * init)" .PP Allocate or retrieve stable state storage for the current component cell\&. .PP \fBParameters\fP .RS 4 \fIsize\fP Byte size of the state value\&. .br \fIinit\fP Pointer to initial value bytes (or NULL for zero-init)\&. .RE .PP \fBReturns\fP .RS 4 Stable pointer to the state payload (valid until component unmounts)\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for bud from the source code\&.