| 270 | */ |
| 271 | |
| 272 | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { |
| 273 | luaL_getmetatable(L, tname); /* try to get metatable */ |
| 274 | if (!lua_isnil(L, -1)) /* name already in use? */ |
| 275 | return 0; /* leave previous value on top, but return 0 */ |
| 276 | lua_pop(L, 1); |
| 277 | lua_newtable(L); /* create metatable */ |
| 278 | lua_pushvalue(L, -1); |
| 279 | lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ |
| 280 | return 1; |
| 281 | } |
| 282 | |
| 283 | |
| 284 | LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { |
no test coverage detected