lua-users home
lua-l archive

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


I'm calling a Lua library I did not write.  From the C API, that is.
The library does not create its userdata metatables in C by
luaL_newmetatable.  Instead, it sets them to tables present in the calling
environment at the moment when the object is constructed.

In consequence I can't check the userdata subtype of something on the Lua
stack by calling luaL_checkudata.

Since I strongly prefer the message "calling 'mymethod' on bad self"
to "Segmentation fault (core dumped)", I would like to check that subtype.
However, it can't be guaranteed that the metatable in question is present
under its original name in the environment that calls my routine.

What other ways are there to do the test?