ChaiScript:公开类的数据成员变量

时间:2013-09-09 07:13:44

标签: c++ windows visual-studio-2012 chaiscript

我正在尝试将Ogre::Vector2类公开给ChaiScript。我希望公开类的xy以及as-per this post on their forum,看起来您只需要像任何其他函数一样添加它。但这对我不起作用,它给了我以下错误信息:

  

“函数'x'的函数调度错误”带参数:   (const class Ogre :: Vector2)。()

注意:我尝试在脚本中以v.xv.x()的形式访问它们。

我对该模块的定义如下:

using namespace chaiscript;
ModulePtr module(new Module());
module->add(user_type<Ogre::Vector2>(), "Ogre::Vector2");
module->add(constructor<Ogre::Vector2()>(), "Ogre::Vector2");
module->add(constructor<Ogre::Vector2(float, float)>(), "Ogre::Vector2");
module->add(constructor<Ogre::Vector2(float)>(), "Ogre::Vector2");
module->add(constructor<Ogre::Vector2(const Ogre::Vector2&)>(), "Ogre::Vector2");
module->add(fun(&Ogre::Vector2::x), "x");
module->add(fun(&Ogre::Vector2::y), "y");
module->add(fun<Ogre::Vector2& (Ogre::Vector2::*)(const Ogre::Vector2&)>(&Ogre::Vector2::operator =), "=");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const Ogre::Vector2&) const>(&Ogre::Vector2::operator+), "+");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const Ogre::Vector2&) const>(&Ogre::Vector2::operator-), "-");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const Ogre::Vector2&) const>(&Ogre::Vector2::operator*), "*");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const float) const>(&Ogre::Vector2::operator*), "*");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const Ogre::Vector2&) const>(&Ogre::Vector2::operator/), "/");
module->add(fun<Ogre::Vector2 (Ogre::Vector2::*)(const float) const>(&Ogre::Vector2::operator/), "/");

我最初尝试通过他们的class helper macro定义这个类,然后手动定义了这个模块,遇到了这个错误。由于他们的论坛已禁用新主题创作和新帖子(DARN you,spammers!),我在这里发布此问题。我们非常感谢您解决此问题的任何帮助。

NOTE2 :我正在使用ChaiScript-4.2.0

0 个答案:

没有答案
相关问题