Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lualib.h File Reference
#include "lua.h"

Go to the source code of this file.

Macros

#define LUA_FILEHANDLE   "FILE*"
 
#define LUA_COLIBNAME   "coroutine"
 
#define LUA_TABLIBNAME   "table"
 
#define LUA_IOLIBNAME   "io"
 
#define LUA_OSLIBNAME   "os"
 
#define LUA_STRLIBNAME   "string"
 
#define LUA_MATHLIBNAME   "math"
 
#define LUA_DBLIBNAME   "debug"
 
#define LUA_LOADLIBNAME   "package"
 
#define lua_assert(x)   ((void)0)
 

Functions

LUALIB_API int luaopen_base (lua_State *L)
 
LUALIB_API int luaopen_table (lua_State *L)
 
LUALIB_API int luaopen_io (lua_State *L)
 
LUALIB_API int luaopen_os (lua_State *L)
 
LUALIB_API int luaopen_string (lua_State *L)
 
LUALIB_API int luaopen_math (lua_State *L)
 
LUALIB_API int luaopen_debug (lua_State *L)
 
LUALIB_API int luaopen_package (lua_State *L)
 
LUALIB_API void luaL_openlibs (lua_State *L)
 

Macro Definition Documentation

◆ lua_assert

#define lua_assert ( x)    ((void)0)

Definition at line 49 of file lua-5.1.5/src/lualib.h.

◆ LUA_COLIBNAME

#define LUA_COLIBNAME   "coroutine"

Definition at line 18 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_base().

◆ LUA_DBLIBNAME

#define LUA_DBLIBNAME   "debug"

Definition at line 36 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_debug().

◆ LUA_FILEHANDLE

#define LUA_FILEHANDLE   "FILE*"

◆ LUA_IOLIBNAME

#define LUA_IOLIBNAME   "io"

Definition at line 24 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_io().

◆ LUA_LOADLIBNAME

#define LUA_LOADLIBNAME   "package"

Definition at line 39 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_package().

◆ LUA_MATHLIBNAME

#define LUA_MATHLIBNAME   "math"

Definition at line 33 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_math().

◆ LUA_OSLIBNAME

#define LUA_OSLIBNAME   "os"

Definition at line 27 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_os().

◆ LUA_STRLIBNAME

#define LUA_STRLIBNAME   "string"

Definition at line 30 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_string().

◆ LUA_TABLIBNAME

#define LUA_TABLIBNAME   "table"

Definition at line 21 of file lua-5.1.5/src/lualib.h.

Referenced by luaopen_table().

Function Documentation

◆ luaL_openlibs()

LUALIB_API void luaL_openlibs ( lua_State * L)

Definition at line 30 of file lua-5.1.5/src/linit.c.

30 {
31 const luaL_Reg *lib = lualibs;
32 for (; lib->func; lib++) {
33 lua_pushcfunction(L, lib->func);
34 lua_pushstring(L, lib->name);
35 lua_call(L, 1, 0);
36 }
37}
LUA_API void lua_pushstring(lua_State *L, const char *s)
static const luaL_Reg lualibs[]
#define lua_pushcfunction(L, f)
#define lua_call(L, n, r)
lua_CFunction func
const char * name

◆ luaopen_base()

LUALIB_API int luaopen_base ( lua_State * L)

Definition at line 648 of file lua-5.1.5/src/lbaselib.c.

648 {
649 base_open(L);
651 return 2;
652}
LUALIB_API void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l)
static const luaL_Reg co_funcs[]
static void base_open(lua_State *L)
#define LUA_COLIBNAME

◆ luaopen_debug()

LUALIB_API int luaopen_debug ( lua_State * L)

Definition at line 394 of file lua-5.1.5/src/ldblib.c.

394 {
396 return 1;
397}
static const luaL_Reg dblib[]
#define LUA_DBLIBNAME

◆ luaopen_io()

LUALIB_API int luaopen_io ( lua_State * L)

Definition at line 537 of file lua-5.1.5/src/liolib.c.

537 {
538 createmeta(L);
539 /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
540 newfenv(L, io_fclose);
542 /* open library */
544 /* create (and set) default files */
545 newfenv(L, io_noclose); /* close function for default files */
546 createstdfile(L, stdin, IO_INPUT, "stdin");
547 createstdfile(L, stdout, IO_OUTPUT, "stdout");
548 createstdfile(L, stderr, 0, "stderr");
549 lua_pop(L, 1); /* pop environment for default files */
550 lua_getfield(L, -1, "popen");
551 newfenv(L, io_pclose); /* create environment for 'popen' */
552 lua_setfenv(L, -2); /* set fenv for 'popen' */
553 lua_pop(L, 1); /* pop 'popen' */
554 return 1;
555}
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUA_API int lua_setfenv(lua_State *L, int idx)
static void createmeta(lua_State *L)
static void createstdfile(lua_State *L, FILE *f, int k, const char *fname)
#define IO_INPUT
static int io_fclose(lua_State *L)
static void newfenv(lua_State *L, lua_CFunction cls)
static int io_noclose(lua_State *L)
static const luaL_Reg iolib[]
#define IO_OUTPUT
static int io_pclose(lua_State *L)
#define LUA_ENVIRONINDEX
#define lua_pop(L, n)
#define LUA_IOLIBNAME
#define lua_replace(L, idx)

◆ luaopen_math()

LUALIB_API int luaopen_math ( lua_State * L)

Definition at line 251 of file lua-5.1.5/src/lmathlib.c.

251 {
253 lua_pushnumber(L, PI);
254 lua_setfield(L, -2, "pi");
255 lua_pushnumber(L, HUGE_VAL);
256 lua_setfield(L, -2, "huge");
257#if defined(LUA_COMPAT_MOD)
258 lua_getfield(L, -1, "fmod");
259 lua_setfield(L, -2, "mod");
260#endif
261 return 1;
262}
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
#define PI
static const luaL_Reg mathlib[]
#define LUA_MATHLIBNAME

◆ luaopen_os()

LUALIB_API int luaopen_os ( lua_State * L)

Definition at line 239 of file lua-5.1.5/src/loslib.c.

239 {
241 return 1;
242}
static const luaL_Reg syslib[]
#define LUA_OSLIBNAME

◆ luaopen_package()

LUALIB_API int luaopen_package ( lua_State * L)

Definition at line 627 of file lua-5.1.5/src/loadlib.c.

627 {
628 int i;
629 /* create new type _LOADLIB */
630 luaL_newmetatable(L, "_LOADLIB");
632 lua_setfield(L, -2, "__gc");
633 /* create `package' table */
635#if defined(LUA_COMPAT_LOADLIB)
636 lua_getfield(L, -1, "loadlib");
637 lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
638#endif
639 lua_pushvalue(L, -1);
641 /* create `loaders' table */
642 lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
643 /* fill it with pre-defined loaders */
644 for (i=0; loaders[i] != NULL; i++) {
646 lua_rawseti(L, -2, i+1);
647 }
648 lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
649 setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */
650 setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
651 /* store config information */
654 lua_setfield(L, -2, "config");
655 /* set field `loaded' */
656 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);
657 lua_setfield(L, -2, "loaded");
658 /* set field `preload' */
659 lua_newtable(L);
660 lua_setfield(L, -2, "preload");
662 luaL_register(L, NULL, ll_funcs); /* open lib into global table */
663 lua_pop(L, 1);
664 return 1; /* return 'package' table */
665}
#define NULL
Definition gmacros.h:924
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
LUALIB_API const char * luaL_findtable(lua_State *L, int idx, const char *fname, int szhint)
static const luaL_Reg ll_funcs[]
static int gctm(lua_State *L)
static const lua_CFunction loaders[]
static void setpath(lua_State *L, const char *fieldname, const char *envname, const char *def)
static const luaL_Reg pk_funcs[]
#define LUA_REGISTRYINDEX
#define lua_pushliteral(L, s)
#define lua_newtable(L)
#define LUA_GLOBALSINDEX
#define LUA_CPATH
#define LUA_EXECDIR
#define LUA_DIRSEP
#define LUA_CPATH_DEFAULT
#define LUA_PATH_MARK
#define LUA_PATH
#define LUA_PATHSEP
#define LUA_IGMARK
#define LUA_PATH_DEFAULT
#define LUA_LOADLIBNAME

◆ luaopen_string()

LUALIB_API int luaopen_string ( lua_State * L)

Definition at line 862 of file lua-5.1.5/src/lstrlib.c.

862 {
864#if defined(LUA_COMPAT_GFIND)
865 lua_getfield(L, -1, "gmatch");
866 lua_setfield(L, -2, "gfind");
867#endif
869 return 1;
870}
static void createmetatable(lua_State *L)
static const luaL_Reg strlib[]
#define LUA_STRLIBNAME

◆ luaopen_table()

LUALIB_API int luaopen_table ( lua_State * L)

Definition at line 283 of file lua-5.1.5/src/ltablib.c.

283 {
285 return 1;
286}
static const luaL_Reg tab_funcs[]
#define LUA_TABLIBNAME