SWIG and JavaScript - Part One

I experiment with a lot of ideas for projects and see which ideas stick, which seem interesting, which require something that I can't provide, etc.

A project that I'm working on now may well be interesting and within my capabilities and the resources that I can muster, but I don't want to identify it specifically yet.

Anyway, this project requires using Node.js to talk to a C++ library with an extensive API. An interesting detail is that this library already has a solid Python API, built via SWIG.

JavaScript and SWIG

Version 3.0 of SWIG began to support JavaScript. It supports using JavaScriptCore or V8 as the JS engine, and Node.js as a specialization of the V8 support.

For now, I have hacked the SWIG interface files from the C++ library to wrap Python-specific portions in #ifdef SWIG_PYTHON so that they can be shared with JavaScript. In the longer term, should this project work out and I decide to upstream the changes to support having JavaScript bindings, I will clean this up and move some things into separate files for each language in a tidier fashion.

In fairly short order, I was able to ...

read more »