NAME
bud/cx.h - Pure-C .cx (JSX + component + portable closure) to C11 transpiler API.
SYNOPSIS
#include <stddef.h>
#include <stdint.h>
Data Structures
Fixed-width source mapping record (20 bytes).
Transpiler diagnostic with 1-based line/column and byte offset.
Byte slice [off, off + len) into the original .cx source buffer.
Transpilation options.
Output of cx_transpile(); release via cx_result_free().
Typedefs
Semantic kind of a source-mapping span between .cx and emitted .c.
Fixed-width source mapping record (20 bytes).
Transpiler diagnostic with 1-based line/column and byte offset.
Byte slice [off, off + len) into the original .cx source buffer.
Transpilation options.
Output of cx_transpile(); release via cx_result_free().
Enumerations
Semantic kind of a source-mapping span between .cx and emitted .c.
Functions
Transpile .cx source text into portable C11 targeting bud_reconcile.h.
Free buffers owned by res and zero the struct.
Write the span table to a JSON file (--map).
Write a C header declaring props structs and render prototypes for all non-static components in res (requires opt->build_index = 1).
Map a byte offset in .cx source to the corresponding offset in emitted .c.
Map a byte offset in emitted .c back to the corresponding offset in .cx.
Detailed Description
Pure-C .cx (JSX + component + portable closure) to C11 transpiler API.
Designed as an in-memory library callable from both the cx CLI and cx-lsp with zero external dependencies beyond libc.
Enumeration Type Documentation
enum cx_span_kind
Semantic kind of a source-mapping span between .cx and emitted .c.
Enumerator
- CX_SPAN_PASSTHROUGH
- Verbatim C slice
- CX_SPAN_EXPR
- {expr} interpolation inside JSX
- CX_SPAN_TAG
- Lowercase HTML/native tag name
- CX_SPAN_COMPONENT
- Uppercase component tag name
- CX_SPAN_ATTR
- JSX attribute or prop name
- CX_SPAN_CLOSURE
- Lifted [...](...) { ... } closure body
- CX_SPAN_LOOP
- {for (...)} or {if (...)} control header
Function Documentation
int cx_map_c_to_cx (const cx_result * res, uint32_t c_off, uint32_t * out_cx_off, uint8_t * out_kind)
Map a byte offset in emitted .c back to the corresponding offset in .cx.
Returns
1 if mapped, 0 if no span covers c_off.
int cx_map_cx_to_c (const cx_result * res, uint32_t cx_off, uint32_t * out_c_off, uint8_t * out_kind)
Map a byte offset in .cx source to the corresponding offset in emitted .c.
Returns
1 if mapped, 0 if no span covers cx_off.
int cx_transpile (const cx_options * opt, const char * src, size_t len, cx_result * out)
Transpile .cx source text into portable C11 targeting bud_reconcile.h.
Returns
0 on allocation/API success (check out->ok for syntax diagnostics), -1 on OOM/invalid args.
int cx_write_header (const cx_result * res, const char * src, const char * path)
Write a C header declaring props structs and render prototypes for all non-static components in res (requires opt->build_index = 1).
Returns
0 on success, -1 on I/O error.
int cx_write_map_json (const cx_result * res, const char * path)
Write the span table to a JSON file (--map).
Returns
0 on success, -1 on I/O error.
Author
Generated automatically by Doxygen for bud from the source code.