[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tolua bug?
- From: Mike Clifton <mclifton@...>
- Date: Wed, 21 Jan 2004 16:32:20 -0700
Unfortunately, tolua++ seems to fix one bug in tolua, but introduces
another. Take the following package for example:
module Test {
enum {
POINT = 100,
LINE = 101,
POLYGON = 102
};
class Vector2D {
float x;
float y;
};
class Vector3D {
Vector2D *GetSomething(int id);
float x;
float y;
float z;
};
}
tolua++ provides correct access to the x and y member variables, whereas
tolua creates overlapping function names. Unfortunately, tolua++ creates
an invalid wrapper for the GetSomething function. A couple lines of
generated code look like this:
Vector3D* self = (Vector3D*) tolua_tousertype(tolua_S,1,0);
id = *(( *) (int) tolua_tousertype(tolua_S,2,0));
Vector2D* tolua_ret = (Vector2D*) self->GetSomething(id);
This problem seems to be related to the enums in the package definition.
If I change the enums to #defines as below, then the problem goes away:
#define POINT 100
#define LINE 101
#define POLYGON 102
Now, the generated code looks like this:
Vector3D* self = (Vector3D*) tolua_tousertype(tolua_S,1,0);
int id = ((int) tolua_tonumber(tolua_S,2,0));
Vector2D* tolua_ret = (Vector2D*) self->GetSomething(id);
So, maybe the answer is simple:
1. If you want to use structs with similarly-named fields, don't use tolua.
2. If you want to use enums, don't use tolua++.
Is this enum thing a known problem in tolua++? Before I go switching
everything over to use tolua++, I'd like to know that it's a bit more
solid than tolua, and I can't decide which one works better.
Waldemar Celes wrote:
Ariel Manzur has been doing a great job fixing bugs and extending tolua.
See tolua++ (http://www.codenix.com/~tolua/).
-- Waldemar
At 15:43 20/1/2004 -0800, you wrote:
There are a number of bugs in tolua5a. There are also problems with
renaming (@) objects and name conflicts. You could look back through the
lua-l archives for more details. It would be nice if someone were to fix
these problems as tolua's author seems to have gone AWOL.
Nick