jsapigen - A glue-code generator for SpiderMonkey


jsapigen generates glue code for embedding SpiderMonkey in C applications.

jsapigen provides a simple interface definition language for describing the connection between native C code and the JavaScript environment. It converts such IDL descriptions to C code which is then compiled and linked into an application during the build process.


The following code is a snippet of an IDL file. Running jsapigen on this example generates glue code for integration with SpiderMonkey.

function void js_function : c_function (int=2);

The example shows the declaration of a JavaScript function js_function which executes the C function c_function on invocation. It takes one argument of type int and returns nothing. If the argument is omitted, a default value of 2 is used.

This simple example only shows some of jsapigen's features. By now, the program covers roughly 90% of all possible scenarios and often it is possible to create the complete glue code automatically. jsapigen is intended to be used as a preprocessor for C source files and integrates perfectly with make.

jsapigen also saves you a lot of typing. Generated glue code in C is larger in size then its corresponding IDL description by an estimated factor of 20-50. For example, the one-liner above generates 37 lines of C code, plus another 32 lines with declarations and data structures.


With jsapigen, it is possible to generate most glue code automatically. The software can


The latest release is jsapigen 0.5.1. Some highlights are

The latest snapshot of jsapigen is available from Git. You can checkout the repository with the following command.

git clone git://jsapigen.git.sourceforge.net/gitroot/jsapigen/jsapigen

This creates the directory jsapigen in your current working directory which contains a copy of the latest master branch from the public Git repository.


A manual for jsapigen 0.5.1 is available in the download section on SourceForge.net. A single-page version is available for online reading.

Legal stuff, author, and contact info ...

jsapigen is written and maintained by Thomas Zimmermann <tdz@users.sourceforge.net>. It is free software under the terms of the GNU General Public License, Version 3 or later. Of course, the generated source code is not covered by the GNU GPL, but a license of your choice.

Your are most welcome to contribute to this project. Patches, feature requests, etc. should be submitted via the project's page on SourceForge.net, or the mailing list <jsapigen-devel@lists.sourceforge.net>. This is also the preferred place for jsapigen-related discussions. If you are only interested in new releases please subscribe to <jsapigen-announce@lists.sourceforge.net>. If you need near-term help or just have a simple question, please join the IRC channel #jsapigen on irc.freenode.org.

Copyright © 2008-2010 Thomas Zimmermann

Get jsapigen at SourceForge.net. Fast, secure and Free Open Source software downloads Valid HTML 4.01 Strict CSS is valid!