-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscode_extension_minimal.affine
More file actions
33 lines (29 loc) · 1.21 KB
/
Copy pathvscode_extension_minimal.affine
File metadata and controls
33 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Minimal demonstration of issue #35 Phase 2 — a VS Code extension
// authored entirely in AffineScript that uses the stdlib/Vscode.affine
// bindings.
//
// Compile via: affinescript compile examples/vscode_extension_minimal.affine -o ext.cjs
// Then point a VS Code extension package.json's "main" field at ext.cjs
// and wire the JS-side adapter (see packages/affine-vscode/README.adoc).
//
// The extension registers a single command ("affinescript.helloAffine")
// that pops up an information message when invoked.
use Vscode::{registerCommand, showInformationMessage, pushSubscription};
// `handler_0` is a no-arg function whose Wasm table index becomes the
// callback bound to the registered command. Phase 3 will replace this
// hand-rolled indirection with proper closure conversion.
pub fn handler_0() -> Int {
let _ = showInformationMessage("Hello from AffineScript!");
return 0;
}
pub fn activate(ctx: ExtensionContext) -> Int {
let d = registerCommand("affinescript.helloAffine", fn(u: Unit) => handler_0());
let _ = pushSubscription(ctx, d);
return 0;
}
pub fn deactivate() -> Int {
return 0;
}