About ChaiScript

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

ChaiScript is licensed under the BSD license.

Download

Due to an increased release schedule, and the nature of ChaiScript being a header-only library, binary releases will be made less often. Previous releases can be found on github.

Version: 4.2.0 Released: 12/1/2012
(Requires Boost)
Source (tar.bz2)
Source (zip)

Version: 5.2.0 Released: 12/1/2012
(Requires C++11 Compiler)
Source (tar.bz2)
Source (zip)

How bind attribute

Hi !
I create a class V3:

class V3{
    public:
    V3(){x=0;y=0;z=0;}
    V3(const V3 &other){x=other.x;y=other.y;z=other.z;}
    V3(Ogre::Vector3 other){x=other.x;y=other.y;z=other.z;}
    V3(double X, double Y, double Z){x=X;y=Y;z=Z;}
    Ogre::Vector3 toVector3(){return Ogre::Vector3(x,y,z);}
    double x;
    double y;
    double z;
};
    chai->add(user_type<V3>(), "V3");
    chai->add(constructor<V3()>(), "V3");
    chai->add(constructor<V3(const V3 &)>(), "V3");
    chai->add(constructor<V3(double,double,double)>(), "V3");

In ChaiScript :

var myVar= V3();
print(myVar.x); // how bind x,y,z attribute to ChaiScript

Thanks for help.

Just like any other

Just like any other member:

chai->add(fun(&V3::x), "x");
chai->add(fun(&V3::x), "y");
chai->add(fun(&V3::x), "z");
chai->add(fun(&V3::toVector), "toVector");

This would round out your class.

Support ChaiScript by sharing it with your friends: