static int luaB_cowrap(lua_State * L) { luaB_cocreate(L); lua_pushcclosure(L, luaB_auxwrap, 1); return 1; }
/** * Creates a new coroutine, with body f. f must be a Lua function. * Returns a function that resumes the coroutine each time it is * called. Any arguments passed to the function behave as the extra * arguments to resume. Returns the same values returned by resume, * except the first boolean. In case of error, propagates the error. */ static int luaB_cowrap (lua_State *L) { luaB_cocreate(L); /* 上面函数执行后 function 在栈顶, function 为其 upvalue */ lua_pushcclosure(L, luaB_auxwrap, 1); return 1; }