a C ABI, so this can be embedded rather than spawned

Every desktop shell that reads typikon today runs the binary and parses
its JSON. That costs about 1.5ms and is the right answer for a calendar
that changes once a day, but it is the wrong shape for anything with an
FFI and no business spawning a process on every redraw.

Dates cross as Julian Day Numbers, so no struct layout is part of the
contract. A day is opaque and owns its strings, built once when it is
reckoned: an accessor returns the same borrowed pointer every time, so a
statusline polling one in a loop allocates nothing. The accessors carry
every field of the JSON, so nothing on the other side needs a parser.

The Python bindings and this were resolving a jurisdiction by two copies
of the same logic, and the copy here leaked one per call. Both now share
jurisdictions::resolve_full, which interns the combinations instead.

The header is a promise made in a second file, and a second file drifts:
a test reads both and fails if either has a symbol the other does not,
and does the same for the LuaJIT cdef, where a stale declaration is a
segfault rather than a compile error.
This commit is contained in:
funkpower
2026-09-18 14:46:25 -04:00
parent 452d7fc0a1
commit d90d4c171f
14 changed files with 1523 additions and 98 deletions
+17 -1
View File
@@ -46,9 +46,25 @@ jobs:
# The binding code only exists under the feature, so a bare clippy
# run never looks at src/python.rs.
cargo clippy --features python --all-targets -- -D warnings
cargo clippy --features capi --all-targets -- -D warnings
- name: Rust tests
run: cargo test
run: |
cargo test
cargo test --features capi
# The header and the LuaJIT cdef are checked against the library by the
# Rust tests; this checks that a C compiler agrees, which they cannot.
- name: C ABI
run: |
apt-get update && apt-get install -y --no-install-recommends gcc luajit
cargo build --release --features capi
cc -Wall -Wextra -Werror -Iinclude examples/c/demo.c \
-Ltarget/release -ltypikon -o /tmp/demo
LD_LIBRARY_PATH=target/release /tmp/demo rocor
LD_LIBRARY_PATH=target/release /tmp/demo --list
TYPIKON_LIB=target/release/libtypikon.so \
luajit examples/lua/statusline.lua rocor
# The CLI and the bindings are the same engine, so they have to agree. This
# is the check that caught the bindings resolving their own default