lua-users home
lua-l archive

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


Hi,
I've been reading that example in lua-users.org and I don't fully undestand
the function check_image:

lua_getmetatable(L, index);
if( ! lua_equal(L, lua_upvalueindex(1), -1) )
  luaL_typerror(L, index, "Image");  /* die */

to check that the index is an Image, the metatable of the image and the
upvalue should be the same, but why is the metatable of the Image in the
index 1 in this moment?
When calling a metatable method, is the upvalue also placed in the
pseudo-stack? And what if the method of the metatable also has upvalues? are
they placed in the next indices or do they overwrite the previous upvalues?

Thanks in advance,


Ignacio Castaño
castanyo@yahoo.es


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com