lua-users home
lua-l archive

Re: property based C++ API with Lunar?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,
I've implemented the solution and it works great. After that it was very easy to implement the getter as well. Thank you again!
Best Regards
Micha
Hakki Dogusan schrieb:
Hi,
Michael Bauroth wrote:
Sorry that I ask: what do you mean with a table? Have you eventually a short sample for me? Unfortunately I have to learn Lua, C++ in depth and the bridge stuff at the same time.
Best Regards
Micha
Ignacio Burgueño schrieb:
Michael Bauroth wrote:
Hi,
I have implemented your solution, but had to change two lines because of a compiler error (VS2008). What do you mean?
[snip]
Just another question. What can I change to use the same solution as well for methods with more than one parameter, e.g. instead of btn:SetPosition( 1, 1 ) I want to use btn.Position = 1, 1?
I don't think this is possible since the __newindex and __index metamethods don't take multiple values. There was some discussion of the list some time ago about this.
What you might do instead is something like:
btn.Position = {1,1}
And deal with a table in your C++ implementation.
Regards,
Ignacio
Maybe, something like that..
-- Lua
btn.Position = {1,1}
// C
LCB_IMPL_SET(Button, Position)
{
 luaL_checktype(L, 1, LUA_TTABLE);
 lua_rawgeti(L, 1, 1);
 int x = lua_tonumber(L, -1);
 lua_pop(L, 1);
 lua_rawgeti(L, 1, 2);
 int y = lua_tonumber(L, -1);
 lua_pop(L, 1);
 button->SetPosition(x,y);
 return 0;
}
--
Regards,
Hakki Dogusan

AltStyle によって変換されたページ (->オリジナル) /