Files
zeekay ed429a2283 rename capnp/capnpc → zap/zapc — ZAP-native runtime, no Cap'n Proto
Cap'n Proto was the canonical name for this Rust implementation. The
ZAP rebrand had only been applied as a directory rename so far —
crate names, schema file extensions, import paths, and binaries all
still said `capnp` / `capnpc`. This commit makes the rebrand real.

Workspace renames:
- crate capnp/  → zap/  (name = "zap")
- crate capnpc/ → zapc/ (name = "zapc")
- crate capnp-futures/ → zap-futures/
- crate capnp-rpc/     → zap-rpc/

Source-file renames:
- *_capnp.rs → *_zap.rs (~12 files: schema_zap.rs, rpc_zap.rs, etc.)
- capnpc-rust.rs → zapc-rust.rs (the codegen binary entry point)
- *.capnp → *.zap (33 schema files)

Identifier renames across the workspace (96 files rewritten):
- `use capnp::`             → `use zap::`
- `extern crate capnp`      → `extern crate zap`
- `capnp::generated_code!`  → `zap::generated_code!`
- `capnp::traits::Owned`    → `zap::traits::Owned`
- `capnp::message::...`     → `zap::message::...`
- `capnp::Error/Result`     → `zap::Error/Result`
- `capnp::Word`             → `zap::Word`
- `capnp::primitive_list`   → `zap::primitive_list`
- `capnp::any_pointer`      → `zap::any_pointer`
- (etc. — see python script in commit history for full list)

Cargo.toml dep keys:
- `capnp = { path = ... }`  → `zap = { path = ... }`
- `[dependencies.capnp]`     → `[dependencies.zap]`
- `capnpc = { ... }`        → `zapc = { ... }`
- Per-crate name= field and bin = "capnpc-rust" → "zapc"

Schema header strip:
- `using Cxx = import "/capnp/c++.capnp";` lines removed (C++ binding
  hints; Rust output doesn't need them, and they referenced a system
  /usr/include path we don't ship)
- `$Cxx.namespace("capnp::...")` annotations removed

Build-time decoupling for the benchmark:
- Pre-generated `carsales_zap.rs`, `catrank_zap.rs`, `eval_zap.rs` are
  now committed in benchmark/. benchmark/build.rs just copies them
  into OUT_DIR instead of invoking the schema compiler at build time.
- benchmark/Cargo.toml drops the [build-dependencies] zapc entry.
  Building the benchmark needs ONLY the `zap` runtime crate; no
  schema-compiler binary, no plugin, no shell-out.

To regenerate the schema-bound .rs from .zap (developer-only step):
  cargo build --release --bin zapc
  ln -sf zapc target/release/capnpc-rust  # plugin discovery name
  cd benchmark && PATH=../target/release:$PATH \
    capnp compile -orust eval.zap catrank.zap carsales.zap

The `capnp` tool here is the upstream C++ schema-text parser — only
used as a parser frontend at codegen time, never linked into the
benchmark binary. Runtime + build = 100% zap/zapc only.

Verified by:
  cargo tree -p benchmark --release  →  no capnp dep
  grep -rE 'capnp|Capnp|CAPNP' .     →  0 hits in active source
  cargo build -p benchmark --release →  clean build, no system tool
  bash ./benchmark/bench.sh quick    →  runs end-to-end

Other workspace members (fill_random_values, addressbook,
wasm-hello-world, capnpc/test fixtures) still use build.rs schema
compilation at build time; they require a `zap` binary in PATH.
That's pre-existing — the upstream Cap'n Proto Rust workspace had the
same requirement against the `capnp` binary. Out of scope for this PR.
2026-05-27 12:36:19 -07:00

69 lines
1.6 KiB
Plaintext

@0xca7ae4b25d718dfc;
using Fill = import "fill.zap";
const palette: List(Color) = [
(red = 0x22, green = 0xd7, blue = 0xb5),
(red = 0x11, green = 0xb1, blue = 0x86),
(red = 0x7c, green = 0xa4, blue = 0xf5),
(red = 0xe7, green = 0x60, blue = 0x1d),
(red = 0x25, green = 0x23, blue = 0x25),
(red = 0x89, green = 0x74, blue = 0x59),
];
# Try adding this annotation to the Color fields below:
# $Fill.SelectFrom(List(Color)).choices(.palette);
struct Color {
red @0 : UInt8;
green @1 : UInt8;
blue @2 : UInt8;
}
struct Point {
# A point in normalized coordinates. (0,0) is the upper-left of
# the current subcanvas, and (1,1) is the lower-right of the current
# subcanvas.
x @0 : Float64;
y @1 : Float64;
}
struct Line {
start @0 : Point;
end @1 : Point;
thickness @2 : Float64 $Fill.float64Range((min = 0.01, max = 0.95));
# Stroke width, as a percent of the current subcanvas's diagonal length.
color @3 : Color;
}
struct Circle {
center @0 : Point;
# The center of the circle.
radius @1 : Float64 $Fill.float64Range((min = 0.01, max = 0.25));
# The radius of the circle, as a proportion of the current
# subcanvas's diagonal length.
fillColor @2 : Color;
}
struct Subcanvas {
# A canvas contained in a larger canvas.
center @0 : Point;
width @1 : Float64;
height @2 : Float64;
canvas @3 : Canvas;
}
struct Canvas {
# A canvas containing some geometric elements.
backgroundColor @0 : Color;
lines @1 : List(Line) $Fill.lengthRange((max = 5));
circles @2 : List(Circle) $Fill.lengthRange((max = 5));
subcanvases @3 : List(Subcanvas) $Fill.lengthRange((max = 3));
}