lua-users home
lua-l archive

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


Hmm, I think I experienced your original problem as well. It only happened with one class I was using, and mysteriously disappeared when I later added more member variables to the class.

I'd also be interested to hear if there's a way around this, as I'm sure it'll come back sooner or later and bite me.

You could try modifying your class to look like the following, and see what happens. It's not a real solution, but I'd be curious to hear what happens.

class MyContainer {
  void *dummy;
  MyString first_value;
  ...
}

-Mike

Johann Hibschman wrote:

I think I've figured out my odd problem with tolua5.0, as mentioned in

http://lua-users.org/lists/lua-l/2004-01/msg00136.html

but it seems like it should have come up before, if true.

I think my problem is that I have a class MyString and a class MyContainer arranged as:

class MyContainer {
  MyString first_value;
  ...
}

Now, the address of a MyContainer instance and of MyContainer.first_value are the same. This seems to confuse tolua, since now two objects of different types have the same key into the global table.

Hence:

Lua 5.0  Copyright (C) 1994-2003 Tecgraf, PUC-Rio
 > c = MyContainer:new()
 > =tolua.type(c)
MyContainer
 > first = c.first_value
 > =tolua.type(c)
MyString

Is there any way around this? I'm using tolua++1.0.2, but I get the same results on plain tolua5.0.

Cheers,

Johann