webCppSeededContent function

String webCppSeededContent({
  1. required String lib,
  2. required String className,
  3. required String implClass,
  4. required String starterBody,
})

web/src/Hybrid<Class>.cpp seeded from the generator's interface-complete starter (<lib>.impl.g.cpp). starterBody is that file from its ownership conventions onward — its quick-start (CMakeLists, plugin-init registration) does not apply to a wasm module, so the header here replaces it. The shared-impl marker line keeps web on src/ until the author deletes it.

Implementation

String webCppSeededContent({
  required String lib,
  required String className,
  required String implClass,
  required String starterBody,
}) =>
    '// Hybrid$className — web (WASM) implementation. Seeded once by nitrogen link\n'
    '// from lib/src/generated/cpp/$lib.impl.g.cpp; never overwritten.\n'
    '//\n'
    '// TODO: implement all pure-virtual methods declared in Hybrid$className\n'
    '//   While the line above exists, web keeps compiling the shared\n'
    '//   src/Hybrid$className.cpp. Implement the methods, delete that line, and\n'
    '//   re-run `nitrogen link` to build the module from this file instead.\n'
    '//   The module is single-threaded: never block; post async results from\n'
    '//   emscripten_async_call or a JS callback, not from a std::thread.\n'
    '//\n'
    '$starterBody'
    '\n'
    '// Registered when the wasm module instantiates.\n'
    'namespace {\n'
    '  struct _AutoRegister {\n'
    '    _AutoRegister() { ${lib}_register_impl(new $implClass()); }\n'
    '  };\n'
    '  static _AutoRegister _auto_register_instance;\n'
    '}\n';