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

StackOverflow https://stackoverflow.com/questions/2563411

  •  23-09-2019
  •  | 
  •  

문제

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.

도움이 되었습니까?

해결책 2

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top