Commit 1f40fc6
feat(vscode): function-value callback ABI — registerCommand/onDidSave/withProgress (Refs #199)
#199 PR-5a (owner chose the function-value ABI). Replaces the brittle
wasm-table-index `handler: Int` convention with real function values.
ABI shape: `handler: fn(Unit) -> R` (not `fn() -> R`). AffineScript
types a zero-param function as its bare return type (typecheck.ml:752),
so `fn() -> Int` collapses to `Int`; the explicit `Unit` param is the
honest callback shape and needs zero compiler change (verified).
- stdlib/Vscode.affine: registerCommand / onDidSaveTextDocument /
withProgressNotification handler params Int -> fn(Unit) -> R. Also
removes the duplicate `extern type Thenable;` introduced in #198
(line 43 already declares it) — resolved at source.
- examples/vscode_extension_minimal.affine + editors/vscode/src/
extension.affine: call sites migrated from numbered indices to
`fn(u: Unit) => handler_x()` lambdas (behaviour-preserving; named
handlers unchanged).
Verified: stdlib/example/editors all typecheck; dune test 253/253
(the prior Examples-parse regression was my own `_u` typo — leading-
underscore idents parse-error in params, a separate minor lexer
observation; used `u`). Deno-ESM emits
`registerCommand("…", ((u) => handler_0()))` — a real JS arrow passed
directly, so the Deno fn-value extern path (PR-5b) needs no codegen
change. Wasm/mod.js marshalling (PR-5c) and the rsr-certifier pilot
(PR-5d) follow.
Refs #199
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 42e6e2b commit 1f40fc6
3 files changed
Lines changed: 22 additions & 19 deletions
File tree
- editors/vscode/src
- examples
- stdlib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
266 | | - | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
298 | | - | |
| 300 | + | |
| 301 | + | |
299 | 302 | | |
300 | 303 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
0 commit comments