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

Go to the source code of this file.

Macros

#define lua_c
 
#define LUA_PROMPT   "> "
 
#define LUA_PROMPT2   ">> "
 
#define LUA_PROGNAME   "lua"
 
#define LUA_MAXINPUT   512
 
#define LUA_INIT   "LUA_INIT"
 
#define LUA_INITVERSION   LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
 
#define lua_stdin_is_tty()   1 /* assume stdin is a tty */
 
#define lua_readline(L, b, p)
 
#define lua_saveline(L, idx)   { (void)L; (void)idx; }
 
#define lua_freeline(L, b)   { (void)L; (void)b; }
 
#define EOFMARK   "<eof>"
 
#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)
 
#define noextrachars(x)   {if ((x)[2] != '\0') return -1;}
 
#define has_i   0 /* -i */
 
#define has_v   1 /* -v */
 
#define has_e   2 /* -e */
 
#define has_E   3 /* -E */
 
#define num_has   4 /* number of 'has_*' */
 

Functions

static void lstop (lua_State *L, lua_Debug *ar)
 
static void laction (int i)
 
static void print_usage (const char *badoption)
 
static void l_message (const char *pname, const char *msg)
 
static int report (lua_State *L, int status)
 
static void finalreport (lua_State *L, int status)
 
static int traceback (lua_State *L)
 
static int docall (lua_State *L, int narg, int nres)
 
static void print_version (void)
 
static int getargs (lua_State *L, char **argv, int n)
 
static int dofile (lua_State *L, const char *name)
 
static int dostring (lua_State *L, const char *s, const char *name)
 
static int dolibrary (lua_State *L, const char *name)
 
static const char * get_prompt (lua_State *L, int firstline)
 
static int incomplete (lua_State *L, int status)
 
static int pushline (lua_State *L, int firstline)
 
static int loadline (lua_State *L)
 
static void dotty (lua_State *L)
 
static int handle_script (lua_State *L, char **argv, int n)
 
static int collectargs (char **argv, int *args)
 
static int runargs (lua_State *L, char **argv, int n)
 
static int handle_luainit (lua_State *L)
 
static int pmain (lua_State *L)
 
int main (int argc, char **argv)
 

Variables

static lua_StateglobalL = NULL
 
static const char * progname = LUA_PROGNAME
 

Macro Definition Documentation

#define EOFMARK   "<eof>"

Definition at line 243 of file lua.cpp.

Referenced by incomplete().

#define has_e   2 /* -e */

Definition at line 350 of file lua.cpp.

Referenced by collectargs(), and pmain().

#define has_E   3 /* -E */

Definition at line 351 of file lua.cpp.

Referenced by collectargs(), and pmain().

#define has_i   0 /* -i */

Definition at line 348 of file lua.cpp.

Referenced by collectargs(), and pmain().

#define has_v   1 /* -v */

Definition at line 349 of file lua.cpp.

Referenced by collectargs(), and pmain().

#define lua_c

Definition at line 12 of file lua.cpp.

#define lua_freeline (   L,
  b 
)    { (void)L; (void)b; }

Definition at line 80 of file lua.cpp.

Referenced by pushline().

#define LUA_INIT   "LUA_INIT"

Definition at line 34 of file lua.cpp.

Referenced by handle_luainit().

#define LUA_INITVERSION   LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR

Definition at line 37 of file lua.cpp.

Referenced by handle_luainit().

#define LUA_MAXINPUT   512

Definition at line 30 of file lua.cpp.

Referenced by pushline().

#define LUA_PROGNAME   "lua"

Definition at line 26 of file lua.cpp.

#define LUA_PROMPT   "> "

Definition at line 21 of file lua.cpp.

Referenced by get_prompt().

#define LUA_PROMPT2   ">> "

Definition at line 22 of file lua.cpp.

Referenced by get_prompt().

#define lua_readline (   L,
  b,
  p 
)
Value:
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1806
#define LUA_MAXINPUT
Definition: lua.cpp:30
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
GLfloat GLfloat p
Definition: glew.h:12766

Definition at line 76 of file lua.cpp.

Referenced by pushline().

#define lua_saveline (   L,
  idx 
)    { (void)L; (void)idx; }

Definition at line 79 of file lua.cpp.

Referenced by loadline().

#define lua_stdin_is_tty ( )    1 /* assume stdin is a tty */

Definition at line 53 of file lua.cpp.

Referenced by pmain().

#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)

Definition at line 244 of file lua.cpp.

Referenced by incomplete().

#define noextrachars (   x)    {if ((x)[2] != '\0') return -1;}

Definition at line 344 of file lua.cpp.

Referenced by collectargs().

#define num_has   4 /* number of 'has_*' */

Definition at line 353 of file lua.cpp.

Referenced by pmain().

Function Documentation

static int collectargs ( char **  argv,
int args 
)
static

Definition at line 356 of file lua.cpp.

References has_e, has_E, has_i, has_v, i, and noextrachars.

Referenced by pmain().

static int docall ( lua_State L,
int  narg,
int  nres 
)
static
static int dofile ( lua_State L,
const char *  name 
)
static

Definition at line 209 of file lua.cpp.

References docall(), LUA_OK, luaL_loadfile, and report().

Referenced by handle_luainit(), and pmain().

static int dolibrary ( lua_State L,
const char *  name 
)
static

Definition at line 223 of file lua.cpp.

References docall(), lua_getglobal(), LUA_OK, lua_pushstring(), lua_setglobal(), and report().

Referenced by runargs().

static int dostring ( lua_State L,
const char *  s,
const char *  name 
)
static

Definition at line 216 of file lua.cpp.

References docall(), LUA_OK, luaL_loadbuffer, and report().

Referenced by handle_luainit(), and runargs().

static void dotty ( lua_State L)
static
static void finalreport ( lua_State L,
int  status 
)
static

Definition at line 148 of file lua.cpp.

References l_message(), LUA_OK, lua_pop, lua_tostring, LUA_TSTRING, lua_type(), game_logic::msg(), and progname.

Referenced by main().

static const char* get_prompt ( lua_State L,
int  firstline 
)
static

Definition at line 234 of file lua.cpp.

References lua_getglobal(), LUA_PROMPT, LUA_PROMPT2, and lua_tostring.

Referenced by pushline().

static int getargs ( lua_State L,
char **  argv,
int  n 
)
static

Definition at line 191 of file lua.cpp.

References i, lua_createtable(), lua_pushstring(), lua_rawseti(), and luaL_checkstack().

Referenced by handle_script().

static int handle_luainit ( lua_State L)
static

Definition at line 422 of file lua.cpp.

References dofile(), dostring(), ai::registry::init(), LUA_INIT, LUA_INITVERSION, and LUA_OK.

Referenced by pmain().

static int handle_script ( lua_State L,
char **  argv,
int  n 
)
static

Definition at line 325 of file lua.cpp.

References docall(), getargs(), lua_insert(), LUA_MULTRET, LUA_OK, lua_pop, lua_setglobal(), luaL_loadfile, and report().

Referenced by pmain().

static int incomplete ( lua_State L,
int  status 
)
static

Definition at line 246 of file lua.cpp.

References EOFMARK, LUA_ERRSYNTAX, lua_pop, lua_tolstring(), marklen, and game_logic::msg().

Referenced by loadline().

static void l_message ( const char *  pname,
const char *  msg 
)
static

Definition at line 128 of file lua.cpp.

References luai_writestringerror.

Referenced by dotty(), finalreport(), main(), and report().

static void laction ( int  i)
static

Definition at line 100 of file lua.cpp.

References lstop(), LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKRET, and lua_sethook().

Referenced by docall().

static int loadline ( lua_State L)
static
static void lstop ( lua_State L,
lua_Debug ar 
)
static

Definition at line 93 of file lua.cpp.

References lua_sethook(), and luaL_error().

Referenced by laction().

int main ( int  argc,
char **  argv 
)
static int pmain ( lua_State L)
static
static void print_usage ( const char *  badoption)
static

Definition at line 107 of file lua.cpp.

References LUA_QL, luai_writestringerror, and progname.

Referenced by main(), and pmain().

static void print_version ( void  )
static

Definition at line 185 of file lua.cpp.

References LUA_COPYRIGHT.

Referenced by pmain().

static int pushline ( lua_State L,
int  firstline 
)
static

Definition at line 259 of file lua.cpp.

References get_prompt(), lua_freeline, LUA_MAXINPUT, lua_pop, lua_pushfstring(), lua_pushstring(), and lua_readline.

Referenced by loadline().

static int report ( lua_State L,
int  status 
)
static
static int runargs ( lua_State L,
char **  argv,
int  n 
)
static

Definition at line 394 of file lua.cpp.

References dolibrary(), dostring(), i, lua_assert, and LUA_OK.

Referenced by pmain().

static int traceback ( lua_State L)
static

Definition at line 159 of file lua.cpp.

References lua_isnoneornil, lua_pushliteral, lua_tostring, luaL_callmeta(), luaL_traceback(), and game_logic::msg().

Referenced by docall().

Variable Documentation

lua_State* globalL = NULL
static

Definition at line 87 of file lua.cpp.

const char* progname = LUA_PROGNAME
static

Definition at line 89 of file lua.cpp.

Referenced by dotty(), finalreport(), pmain(), print_usage(), and report().