Seed - GObject JavaScriptCore bridge

Seed is a library and interpreter, dynamically bridging (through GObjectIntrospection) the WebKitJavaScriptCore engine, with the GNOME platform. Seed serves as something which enables you to write standalone applications in JavaScript, or easily enable your application to be extensible in JavaScript.

Latest release can be found here

Introduction

Seed is built around the idea of "minimal-platform", in that it seems a theoretically ideal GNOME development language provides no platform of its own, but instead seamlessly integrates with the already quite large GNOME platform. Some of Seed are listed below:

Automatic and powerful type conversion, capable of converting between everything from simple types, to GList/Array, to boxing JavaScript functions up in C function pointers (required by some libraries for say, foreach functions).

Automatic GError integration with JavaScript exceptions. You leave the GError argument out of your arguments, and internally Seed passes it in to the method, and throws an exception with the proper name and message if an error is generated.

Some "syntactic sugar" which makes code more pleasant to write, such as JSON key/value pairs for constructor properties, literals for structs (stage.color = {red: 200}).

Ability to define new GTypes which inherit from existing GTypes. As of now you can not implement abstract methods, but beyond that it works. Signals and properties work.

A C module system, useful for binding libraries which are not GObject based (such as readline, sqlite, and many low level POSIX functons).

At this point, the vast majority of the GNOME platform is usable from Seed.

In general using any GObject based API (internal to your application, or a library) in Seed, should not be difficult, and should simply require a few changes to your build scripts to allow generation of the introspection data.

Current Status

By and large Seed is able to properly bind anything in the GNOME platform. One of the biggest shortfalls in Seed as of now is the lack of ability to implement GObject interfaces (though in general subclassing does work). I believe Seed to be mostly leak free at this point, however it is not as memory efficient as it could be, in particular where closures are involved (It still compares quite favorably to languages such as Python however).

License

Seed is available under the LGPL. Most of the examples are under a BSD license, however some of the more complicated ones (such as lightsoff or same-seed) are under the GPL.

Documentation

Seed has a wide variety of examples, located at http://git.gnome.org/cgit/seed-examples, covering many common tasks in a "cookbook" style fashion, and several more complete applications. Seed has a (small) documentation site which covers the C API, the Seed runtime, and a tutorial aimed at Gtk beginners to create a small web browser. In the future this will likely be expanded.

Signals

Note that the function could be an inline anonymous function, instead of a closure. Also of interest is the fact that the second argument to the signal connections represents the userdata which is passed to the signal handler.

Error Handling

try{varfile = Gio.file_new_for_path("/tmp");varfstream = file.replace();}catch (e){// e.name is equal to GIoError.// e.message is equal to "Error opening file '/tmp/': Is a directory// Also has source file/line number, as line and sourceURL properties}

Struct/Boxed Literals

stage.color = {red:255, alpha:80}; // Struct is allocated (with GSlice). // Other elements are initialised to zero.// When the stage is destroyed, or the color changes, the struct is freed.