[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: GUI interface style query
- From: "Grisha" <grisha@...>
- Date: Fri, 29 Oct 2004 16:02:33 +0400
I must note that the first approach should work faster with the first
usecase, since there's no table constructor there. In similar situation I
used different style: you can't access children through C interface, but you
can store references to them as separate Lua fields in the object. Something
like this:
-- creates button and adds it to the dialog's children list
function dialogbase:button()
local btn = ui.createbutton()
self:add(btn)
end
mydialog = ui.createdialog()
mydialog.ok = mydialog:button()
mydialog.cancel = mydialog:button()
Best Regards,
Grisha
----- Original Message -----
From: "David Given" <dg@cowlark.com>
To: <lua@bazar2.conectiva.com.br>
Sent: Friday, October 29, 2004 3:47 PM
Subject: GUI interface style query
> In-house, we're using Lua as a RAD scripting engine for our embedded GUI.
And,
> I must say, it's working pretty nicely.
>
> So I'm writing a set of Lua wrappers around our OO-based hierarchical
visible
> object model. The basic primitives are: getchildren, getparent, add and
sub.
>
> getparent, add and sub are pretty simple; getchildren, however, gets a
list of
> a particular object's children. What's the best way of returning this?
>
> Currently what it does is to return a tuple of all the object's children.
This
> means that if you know how many children there are, you can do this:
>
> child1, child2, child3 = object:getchildren()
>
> OTOH, if you don't, you have to do this:
>
> childarray = {object:getchildren()}
>
> ...which is a bit ugly.
>
> The other approach is to have the C code construct an array and return
that.
> This means these two lines become:
>
> child1, child2, child3 = unpack(object:getchildren())
>
> and:
>
> childarray = object:getchildren()
>
> *shrug* Both approaches are equally valid. Does anyone have any particular
> comments, advice, related war stories?
>
> --
> +- David Given --McQ-+ "Under communism, man exploits man. Under
> | dg@cowlark.com | capitalism, it's just the opposite." --- John
> | (dg@tao-group.com) | Kenneth Galbrith
> +- www.cowlark.com --+