The Battle for Wesnoth  1.15.12+dev
Macros | Functions | Variables
lcorolib.cpp File Reference
#include "lprefix.h"
#include <stdlib.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for lcorolib.cpp:

Go to the source code of this file.

Macros

#define lcorolib_c
 
#define LUA_LIB
 
#define COS_RUN   0
 
#define COS_DEAD   1
 
#define COS_YIELD   2
 
#define COS_NORM   3
 

Functions

static lua_Stategetco (lua_State *L)
 
static int auxresume (lua_State *L, lua_State *co, int narg)
 
static int luaB_coresume (lua_State *L)
 
static int luaB_auxwrap (lua_State *L)
 
static int luaB_cocreate (lua_State *L)
 
static int luaB_cowrap (lua_State *L)
 
static int luaB_yield (lua_State *L)
 
static int auxstatus (lua_State *L, lua_State *co)
 
static int luaB_costatus (lua_State *L)
 
static int luaB_yieldable (lua_State *L)
 
static int luaB_corunning (lua_State *L)
 
static int luaB_close (lua_State *L)
 
LUAMOD_API int luaopen_coroutine (lua_State *L)
 

Variables

static const char *const statname []
 
static const luaL_Reg co_funcs []
 

Macro Definition Documentation

◆ COS_DEAD

#define COS_DEAD   1

Definition at line 115 of file lcorolib.cpp.

Referenced by auxstatus(), and luaB_close().

◆ COS_NORM

#define COS_NORM   3

Definition at line 117 of file lcorolib.cpp.

Referenced by auxstatus().

◆ COS_RUN

#define COS_RUN   0

Definition at line 114 of file lcorolib.cpp.

Referenced by auxstatus().

◆ COS_YIELD

#define COS_YIELD   2

Definition at line 116 of file lcorolib.cpp.

Referenced by auxstatus(), and luaB_close().

◆ lcorolib_c

#define lcorolib_c

Definition at line 7 of file lcorolib.cpp.

◆ LUA_LIB

#define LUA_LIB

Definition at line 8 of file lcorolib.cpp.

Function Documentation

◆ auxresume()

static int auxresume ( lua_State L,
lua_State co,
int  narg 
)
static

Definition at line 32 of file lcorolib.cpp.

References lua_checkstack(), LUA_OK, lua_pop, lua_pushliteral, lua_resume(), lua_xmove(), and LUA_YIELD.

Referenced by luaB_auxwrap(), and luaB_coresume().

◆ auxstatus()

static int auxstatus ( lua_State L,
lua_State co 
)
static

Definition at line 124 of file lcorolib.cpp.

References COS_DEAD, COS_NORM, COS_RUN, COS_YIELD, lua_getstack(), lua_gettop(), LUA_OK, lua_status(), and LUA_YIELD.

Referenced by luaB_close(), and luaB_costatus().

◆ getco()

static lua_State* getco ( lua_State L)
static

Definition at line 21 of file lcorolib.cpp.

References lua_tothread(), and luaL_argexpected.

Referenced by luaB_close(), luaB_coresume(), luaB_costatus(), and luaB_yieldable().

◆ luaB_auxwrap()

static int luaB_auxwrap ( lua_State L)
static

◆ luaB_close()

static int luaB_close ( lua_State L)
static

◆ luaB_cocreate()

static int luaB_cocreate ( lua_State L)
static

Definition at line 92 of file lcorolib.cpp.

References lua_newthread(), lua_pushvalue(), LUA_TFUNCTION, lua_xmove(), and luaL_checktype().

Referenced by luaB_cowrap().

◆ luaB_coresume()

static int luaB_coresume ( lua_State L)
static

Definition at line 56 of file lcorolib.cpp.

References auxresume(), getco(), lua_gettop(), lua_insert, and lua_pushboolean().

◆ luaB_corunning()

static int luaB_corunning ( lua_State L)
static

Definition at line 160 of file lcorolib.cpp.

References lua_pushboolean(), and lua_pushthread().

◆ luaB_costatus()

static int luaB_costatus ( lua_State L)
static

Definition at line 146 of file lcorolib.cpp.

References auxstatus(), getco(), lua_pushstring(), and statname.

◆ luaB_cowrap()

static int luaB_cowrap ( lua_State L)
static

Definition at line 102 of file lcorolib.cpp.

References lua_pushcclosure(), luaB_auxwrap(), and luaB_cocreate().

◆ luaB_yield()

static int luaB_yield ( lua_State L)
static

Definition at line 109 of file lcorolib.cpp.

References lua_gettop(), and lua_yield.

◆ luaB_yieldable()

static int luaB_yieldable ( lua_State L)
static

Definition at line 153 of file lcorolib.cpp.

References getco(), lua_isnone, lua_isyieldable(), and lua_pushboolean().

◆ luaopen_coroutine()

LUAMOD_API int luaopen_coroutine ( lua_State L)

Definition at line 203 of file lcorolib.cpp.

References luaL_newlib.

Referenced by lua_kernel_base::lua_kernel_base().

Variable Documentation

◆ co_funcs

const luaL_Reg co_funcs[]
static
Initial value:
= {
{"create", luaB_cocreate},
{"resume", luaB_coresume},
{"running", luaB_corunning},
{"status", luaB_costatus},
{"wrap", luaB_cowrap},
{"yield", luaB_yield},
{"isyieldable", luaB_yieldable},
{"close", luaB_close},
{NULL, NULL}
}
static int luaB_cocreate(lua_State *L)
Definition: lcorolib.cpp:92
static int luaB_yield(lua_State *L)
Definition: lcorolib.cpp:109
static int luaB_cowrap(lua_State *L)
Definition: lcorolib.cpp:102
static int luaB_costatus(lua_State *L)
Definition: lcorolib.cpp:146
static int luaB_close(lua_State *L)
Definition: lcorolib.cpp:167
static int luaB_coresume(lua_State *L)
Definition: lcorolib.cpp:56
static int luaB_corunning(lua_State *L)
Definition: lcorolib.cpp:160
static int luaB_yieldable(lua_State *L)
Definition: lcorolib.cpp:153

Definition at line 189 of file lcorolib.cpp.

◆ statname

const char* const statname[]
static
Initial value:
=
{"running", "dead", "suspended", "normal"}

Definition at line 120 of file lcorolib.cpp.

Referenced by luaB_close(), and luaB_costatus().