I just discovered chaiscript and I like it a lot. Now I want to add support for my very simple opengl 3d engine.
I have C++ math-classes: vec2T, vec3T, vec4T, mat2T, mat3T, mat4T, ... (they are actually template classes and there are typedefs that make them vec4i, vec4f, vec4d, ...)
I think I can add them to chaiscript with:
chai.add(chaiscript::user_type<vec4i>(), "vec4i");
right?
Now, I want to test if my script contains a function called "onFrame". If it is, I want it to be called with a vec4i parameter as its first argument. How do I do this?
I understand that I can do something like this:
try
{
chai("onFrame();");
}
catch (const std::exception &)
{
}
If onFrame is not defined in the script, the exception will be ignored this way. I can even pass some integer or string parameters this way. But how do I go on to pass a vec4(x, y, z, w) parameter to it?
Any help is appreciated!