webCppStubContent function
Web-specific C++ impl starter (web/src/Hybrid<Class>.cpp). Inert until it
holds real code — then nitrogen link compiles it for the wasm instead of
the shared src/Hybrid<Class>.cpp. Static-object registration: em++ is
clang, but this form needs no attribute and matches the shared starter.
Implementation
String webCppStubContent({
required String lib,
required String className,
}) =>
'// Hybrid$className — web (WASM) implementation.\n'
'// Generated by nitrogen link. Leave as-is to keep sharing src/Hybrid$className.cpp;\n'
'// fill in the method bodies to give web its own implementation instead.\n'
'// The module is single-threaded: never block, and post async results from\n'
'// emscripten_async_call or a JS callback, not from a std::thread.\n'
'#include "../../lib/src/generated/cpp/$lib.native.g.h"\n'
'\n'
'#include <string>\n'
'\n'
'class Hybrid${className}Impl final : public Hybrid$className {\n'
'public:\n'
' // TODO: implement all pure-virtual methods declared in Hybrid$className\n'
'};\n'
'\n'
'namespace {\n'
' struct _AutoRegister {\n'
' _AutoRegister() { ${lib}_register_impl(new Hybrid${className}Impl()); }\n'
' };\n'
' static _AutoRegister _auto_register_instance;\n'
'}\n';