mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Allow running C functions with coroutine.create(), too.
This commit is contained in:
parent
751ff5b392
commit
3754a8fe7a
@ -479,8 +479,8 @@ LJLIB_CF(coroutine_running)
|
|||||||
LJLIB_CF(coroutine_create)
|
LJLIB_CF(coroutine_create)
|
||||||
{
|
{
|
||||||
lua_State *L1 = lua_newthread(L);
|
lua_State *L1 = lua_newthread(L);
|
||||||
if (!(L->top > L->base && tvisfunc(L->base) && isluafunc(funcV(L->base))))
|
if (!(L->base < L->top && tvisfunc(L->base)))
|
||||||
lj_err_arg(L, 1, LJ_ERR_NOLFUNC);
|
lj_err_argt(L, 1, LUA_TFUNCTION);
|
||||||
setfuncV(L, L1->top++, funcV(L->base));
|
setfuncV(L, L1->top++, funcV(L->base));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ static int setjitmode(lua_State *L, int mode)
|
|||||||
if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE)
|
if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE)
|
||||||
lj_err_caller(L, LJ_ERR_NOJIT);
|
lj_err_caller(L, LJ_ERR_NOJIT);
|
||||||
err:
|
err:
|
||||||
lj_err_arg(L, 1, LJ_ERR_NOLFUNC);
|
lj_err_argt(L, 1, LUA_TFUNCTION);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ ERRDEF(BADVAL, "invalid value")
|
|||||||
ERRDEF(NOVAL, "value expected")
|
ERRDEF(NOVAL, "value expected")
|
||||||
ERRDEF(NOCORO, "coroutine expected")
|
ERRDEF(NOCORO, "coroutine expected")
|
||||||
ERRDEF(NOTABN, "nil or table expected")
|
ERRDEF(NOTABN, "nil or table expected")
|
||||||
ERRDEF(NOLFUNC, "Lua function expected")
|
|
||||||
ERRDEF(NOFUNCL, "function or level expected")
|
ERRDEF(NOFUNCL, "function or level expected")
|
||||||
ERRDEF(NOSFT, "string/function/table expected")
|
ERRDEF(NOSFT, "string/function/table expected")
|
||||||
ERRDEF(NOPROXY, "boolean or proxy expected")
|
ERRDEF(NOPROXY, "boolean or proxy expected")
|
||||||
|
Loading…
Reference in New Issue
Block a user