Very interesting!

Skimming through the examples, I'm trying to understand what makes this
different than embind? What kind of C++ class features are you planning to
support?

I was testing out embind a few years back with the idea of exposing
MathGeoLib ( http://clb.demon.fi/MathGeoLib/nightly/ ) as a JavaScript API.
Here is a live demo of that test:
https://dl.dropboxusercontent.com/u/40949268/emcc/MathGeoLibTest.html . In
that test, I found that value types were a bit difficult to emulate cleanly
without support for destructors. Btw, if you haven't seen, we have a list
of embind-related threads at
https://github.com/kripken/emscripten/labels/embind , I wonder if nbind
might be able to work on some of those?

2015-08-31 4:38 GMT+03:00 Juha Järvi <[email protected]>:

> 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.
>

-- 
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.

Reply via email to