| 230 | */ |
| 231 | |
| 232 | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { |
| 233 | luaL_getmetatable(L, tname); /* try to get metatable */ |
| 234 | if (!lua_isnil(L, -1)) /* name already in use? */ |
| 235 | return 0; /* leave previous value on top, but return 0 */ |
| 236 | lua_pop(L, 1); |
| 237 | lua_newtable(L); /* create metatable */ |
| 238 | lua_pushvalue(L, -1); |
| 239 | lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ |
| 240 | return 1; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { |
no test coverage detected