Repository navigation
examples/c-interop: the rewritten example, recovered from an unpushed 2026-09-20 branch; to be respelled to the facade surface - #1640
Conversation
258d7d5 to
954255a
Compare
954255a to
459a0d5
Compare
459a0d5 to
012bfd7
Compare
a7998ec to
f970b89
Compare
|
Battery green — stack #1646 (main → #1636 → #1641 → #1630 → #1628 → #1625 → #1645 → #1640), top 3e298d3 on main c18fdfe, pinned seed, cold c_import cache, audits included: Contents: the build-runner unblock (#1636) and the #1635 compiler fix (#1641); 12b's facade gaps (#1630: optional callbacks, Ready to merge: |
3e298d3 to
630dcfa
Compare
…brary and a vendored one) and its README — recovered from the unpushed 2026-09-20 branch c-interop-example (its compiler fixes landed in be767c0, the example did not)
…es, a project-local facade for the vendored tally; zero unsafe in the program The example is respelled to the modeled-C facade surface (ruling §66, spec §16.2b). src/database.w (16 unsafe, the hand-written owning wrapper) is gone: the project carries its own verbatim copy of lib/facades/sqlite3.w as src/facades/sqlite3.w (§16.2b.1: a facade is the importing project's own until the package ships it), and src/main.w and the tests use the rendered surface — Database.open, db.exec(sql, None, None, null), db.prepare, stmt.bind_int, stmt.step, stmt.column_int/column_text as Option[&CStr], db.errcode/errmsg, and FailedWithResource on a failed open with its errmsg still readable. No Drop impls, no raw pointer, no unsafe. src/facades/tally.w is the project-local facade for the vendored library: one contract per header declaration, quoted from tally.h; the by-value tally_widen is a lend. tally has no resource. Three calls stay raw in src/tally.w (4 unsafe, was 5), each named in the facade: tally_range and tally_total take a buffer with an element count, which D64's byte-length pairing does not cover; tally_each is a callback with userdata on a function whose first parameter is not a resource, which the callback contract cannot be stated on. sqlite3_bind_text needs `param 4 fixed SQLITE_TRANSIENT` (D64 fixed arguments, #1624), so the example binds an integer. The README says all of this. build.w links tally once (the c_import link hint, not link_system_lib as well): no duplicate-library warning. Output is unchanged line for line; 12 tests pass over the real libraries.
…yte, pzTail and errmsg are the facade's fixed arguments (D64 §16.2b.11); the facade copy tracks lib/facades/sqlite3.w
…ies to c_import translations only (read from decl_is_c_import — facade facts are collected before ci_syms exists; stage 13's runtime rows render nothing); the contract snapshot records 12b's library-prefix presentation; three debug-alloc z_stream fixtures spell Stream.init; src/InitTemplates.w regenerated from the rewritten guide (tools/gen_init_templates.w moved to std.fs)
630dcfa to
45b6c2a
Compare
Recovered from the local branch
c-interop-example(2026-09-20, never pushed): its compiler fixes landed in be767c0 ("Five defects the c-interop example exposed … the old example removed"), but the rewritten example itself —examples/c-interopas a project over the system sqlite3 and a vendoredtally.c(build.w, src/{main,database,tally}.w, tests, vendor/) — never did, so main has noexamples/c-interopat all.This is the example as written on 09-20, before the facade language (D51 stages 5–13), so it will not pass
:user-programs-safeas-is. The follow-up commit on this layer respells it to the facade surface (use facades.sqlite3; a project-localc facadefor the vendoredtallyper §16.2b.1) with zerounsafe, and the README describes the program that is there. Layer on the modeled-C batch stack (basemodeled-c-uat-rewrite).