Tutorial :SWIG and Javascript: does embedding the JVM/Rhino into my C++ app is still the only solution?


I really like the idea of automatic binding generation like SWIG does. But it is still lacking Javascript binding. I read that it could not be done with Spidermonkey because of the JS Context that must be passed as parameter to each function.

The only solution I found is to embed a JVM into my C++ application, generating bindings to Java using SWIG, and then using Rhino engine as the JS interpreter. It works fine, but it is really heavyweight!

Any other ideas?

Note: yes I know, I could use Python or Lua instead. But my question is really about JS.


If you are not in a hurry: Wait for the SWIG Javascript bindings that might be developed as GSoC-2012 project "New module for Javascript" by Neha Narang.

The abstract says:

This project aims to add Javascript as a new supported target language to swig to automate the generation of Javascript wrappers over C++.

The project repository is https://github.com/Neha03/gsoc2012-javascript.


Well, since I don't have any answers, I think that I must use other alternatives than SWIG.

I found that page on the mozilla developer center mentioning several projects for wrapping JS with the Spidermonkey engine: Spiderape, Flusspferd, TriXUL and jsapigen.

For V8, there is a similar project called v8-juice from the creator of Spiderape.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »