lua-users home
lua-l archive

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


> > No, try it! From Lua you can only set the metatables of 
> tables, not of 
> > udata, precisely to avoid crashing the host app from Lua.
> 
> great!  and i see getmetatable() does work, making it 
> possible to check the 
> type.

Using getmetatable was my first thought as well. But that is only half
the story. The check in luaL_checkudata gets both the metatable from the
udata and the metatable from the registry for the specified type. Then
it checks if they are the same. So in lua I can only get the udata
metatable but not the other table to compare against.

It doesn't matter anyway, I have decided not to bother checking the
udata type in lua. There is almost nothing I can do with the wrong type
that wont produce an error of some sort already.

- DC