annotate lib/lua/lua-5.2.2/linit.c @ 1996:f7e8c4d4a01b

sound id fix
author zipi
date Sun, 03 Nov 2013 14:29:45 +0000
parents 41cc4dd3c122
children
rev   line source
1866
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
1 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
2 ** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
3 ** Initialization of libraries for lua.c and other clients
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
4 ** See Copyright Notice in lua.h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
5 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
6
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
7
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
8 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
9 ** If you embed Lua in your program and need to open the standard
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
10 ** libraries, call luaL_openlibs in your program. If you need a
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
11 ** different set of libraries, copy this file to your project and edit
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
12 ** it to suit your needs.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
13 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
14
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
15
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
16 #define linit_c
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
17 #define LUA_LIB
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
18
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
19 #include "lua.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
20
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
21 #include "lualib.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
22 #include "lauxlib.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
23
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
24
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
25 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
26 ** these libs are loaded by lua.c and are readily available to any Lua
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
27 ** program
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
28 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
29 static const luaL_Reg loadedlibs[] = {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
30 {"_G", luaopen_base},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
31 {LUA_LOADLIBNAME, luaopen_package},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
32 {LUA_COLIBNAME, luaopen_coroutine},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
33 {LUA_TABLIBNAME, luaopen_table},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
34 {LUA_IOLIBNAME, luaopen_io},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
35 {LUA_OSLIBNAME, luaopen_os},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
36 {LUA_STRLIBNAME, luaopen_string},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
37 {LUA_BITLIBNAME, luaopen_bit32},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
38 {LUA_MATHLIBNAME, luaopen_math},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
39 {LUA_DBLIBNAME, luaopen_debug},
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
40 {NULL, NULL}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
41 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
42
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
43
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
44 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
45 ** these libs are preloaded and must be required before used
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
46 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
47 static const luaL_Reg preloadedlibs[] = {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
48 {NULL, NULL}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
49 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
50
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
51
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
52 LUALIB_API void luaL_openlibs (lua_State *L) {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
53 const luaL_Reg *lib;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
54 /* call open functions from 'loadedlibs' and set results to global table */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
55 for (lib = loadedlibs; lib->func; lib++) {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
56 luaL_requiref(L, lib->name, lib->func, 1);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
57 lua_pop(L, 1); /* remove lib */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
58 }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
59 /* add open functions from 'preloadedlibs' into 'package.preload' table */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
60 luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
61 for (lib = preloadedlibs; lib->func; lib++) {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
62 lua_pushcfunction(L, lib->func);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
63 lua_setfield(L, -2, lib->name);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
64 }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
65 lua_pop(L, 1); /* remove _PRELOAD table */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
66 }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
67