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

Go to the source code of this file.

Classes

struct  LoadF
 
struct  LoadS
 

Macros

#define lauxlib_c
 
#define LUA_LIB
 
#define LEVELS1   12 /* size of the first part of the stack */
 
#define LEVELS2   10 /* size of the second part of the stack */
 
#define inspectstat(stat, what)   /* no op */
 
#define buffonstack(B)   ((B)->b != (B)->initb)
 
#define freelist   0
 

Typedefs

typedef struct LoadF LoadF
 
typedef struct LoadS LoadS
 

Functions

static int findfield (lua_State *L, int objidx, int level)
 
static int pushglobalfuncname (lua_State *L, lua_Debug *ar)
 
static void pushfuncname (lua_State *L, lua_Debug *ar)
 
static int countlevels (lua_State *L)
 
LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level)
 
LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg)
 
static int typeerror (lua_State *L, int narg, const char *tname)
 
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname)
 
static void tag_error (lua_State *L, int narg, int tag)
 
LUALIB_API void luaL_where (lua_State *L, int level)
 
LUALIB_API int luaL_error (lua_State *L, const char *fmt,...)
 
LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname)
 
LUALIB_API int luaL_execresult (lua_State *L, int stat)
 
LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname)
 
LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname)
 
LUALIB_API voidluaL_testudata (lua_State *L, int ud, const char *tname)
 
LUALIB_API voidluaL_checkudata (lua_State *L, int ud, const char *tname)
 
LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, const char *const lst[])
 
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg)
 
LUALIB_API void luaL_checktype (lua_State *L, int narg, int t)
 
LUALIB_API void luaL_checkany (lua_State *L, int narg)
 
LUALIB_API const char * luaL_checklstring (lua_State *L, int narg, size_t *len)
 
LUALIB_API const char * luaL_optlstring (lua_State *L, int narg, const char *def, size_t *len)
 
LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg)
 
LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def)
 
LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg)
 
LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg)
 
LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, lua_Integer def)
 
LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int narg, lua_Unsigned def)
 
LUALIB_API char * luaL_prepbuffsize (luaL_Buffer *B, size_t sz)
 
LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l)
 
LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s)
 
LUALIB_API void luaL_pushresult (luaL_Buffer *B)
 
LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz)
 
LUALIB_API void luaL_addvalue (luaL_Buffer *B)
 
LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B)
 
LUALIB_API char * luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz)
 
LUALIB_API int luaL_ref (lua_State *L, int t)
 
LUALIB_API void luaL_unref (lua_State *L, int t, int ref)
 
static const char * getF (lua_State *L, void *ud, size_t *size)
 
static int errfile (lua_State *L, const char *what, int fnameindex)
 
static int skipBOM (LoadF *lf)
 
static int skipcomment (LoadF *lf, int *cp)
 
LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, const char *mode)
 
static const char * getS (lua_State *L, void *ud, size_t *size)
 
LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size, const char *name, const char *mode)
 
LUALIB_API int luaL_loadstring (lua_State *L, const char *s)
 
LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event)
 
LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event)
 
LUALIB_API int luaL_len (lua_State *L, int idx)
 
LUALIB_API const char * luaL_tolstring (lua_State *L, int idx, size_t *len)
 
static const char * luaL_findtable (lua_State *L, int idx, const char *fname, int szhint)
 
static int libsize (const luaL_Reg *l)
 
LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, int sizehint)
 
LUALIB_API void luaL_openlib (lua_State *L, const char *libname, const luaL_Reg *l, int nup)
 
LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup)
 
LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname)
 
LUALIB_API void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb)
 
LUALIB_API const char * luaL_gsub (lua_State *L, const char *s, const char *p, const char *r)
 
static voidl_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
 
static int panic (lua_State *L)
 
LUALIB_API lua_StateluaL_newstate (void)
 
LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver)
 

Macro Definition Documentation

#define buffonstack (   B)    ((B)->b != (B)->initb)

Definition at line 433 of file lauxlib.cpp.

Referenced by luaL_addvalue(), luaL_prepbuffsize(), and luaL_pushresult().

#define freelist   0

Definition at line 521 of file lauxlib.cpp.

Referenced by luaL_ref(), and luaL_unref().

#define inspectstat (   stat,
  what 
)    /* no op */

Definition at line 242 of file lauxlib.cpp.

Referenced by luaL_execresult().

#define lauxlib_c

Definition at line 18 of file lauxlib.cpp.

#define LEVELS1   12 /* size of the first part of the stack */

Definition at line 33 of file lauxlib.cpp.

Referenced by luaL_traceback().

#define LEVELS2   10 /* size of the second part of the stack */

Definition at line 34 of file lauxlib.cpp.

Referenced by luaL_traceback().

#define LUA_LIB

Definition at line 19 of file lauxlib.cpp.

Typedef Documentation

typedef struct LoadF LoadF
typedef struct LoadS LoadS

Function Documentation

static int countlevels ( lua_State L)
static

Definition at line 100 of file lauxlib.cpp.

References lua_getstack().

Referenced by luaL_traceback().

static int errfile ( lua_State L,
const char *  what,
int  fnameindex 
)
static

Definition at line 589 of file lauxlib.cpp.

References LUA_ERRFILE, lua_pushfstring(), lua_remove(), and lua_tostring.

Referenced by luaL_loadfilex().

static int findfield ( lua_State L,
int  objidx,
int  level 
)
static
static const char* getF ( lua_State L,
void ud,
size_t *  size 
)
static

Definition at line 571 of file lauxlib.cpp.

References LoadF::buff, LoadF::f, and LoadF::n.

Referenced by luaL_loadfilex().

static const char* getS ( lua_State L,
void ud,
size_t *  size 
)
static

Definition at line 674 of file lauxlib.cpp.

References LoadS::s, and LoadS::size.

Referenced by luaL_loadbufferx().

static void* l_alloc ( void ud,
void ptr,
size_t  osize,
size_t  nsize 
)
static

Definition at line 921 of file lauxlib.cpp.

Referenced by luaL_newstate().

static int libsize ( const luaL_Reg l)
static

Definition at line 799 of file lauxlib.cpp.

References luaL_Reg::name.

Referenced by luaL_openlib().

LUALIB_API void luaL_addlstring ( luaL_Buffer B,
const char *  s,
size_t  l 
)
LUALIB_API void luaL_addstring ( luaL_Buffer B,
const char *  s 
)

Definition at line 468 of file lauxlib.cpp.

References luaL_addlstring().

Referenced by addquoted(), and luaL_gsub().

LUALIB_API void luaL_addvalue ( luaL_Buffer B)
LUALIB_API int luaL_argerror ( lua_State L,
int  narg,
const char *  extramsg 
)

Definition at line 152 of file lauxlib.cpp.

References lua_getinfo(), lua_getstack(), LUA_QS, lua_tostring, luaL_error(), lua_Debug::name, lua_Debug::namewhat, and pushglobalfuncname().

Referenced by ai::cfun_ai_get_suitable_keep(), checkoption(), db_getinfo(), db_getlocal(), db_setlocal(), db_setuservalue(), find_widget(), g_read(), impl_context_accessor(), game_lua_kernel::impl_game_config_set(), impl_race_get(), impl_side_set(), impl_unit_attack_get(), impl_unit_attack_set(), impl_unit_attacks_get(), impl_unit_attacks_len(), impl_unit_get(), impl_unit_set(), impl_unit_status_get(), impl_unit_status_set(), impl_unit_type_get(), impl_unit_variables_get(), impl_unit_variables_set(), lua_gui2::intf_add_dialog_tree_node(), intf_add_known_unit(), intf_add_modification(), intf_compare_versions(), game_lua_kernel::intf_erase_unit(), game_lua_kernel::intf_extract_unit(), game_lua_kernel::intf_find_cost_map(), intf_find_path(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_find_reach(), lua_map_location::intf_get_adjacent_tiles(), lua_gui2::intf_get_dialog_value(), lua_map_location::intf_get_direction(), lua_map_location::intf_get_in_basis_N_NE(), game_lua_kernel::intf_get_side_variable(), game_lua_kernel::intf_get_starting_location(), game_lua_kernel::intf_get_time_of_day(), game_lua_kernel::intf_get_unit(), game_lua_kernel::intf_highlight_hex(), game_lua_kernel::intf_match_unit(), intf_name_generator(), lua_map_location::intf_parse_direction(), game_lua_kernel::intf_put_recall_unit(), game_lua_kernel::intf_put_unit(), intf_random(), game_lua_kernel::intf_random(), lua_fileops::intf_read_file(), lua_gui2::intf_remove_dialog_item(), lua_kernel_base::intf_require(), game_lua_kernel::intf_select_unit(), lua_gui2::intf_set_dialog_active(), lua_gui2::intf_set_dialog_callback(), lua_gui2::intf_set_dialog_canvas(), lua_gui2::intf_set_dialog_markup(), lua_gui2::intf_set_dialog_value(), lua_gui2::intf_set_dialog_visible(), game_lua_kernel::intf_set_side_variable(), game_lua_kernel::intf_set_time_of_day(), game_lua_kernel::intf_set_variable(), game_lua_kernel::intf_simulate_combat(), intf_synchronize_choice(), intf_synchronize_choices(), intf_transform_unit(), lua_map_location::intf_vector_negation(), lua_map_location::intf_write_direction(), load_fake_units(), lua_fileops::load_file(), lua_check_impl::lua_check(), luaL_checkany(), luaL_checkoption(), game_lua_kernel::run_wml_conditional(), lua_gui2::show_message_dialog(), str_format(), and typeerror().

LUALIB_API void luaL_buffinit ( lua_State L,
luaL_Buffer B 
)
LUALIB_API char* luaL_buffinitsize ( lua_State L,
luaL_Buffer B,
size_t  sz 
)

Definition at line 506 of file lauxlib.cpp.

References luaL_buffinit(), and luaL_prepbuffsize().

Referenced by str_char(), str_lower(), str_rep(), str_reverse(), and str_upper().

LUALIB_API int luaL_callmeta ( lua_State L,
int  obj,
const char *  event 
)

Definition at line 717 of file lauxlib.cpp.

References lua_absindex(), lua_call, lua_pushvalue(), and luaL_getmetafield().

Referenced by luaL_tolstring(), and traceback().

LUALIB_API void luaL_checkany ( lua_State L,
int  narg 
)
LUALIB_API lua_Integer luaL_checkinteger ( lua_State L,
int  narg 
)
LUALIB_API const char* luaL_checklstring ( lua_State L,
int  narg,
size_t *  len 
)
LUALIB_API lua_Number luaL_checknumber ( lua_State L,
int  narg 
)
LUALIB_API int luaL_checkoption ( lua_State L,
int  narg,
const char *  def,
const char *const  lst[] 
)
LUALIB_API void luaL_checkstack ( lua_State L,
int  space,
const char *  msg 
)
LUALIB_API void luaL_checktype ( lua_State L,
int  narg,
int  t 
)
LUALIB_API void* luaL_checkudata ( lua_State L,
int  ud,
const char *  tname 
)
LUALIB_API lua_Unsigned luaL_checkunsigned ( lua_State L,
int  narg 
)
LUALIB_API void luaL_checkversion_ ( lua_State L,
lua_Number  ver 
)
LUALIB_API int luaL_error ( lua_State L,
const char *  fmt,
  ... 
)
LUALIB_API int luaL_execresult ( lua_State L,
int  stat 
)
LUALIB_API int luaL_fileresult ( lua_State L,
int  stat,
const char *  fname 
)
static const char* luaL_findtable ( lua_State L,
int  idx,
const char *  fname,
int  szhint 
)
static
LUALIB_API int luaL_getmetafield ( lua_State L,
int  obj,
const char *  event 
)
LUALIB_API int luaL_getsubtable ( lua_State L,
int  idx,
const char *  fname 
)
LUALIB_API const char* luaL_gsub ( lua_State L,
const char *  s,
const char *  p,
const char *  r 
)
LUALIB_API int luaL_len ( lua_State L,
int  idx 
)

Definition at line 727 of file lauxlib.cpp.

References int(), lua_len(), lua_pop, lua_tointegerx(), and luaL_error().

Referenced by gctm(), ll_addtoclib(), tconcat(), and unpack().

LUALIB_API int luaL_loadbufferx ( lua_State L,
const char *  buff,
size_t  size,
const char *  name,
const char *  mode 
)

Definition at line 684 of file lauxlib.cpp.

References getS(), lua_load(), LoadS::s, and LoadS::size.

Referenced by luaB_load().

LUALIB_API int luaL_loadfilex ( lua_State L,
const char *  filename,
const char *  mode 
)
LUALIB_API int luaL_loadstring ( lua_State L,
const char *  s 
)
LUALIB_API int luaL_newmetatable ( lua_State L,
const char *  tname 
)
LUALIB_API lua_State* luaL_newstate ( void  )

Definition at line 939 of file lauxlib.cpp.

References l_alloc(), lua_atpanic(), lua_newstate(), and panic().

Referenced by main().

LUALIB_API void luaL_openlib ( lua_State L,
const char *  libname,
const luaL_Reg l,
int  nup 
)
LUALIB_API lua_Integer luaL_optinteger ( lua_State L,
int  narg,
lua_Integer  def 
)

Definition at line 409 of file lauxlib.cpp.

References luaL_checkinteger(), and luaL_opt.

Referenced by f_setvbuf(), intf_name_generator(), str_byte(), str_find_aux(), str_gsub(), and str_sub().

LUALIB_API const char* luaL_optlstring ( lua_State L,
int  narg,
const char *  def,
size_t *  len 
)

Definition at line 366 of file lauxlib.cpp.

References lua_isnoneornil, and luaL_checklstring().

Referenced by str_rep(), and tconcat().

LUALIB_API lua_Number luaL_optnumber ( lua_State L,
int  narg,
lua_Number  def 
)

Definition at line 386 of file lauxlib.cpp.

References luaL_checknumber(), and luaL_opt.

Referenced by f_seek(), and os_difftime().

LUALIB_API lua_Unsigned luaL_optunsigned ( lua_State L,
int  narg,
lua_Unsigned  def 
)

Definition at line 415 of file lauxlib.cpp.

References luaL_checkunsigned(), and luaL_opt.

LUALIB_API char* luaL_prepbuffsize ( luaL_Buffer B,
size_t  sz 
)
LUALIB_API void luaL_pushmodule ( lua_State L,
const char *  modname,
int  sizehint 
)
LUALIB_API void luaL_pushresult ( luaL_Buffer B)
LUALIB_API void luaL_pushresultsize ( luaL_Buffer B,
size_t  sz 
)

Definition at line 481 of file lauxlib.cpp.

References luaL_addsize, and luaL_pushresult().

Referenced by str_char(), str_lower(), str_rep(), str_reverse(), and str_upper().

LUALIB_API int luaL_ref ( lua_State L,
int  t 
)
LUALIB_API void luaL_requiref ( lua_State L,
const char *  modname,
lua_CFunction  openf,
int  glb 
)
LUALIB_API void luaL_setfuncs ( lua_State L,
const luaL_Reg l,
int  nup 
)
LUALIB_API void luaL_setmetatable ( lua_State L,
const char *  tname 
)
LUALIB_API void* luaL_testudata ( lua_State L,
int  ud,
const char *  tname 
)
LUALIB_API const char* luaL_tolstring ( lua_State L,
int  idx,
size_t *  len 
)
LUALIB_API void luaL_traceback ( lua_State L,
lua_State L1,
const char *  msg,
int  level 
)
LUALIB_API int luaL_typerror ( lua_State L,
int  narg,
const char *  tname 
)
LUALIB_API void luaL_unref ( lua_State L,
int  t,
int  ref 
)
LUALIB_API void luaL_where ( lua_State L,
int  level 
)
static int panic ( lua_State L)
static

Definition at line 932 of file lauxlib.cpp.

References lua_tostring, and luai_writestringerror.

Referenced by luaD_throw(), and luaL_newstate().

static void pushfuncname ( lua_State L,
lua_Debug ar 
)
static
static int pushglobalfuncname ( lua_State L,
lua_Debug ar 
)
static
static int skipBOM ( LoadF lf)
static

Definition at line 598 of file lauxlib.cpp.

References LoadF::buff, c, LoadF::f, and LoadF::n.

Referenced by skipcomment().

static int skipcomment ( LoadF lf,
int cp 
)
static

Definition at line 619 of file lauxlib.cpp.

References LoadF::f, and skipBOM().

Referenced by luaL_loadfilex().

static void tag_error ( lua_State L,
int  narg,
int  tag 
)
static
static int typeerror ( lua_State L,
int  narg,
const char *  tname 
)
static