bud/cx.h(3)bud

NAME

bud/cx.h - Pure-C .cx (JSX + component + portable closure) to C11 transpiler API.

SYNOPSIS

#include <stddef.h>
#include <stdint.h>

Data Structures

struct cx_span

Fixed-width source mapping record (20 bytes).

struct cx_diag

Transpiler diagnostic with 1-based line/column and byte offset.

struct cx_slice

Byte slice [off, off + len) into the original .cx source buffer.

struct cx_options

Transpilation options.

struct cx_result

Output of cx_transpile(); release via cx_result_free().

Typedefs

typedef enum cx_span_kind cx_span_kind

Semantic kind of a source-mapping span between .cx and emitted .c.

typedef struct cx_span cx_span

Fixed-width source mapping record (20 bytes).

typedef struct cx_diag cx_diag

Transpiler diagnostic with 1-based line/column and byte offset.

typedef struct cx_slice cx_slice

Byte slice [off, off + len) into the original .cx source buffer.

typedef struct cx_options cx_options

Transpilation options.

typedef struct cx_result cx_result

Output of cx_transpile(); release via cx_result_free().

Enumerations

enum cx_span_kind { CX_SPAN_PASSTHROUGH = 0, CX_SPAN_EXPR = 1, CX_SPAN_TAG = 2, CX_SPAN_COMPONENT = 3, CX_SPAN_ATTR = 4, CX_SPAN_CLOSURE = 5, CX_SPAN_LOOP = 6 }

Semantic kind of a source-mapping span between .cx and emitted .c.

Functions

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.

void cx_result_free (cx_result *res)

Free buffers owned by res and zero the struct.

int cx_write_map_json (const cx_result *res, const char *path)

Write the span table to a JSON file (--map).

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).

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.

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.

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.