tolua 4.0a suggestions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

tolua 4.0a suggestions

Christian Vogler-2
I've been playing with tolua 4.0a. In general, it does just as great a
job as tolua 3.2, but one change broke our project. In a way it is our
fault, because it relied on the undocumented data structures that
tolua exposed to lua. Nevertheless, I think that some information in
the data structures was genuinely useful, and I would like to suggest
an addition to the tolua API to expose the equivalent of that information.

We need specifically the information that the .tolua_itag table
provided: given the name of a class, what is the tag of its instance?
In our case, constructing a dummy instance of the class and finding
out via the tag() function is not an option. Alternatively, given the
tag of a class, returning the tag of the corresponding instance would
also work.


So, ideally I would like to see something like this:

tolua.instance_tag(classname) --> returns tag of instance or nil if
classname is not known to tolua.

OR:

tolua.instance_tag(classtag) --> returns tag of instance or nil if
classtag is not known to tolua.

Comments anyone?

(The rest of this message is quite technical - feel free to skip)

The reason why we need this information is that we have some objects
that act as proxies for others. Consider something like:

class A {
   int do_something();
};

class AProxy {
   AProxy(A *instance);
};


In lua, we must be able to do the following:

a_inst = A:new()
a_proxy = AProxy:new(a_inst)
result = a_proxy:do_something()  --> returns a_inst:do_something()

The way this works in our project is that we set up the gettable tag
method for the AProxy class to forward to the A class. Because we have
a lot of these kinds of classes lying around, this is far easier than
writing the bindings like this:


class A {
   int do_something();
};

class AProxy {
   int do_something();
};


This is prone to errors (incorrectly copying methods from A to
AProxy). It is also very tedious to set up, since some classes have a
lot of methods and multiple classes that can act as proxies. It is
less robust to additions to our class interfaces, which still
invariably happen from time to time. Worst of all, it amounts to an
enormous increase in code size of the generated bindings.

To set up the proxy mechanism, we used to look through all
tolua-registered classes, and for the ones that could act as proxies,
we recovered its instance tag, then registered the tag method. This is
where the request for tolua.instance_tag() comes in.

- Christian

Reply | Threaded
Open this post in threaded view
|

Re: tolua 4.0a suggestions

Waldemar Celes-3

>
>
> We need specifically the information that the .tolua_itag table
> provided: given the name of a class, what is the tag of its instance?
> In our case, constructing a dummy instance of the class and finding
> out via the tag() function is not an option. Alternatively, given the
> tag of a class, returning the tag of the corresponding instance would
> also work.

Lua 4.1 will provide support for extended types,
allowing the programmer to bind a name to a tag.
This feature will be, of course, used by tolua to register its types.
So, querying a tag given its name (and vice versa) will be naturally
supported.

-- waldemar




Reply | Threaded
Open this post in threaded view
|

Re: tolua 4.0a suggestions

Christian Vogler-2
Waldemar,

On Mon, Mar 05, 2001 at 04:32:44PM -0300, Waldemar Celes wrote:
> Lua 4.1 will provide support for extended types,
> allowing the programmer to bind a name to a tag.
> This feature will be, of course, used by tolua to register its types.
> So, querying a tag given its name (and vice versa) will be naturally
> supported.

that's great to hear. 

Do you have any plans porting tklua and gllua to the 4.x series? As I
said in my message to the list, if not, I will look into this by
myself, but either way, I need to know, because this is high priority
for Siome and me.

- Christian

Reply | Threaded
Open this post in threaded view
|

Re: tolua 4.0a suggestions

Waldemar Celes-3

>
>
> Do you have any plans porting tklua and gllua to the 4.x series? As I
> said in my message to the list, if not, I will look into this by
> myself, but either way, I need to know, because this is high priority
> for Siome and me.
>

I am working on gllua. I would appreciate if someone could try to port
tklua.
I haven't used tklua lately, and I am afraid I will not find a spare time
to
work on it.

-- waldemar