Adopt C99 bool in the midend API.

This changes parameters of midend_size and midend_print_puzzle, the
return types of midend_process_key, midend_wants_statusbar,
midend_can_format_as_text_now and midend_can_{undo,redo}, the 'bval'
field in struct config_item, and finally the return type of the
function pointer passed to midend_deserialise and identify_game.

The last of those changes requires a corresponding fix in clients of
midend_deserialise and identify_game, so in this commit I've also
updated all the in-tree front ends to match. I expect downstream front
ends will need to do the same when they merge this change.
This commit is contained in:
Simon Tatham
2018-11-13 21:37:09 +00:00
parent a76d269cf2
commit cd6cadbecf
7 changed files with 50 additions and 51 deletions

View File

@ -2854,7 +2854,7 @@ when finished with by passing it to the game's own
\H{midend-size} \cw{midend_size()}
\c void midend_size(midend *me, int *x, int *y, int user_size);
\c void midend_size(midend *me, int *x, int *y, bool user_size);
Tells the mid-end to figure out its window size.
@ -2872,7 +2872,7 @@ status bar is also not included in this size.)
Use \c{user_size} to indicate whether \c{*x} and \c{*y} are a
requested size, or just a maximum size.
If \c{user_size} is set to \cw{TRUE}, the mid-end will treat the
If \c{user_size} is set to \cw{true}, the mid-end will treat the
input size as a request, and will pick a tile size which
approximates it \e{as closely as possible}, going over the game's
preferred tile size if necessary to achieve this. The mid-end will
@ -2995,7 +2995,7 @@ call to this function. Some back ends require that \cw{midend_size()}
\H{midend-process-key} \cw{midend_process_key()}
\c int midend_process_key(midend *me, int x, int y, int button);
\c bool midend_process_key(midend *me, int x, int y, int button);
The front end calls this function to report a mouse or keyboard
event. The parameters \c{x}, \c{y} and \c{button} are almost
@ -3028,10 +3028,10 @@ Calling this function is very likely to result in calls back to the
front end's drawing API and/or \cw{activate_timer()}
(\k{frontend-activate-timer}).
The return value from \cw{midend_process_key()} is non-zero, unless
the effect of the keypress was to request termination of the
program. A front end should shut down the puzzle in response to a
zero return.
The return value from \cw{midend_process_key()} is \cw{true} unless
the effect of the keypress was to request termination of the program.
A front end should shut down the puzzle in response to a \cw{false}
return.
\H{midend-request-keys} \cw{midend_request_keys()}
@ -3147,9 +3147,9 @@ of the corresponding \cw{struct preset_menu_entry} returned by
\H{midend-wants-statusbar} \cw{midend_wants_statusbar()}
\c int midend_wants_statusbar(midend *me);
\c bool midend_wants_statusbar(midend *me);
This function returns \cw{TRUE} if the puzzle has a use for a
This function returns \cw{true} if the puzzle has a use for a
textual status line (to display score, completion status, currently
active tiles, time, or anything else).
@ -3267,12 +3267,12 @@ The returned string, if it is non-\cw{NULL}, is dynamically allocated.
\H{midend-can-format-as-text-now} \cw{midend_can_format_as_text_now()}
\c int midend_can_format_as_text_now(midend *me);
\c bool midend_can_format_as_text_now(midend *me);
Returns \cw{TRUE} if the game code is capable of formatting puzzles
Returns \cw{true} if the game code is capable of formatting puzzles
of the currently selected game type as ASCII.
If this returns \cw{FALSE}, then \cw{midend_text_format()}
If this returns \cw{false}, then \cw{midend_text_format()}
(\k{midend-text-format}) will return \cw{NULL}.
\H{midend-text-format} \cw{midend_text_format()}
@ -3324,18 +3324,18 @@ status code.)
\H{midend-can-undo} \cw{midend_can_undo()}
\c int midend_can_undo(midend *me);
\c bool midend_can_undo(midend *me);
Returns \cw{TRUE} if the midend is currently in a state where the undo
Returns \cw{true} if the midend is currently in a state where the undo
operation is meaningful (i.e. at least one position exists on the undo
chain before the present one). Front ends may wish to use this to
visually activate and deactivate an undo button.
\H{midend-can-redo} \cw{midend_can_redo()}
\c int midend_can_redo(midend *me);
\c bool midend_can_redo(midend *me);
Returns \cw{TRUE} if the midend is currently in a state where the redo
Returns \cw{true} if the midend is currently in a state where the redo
operation is meaningful (i.e. at least one position exists on the redo
chain after the present one). Front ends may wish to use this to
visually activate and deactivate a redo button.
@ -3367,7 +3367,7 @@ output string.
\H{midend-deserialise} \cw{midend_deserialise()}
\c const char *midend_deserialise(midend *me,
\c int (*read)(void *ctx, void *buf, int len), void *rctx);
\c bool (*read)(void *ctx, void *buf, int len), void *rctx);
This function is the counterpart to \cw{midend_serialise()}. It
calls the supplied \cw{read} function repeatedly to read a quantity
@ -3376,8 +3376,8 @@ as output by \cw{midend_serialise()}.
The \cw{read} function is called with the first parameter (\c{ctx})
equal to \c{rctx}, and should attempt to read \c{len} bytes of data
into the buffer pointed to by \c{buf}. It should return \cw{FALSE}
on failure or \cw{TRUE} on success. It should not report success
into the buffer pointed to by \c{buf}. It should return \cw{false}
on failure or \cw{true} on success. It should not report success
unless it has filled the entire buffer; on platforms which might be
reading from a pipe or other blocking data source, \c{read} is
responsible for looping until the whole buffer has been filled.
@ -3405,7 +3405,7 @@ place.
\H{identify-game} \cw{identify_game()}
\c const char *identify_game(char **name,
\c int (*read)(void *ctx, void *buf, int len), void *rctx);
\c bool (*read)(void *ctx, void *buf, int len), void *rctx);
This function examines a serialised midend stream, of the same kind
used by \cw{midend_serialise()} and \cw{midend_deserialise()}, and