The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
loadlib.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for loadlib.cpp:

Go to the source code of this file.

Macros

#define loadlib_c
 
#define LUA_LIB
 
#define LUA_PATH   "LUA_PATH"
 
#define LUA_CPATH   "LUA_CPATH"
 
#define LUA_PATHSUFFIX   "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
 
#define LUA_PATHVERSION   LUA_PATH LUA_PATHSUFFIX
 
#define LUA_CPATHVERSION   LUA_CPATH LUA_PATHSUFFIX
 
#define LUA_PATH_SEP   ";"
 
#define LUA_PATH_MARK   "?"
 
#define LUA_EXEC_DIR   "!"
 
#define LUA_IGMARK   "-"
 
#define LUA_CSUBSEP   LUA_DIRSEP
 
#define LUA_LSUBSEP   LUA_DIRSEP
 
#define LUA_POF   "luaopen_"
 
#define LUA_OFSEP   "_"
 
#define CLIBS   "_CLIBS"
 
#define LIB_FAIL   "open"
 
#define ERRLIB   1
 
#define ERRFUNC   2
 
#define setprogdir(L)   ((void)0)
 
#define LIB_FAIL   "absent"
 
#define DLMSG   "dynamic libraries not enabled; check your Lua installation"
 
#define AUXMARK   "\1"
 

Functions

static void ll_unloadlib (void *lib)
 
static voidll_load (lua_State *L, const char *path, int seeglb)
 
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym)
 
static voidll_checkclib (lua_State *L, const char *path)
 
static void ll_addtoclib (lua_State *L, const char *path, void *plib)
 
static int gctm (lua_State *L)
 
static int ll_loadfunc (lua_State *L, const char *path, const char *sym)
 
static int ll_loadlib (lua_State *L)
 
static int readable (const char *filename)
 
static const char * pushnexttemplate (lua_State *L, const char *path)
 
static const char * searchpath (lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep)
 
static int ll_searchpath (lua_State *L)
 
static const char * findfile (lua_State *L, const char *name, const char *pname, const char *dirsep)
 
static int checkload (lua_State *L, int stat, const char *filename)
 
static int searcher_Lua (lua_State *L)
 
static int loadfunc (lua_State *L, const char *filename, const char *modname)
 
static int searcher_C (lua_State *L)
 
static int searcher_Croot (lua_State *L)
 
static int searcher_preload (lua_State *L)
 
static void findloader (lua_State *L, const char *name)
 
static int ll_require (lua_State *L)
 
static void set_env (lua_State *L)
 
static void dooptions (lua_State *L, int n)
 
static void modinit (lua_State *L, const char *modname)
 
static int ll_module (lua_State *L)
 
static int ll_seeall (lua_State *L)
 
static int noenv (lua_State *L)
 
static void setpath (lua_State *L, const char *fieldname, const char *envname1, const char *envname2, const char *def)
 
static void createsearcherstable (lua_State *L)
 
LUAMOD_API int luaopen_package (lua_State *L)
 

Variables

static const luaL_Reg pk_funcs []
 
static const luaL_Reg ll_funcs []
 

Macro Definition Documentation

#define AUXMARK   "\1"

Definition at line 621 of file loadlib.cpp.

Referenced by setpath().

#define CLIBS   "_CLIBS"

Definition at line 95 of file loadlib.cpp.

Referenced by ll_addtoclib(), ll_checkclib(), and luaopen_package().

#define DLMSG   "dynamic libraries not enabled; check your Lua installation"

Definition at line 225 of file loadlib.cpp.

Referenced by ll_load(), and ll_sym().

#define ERRFUNC   2

Definition at line 102 of file loadlib.cpp.

Referenced by ll_loadfunc(), loadfunc(), and searcher_Croot().

#define ERRLIB   1

Definition at line 101 of file loadlib.cpp.

Referenced by ll_loadfunc(), and ll_loadlib().

#define LIB_FAIL   "open"

Definition at line 222 of file loadlib.cpp.

Referenced by ll_loadlib().

#define LIB_FAIL   "absent"

Definition at line 222 of file loadlib.cpp.

#define loadlib_c

Definition at line 23 of file loadlib.cpp.

#define LUA_CPATH   "LUA_CPATH"

Definition at line 41 of file loadlib.cpp.

Referenced by luaopen_package().

#define LUA_CPATHVERSION   LUA_CPATH LUA_PATHSUFFIX

Definition at line 47 of file loadlib.cpp.

Referenced by luaopen_package().

#define LUA_CSUBSEP   LUA_DIRSEP

Definition at line 79 of file loadlib.cpp.

Referenced by searcher_C(), and searcher_Croot().

#define LUA_EXEC_DIR   "!"

Definition at line 65 of file loadlib.cpp.

Referenced by luaopen_package().

#define LUA_IGMARK   "-"

Definition at line 68 of file loadlib.cpp.

Referenced by loadfunc(), and luaopen_package().

#define LUA_LIB

Definition at line 24 of file loadlib.cpp.

#define LUA_LSUBSEP   LUA_DIRSEP

Definition at line 83 of file loadlib.cpp.

Referenced by searcher_Lua().

#define LUA_OFSEP   "_"

Definition at line 91 of file loadlib.cpp.

Referenced by loadfunc().

#define LUA_PATH   "LUA_PATH"

Definition at line 37 of file loadlib.cpp.

Referenced by luaopen_package().

#define LUA_PATH_MARK   "?"

Definition at line 62 of file loadlib.cpp.

Referenced by luaopen_package(), and searchpath().

#define LUA_PATH_SEP   ";"

Definition at line 59 of file loadlib.cpp.

Referenced by luaopen_package(), pushnexttemplate(), and setpath().

#define LUA_PATHSUFFIX   "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR

Definition at line 44 of file loadlib.cpp.

#define LUA_PATHVERSION   LUA_PATH LUA_PATHSUFFIX

Definition at line 46 of file loadlib.cpp.

Referenced by luaopen_package().

#define LUA_POF   "luaopen_"

Definition at line 88 of file loadlib.cpp.

Referenced by loadfunc().

#define setprogdir (   L)    ((void)0)

Definition at line 104 of file loadlib.cpp.

Referenced by setpath().

Function Documentation

static int checkload ( lua_State L,
int  stat,
const char *  filename 
)
static

Definition at line 397 of file loadlib.cpp.

References lua_pushstring(), LUA_QS, lua_tostring, and luaL_error().

Referenced by searcher_C(), searcher_Croot(), and searcher_Lua().

static void createsearcherstable ( lua_State L)
static
static void dooptions ( lua_State L,
int  n 
)
static

Definition at line 557 of file loadlib.cpp.

References i, lua_call, lua_isfunction, and lua_pushvalue().

Referenced by ll_module().

static const char* findfile ( lua_State L,
const char *  name,
const char *  pname,
const char *  dirsep 
)
static
static void findloader ( lua_State L,
const char *  name 
)
static
static int gctm ( lua_State L)
static

Definition at line 274 of file loadlib.cpp.

References ll_unloadlib(), lua_pop, lua_rawgeti(), lua_touserdata(), and luaL_len().

Referenced by luaopen_package().

static void ll_addtoclib ( lua_State L,
const char *  path,
void plib 
)
static
static void* ll_checkclib ( lua_State L,
const char *  path 
)
static

Definition at line 250 of file loadlib.cpp.

References CLIBS, lua_getfield(), lua_pop, LUA_REGISTRYINDEX, and lua_touserdata().

Referenced by ll_loadfunc().

static void * ll_load ( lua_State L,
const char *  path,
int  seeglb 
)
static

Definition at line 233 of file loadlib.cpp.

References DLMSG, and lua_pushliteral.

Referenced by ll_loadfunc().

static int ll_loadfunc ( lua_State L,
const char *  path,
const char *  sym 
)
static
static int ll_loadlib ( lua_State L)
static
static int ll_module ( lua_State L)
static
static int ll_require ( lua_State L)
static
static int ll_searchpath ( lua_State L)
static
static int ll_seeall ( lua_State L)
static
static lua_CFunction ll_sym ( lua_State L,
void lib,
const char *  sym 
)
static

Definition at line 240 of file loadlib.cpp.

References DLMSG, and lua_pushliteral.

Referenced by ll_loadfunc().

static void ll_unloadlib ( void lib)
static

Definition at line 228 of file loadlib.cpp.

Referenced by gctm().

static int loadfunc ( lua_State L,
const char *  filename,
const char *  modname 
)
static
LUAMOD_API int luaopen_package ( lua_State L)
static void modinit ( lua_State L,
const char *  modname 
)
static

Definition at line 569 of file loadlib.cpp.

References lua_pushlstring(), lua_pushstring(), lua_pushvalue(), and lua_setfield().

Referenced by ll_module().

static int noenv ( lua_State L)
static

Definition at line 627 of file loadlib.cpp.

References lua_getfield(), lua_pop, LUA_REGISTRYINDEX, and lua_toboolean().

Referenced by setpath().

static const char* pushnexttemplate ( lua_State L,
const char *  path 
)
static

Definition at line 337 of file loadlib.cpp.

References LUA_PATH_SEP, and lua_pushlstring().

Referenced by searchpath().

static int readable ( const char *  filename)
static

Definition at line 329 of file loadlib.cpp.

Referenced by searchpath().

static int searcher_C ( lua_State L)
static

Definition at line 436 of file loadlib.cpp.

References checkload(), findfile(), loadfunc(), LUA_CSUBSEP, and luaL_checkstring.

Referenced by createsearcherstable().

static int searcher_Croot ( lua_State L)
static
static int searcher_Lua ( lua_State L)
static

Definition at line 409 of file loadlib.cpp.

References checkload(), findfile(), LUA_LSUBSEP, LUA_OK, luaL_checkstring, and luaL_loadfile.

Referenced by createsearcherstable().

static int searcher_preload ( lua_State L)
static
static const char* searchpath ( lua_State L,
const char *  name,
const char *  path,
const char *  sep,
const char *  dirsep 
)
static
static void set_env ( lua_State L)
static
static void setpath ( lua_State L,
const char *  fieldname,
const char *  envname1,
const char *  envname2,
const char *  def 
)
static

Variable Documentation

const luaL_Reg ll_funcs[]
static
Initial value:
= {
{"module", ll_module},
{"require", ll_require},
{NULL, NULL}
}
static int ll_require(lua_State *L)
Definition: loadlib.cpp:507
static int ll_module(lua_State *L)
Definition: loadlib.cpp:584

Definition at line 665 of file loadlib.cpp.

const luaL_Reg pk_funcs[]
static
Initial value:
= {
{"loadlib", ll_loadlib},
{"searchpath", ll_searchpath},
{"seeall", ll_seeall},
{NULL, NULL}
}
static int ll_searchpath(lua_State *L)
Definition: loadlib.cpp:371
static int ll_loadlib(lua_State *L)
Definition: loadlib.cpp:306
static int ll_seeall(lua_State *L)
Definition: loadlib.cpp:603

Definition at line 655 of file loadlib.cpp.