mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
setmetatable raise error
This commit is contained in:
@@ -858,6 +858,8 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
|
||||
}
|
||||
switch (ttnov(obj)) {
|
||||
case LUA_TTABLE: {
|
||||
if (isshared(hvalue(obj)))
|
||||
luaG_runerror(L, "can't setmetatable to shared table");
|
||||
hvalue(obj)->metatable = mt;
|
||||
if (mt) {
|
||||
luaC_objbarrier(L, gcvalue(obj), mt);
|
||||
@@ -1041,10 +1043,8 @@ LUA_API void lua_clonefunction (lua_State *L, const void * fp) {
|
||||
}
|
||||
|
||||
LUA_API void lua_sharefunction (lua_State *L, int index) {
|
||||
if (!lua_isfunction(L,index) || lua_iscfunction(L,index)) {
|
||||
lua_pushstring(L, "Only Lua function can share");
|
||||
lua_error(L);
|
||||
}
|
||||
if (!lua_isfunction(L,index) || lua_iscfunction(L,index))
|
||||
luaG_runerror(L, "Only Lua function can share");
|
||||
LClosure *f = cast(LClosure *, lua_topointer(L, index));
|
||||
luaF_shareproto(f->p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user