About ChaiScript

ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility in mind. It is an ECMAScript-inspired, embedded functional-like language.

ChaiScript is licensed under the BSD license.

Download

Version: 2.3.3 Released: 5/15/2010

Source
Windows
Linux

Object Model

Extending Registered C++ Classes

You may extend C++ classes that you have previously registered with the ChaiScript engine using the method definition syntax:

Method Definition ::= class_name "::" method_name "(" [arg ("," arg)*] ")" block

ChaiScript's Native Object Types

Constructors and Methods

Using the same method definition syntax you can create a constructor and add methods to a new type. For example:

def MyClass::MyClass() { }

This creates a constructor for the 'MyClass' type, which, if it doesn't already exist, will now be visible to your script. To instantiate a value of 'MyClass', call its constructor directly:

var myobject = MyClass()

Attributes

Attribute Definition ::= "attr" class_name "::" attribute_name

In addition to extending your new type with methods, you may also add attributes.

Extended example:

attr Rectangle::height
attr Rectangle::width
def Rectangle::Rectangle() { this.height = 10; this.width = 20 }
def Rectangle::area() { this.height * this.width }
 
var rect = Rectangle()
rect.height = 30
print(rect.area())