Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lua-5.2.4/src/linit.c
Go to the documentation of this file.
1/*
2** $Id: linit.c,v 1.32.1.1 2013/04/12 18:48:47 roberto Exp $
3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h
5*/
6
7
8/*
9** If you embed Lua in your program and need to open the standard
10** libraries, call luaL_openlibs in your program. If you need a
11** different set of libraries, copy this file to your project and edit
12** it to suit your needs.
13*/
14
15
16#define linit_c
17#define LUA_LIB
18
19#include "lua.h"
20
21#include "lualib.h"
22#include "lauxlib.h"
23
24
25/*
26** these libs are loaded by lua.c and are readily available to any Lua
27** program
28*/
42
43
44/*
45** these libs are preloaded and must be required before used
46*/
47static const luaL_Reg preloadedlibs[] = {
48 {NULL, NULL}
49};
50
51
53 const luaL_Reg *lib;
54 /* call open functions from 'loadedlibs' and set results to global table */
55 for (lib = loadedlibs; lib->func; lib++) {
56 luaL_requiref(L, lib->name, lib->func, 1);
57 lua_pop(L, 1); /* remove lib */
58 }
59 /* add open functions from 'preloadedlibs' into 'package.preload' table */
60 luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
61 for (lib = preloadedlibs; lib->func; lib++) {
62 lua_pushcfunction(L, lib->func);
63 lua_setfield(L, -2, lib->name);
64 }
65 lua_pop(L, 1); /* remove _PRELOAD table */
66}
67
#define NULL
Definition gmacros.h:924
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUALIB_API int luaopen_base(lua_State *L)
LUALIB_API int luaopen_debug(lua_State *L)
LUALIB_API int luaopen_io(lua_State *L)
LUALIB_API int luaopen_math(lua_State *L)
LUALIB_API int luaopen_package(lua_State *L)
LUALIB_API int luaopen_os(lua_State *L)
LUALIB_API int luaopen_string(lua_State *L)
LUALIB_API int luaopen_table(lua_State *L)
#define lua_pushcfunction(L, f)
#define LUA_REGISTRYINDEX
#define lua_pop(L, n)
#define LUALIB_API
#define LUA_MATHLIBNAME
#define LUA_DBLIBNAME
#define LUA_IOLIBNAME
#define LUA_COLIBNAME
#define LUA_LOADLIBNAME
#define LUA_STRLIBNAME
#define LUA_TABLIBNAME
#define LUA_OSLIBNAME
LUALIB_API void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb)
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
LUAMOD_API int luaopen_bit32(lua_State *L)
LUAMOD_API int luaopen_coroutine(lua_State *L)
static const luaL_Reg loadedlibs[]
static const luaL_Reg preloadedlibs[]
LUALIB_API void luaL_openlibs(lua_State *L)
#define LUA_BITLIBNAME
lua_CFunction func
const char * name