Category : emscripten

I am looking to compile some C++ code that makes heavy usage of exceptions into a wasm target. Unfortunately, most browsers don’t have Webassembly Exception Handling turned on (I believe only Chrome supports it behind a flag chrome://flags#enable-webassembly), and there’s a tremendous performance hit in how emscripten wraps exceptions into a javascript try/catch. We’ve noticed ..

Read more

Consider the following contrived example: class IBar { void qux() = 0; }; class IFoo { void execute(const IBar &bar) = 0; }; struct FooWrapper : public wrapper<IFoo> { EMSCRIPTEN_WRAPPER(FooWrapper); void execute(const IBar &bar) override { return call<void>("execute", bar); } }; EMSCRIPTEN_BINDINGS(IFoo) { class_<IFoo>("IFoo") .function("execute", &IFoo::execute, allow_raw_pointers(), pure_virtual()) .allow_subclass<FooWrapper>("FooWrapper"); } If I try to compile ..

Read more

Consider the following C++ code and corresponding Emscripten bindings. class IBar { void qux() = 0; }; struct BarWrapper : public wrapper<IBar> { void qux() override { return call<>("qux"); } } EMSCRIPTEN_BINDINGS(IBar) { class_<IBar>("IBar") .smart_ptr<std::shared_ptr<IBar>>("IBar") .function("qux", &IBar::qux) .allow_subclass<BarWrapper>("BarWrapper");; } class Foo { std::shared_ptr<IBar> getBar() const; void setBar(std::shared_ptr<IBar> bar); }; EMSCRIPTEN_BINDINGS(Foo) { class_<Options>("Foo") .constructor<>() .property("bar", &Foo::getBar, ..

Read more

I have a working C++ static library that I’m porting to WebAssembly using Emscripten. Right now, I’m trying to get its existing unit tests running. I’m using the following Python script to serve the HTML file Emscripten generated. #!/usr/bin/env python3 import sys from http.server import HTTPServer, SimpleHTTPRequestHandler, test class CORSRequestHandler (SimpleHTTPRequestHandler): def end_headers (self): self.send_header("Cross-Origin-Embedder-Policy", ..

Read more