Logo        Welcome to SnowMonkey project website!

Go to project page:

The goal of this project is to create binding library for SpiderMonkey (Netscape's implementation of JavaScript engine, see for more details). This library will make heavy usage of templates, STL and Boost libraries in order to simplify binding syntax as much as possible. Final binding syntax should look as following:

#include <snowmonkey.hpp>

using snow_monkey;

// classes which will be registered
class MyClass
  int abc;
  // constructors
  Myclass() {}
  MyClass(int, int) {}
  // methods
  void foo() {}
  int bar(int, double, long) { return 0; }
  // member variables and property getters/setters
  int prop;
  double ro_value;
  int get_abc() const { return abc; }
  void set_abc(int v) { abc = v; }
  // static methods
  static void s_foo() {}
  // static member variables and property getters/setters
  static int s_bar;
  // enum
  enum { AA, BB = 10, CC };

int MyClass::s_bar = 0;

class OtherClass
  void foo(int) {}

int main()
  // create JS Engine object

  // import various external items to JS Engine
    // register class Myclass
      // register constructors
      .ctor<int, int>()
      // register methods
      .fun("foo", &MyClass::foo)
      .fun("bar", &MyClass::bar)
      // register properties
      .prop("prop", get(&MyClass::prop), set(&MyClass::prop))
      .prop("abc", get(&MyClass::get_abc), set(&MyClass::set_abc))
      .prop("value", get(&MyClass::ro_value))
      // register static methods
      .s_fun(""_foo", &MyClass::s_foo),
      // register static properties
      .s_prop("s_bar", get(&MyClass::s_bar), set(&MyClass::s_bar))
      // register enums (their values will be registered as static read-only properties)
        enum_val("AA", MyClass::AA),
        enum_val("BB", MyClass::BB),
        enum_val("CC", MyClass::CC)
      // register class OtherClass
        .fun("foo", &OtherClass::foo)

  // execute some JS Script
  char* js_script = 
    "var mc = new MyClas();\n"
    "var oc = new OtherClass();\n"
    ", 2, 3));