Use lua for special level files
Game is playable, and should compile on linux and Windows. Assumes you have a lua 5.3 library available. Removes level compiler and associated files. Replaces special level des-files with lua scripts. Exposes some NetHack internals to lua: - des-table with commands to create special levels - nh-table with NetHack core commands - nhc-table with some constants - u-table with some player-specific data (u-struct) - selection userdata Adds some rudimentary tests. Adds new extended command #wizloadlua to run a specific script, and #wizloaddes to run a specific level-creation script. nhlib.lua is loaded for every lua script. Download and untar lua: mkdir lib cd lib curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz tar zxf lua-5.3.5.tar.gz Then make nethack normally.
This commit is contained in:
@@ -33,6 +33,7 @@ typedef struct align { /* alignment & record */
|
||||
|
||||
#define AM_SPLEV_CO 3
|
||||
#define AM_SPLEV_NONCO 7
|
||||
#define AM_SPLEV_RANDOM 8
|
||||
|
||||
#define Amask2align(x) \
|
||||
((aligntyp)((!(x)) ? A_NONE : ((x) == AM_LAWFUL) ? A_LAWFUL \
|
||||
|
||||
@@ -417,12 +417,9 @@ E struct restore_info restoreinfo;
|
||||
|
||||
E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
|
||||
|
||||
struct opvar {
|
||||
xchar spovartyp; /* one of SPOVAR_foo */
|
||||
union {
|
||||
char *str;
|
||||
long l;
|
||||
} vardata;
|
||||
struct selectionvar {
|
||||
int wid, hei;
|
||||
char *map;
|
||||
};
|
||||
|
||||
struct autopickup_exception {
|
||||
@@ -867,7 +864,7 @@ struct instance_globals {
|
||||
d_level save_dlevel;
|
||||
|
||||
/* do_name.c */
|
||||
struct opvar *gloc_filter_map;
|
||||
struct selectionvar *gloc_filter_map;
|
||||
int gloc_filter_floodfill_match_glyph;
|
||||
int via_naming;
|
||||
|
||||
@@ -1178,6 +1175,7 @@ struct instance_globals {
|
||||
int num_lregions;
|
||||
/* positions touched by level elements explicitly defined in the des-file */
|
||||
char SpLev_Map[COLNO][ROWNO];
|
||||
struct sp_coder *coder;
|
||||
xchar xstart, ystart;
|
||||
char xsize, ysize;
|
||||
boolean splev_init_present;
|
||||
@@ -1187,7 +1185,6 @@ struct instance_globals {
|
||||
struct obj *container_obj[MAX_CONTAINMENT];
|
||||
int container_idx;
|
||||
struct monst *invent_carrying_monster;
|
||||
aligntyp ralign[3];
|
||||
|
||||
/* spells.c */
|
||||
int spl_sortmode; /* index into spl_sortchoices[] */
|
||||
|
||||
@@ -254,6 +254,7 @@ E void NDECL(sanity_check);
|
||||
E char* FDECL(key2txt, (UCHAR_P, char *));
|
||||
E char FDECL(yn_function, (const char *, const char *, CHAR_P));
|
||||
E boolean FDECL(paranoid_query, (BOOLEAN_P, const char *));
|
||||
E void FDECL(makemap_prepost, (BOOLEAN_P, BOOLEAN_P));
|
||||
|
||||
/* ### dbridge.c ### */
|
||||
|
||||
@@ -915,8 +916,10 @@ E char *FDECL(mungspaces, (char *));
|
||||
E char *FDECL(trimspaces, (char *));
|
||||
E char *FDECL(strip_newline, (char *));
|
||||
E char *FDECL(stripchars, (char *, const char *, const char *));
|
||||
E char *FDECL(stripdigits, (char *));
|
||||
E char *FDECL(eos, (char *));
|
||||
E boolean FDECL(str_end_is, (const char *, const char *));
|
||||
E int FDECL(str_lines_maxlen, (const char *));
|
||||
E char *FDECL(strkitten, (char *, CHAR_P));
|
||||
E void FDECL(copynchars, (char *, const char *, int));
|
||||
E char FDECL(chrcasecpy, (int, int));
|
||||
@@ -1262,6 +1265,7 @@ E void FDECL(add_subroom, (struct mkroom *, int, int, int, int, BOOLEAN_P,
|
||||
SCHAR_P, BOOLEAN_P));
|
||||
E void NDECL(makecorridors);
|
||||
E void FDECL(add_door, (int, int, struct mkroom *));
|
||||
E void NDECL(clear_level_structures);
|
||||
E void NDECL(mklev);
|
||||
#ifdef SPECIALIZATION
|
||||
E void FDECL(topologize, (struct mkroom *, BOOLEAN_P));
|
||||
@@ -1646,6 +1650,28 @@ E void NDECL(init_lan_features);
|
||||
E char *NDECL(lan_username);
|
||||
#endif
|
||||
|
||||
/* ### nhlsel.c ### */
|
||||
E struct selectionvar *FDECL(l_selection_check, (lua_State *, int));
|
||||
E int FDECL(l_selection_register, (lua_State *));
|
||||
|
||||
/* ### nhlua.c ### */
|
||||
E boolean FDECL(load_lua, (const char *));
|
||||
E void FDECL(nhl_error, (lua_State *, const char *));
|
||||
E void FDECL(lcheck_param_table, (lua_State *));
|
||||
E schar FDECL(get_table_mapchr, (lua_State *, const char *));
|
||||
E schar FDECL(get_table_mapchr_opt, (lua_State *, const char *, SCHAR_P));
|
||||
E schar FDECL(splev_chr2typ, (CHAR_P));
|
||||
E schar FDECL(check_mapchr, (const char *));
|
||||
E int FDECL(get_table_int, (lua_State *, const char *));
|
||||
E int FDECL(get_table_int_opt, (lua_State *, const char *, int));
|
||||
E char *FDECL(get_table_str, (lua_State *, const char *));
|
||||
E char *FDECL(get_table_str_opt, (lua_State *, const char *, char *));
|
||||
E int FDECL(get_table_boolean, (lua_State *, const char *));
|
||||
E int FDECL(get_table_boolean_opt, (lua_State *, const char *, int));
|
||||
E int FDECL(get_table_option, (lua_State *, const char *, const char *, const char *const *));
|
||||
E int FDECL(str_lines_max_width, (const char *));
|
||||
E char *FDECL(stripdigits, (char *));
|
||||
|
||||
/* ### nhregex.c ### */
|
||||
E struct nhregex *NDECL(regex_init);
|
||||
E boolean FDECL(regex_compile, (const char *, struct nhregex *));
|
||||
@@ -2371,11 +2397,26 @@ E boolean
|
||||
FDECL(dig_corridor, (coord *, coord *, BOOLEAN_P, SCHAR_P, SCHAR_P));
|
||||
E void FDECL(fill_room, (struct mkroom *, BOOLEAN_P));
|
||||
E boolean FDECL(load_special, (const char *));
|
||||
E xchar FDECL(selection_getpoint, (int, int, struct opvar *));
|
||||
E struct opvar *FDECL(selection_opvar, (char *));
|
||||
E void FDECL(opvar_free_x, (struct opvar *));
|
||||
E xchar FDECL(selection_getpoint, (int, int, struct selectionvar *));
|
||||
E struct selectionvar *NDECL(selection_new);
|
||||
E void FDECL(selection_free, (struct selectionvar *));
|
||||
#if !defined(IN_SP_LEV_C)
|
||||
E void FDECL(set_selection_floodfillchk, (int FDECL((*), (int,int))));
|
||||
E void FDECL(selection_floodfill, (struct opvar *, int, int, BOOLEAN_P));
|
||||
#endif
|
||||
E void FDECL(selection_floodfill, (struct selectionvar *, int, int, BOOLEAN_P));
|
||||
E void FDECL(get_location_coord, (schar *, schar *, int, struct mkroom *, long));
|
||||
E void FDECL(selection_setpoint, (int, int, struct selectionvar *, XCHAR_P));
|
||||
E struct selectionvar * FDECL(selection_not, (struct selectionvar *));
|
||||
E void FDECL(selection_filter_percent, (struct selectionvar *, int));
|
||||
E int FDECL(selection_rndcoord, (struct selectionvar *, schar *, schar *, BOOLEAN_P));
|
||||
E void FDECL(selection_do_grow, (struct selectionvar *, int));
|
||||
E void FDECL(selection_do_line, (SCHAR_P, SCHAR_P, SCHAR_P, SCHAR_P, struct selectionvar *));
|
||||
E void FDECL(selection_do_randline, (SCHAR_P, SCHAR_P, SCHAR_P, SCHAR_P, SCHAR_P, SCHAR_P, struct selectionvar *));
|
||||
E struct selectionvar *FDECL(selection_filter_mapchar, (struct selectionvar *, XCHAR_P, int));
|
||||
E void FDECL(set_floodfillchk_match_under, (XCHAR_P));
|
||||
E void FDECL(selection_do_ellipse, (struct selectionvar *, int, int, int, int, int));
|
||||
E void NDECL(update_croom);
|
||||
E void FDECL(l_register_des, (lua_State *));
|
||||
|
||||
/* ### spell.c ### */
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#define ENGRAVEFILE "engrave" /* random engravings on the floor */
|
||||
#define BOGUSMONFILE "bogusmon" /* hallucinatory monsters */
|
||||
#define TRIBUTEFILE "tribute" /* 3.6 tribute to Terry Pratchett */
|
||||
#define LEV_EXT ".lev" /* extension for special level files */
|
||||
#define LEV_EXT ".lua" /* extension for special level files */
|
||||
|
||||
/* Assorted definitions that may depend on selections in config.h. */
|
||||
|
||||
|
||||
@@ -284,4 +284,9 @@ extern void FDECL(nhassert_failed, (const char * exp, const char * file,
|
||||
#define nethack_enter(argc, argv) nethack_enter_winnt()
|
||||
extern void FDECL(nethack_exit, (int)) NORETURN;
|
||||
extern boolean FDECL(file_exists, (const char *));
|
||||
|
||||
#ifndef SYSTEM_H
|
||||
#include "system.h"
|
||||
#endif
|
||||
|
||||
#endif /* NTCONF_H */
|
||||
|
||||
345
include/sp_lev.h
345
include/sp_lev.h
@@ -42,148 +42,9 @@ enum lvlinit_types {
|
||||
LVLINIT_ROGUE
|
||||
};
|
||||
|
||||
/* max. # of random registers */
|
||||
#define MAX_REGISTERS 10
|
||||
|
||||
/* max. nested depth of subrooms */
|
||||
#define MAX_NESTED_ROOMS 5
|
||||
|
||||
/* max. # of opcodes per special level */
|
||||
#define SPCODER_MAX_RUNTIME 65536
|
||||
|
||||
/* Opcodes for creating the level
|
||||
* If you change these, also change opcodestr[] in util/lev_main.c
|
||||
*/
|
||||
enum opcode_defs {
|
||||
SPO_NULL = 0,
|
||||
SPO_MESSAGE,
|
||||
SPO_MONSTER,
|
||||
SPO_OBJECT,
|
||||
SPO_ENGRAVING,
|
||||
SPO_ROOM,
|
||||
SPO_SUBROOM,
|
||||
SPO_DOOR,
|
||||
SPO_STAIR,
|
||||
SPO_LADDER,
|
||||
SPO_ALTAR,
|
||||
SPO_FOUNTAIN,
|
||||
SPO_SINK,
|
||||
SPO_POOL,
|
||||
SPO_TRAP,
|
||||
SPO_GOLD,
|
||||
SPO_CORRIDOR,
|
||||
SPO_LEVREGION,
|
||||
SPO_DRAWBRIDGE,
|
||||
SPO_MAZEWALK,
|
||||
SPO_NON_DIGGABLE,
|
||||
SPO_NON_PASSWALL,
|
||||
SPO_WALLIFY,
|
||||
SPO_MAP,
|
||||
SPO_ROOM_DOOR,
|
||||
SPO_REGION,
|
||||
SPO_MINERALIZE,
|
||||
SPO_CMP,
|
||||
SPO_JMP,
|
||||
SPO_JL,
|
||||
SPO_JLE,
|
||||
SPO_JG,
|
||||
SPO_JGE,
|
||||
SPO_JE,
|
||||
SPO_JNE,
|
||||
SPO_TERRAIN,
|
||||
SPO_REPLACETERRAIN,
|
||||
SPO_EXIT,
|
||||
SPO_ENDROOM,
|
||||
SPO_POP_CONTAINER,
|
||||
SPO_PUSH,
|
||||
SPO_POP,
|
||||
SPO_RN2,
|
||||
SPO_DEC,
|
||||
SPO_INC,
|
||||
SPO_MATH_ADD,
|
||||
SPO_MATH_SUB,
|
||||
SPO_MATH_MUL,
|
||||
SPO_MATH_DIV,
|
||||
SPO_MATH_MOD,
|
||||
SPO_MATH_SIGN,
|
||||
SPO_COPY,
|
||||
SPO_END_MONINVENT,
|
||||
SPO_GRAVE,
|
||||
SPO_FRAME_PUSH,
|
||||
SPO_FRAME_POP,
|
||||
SPO_CALL,
|
||||
SPO_RETURN,
|
||||
SPO_INITLEVEL,
|
||||
SPO_LEVEL_FLAGS,
|
||||
SPO_VAR_INIT, /* variable_name data */
|
||||
SPO_SHUFFLE_ARRAY,
|
||||
SPO_DICE,
|
||||
|
||||
SPO_SEL_ADD,
|
||||
SPO_SEL_POINT,
|
||||
SPO_SEL_RECT,
|
||||
SPO_SEL_FILLRECT,
|
||||
SPO_SEL_LINE,
|
||||
SPO_SEL_RNDLINE,
|
||||
SPO_SEL_GROW,
|
||||
SPO_SEL_FLOOD,
|
||||
SPO_SEL_RNDCOORD,
|
||||
SPO_SEL_ELLIPSE,
|
||||
SPO_SEL_FILTER,
|
||||
SPO_SEL_GRADIENT,
|
||||
SPO_SEL_COMPLEMENT,
|
||||
|
||||
MAX_SP_OPCODES
|
||||
};
|
||||
|
||||
/* MONSTER and OBJECT can take a variable number of parameters,
|
||||
* they also pop different # of values from the stack. So,
|
||||
* first we pop a value that tells what the _next_ value will
|
||||
* mean.
|
||||
*/
|
||||
/* MONSTER */
|
||||
enum sp_mon_var_flags {
|
||||
SP_M_V_PEACEFUL = 0,
|
||||
SP_M_V_ALIGN,
|
||||
SP_M_V_ASLEEP,
|
||||
SP_M_V_APPEAR,
|
||||
SP_M_V_NAME,
|
||||
SP_M_V_FEMALE,
|
||||
SP_M_V_INVIS,
|
||||
SP_M_V_CANCELLED,
|
||||
SP_M_V_REVIVED,
|
||||
SP_M_V_AVENGE,
|
||||
SP_M_V_FLEEING,
|
||||
SP_M_V_BLINDED,
|
||||
SP_M_V_PARALYZED,
|
||||
SP_M_V_STUNNED,
|
||||
SP_M_V_CONFUSED,
|
||||
SP_M_V_SEENTRAPS,
|
||||
|
||||
SP_M_V_END
|
||||
};
|
||||
|
||||
/* OBJECT */
|
||||
enum sp_obj_var_flags {
|
||||
SP_O_V_SPE = 0,
|
||||
SP_O_V_CURSE,
|
||||
SP_O_V_CORPSENM,
|
||||
SP_O_V_NAME,
|
||||
SP_O_V_QUAN,
|
||||
SP_O_V_BURIED,
|
||||
SP_O_V_LIT,
|
||||
SP_O_V_ERODED,
|
||||
SP_O_V_LOCKED,
|
||||
SP_O_V_TRAPPED,
|
||||
SP_O_V_RECHARGED,
|
||||
SP_O_V_INVIS,
|
||||
SP_O_V_GREASED,
|
||||
SP_O_V_BROKEN,
|
||||
SP_O_V_COORD,
|
||||
|
||||
SP_O_V_END
|
||||
};
|
||||
|
||||
/* When creating objects, we need to know whether
|
||||
* it's a container and/or contents.
|
||||
*/
|
||||
@@ -199,25 +60,6 @@ enum sp_obj_var_flags {
|
||||
#define SEL_GRADIENT_RADIAL 0
|
||||
#define SEL_GRADIENT_SQUARE 1
|
||||
|
||||
/* variable types */
|
||||
#define SPOVAR_NULL 0x00
|
||||
#define SPOVAR_INT 0x01 /* l */
|
||||
#define SPOVAR_STRING 0x02 /* str */
|
||||
#define SPOVAR_VARIABLE 0x03 /* str (contains the variable name) */
|
||||
#define SPOVAR_COORD \
|
||||
0x04 /* coordinate, encoded in l; use SP_COORD_X() and SP_COORD_Y() */
|
||||
#define SPOVAR_REGION 0x05 /* region, encoded in l; use SP_REGION_X1() etc \
|
||||
*/
|
||||
#define SPOVAR_MAPCHAR 0x06 /* map char, in l */
|
||||
#define SPOVAR_MONST \
|
||||
0x07 /* monster class & specific monster, encoded in l; use SP_MONST_... \
|
||||
*/
|
||||
#define SPOVAR_OBJ \
|
||||
0x08 /* object class & specific object type, encoded in l; use \
|
||||
SP_OBJ_... */
|
||||
#define SPOVAR_SEL 0x09 /* selection. char[COLNO][ROWNO] in str */
|
||||
#define SPOVAR_ARRAY 0x40 /* used in splev_var & lc_vardefs, not in opvar */
|
||||
|
||||
#define SP_COORD_IS_RANDOM 0x01000000L
|
||||
/* Humidity flags for get_location() and friends, used with
|
||||
* SP_COORD_PACK_RANDOM() */
|
||||
@@ -234,76 +76,18 @@ enum sp_obj_var_flags {
|
||||
#define SP_COORD_PACK(x, y) (((x) & 0xff) + (((y) & 0xff) << 16))
|
||||
#define SP_COORD_PACK_RANDOM(f) (SP_COORD_IS_RANDOM | (f))
|
||||
|
||||
#define SP_REGION_X1(l) (l & 0xff)
|
||||
#define SP_REGION_Y1(l) ((l >> 8) & 0xff)
|
||||
#define SP_REGION_X2(l) ((l >> 16) & 0xff)
|
||||
#define SP_REGION_Y2(l) ((l >> 24) & 0xff)
|
||||
#define SP_REGION_PACK(x1, y1, x2, y2) \
|
||||
(((x1) & 0xff) + (((y1) & 0xff) << 8) + (((x2) & 0xff) << 16) \
|
||||
+ (((y2) & 0xff) << 24))
|
||||
|
||||
/* permonst index, object index, and lit value might be negative;
|
||||
* add 10 to accept -1 through -9 while forcing non-negative for bit shift
|
||||
*/
|
||||
#define SP_MONST_CLASS(l) ((l) & 0xff)
|
||||
#define SP_MONST_PM(l) ((((l) >> 8) & 0xffff) - 10)
|
||||
#define SP_MONST_PACK(pm, cls) (((10 + (pm)) << 8) | ((cls) & 0xff))
|
||||
|
||||
#define SP_OBJ_CLASS(l) ((l) & 0xff)
|
||||
#define SP_OBJ_TYP(l) ((((l) >> 8) & 0xffff) - 10)
|
||||
#define SP_OBJ_PACK(ob, cls) (((10 + (ob)) << 8) | ((cls) & 0xff))
|
||||
|
||||
#define SP_MAPCHAR_TYP(l) ((l) & 0xff)
|
||||
#define SP_MAPCHAR_LIT(l) ((((l) >> 8) & 0xffff) - 10)
|
||||
#define SP_MAPCHAR_PACK(typ, lit) (((10 + (lit)) << 8) | ((typ) & 0xff))
|
||||
|
||||
struct splev_var {
|
||||
struct splev_var *next;
|
||||
char *name;
|
||||
xchar svtyp; /* SPOVAR_foo */
|
||||
union {
|
||||
struct opvar *value;
|
||||
struct opvar **arrayvalues;
|
||||
} data;
|
||||
long array_len;
|
||||
};
|
||||
|
||||
struct splevstack {
|
||||
long depth;
|
||||
long depth_alloc;
|
||||
struct opvar **stackdata;
|
||||
};
|
||||
|
||||
struct sp_frame {
|
||||
struct sp_frame *next;
|
||||
struct splevstack *stack;
|
||||
struct splev_var *variables;
|
||||
long n_opcode;
|
||||
};
|
||||
|
||||
struct sp_coder {
|
||||
struct splevstack *stack;
|
||||
struct sp_frame *frame;
|
||||
int premapped;
|
||||
boolean solidify;
|
||||
struct mkroom *croom;
|
||||
int room_stack;
|
||||
struct mkroom *tmproomlist[MAX_NESTED_ROOMS + 1];
|
||||
boolean failed_room[MAX_NESTED_ROOMS + 1];
|
||||
int n_subroom;
|
||||
boolean exit_script;
|
||||
int lvl_is_joined;
|
||||
boolean check_inaccessibles;
|
||||
|
||||
int opcode; /* current opcode */
|
||||
struct opvar *opdat; /* current push data (req. opcode == SPO_PUSH) */
|
||||
};
|
||||
|
||||
/* special level coder CPU flags */
|
||||
#define SP_CPUFLAG_LT 1
|
||||
#define SP_CPUFLAG_GT 2
|
||||
#define SP_CPUFLAG_EQ 4
|
||||
#define SP_CPUFLAG_ZERO 8
|
||||
|
||||
/*
|
||||
* Structures manipulated by the special levels loader & compiler
|
||||
*/
|
||||
@@ -315,15 +99,6 @@ typedef struct {
|
||||
int x, y;
|
||||
} unpacked_coord;
|
||||
|
||||
typedef struct {
|
||||
int cmp_what;
|
||||
int cmp_val;
|
||||
} opcmp;
|
||||
|
||||
typedef struct {
|
||||
long jmp_target;
|
||||
} opjmp;
|
||||
|
||||
typedef struct {
|
||||
xchar init_style; /* one of LVLINIT_foo */
|
||||
long flags;
|
||||
@@ -416,122 +191,4 @@ typedef struct {
|
||||
char **map;
|
||||
} mazepart;
|
||||
|
||||
typedef struct {
|
||||
int opcode;
|
||||
struct opvar *opdat;
|
||||
} _opcode;
|
||||
|
||||
typedef struct {
|
||||
_opcode *opcodes;
|
||||
long n_opcodes;
|
||||
} sp_lev;
|
||||
|
||||
typedef struct {
|
||||
xchar x, y, direction, count, lit;
|
||||
char typ;
|
||||
} spill;
|
||||
|
||||
/* only used by lev_comp */
|
||||
struct lc_funcdefs_parm {
|
||||
char *name;
|
||||
char parmtype;
|
||||
struct lc_funcdefs_parm *next;
|
||||
};
|
||||
|
||||
struct lc_funcdefs {
|
||||
struct lc_funcdefs *next;
|
||||
char *name;
|
||||
long addr;
|
||||
sp_lev code;
|
||||
long n_called;
|
||||
struct lc_funcdefs_parm *params;
|
||||
long n_params;
|
||||
};
|
||||
|
||||
struct lc_vardefs {
|
||||
struct lc_vardefs *next;
|
||||
char *name;
|
||||
long var_type; /* SPOVAR_foo */
|
||||
long n_used;
|
||||
};
|
||||
|
||||
struct lc_breakdef {
|
||||
struct lc_breakdef *next;
|
||||
struct opvar *breakpoint;
|
||||
int break_depth;
|
||||
};
|
||||
|
||||
/*
|
||||
* Quick! Avert your eyes while you still have a chance!
|
||||
*/
|
||||
#ifdef SPEC_LEV
|
||||
/* compiling lev_comp rather than nethack */
|
||||
/* clang format off */
|
||||
#ifdef USE_OLDARGS
|
||||
#ifndef VA_TYPE
|
||||
typedef const char *vA;
|
||||
#define VA_TYPE
|
||||
#endif
|
||||
/* hack to avoid "warning: cast to 'vA' (aka 'const char *') from smaller
|
||||
integer type 'int' [-Wint-to-pointer-cast]" */
|
||||
#define vA_(a) ((vA) (long) a)
|
||||
#undef VA_ARGS /* redefine with the maximum number actually used */
|
||||
#undef VA_SHIFT /* ditto */
|
||||
#undef VA_PASS1
|
||||
#define VA_ARGS \
|
||||
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, \
|
||||
arg12, arg13, arg14
|
||||
/* Unlike in the core, lev_comp's VA_SHIFT should be completely safe,
|
||||
because callers always pass all these arguments. */
|
||||
#define VA_SHIFT() \
|
||||
(arg1 = arg2, arg2 = arg3, arg3 = arg4, arg4 = arg5, arg5 = arg6, \
|
||||
arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = arg10, arg10 = arg11, \
|
||||
arg11 = arg12, arg12 = arg13, arg13 = arg14, arg14 = 0)
|
||||
/* standard NULL may be either (void *)0 or plain 0, both of
|
||||
which would need to be explicitly cast to (char *) here */
|
||||
#define VA_PASS1(a1) \
|
||||
vA_(a1), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS2(a1,a2) \
|
||||
vA_(a1), vA_(a2), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS3(a1,a2,a3) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS4(a1,a2,a3,a4) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(0), vA_(0), vA_(0), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS5(a1,a2,a3,a4,a5) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(a5), vA_(0), vA_(0), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS7(a1,a2,a3,a4,a5,a6,a7) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(a5), vA_(a6), vA_(a7), vA_(0), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS8(a1,a2,a3,a4,a5,a6,a7,a8) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(a5), vA_(a6), vA_(a7), vA_(a8), \
|
||||
vA_(0), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS9(a1,a2,a3,a4,a5,a6,a7,a8,a9) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(a5), vA_(a6), vA_(a7), vA_(a8), \
|
||||
vA_(a9), vA_(0), vA_(0), vA_(0), vA_(0), vA_(0)
|
||||
#define VA_PASS14(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
|
||||
vA_(a1), vA_(a2), vA_(a3), vA_(a4), vA_(a5), vA_(a6), vA_(a7), vA_(a8), \
|
||||
vA_(a9), vA_(a10), vA_(a11), vA_(a12), vA_(a13), vA_(a14)
|
||||
#else /*!USE_OLDARGS*/
|
||||
/* USE_STDARG and USE_VARARGS don't need to pass dummy arguments
|
||||
or cast real ones */
|
||||
#define VA_PASS1(a1) a1
|
||||
#define VA_PASS2(a1,a2) a1, a2
|
||||
#define VA_PASS3(a1,a2,a3) a1, a2, a3
|
||||
#define VA_PASS4(a1,a2,a3,a4) a1, a2, a3, a4
|
||||
#define VA_PASS5(a1,a2,a3,a4,a5) a1, a2, a3, a4, a5
|
||||
#define VA_PASS7(a1,a2,a3,a4,a5,a6,a7) a1, a2, a3, a4, a5, a6, a7
|
||||
#define VA_PASS8(a1,a2,a3,a4,a5,a6,a7,a8) a1, a2, a3, a4, a5, a6, a7, a8
|
||||
#define VA_PASS9(a1,a2,a3,a4,a5,a6,a7,a8,a9) a1, a2, a3, a4, a5, a6, a7, a8, a9
|
||||
#define VA_PASS14(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
|
||||
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14
|
||||
#endif /*?USE_OLDARGS*/
|
||||
/* clang format on */
|
||||
/* You were warned to avert your eyes.... */
|
||||
#endif /*SPEC_LEV*/
|
||||
|
||||
#endif /* SP_LEV_H */
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#if !defined(WIN32)
|
||||
#if !defined(__cplusplus) && !defined(__GO32__)
|
||||
|
||||
#define E extern
|
||||
|
||||
/* some old <sys/types.h> may not define off_t and size_t; if your system is
|
||||
@@ -339,7 +339,7 @@ E int FDECL(memcmp, (const void *, const void *, size_t));
|
||||
E void *FDECL(memcpy, (void *, const void *, size_t));
|
||||
E void *FDECL(memset, (void *, int, size_t));
|
||||
#else
|
||||
#if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32)
|
||||
#if defined(AZTEC_50) || defined(NHSTDC))
|
||||
E int FDECL(memcmp, (const void *, const void *, size_t));
|
||||
E void *FDECL(memcpy, (void *, const void *, size_t));
|
||||
E void *FDECL(memset, (void *, int, size_t));
|
||||
@@ -453,7 +453,7 @@ E char *FDECL(rindex, (const char *, int));
|
||||
* If your system defines sprintf, et al, in stdio.h, add to the initial
|
||||
* #if.
|
||||
*/
|
||||
#if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
|
||||
#if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60)
|
||||
#define SPRINTF_PROTO
|
||||
#endif
|
||||
#if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
|
||||
@@ -567,5 +567,10 @@ E int FDECL(atoi, (const char *));
|
||||
#undef E
|
||||
|
||||
#endif /* !__cplusplus && !__GO32__ */
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#endif /* SYSTEM_H */
|
||||
|
||||
Reference in New Issue
Block a user