1
我想通过基类指针从C++传递到Lua使用LuaBridge的对象。派生类和基类都已正确注册到LuaBridge。LuaBridge和继承
在C++方面:
// Assume both Foo and FooBase are registered properly with LuaBridge,
// exposing the a, b, and c properties
struct FooBase
{
int a;
// ...
};
struct Foo : public FooBase
{
int b;
int c;
// ...
};
// ... other code ...
void Bar(const FooBase* foo)
{
// Assume that 'foo' is a pointer to a valid 'Foo' object
luabridge::LuaRef ref = luabridge::getGlobal(L, "bar");
ref(foo);
}
在Lua的一面:
function bar(foo)
foo.a -- This is ok
foo.b -- This is nil
end
我怎样才能 '铸下' 从FooBase*
到Foo*
在Lua? Lua/LuaBridge是否支持这个?