What's GLUEscript?

GLUEscript (Glueing Libraries Using EcmaScript) is the successor of wxJavaScript. The new name covers the goal of this project: create a JavaScript engine which can be used as a general purpose language (like Perl for instance).

Read the history behind GLUEscript.

GLUEscript is developed by Franky Braem

SpiderMonkey

GLUEscript uses SpiderMonkey, the JavaScript engine used in FireFox.

SpiderMonkey

Portable Code

GLUEscript is written in portable C++ code. GLUEscript uses PoCo, a library for writing portable C++ code. And wxWidgets is used as GUI toolset. The GUI glue is optional.

Powered by POCO
Built with wxWidgets

GLUEscript uses Premake for generating makefiles for gcc, project files for Visual C++, CodeLite, Code::Blocks, ... Premake can be used on Windows, Linux and MacOS.

A sample: using cURL, e4x and wxWidgets to view an RSS feed

This sample will show the RSS feed of this website. For this we need:

  • cURL is used for retrieving the RSS feed
  • E4X is used to parse the XML retrieved from the RSS feed
  • wxWidgets is used for showing the RSS feed in a HTMLWindow

First we load the glues we need:

var curl = require("curl");
var wx = require("wx");

Then we initialize E4X:

XML.ignoreComments = true;
XML.ignoreWhitespace = true;
XML.prettyPrinting = false;
XML.prettyIndent = 0;

A function is created to load the RSS feed with cURL:

function loadFeed()
{
  var c = new curl.Easy();
  
  var xmlString = "";
  c.url = "http://gluescript.sourceforge.net/?q=rss.xml";
  c.onWrite = function write(buffer)
  {
    xmlString += buffer.toString();
    return buffer.size;
  }
  print(curl.Easy.strerror(c.perform()), "\n");
    
  // Skip the process instruction (see http://developer.mozilla.org/en/docs/E4X)
  return new XML(xmlString.substr(xmlString.indexOf("\n")));
}

The init function will call loadFeed and initializes wxWidgets:

function init()
{
  var rss = loadFeed();

  var frame = new wx.Frame(null, 1);
  topWindow = frame;

  var htmlWindow = new wx.HtmlWindow();
  htmlWindow.create(frame);
  
  htmlWindow.setRelatedFrame(frame, "%s");
  var page = "<html><head><title>GLUEscript RSS</title></head><body>";
  for each(var item in rss.channel.child('item'))
  {
    page += "<h2>" + item.title + "</h2><br>";
    page += "<p>" + item.description + "</p>";
  }
  page += "</body></html>";
  htmlWindow.setPage(page);
  frame.visible = true;
  frame.centre();
 
  return true;
}

wx.TheApp.onInit = init;

This is the result when the script is run: