lua-users home
lua-l archive

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


Hi there.

I have already implemented a small patch for this. 

Look at http://article.gmane.org/gmane.comp.lang.lua.general/7180
(or any other archive mirror of this list ;)

This should hopefully solve your problem. If not, you may want to put
the two structs in different modules. Since the module name is usually
inserted into the C function name, that should fix your problem.

Good luck.
Andre

On Tue, Jan 20, 2004 at 03:15:16PM -0700, Mike Clifton wrote:
> I've run into a problem with tolua, and I'm not sure if I'm using tolua 
> incorrectly, or if this is a bug/limitation of tolua.
> 
> Suppose I have a package file that looks something like this:
> 
> module Test {
> 
> typedef struct {
>     float        x;
>     float        y;
> } vector2d;
> 
> typedef struct {
>     float        x;
>     float        y;
>     float        z;
> } vector3d;
> 
> }
> 
> When I run tolua, the generated code contains multiple functions with 
> the same name. For example, I have two of each of the following functions:
> 
> static int tolua_get_Test_x(lua_State* tolua_S)
> static int tolua_set_Test_x(lua_State* tolua_S)
> static int tolua_get_Test_y(lua_State* tolua_S)
> static int tolua_set_Test_y(lua_State* tolua_S)
> 
> The body of one of these functions would work with the vector2d type, 
> and one of them would work with the vector3d type. Unfortunately, they 
> both have the same name, and so the generated file won't compile. It 
> seems that naming the functions like this would make more sense:
> 
> static int tolua_get_Test_vector2d_x(lua_State* tolua_S)
> static int tolua_get_Test_vector3d_x(lua_State* tolua_S)
> ...etc...
> 
> So, my question comes down to: am I making some mistake - am I using 
> tolua incorrectly? Or, is this a bug in tolua?
> 
> Is it possible to use tolua with two unrelated structs (or classes) that 
> happen to have fields with the same names?
> 
> If this is a bug in tolua, can someone point me to the spot in the tolua 
> source code that I might be able to fix it myself?
> 
> I've actually been using tolua for a while with good success, but have 
> only exposed some methods of C++ classes so far. I only ran into this 
> problem recently when I tried to expose the fields of some structs. I 
> hope there's some way to work around this problem without too much 
> difficulty.
> 
> Thanks,
> Mike
> 

-- 
Tolerance rulez, everything else sux! -- Andre Kloss