.TH "bud/cx.h" 3 "bud" \" -*- nroff -*- .ad l .nh .SH NAME bud/cx.h \- Pure-C \fR\&.cx\fP (JSX + component + portable closure) to C11 transpiler API\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBcx_span\fP" .br .RI "Fixed-width source mapping record (20 bytes)\&. " .ti -1c .RI "struct \fBcx_diag\fP" .br .RI "Transpiler diagnostic with 1-based line/column and byte offset\&. " .ti -1c .RI "struct \fBcx_slice\fP" .br .RI "Byte slice \fR[off, off + len)\fP into the original \fR\&.cx\fP source buffer\&. " .ti -1c .RI "struct \fBcx_options\fP" .br .RI "Transpilation options\&. " .ti -1c .RI "struct \fBcx_result\fP" .br .RI "Output of \fR\fBcx_transpile()\fP\fP; release via \fR\fBcx_result_free()\fP\fP\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef enum \fBcx_span_kind\fP \fBcx_span_kind\fP" .br .RI "Semantic kind of a source-mapping span between \fR\&.cx\fP and emitted \fR\&.c\fP\&. " .ti -1c .RI "typedef struct cx_span \fBcx_span\fP" .br .RI "Fixed-width source mapping record (20 bytes)\&. " .ti -1c .RI "typedef struct cx_diag \fBcx_diag\fP" .br .RI "Transpiler diagnostic with 1-based line/column and byte offset\&. " .ti -1c .RI "typedef struct cx_slice \fBcx_slice\fP" .br .RI "Byte slice \fR[off, off + len)\fP into the original \fR\&.cx\fP source buffer\&. " .ti -1c .RI "typedef struct cx_options \fBcx_options\fP" .br .RI "Transpilation options\&. " .ti -1c .RI "typedef struct cx_result \fBcx_result\fP" .br .RI "Output of \fR\fBcx_transpile()\fP\fP; release via \fR\fBcx_result_free()\fP\fP\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBcx_span_kind\fP { \fBCX_SPAN_PASSTHROUGH\fP = 0, \fBCX_SPAN_EXPR\fP = 1, \fBCX_SPAN_TAG\fP = 2, \fBCX_SPAN_COMPONENT\fP = 3, \fBCX_SPAN_ATTR\fP = 4, \fBCX_SPAN_CLOSURE\fP = 5, \fBCX_SPAN_LOOP\fP = 6 }" .br .RI "Semantic kind of a source-mapping span between \fR\&.cx\fP and emitted \fR\&.c\fP\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "int \fBcx_transpile\fP (const \fBcx_options\fP *opt, const char *src, size_t len, \fBcx_result\fP *out)" .br .RI "Transpile \fR\&.cx\fP source text into portable C11 targeting \fR\fBbud_reconcile\&.h\fP\fP\&. " .ti -1c .RI "void \fBcx_result_free\fP (\fBcx_result\fP *res)" .br .RI "Free buffers owned by \fRres\fP and zero the struct\&. " .ti -1c .RI "int \fBcx_write_map_json\fP (const \fBcx_result\fP *res, const char *path)" .br .RI "Write the span table to a JSON file (\fR--map\fP)\&. " .ti -1c .RI "int \fBcx_write_header\fP (const \fBcx_result\fP *res, const char *src, const char *path)" .br .RI "Write a C header declaring props structs and render prototypes for all non-static components in \fRres\fP (requires \fRopt->build_index = 1\fP)\&. " .ti -1c .RI "int \fBcx_map_cx_to_c\fP (const \fBcx_result\fP *res, uint32_t cx_off, uint32_t *out_c_off, uint8_t *out_kind)" .br .RI "Map a byte offset in \fR\&.cx\fP source to the corresponding offset in emitted \fR\&.c\fP\&. " .ti -1c .RI "int \fBcx_map_c_to_cx\fP (const \fBcx_result\fP *res, uint32_t c_off, uint32_t *out_cx_off, uint8_t *out_kind)" .br .RI "Map a byte offset in emitted \fR\&.c\fP back to the corresponding offset in \fR\&.cx\fP\&. " .in -1c .SH "Detailed Description" .PP Pure-C \fR\&.cx\fP (JSX + component + portable closure) to C11 transpiler API\&. Designed as an in-memory library callable from both the \fRcx\fP CLI and \fRcx-lsp\fP with zero external dependencies beyond libc\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBcx_span_kind\fP" .PP Semantic kind of a source-mapping span between \fR\&.cx\fP and emitted \fR\&.c\fP\&. .PP \fBEnumerator\fP .in +1c .TP \f(BICX_SPAN_PASSTHROUGH \fP Verbatim C slice .TP \f(BICX_SPAN_EXPR \fP \fR{expr}\fP interpolation inside JSX .TP \f(BICX_SPAN_TAG \fP Lowercase HTML/native tag name .TP \f(BICX_SPAN_COMPONENT \fP Uppercase component tag name .TP \f(BICX_SPAN_ATTR \fP JSX attribute or prop name .TP \f(BICX_SPAN_CLOSURE \fP Lifted \fR[\&.\&.\&.](\&.\&.\&.) { \&.\&.\&. }\fP closure body .TP \f(BICX_SPAN_LOOP \fP \fR{for (\&.\&.\&.)}\fP or \fR{if (\&.\&.\&.)}\fP control header .SH "Function Documentation" .PP .SS "int cx_map_c_to_cx (const \fBcx_result\fP * res, uint32_t c_off, uint32_t * out_cx_off, uint8_t * out_kind)" .PP Map a byte offset in emitted \fR\&.c\fP back to the corresponding offset in \fR\&.cx\fP\&. .PP \fBReturns\fP .RS 4 1 if mapped, 0 if no span covers \fRc_off\fP\&. .RE .PP .SS "int cx_map_cx_to_c (const \fBcx_result\fP * res, uint32_t cx_off, uint32_t * out_c_off, uint8_t * out_kind)" .PP Map a byte offset in \fR\&.cx\fP source to the corresponding offset in emitted \fR\&.c\fP\&. .PP \fBReturns\fP .RS 4 1 if mapped, 0 if no span covers \fRcx_off\fP\&. .RE .PP .SS "int cx_transpile (const \fBcx_options\fP * opt, const char * src, size_t len, \fBcx_result\fP * out)" .PP Transpile \fR\&.cx\fP source text into portable C11 targeting \fR\fBbud_reconcile\&.h\fP\fP\&. .PP \fBReturns\fP .RS 4 0 on allocation/API success (check \fRout->ok\fP for syntax diagnostics), -1 on OOM/invalid args\&. .RE .PP .SS "int cx_write_header (const \fBcx_result\fP * res, const char * src, const char * path)" .PP Write a C header declaring props structs and render prototypes for all non-static components in \fRres\fP (requires \fRopt->build_index = 1\fP)\&. .PP \fBReturns\fP .RS 4 0 on success, -1 on I/O error\&. .RE .PP .SS "int cx_write_map_json (const \fBcx_result\fP * res, const char * path)" .PP Write the span table to a JSON file (\fR--map\fP)\&. .PP \fBReturns\fP .RS 4 0 on success, -1 on I/O error\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for bud from the source code\&.