[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: SLB vs LuaBind
- From: Tim Mensch <tim-lua-l@...>
- Date: Wed, 05 Jan 2011 14:46:02 -0700
On 1/5/2011 8:49 AM, Jose Luis Hidalgo wrote:
> I've been trying to see how to deal with registering accessors, and
> the problem I see is how you would use the accessors from lua. For
> example, if you register an accessor (a def_readwrite to a variable
> foo of a class bar) in lua:
>
> b = bar()
> b:foo = 5
> print(b:foo)
That's not legal Lua, AFAIK. b:foo expects function arguments.
Ideally it would actually work like this:
b=bar();
b.foo = 5;
print(b.foo);
That's how it works in, e.g., tolua++ and LuaBind. In fact you can not
only register accessors to public data, you can register an accessor
that calls existing accessors on a C++ class, so the code above could be
calling the C++ member functions bar::setFoo() and bar::getFoo().
And you can still add new members to extend b:
b.somenewmember = 5
I had to dig through tolua++ to fix how that worked WRT
shared_ptr-wrapped objects, so I happen to know how it's done in at
least tolua++; if you're curious I can explain, but there are several
options in Lua.
SLB not having these features was a deal killer for me, so beo wulf
isn't the only person who considers them important. :)
Tim