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是否支持這個?