MCPcopy Create free account
hub / github.com/Tencent/xLua / lua_pcallk

Function lua_pcallk

WebGLPlugins/lapi.c:947–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945
946
947LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
948 lua_KContext ctx, lua_KFunction k) {
949 struct CallS c;
950 int status;
951 ptrdiff_t func;
952 lua_lock(L);
953 api_check(L, k == NULL || !isLua(L->ci),
954 "cannot use continuations inside hooks");
955 api_checknelems(L, nargs+1);
956 api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
957 checkresults(L, nargs, nresults);
958 if (errfunc == 0)
959 func = 0;
960 else {
961 StkId o = index2addr(L, errfunc);
962 api_checkstackindex(L, errfunc, o);
963 func = savestack(L, o);
964 }
965 c.func = L->top - (nargs+1); /* function to be called */
966 if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */
967 c.nresults = nresults; /* do a 'conventional' protected call */
968 status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
969 }
970 else { /* prepare continuation (call is already protected by 'resume') */
971 CallInfo *ci = L->ci;
972 ci->u.c.k = k; /* save continuation */
973 ci->u.c.ctx = ctx; /* save context */
974 /* save information for error recovery */
975 ci->extra = savestack(L, c.func);
976 ci->u.c.old_errfunc = L->errfunc;
977 L->errfunc = func;
978 setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */
979 ci->callstatus |= CIST_YPCALL; /* function can do error recovery */
980 luaD_call(L, c.func, nresults); /* do the call */
981 ci->callstatus &= ~CIST_YPCALL;
982 L->errfunc = ci->u.c.old_errfunc;
983 status = LUA_OK; /* if it is here, there were no errors */
984 }
985 adjustresults(L, nresults);
986 lua_unlock(L);
987 return status;
988}
989
990
991LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,

Callers 3

luaB_pcallFunction · 0.85
luaB_xpcallFunction · 0.85
lua_pcallFunction · 0.85

Calls 3

index2addrFunction · 0.85
luaD_pcallFunction · 0.85
luaD_callFunction · 0.85

Tested by

no test coverage detected