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.
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.
Use the "constructor" function that implicitly creates a function for adding to the runtime.
The "constructor" function is a template function that takes a signature for what you want your constructor to do.
struct MyStruct { //Default constructor MyStruct(); //Copy constructor MyStruct(const MyStruct &); //int constructor MyStruct(int i); } ChaiScript chai; //Add the default constructor chai.add(constructor<MyStruct ()>(), "MyStruct"); //Add the copy constructor chai.add(constructor<MyStruct (const MyStruct &)>(), "MyStruct"); //Add the int constructor chai.add(constructor<MyStruct (int)>(), "MyStruct");
ChaiScript's runtime dispatch capatilibties makes it perfectly legitimate and reasonable to add each constructor with the same name.
Also, notice that the name of the constructor is arbitrary, ChaiScript does not care what it is called, it becomes a regular function to the ChaiScript interpreter.