misc/liblua/lauxlib.h
author unc0rr
Sun, 10 Apr 2011 20:24:25 +0400
changeset 5130 3602ede67ec5
parent 2812 0a24853de796
child 10017 de822cd3df3a
permissions -rw-r--r--
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Auxiliary functions for building Lua libraries
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#ifndef lauxlib_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
#define lauxlib_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
#include <stddef.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
#include <stdio.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
#if defined(LUA_COMPAT_GETN)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
LUALIB_API int (luaL_getn) (lua_State *L, int t);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    20
LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
#else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
#define luaL_getn(L,i)          ((int)lua_objlen(L, i))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
#define luaL_setn(L,i,j)        ((void)0)  /* no op! */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
#endif
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
#if defined(LUA_COMPAT_OPENLIB)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
#define luaI_openlib	luaL_openlib
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
#endif
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
/* extra error code for `luaL_load' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
#define LUA_ERRFILE     (LUA_ERRERR+1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
typedef struct luaL_Reg {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
  const char *name;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
  lua_CFunction func;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
} luaL_Reg;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
                                const luaL_Reg *l, int nup);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
                                const luaL_Reg *l);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
                                                          size_t *l);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
                                          const char *def, size_t *l);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    57
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    58
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
                                          lua_Integer def);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    60
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    61
LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    69
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    70
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
                                   const char *const lst[]);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
LUALIB_API int (luaL_ref) (lua_State *L, int t);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
                                  const char *name);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
LUALIB_API lua_State *(luaL_newstate) (void);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
                                                  const char *r);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
                                         const char *fname, int szhint);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
** ===============================================================
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
** some useful macros
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
** ===============================================================
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
#define luaL_argcheck(L, cond,numarg,extramsg)	\
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
		((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
#define luaL_dofile(L, fn) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
#define luaL_dostring(L, s) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
** {======================================================
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
** Generic Buffer manipulation
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
** =======================================================
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
typedef struct luaL_Buffer {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
  char *p;			/* current position in buffer */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
  int lvl;  /* number of strings in the stack (level) */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
  lua_State *L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
  char buffer[LUAL_BUFFERSIZE];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
} luaL_Buffer;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
#define luaL_addchar(B,c) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
  ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
   (*(B)->p++ = (char)(c)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
/* compatibility only */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
#define luaL_putchar(B,c)	luaL_addchar(B,c)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
#define luaL_addsize(B,n)	((B)->p += (n))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
/* }====================================================== */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
/* compatibility with ref system */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   158
/* pre-defined references */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   159
#define LUA_NOREF       (-2)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
#define LUA_REFNIL      (-1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
      (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
#define lua_unref(L,ref)        luaL_unref(L, LUA_REGISTRYINDEX, (ref))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
#define lua_getref(L,ref)       lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
#define luaL_reg	luaL_Reg
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   171
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   172
#endif
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   173
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174