| 10322 | |
| 10323 | |
| 10324 | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { |
| 10325 | lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ |
| 10326 | if (!lua_isnil(L, -1)) /* name already in use? */ |
| 10327 | return 0; /* leave previous value on top, but return 0 */ |
| 10328 | lua_pop(L, 1); |
| 10329 | lua_newtable(L); /* create metatable */ |
| 10330 | lua_pushvalue(L, -1); |
| 10331 | lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ |
| 10332 | return 1; |
| 10333 | } |
| 10334 | |
| 10335 | |
| 10336 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { |
no test coverage detected