lua-users home
lua-l archive

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


Jose,

  Thanks for your reply! I don't know how Luabind does it (unable to
parse their source), but I suspenct it's something like this.

Suppose we have the following:


C++ land:

  class Bar {
    Foo foo;
  }

  .set_readwrite("foo", & Bar::foo) [1]


Suppose [1] can automatically generate functions :set_foo(...) and
:get_foo(), then we curently have:

Lua land:
  Bar b;
  b:get_foo();
  b:set_foo(...);

But we can't do:
  b.foo
or
  b.foo = 20

If instead of registering functions get_foo and set_foo on the object
b ... we registered those functions in b's meta-table for handling
__index and __new_index, then I think it'd work:

read:  b.foo
  looks up object b, no .foo, looks up b's metatable .. __index
exists, looks into it, finds get_foo

write: b.foo = ...
  looks up object b, no .foo looks up b's metatable, __new_index
exists, looks into it, knows to call set_foo

Does this make sense?

Thanks!
On Wed, Jan 5, 2011 at 7:49 AM, Jose Luis Hidalgo
<joseluis.hidalgo@gmail.com> wrote:
> Hi beo wulf,
>
>   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)
>
> to do that using SLB, right now, is really difficult as the main idea
> behind all this is always registering functions, I can automatically
> generate wrappers for variables but the use in lua would be similar
> to:
>
> b= bar()
> b:setFoo(5)
> print(b:getFoo())
>
> If you are happy with that solution I can quickly add the code to
> generate those wrappers, for a given variable of a class. If you have
> any requirement on how to do this ,you're on time to choose the way we
> wrap variables using SLB.
>
> JL.
>
> On Tue, Jan 4, 2011 at 12:31 PM, beo wulf <beowulf@intamp.com> wrote:
>> Hi Jose,
>>
>>   I've been reading through the SLB code at:
>> hg clone https://slb.googlecode.com/hg/ slb
>>
>>  and I can't figure out how to do the following:
>>
>> I see that you have getInt and setInt functions registered -- however,
>> is it possible to register a variable, like a def_readwrite in
>> Luabind?
>>
>> Thanks!
>>
>> On Thu, Dec 30, 2010 at 3:41 AM, Jose Luis Hidalgo
>> <joseluis.hidalgo@gmail.com> wrote:
>>>
>>> Hi All,
>>>
>>>   I've just updated all the code to support lua 5.2, just need a bit
>>> more testing, and it's done.
>>>
>>> JL.
>>>
>>> On Wed, Dec 29, 2010 at 5:46 PM, beo wulf <beowulf@intamp.com> wrote:
>>> > I'm stuck with Luabind for the next 72 hours, but I'm going to try to switch
>>> > to 5.2 + Luabind this weekend.
>>> >
>>> > Thanks for your efforts!
>>> >
>>> > On Wed, Dec 29, 2010 at 3:03 AM, Jose Luis Hidalgo
>>> > <joseluis.hidalgo@gmail.com> wrote:
>>> >>
>>> >> Hi beo wulf,
>>> >>
>>> >>   Here, I've just started the port:
>>> >>
>>> >> http://code.google.com/p/slb/source/list?r=testing_lua5.2
>>> >>
>>> >> Hybrid classes doesn't work, I probably need to more work there, but I
>>> >> bet you are not going to use them right now (do you?) If you have any
>>> >> problem, or need some help, just drop me an email.
>>> >>
>>> >> Regards,
>>> >>   JL.
>>> >>
>>> >> On Tue, Dec 28, 2010 at 5:33 PM, beo wulf <beowulf@intamp.com> wrote:
>>> >> > If you could port it, it would be amazing. Let me know how I can help.
>>> >> >
>>> >> > Looking at the 5.2 changes -- what are big road blocks besides function
>>> >> > environments / lexical environments?
>>> >> >
>>> >> > On Tue, Dec 28, 2010 at 1:43 AM, Jose Luis Hidalgo
>>> >> > <joseluis.hidalgo@gmail.com> wrote:
>>> >> >>
>>> >> >> Hi beo wulf,
>>> >> >>
>>> >> >>   I just did a test, and I'm not sure if I will be able to recover
>>> >> >> it, but if you really need it, I'd rather restart the port of the
>>> >> >> current version, is something I will do sooner or later. Let me
>>> >> >> contact you once is done.
>>> >> >>
>>> >> >> JL.
>>> >> >>
>>> >> >>
>>> >> >> On Mon, Dec 27, 2010 at 8:36 PM, beo wulf <beowulf@intamp.com> wrote:
>>> >> >> > Hi Jose,
>>> >> >> >
>>> >> >> >   Can you post your older version (that has been ported to Lua 5.2)
>>> >> >> > to
>>> >> >> > github?
>>> >> >> >
>>> >> >> > Thanks!
>>> >> >> >
>>> >> >> > On Mon, Dec 27, 2010 at 1:25 AM, Jose Luis Hidalgo
>>> >> >> > <joseluis.hidalgo@gmail.com> wrote:
>>> >> >> >>
>>> >> >> >> Hi beo wulf,
>>> >> >> >>
>>> >> >> >>   I've already ported an older version of SLB to lua 5.2, and for
>>> >> >> >> SLB
>>> >> >> >> means lots of changes. I'm planning to support lua 5.2 as soon as
>>> >> >> >> lua
>>> >> >> >> 5.2 is stable, meanwhile I would like to make a release with the new
>>> >> >> >> features. If you really, really need lua 5.2, I can see start the
>>> >> >> >> port
>>> >> >> >> in a branch.
>>> >> >> >>
>>> >> >> >> JL.
>>> >> >> >>
>>> >> >> >> On Mon, Dec 27, 2010 at 1:02 AM, beo wulf <beowulf@intamp.com>
>>> >> >> >> wrote:
>>> >> >> >> > Hi Jose,
>>> >> >> >> >
>>> >> >> >> >   I just tried Luabind + lua 5.2 -- doesn't compile (due to
>>> >> >> >> > function
>>> >> >> >> > environments, which are not replaced with lexical environments).
>>> >> >> >> > Any
>>> >> >> >> > plans
>>> >> >> >> > to port SLB to work with lua 5.2?
>>> >> >> >> >
>>> >> >> >> > Thanks!
>>> >> >> >> >
>>> >> >> >> > On Sun, Dec 26, 2010 at 11:07 AM, Jose Luis Hidalgo
>>> >> >> >> > <joseluis.hidalgo@gmail.com> wrote:
>>> >> >> >> >>
>>> >> >> >> >> Hi starwing,
>>> >> >> >> >>
>>> >> >> >> >> On Sun, Dec 26, 2010 at 7:23 PM, starwing <weasley.wx@gmail.com>
>>> >> >> >> >> wrote:
>>> >> >> >> >> > Does SLB support function overload? it's a useful feature.
>>> >> >> >> >> >
>>> >> >> >> >>
>>> >> >> >> >> Mmm... sorry, but no. The problem is lua type marshaling with C++
>>> >> >> >> >> types, there are many ways a type can be "converted" from lua to
>>> >> >> >> >> a
>>> >> >> >> >> C++
>>> >> >> >> >> function/method signature. Overloading could be possible for
>>> >> >> >> >> different
>>> >> >> >> >> number of arguments, though, but no for different signatures with
>>> >> >> >> >> the
>>> >> >> >> >> same number of arguments, and I didn't want to support partial
>>> >> >> >> >> overloading.
>>> >> >> >> >>
>>> >> >> >> >> BTW, the search for the proper method to call will add a
>>> >> >> >> >> significant
>>> >> >> >> >> overhead, SLB is meant to be as faster as possible, near to a
>>> >> >> >> >> hand-coded wrapper. What I usually do with overloading is
>>> >> >> >> >> register
>>> >> >> >> >> each function with a different name in lua, which is not as handy
>>> >> >> >> >> as
>>> >> >> >> >> overload support, but it works.
>>> >> >> >> >>
>>> >> >> >> >> Cheers,
>>> >> >> >> >>   JL.
>>> >> >> >> >>
>>> >> >> >> >> PS: I'm working on registering accessors to instances'
>>> >> >> >> >> attributes,
>>> >> >> >> >> but, I'm not sure about how use it from lua properly, do you have
>>> >> >> >> >> any
>>> >> >> >> >> insights?
>>> >> >> >> >>
>>> >> >> >> >> --
>>> >> >> >> >>   Jose L. Hidalgo Valiño (PpluX)
>>> >> >> >> >>   ---- http://www.pplux.com ----
>>> >> >> >> >>
>>> >> >> >> >
>>> >> >> >> >
>>> >> >> >>
>>> >> >> >>
>>> >> >> >>
>>> >> >> >> --
>>> >> >> >>   Jose L. Hidalgo Valiño (PpluX)
>>> >> >> >>   ---- http://www.pplux.com ----
>>> >> >> >>
>>> >> >> >
>>> >> >> >
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >>   Jose L. Hidalgo Valiño (PpluX)
>>> >> >>   ---- http://www.pplux.com ----
>>> >> >>
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >>   Jose L. Hidalgo Valiño (PpluX)
>>> >>   ---- http://www.pplux.com ----
>>> >>
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>>   Jose L. Hidalgo Valiño (PpluX)
>>>   ---- http://www.pplux.com ----
>>>
>>
>>
>
>
>
> --
>   Jose L. Hidalgo Valiño (PpluX)
>   ---- http://www.pplux.com ----
>
>