Example #1
0
static int co_create(lua_State *L)
{
  int cstacksize = luaL_optint(L, 2, 0);
  lua_State *NL = lua_newcthread(L, cstacksize);
  luaL_argcheck(L, lua_isfunction(L, 1) &&
		   (cstacksize >= 0 ? 1 : !lua_iscfunction(L, 1)),
		1, "Lua function expected");
  lua_pushvalue(L, 1);  /* move function to top */
  lua_xmove(L, NL, 1);  /* move function from L to NL */
  return 1;
}
Example #2
0
static int luaB_cocreate (lua_State *L) {
#ifdef COCO_DISABLE
  lua_State *NL = lua_newthread(L);
  luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
    "Lua function expected");
#else
  int cstacksize = luaL_optint(L, 2, 0);
  lua_State *NL = lua_newcthread(L, cstacksize);
  luaL_argcheck(L, lua_isfunction(L, 1) &&
                   (cstacksize >= 0 ? 1 : !lua_iscfunction(L, 1)),
                1, "Lua function expected");
#endif
  lua_pushvalue(L, 1);  /* move function to top */
  lua_xmove(L, NL, 1);  /* move function from L to NL */
  return 1;
}