If you like embind, here's the equivalent for Node.js and the Electron framework:
https://github.com/charto/nbind It even supports callbacks and value types, but the syntax is a little different from embind, with even less typing. Value objects aren't passed as object literals, but instead they're always initialized through a C++ or JavaScript constructor as they pass between the languages. The next goal is to make it support Emscripten (wrapping embind or otherwise) and automatically produce TypeScript definitions, to allow running a single C++ code base natively on the server (Node.js) and the desktop (Electron) or through Asm.js on browsers (and maybe as a fallback on server and desktop). Unfortunately supporting native mobile with Cordova seems more complicated... Also, here's an article about creating Emscripten libraries in TypeScript: http://blog.charto.net/asm-js/Writing-Emscripten-libraries-in-TypeScript/ Bindings with nbind for a coordinate pair might look like: NBIND_CLASS(Coord) { construct<>(); construct<int, int>(); getset(getX, setX); // etc. method(callWithXY); } To be used from JavaScript as follows: var nbind = require('nbind'); nbind.init(__dirname); var xy = new nbind.module.Coord(12, 34); xy.x = 56; // Prints: 56 34 xy.callWithXY(function(x, y) { console.log(x + ' ' + y); }); The class might be defined as: class Coord { public: Coord(int x = 0, int y = 0) : x(x), y(y) {} int getX() { return(x); } void setX(int xNew) { x = xNew; } // Call a JavaScript callback with x, y as parameters. void callWithXY(nbind::cbFunction &callback) { callback(x, y); } // And others... int x, y; }; -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
