lua-users home
lua-l archive

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

I've been reading that example in 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

Do You Yahoo!?
Get your free address at