Commitf1bfa306Recorded31 Oct 2026Repositorytessera
Register bundled WM input replies and guard linked bindings
Changed
release/prepare-native.mjs | 8 +++++++-
release/sigil-wm-native.c | 8 ++++++++
2 files changed, 15 insertions(+), 1 deletion(-)Diff
release/prepare-native.mjsmodified
@@ -22,7 +22,13 @@ const inventoryBindings = inventoryOriginal.slice(inventoryOriginal.indexOf('
22
if (original.includes('(sigil wm linked)')) throw Error('Use a fresh sigil-wm source archive'); 23
const bindings = original.slice(original.indexOf(' (define native '), original.indexOf(' (define (native-event-text)')) 24
+ original.slice(original.indexOf(' (define submit\n'), original.indexOf(' (define (with-words'));−25
const names = 'native-latency-mark! native-trace-enable! native-trace-dropped native-start! native-options! native-socket-name! native-decoration-default! native-state native-socket native-statistic native-join! event-fd send next event-text submit pixels submit-untraced pixels-untraced inventory-size inventory-copy';+25
const names = 'native-latency-mark! native-trace-enable! native-trace-dropped native-start! native-options! native-socket-name! native-decoration-default! native-state native-socket native-statistic native-join! event-fd send input-reply next event-text submit pixels submit-untraced pixels-untraced inventory-size inventory-copy';+26
// Linked bytecode is removed from the final bundle in favour of this native module.+27
const registrations = new Set([...readFileSync(path.join(source, 'release/sigil-wm-native.c'), 'utf8')+28
.matchAll(/REGISTER\("([^"\n]+)"/g)].map(match => match[1]));+29
for (const name of names.split(' ')) {+30
if (!registrations.has(name)) throw Error('Missing native WM binding: ' + name);+31
} 32
writeFileSync(path.join(wm, 'src/sigil/wm/linked.sgl'), `(define-library (sigil wm linked)\n (import (sigil ffi) (sigil process))\n (export ${names})\n (begin\n${bindings.replace('(or (getenv "SIGIL_WM_LIBRARY") "./build/libsigil-wm.so")', '(getenv "SIGIL_WM_LIBRARY")')}${inventoryBindings}))\n`); 33
writeFileSync(inventoryPath, inventoryOriginal.replace('(import (sigil ffi)', '(import (sigil wm linked) (sigil ffi)') 34
.replace(inventoryOriginal.slice(inventoryOriginal.indexOf(' (define native '), inventoryOriginal.indexOf(' (define (host-output-inventory')), ''));release/sigil-wm-native.cmodified
@@ -112,6 +112,13 @@ static Value send_message(SigilVM *vm, int argc, Value *args) {
112
return sigil_fixnum(wm_send(words)); 113
} 114
+115
static Value input_reply(SigilVM *vm, int argc, Value *args) {+116
(void)argc;+117
PTR_ARG(0, words);+118
INT_ARG(1, kind);+119
return sigil_fixnum(wm_input_reply(words, (int)kind));+120
}+121
122
static Value next_message(SigilVM *vm, int argc, Value *args) { 123
(void)argc; 124
PTR_ARG(0, words);@@ -178,6 +185,7 @@ void sigil__init_tessera_wm(SigilVM *vm) {
185
REGISTER("native-join!", join, 0); 186
REGISTER("event-fd", event_fd, 0); 187
REGISTER("send", send_message, 1);+188
REGISTER("input-reply", input_reply, 2); 189
REGISTER("next", next_message, 1); 190
REGISTER("event-text", event_text, 2); 191
REGISTER("submit", submit_traced, 6);