Done. The basic XPCE canvas library works end to end — both demo exes open a Cosmos Space window, run their event loops, and draw with zero errors.
| File | Role |
|---|---|
libs/space_xpce_prolog.pl |
Raw Prolog backend: window, retained-object drawing (rect/circle/ellipse/arc/line/polygon/text), Prolog-side transform stack, scanline polygon fill, fonts, images, timer loop |
libs/space.co (+ compiled .pl/.cif) |
The Cosmos side of the library: one rel per method, each calling a pl::space_xpce_* predicate, exported as the sp table. It used to be split over space.co (a forwarding layer) and space_xpce.co (the wrapper); the two are now one file. |
misc/simple_xpce.co, misc/demo_space_xpce.co |
Test apps; both built to .exe and verified with live windows |
XPCE_BACKEND.md |
Full notes incl. every XPCE quirk found by probing |
Supporting fixes in compiler/platform/driver.pl + compiler/swi.pl: absolute lib templates recorded at build time, abolish_all_tables + non-tabled loader in exe entries (fixes standalone runs), XPCE DLL staging next to GUI exes.
- Process:
.co→cli.plcompiles to.pl→--mainappendscosmos_entry_main→--exerunsqsave_program. Nothing XPCE-specific except DLL staging below. - DLLs: yes, staged automatically. I dumped the PE import tables (
pl2xpce→ SDL3/cairo/pango/glib/fontconfig/freetype +libswipl.dll, 29 files) and the build copies that closure next to Space exes. Console exes are unaffected. - Built-in utility: only
qsave_program. Two gotchas found empirically: a saved image containinglibrary(pce)never starts (backend loads at runtime instead), and XPCE needs no stub emulator — defaultstand_aloneexe + DLLs beside it works.
Scissor is recorded-not-enforced; line style is remembered but XPCE has no rough/smooth switch; one rel per table name (no overloading); require must stay inside rels for --main programs; value-position calls need the out-param last (e.g. newFont(size,family,style,font)).
Keyboard polling and key releases are no longer stubs: XPCE 10.0.0 exposes the
keyboard as the input device @keyboard_device, and get(@keyboard_device, key_down, Key, @on) answers whether a key is held down right now. Key
releases arrive as the key_up event, which sits under any in
@event_tree rather than under keyboard/.
- Smoke test drew every primitive clean; both exes run with empty stderr.
node --test tests/compiler/compiler.test.mjs: 22 pass, 7 fail — I confirmed viagit stashthat all 7 fail identically on the pristine tree (missing WASM bundle,--exeAV under node spawn, v2/trace/query drift on SWI 10), so no regressions from these changes.
& 'C:\Program Files\swipl\bin\swipl.exe' -q -s D:\Computer\Documents\cosmos\compiler\platform\cli.pl -- D:\Computer\Documents\cosmos\misc\simple_xpce.co D:\Computer\Documents\cosmos\misc\simple_xpce.pl --main --exe 2>&1; echo SIMPLE:$?; & 'C:\Program Files\swipl\bin\swipl.exe' -q -s D:\Computer\Documents\cosmos\compiler\platform\cli.pl -- D:\Computer\Documents\cosmos\misc\demo_space_xpce.co D:\Computer\Documents\cosmos\misc\demo_space_xpce.pl --main --exe 2>&1; echo DEMO:$?