lua-users home
lua-l archive

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


Jose Marin wrote:

Hi!

I have a problem when using Luna (or Lunar):

How I create a method to deal with this:

a = Account(100)
b = Account(200)

b:check(a)


The problem is how to, inside the method 'check', get
the pointer to the class Account.




	
	
		
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/

this code is valid for luna template for lua 4.x (I think)

int your_class::check(lua_State *L)
{
	your_class *p;
	lua_pushnumber(L, 0); /* userdata object is stored in index 0 */
	lua_gettable(L, 1);		/* first argument for the user function y the table object
	p = (some_class *)lua_touserdata(L,-1);
	lua_pop(L,1);
	...
... ...
}