Scripts For Generating Javascript and C/Objective-C Bindings

Last week I mentioned news about some major Cocos2D updates allowing you to use Javascript as a scripting language.

Recently Zynga also released a related set of scripts called Javascript Bindings for C/Objective-C (for any code – not just Cocos2D).

With the Javascript Bindings for C/Objective-C you can access your Objective-C code from JavaScript, and vice versa.

The really cool thing about this library vs. other solutions for working with Javascript through Objective-C is that  you don’t have to modify the source code of your libraries as the included scripts do the work for you, and the Javascript is interpreted through Mozilla’s SpiderMonkey.

Here’s a list of highlights from the read me:

– Supports any Objective-C / C library
– Automatically generates the JS bindings (“glue” code)
– No need to modify the source code of your libraries, or the autogenerated code
– Powerful set of rules to customize the generated JS API
– Automatically converts JS objects/types into Objective-C – –objects/structs/ types and vice-versa
– Supports “subclassing” native objects in JS
– Supports callbacks
– Automatically generates object oriented JS API from C libraries (provided that the C API is OO, like Chipmunk)

You can find Javascript Bindings for C/Objective-C on Github here.

You’ll also need SpiderMonkey (the SpiderMonkey link in the readme appears incorrect but I believe this is the right version) and JRSwizzle.

Full details on how to generate the bindings and use them in your projects are on the Github page along with some examples.

DeliciousTwitterFacebookRedditLinkedInEmail

Original article: Scripts For Generating Javascript and C/Objective-C Bindings

©2012 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *