【发布时间】:2016-11-14 01:10:15
【问题描述】:
目前我正在试验 Luabind-Library,我偶然发现了它的调用语法。它的行为和工作方式与预期的一样,但不知何故我无法理解它为什么或如何做。
有问题的代码如下:
Class Animation
{
std::vector frames;
public:
Animation(){}
~Animation(){}
addFrame(const Texture2D *in_image);
};
//Somewhere else
luabind::module(LuaState)
[
luabind::class_("Animation") // < "Animation" how we want to name the Class in the Lua runtime
.def(luabind::constructor<>()) // < Binds the empty constructor
.def("addFrame", &Animation::addFrame) // < Binds the &Animation::addFrame method to lua with the name "addFrame"
];
更具体地说,我不明白方括号中发生了什么。为什么这行得通?我试图阅读 Luabind 的源代码,遗憾的是没有成功。我也尝试重建这种行为,但也没有成功。
那么,我是否遗漏了一些非常明显的东西?
提前致谢!
【问题讨论】: