updated window_procs

Add a non-string identifier to window_procs for use in runtime
identification of the current window port being used.

Use a macro WPID to add the identification at the top of the
various existing window_procs declarations. It expands to the
existing text string, as well as the newly added field wp_id
with a wp_ identifier.

For example, WPID(tty) expands to: "tty", wp_tty

The generated wp_tty must be present in the wp_ids enum at
the top of include/winprocs.h.

The WINDOWPORT(x) macro has been updated to expand to a simple
value comparison (port.wp_id == wp_x), instead of a
string comparison.
This commit is contained in:
nhmall
2022-06-29 23:21:19 -04:00
parent a518d82c54
commit f228fefabd
15 changed files with 39 additions and 18 deletions

View File

@@ -7,11 +7,20 @@
#include "botl.h"
enum wp_ids { wp_tty = 1, wp_X11, wp_Qt, wp_mswin, wp_curses,
wp_chainin, wp_chainout, wp_safestartup, wp_shim,
wp_hup, wp_guistubs, wp_ttystubs,
#ifdef OUTDATED_STUFF
, wp_mac, wp_Gem, wp_Gnome, wp_amii, wp_amiv
#endif
};
/* NB: this MUST match chain_procs below */
struct window_procs {
const char *name; /* Names should start with [a-z]. Names must
* not start with '-'. Names starting with
* '+' are reserved for processors. */
enum wp_ids wp_id;
unsigned long wincap; /* window port capability options supported */
unsigned long wincap2; /* additional window port capability options */
boolean has_color[CLR_MAX];
@@ -167,6 +176,12 @@ extern
#define status_update (*windowprocs.win_status_update)
#define update_invent_slot (*windowprocs.win_update_invent_slot)
/*
*
*/
#define WPID(name) #name, wp_##name
#define WPIDMINUS(name) "-" #name, wp_##name
/*
* WINCAP
* Window port preference capability bits.
@@ -278,8 +293,13 @@ struct wc_Opt {
/* Macro for the currently active Window Port whose function
pointers have been loaded */
#if 0
/* 3.7 The string comparison version isn't used anymore */
#define WINDOWPORT(wn) \
(windowprocs.name && !strncmpi((#wn), windowprocs.name, strlen((#wn))))
#endif
#define WINDOWPORT(wn) (windowprocs.wp_id == wp_##wn)
/* role selection by player_selection(); this ought to be in the core... */
#define RS_NAME 0
@@ -320,6 +340,7 @@ struct chain_procs {
const char *name; /* Names should start with [a-z]. Names must
* not start with '-'. Names starting with
* '+' are reserved for processors. */
enum wp_ids wp_id;
unsigned long wincap; /* window port capability options supported */
unsigned long wincap2; /* additional window port capability options */
boolean has_color[CLR_MAX];