mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
From Lua 5.2: Add luaL_setmetatable().
Contributed by François Perrad.
This commit is contained in:
parent
cde968f91f
commit
2b8de8cfc6
@ -89,6 +89,7 @@ LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
|
|||||||
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
|
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
|
||||||
int sizehint);
|
int sizehint);
|
||||||
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
|
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
|
||||||
|
LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -193,8 +193,7 @@ static void **ll_register(lua_State *L, const char *path)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
plib = (void **)lua_newuserdata(L, sizeof(void *));
|
plib = (void **)lua_newuserdata(L, sizeof(void *));
|
||||||
*plib = NULL;
|
*plib = NULL;
|
||||||
luaL_getmetatable(L, "_LOADLIB");
|
luaL_setmetatable(L, "_LOADLIB");
|
||||||
lua_setmetatable(L, -2);
|
|
||||||
lua_pushfstring(L, "LOADLIB: %s", path);
|
lua_pushfstring(L, "LOADLIB: %s", path);
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_settable(L, LUA_REGISTRYINDEX);
|
lua_settable(L, LUA_REGISTRYINDEX);
|
||||||
|
@ -1000,6 +1000,12 @@ LUA_API int lua_setmetatable(lua_State *L, int idx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
|
||||||
|
{
|
||||||
|
lua_getfield(L, LUA_REGISTRYINDEX, tname);
|
||||||
|
lua_setmetatable(L, -2);
|
||||||
|
}
|
||||||
|
|
||||||
LUA_API int lua_setfenv(lua_State *L, int idx)
|
LUA_API int lua_setfenv(lua_State *L, int idx)
|
||||||
{
|
{
|
||||||
cTValue *o = index2adr(L, idx);
|
cTValue *o = index2adr(L, idx);
|
||||||
|
Loading…
Reference in New Issue
Block a user