From 0cbb6738ecba8ef6403c7946b8db0be4bf8d2990 Mon Sep 17 00:00:00 2001 From: Istvan Matejcsok <119620946+matejcsok-ee@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:07:09 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20symbol=5Feditor=5Fembind.?= =?UTF-8?q?cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wasm/bindings/symbol_editor_embind.cpp | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 wasm/bindings/symbol_editor_embind.cpp diff --git a/wasm/bindings/symbol_editor_embind.cpp b/wasm/bindings/symbol_editor_embind.cpp new file mode 100644 index 0000000..ecbdf39 --- /dev/null +++ b/wasm/bindings/symbol_editor_embind.cpp @@ -0,0 +1,31 @@ +/* + * Embind bindings for KiCad symbol_editor WASM. + * + * Picked up automatically by scripts/kicad/build-kicad-target.sh when building + * the symbol_editor app (it compiles wasm/bindings/_embind.cpp if present). + * + * The symbol editor is the eeschema kiface launched with + * TOP_FRAME=FRAME_SCH_SYMBOL_EDITOR, so it links the same + * eeschema_kiface_objects as eeschema — including files-io.cpp, whose save + * chokepoint references kicadCollabOnSave. eeschema gets the definition from + * eeschema_embind.cpp; this TU provides it for the symbol_editor link. + * eeschema's other bindings are not pulled in here: they assume a + * SCH_EDIT_FRAME top frame, which this app doesn't have. + */ + +#ifdef __EMSCRIPTEN__ +#include + +// C++ → JS save notification (standalone-hardening save routing). Called from +// the kicad fork's save chokepoints after a successful write to MEMFS, so the +// web app can route the saved bytes onward (API upload, local-disk write-back, +// download). No-op without a JS listener. +extern "C" void kicadCollabOnSave( const char* aPath ) +{ + EM_ASM( { + if( window.kicadCollab && window.kicadCollab.onSave ) + window.kicadCollab.onSave( UTF8ToString( $0 ) ); + }, aPath ); +} + +#endif // __EMSCRIPTEN__