mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Make emcc.c clean under -Wmissing-prototypes etc
Also -Wstrict-prototypes and -Wmissing-variable-declarations. Functions that are called from JavaScript now have a separate declaration at the top of the file with a comment reminding one to update emcclib.js if they're changed.
This commit is contained in:
50
emcc.c
50
emcc.c
@ -59,8 +59,8 @@ extern void js_get_date_64(unsigned *p);
|
|||||||
extern void js_update_permalinks(const char *desc, const char *seed);
|
extern void js_update_permalinks(const char *desc, const char *seed);
|
||||||
extern void js_enable_undo_redo(bool undo, bool redo);
|
extern void js_enable_undo_redo(bool undo, bool redo);
|
||||||
extern void js_update_key_labels(const char *lsk, const char *csk);
|
extern void js_update_key_labels(const char *lsk, const char *csk);
|
||||||
extern void js_activate_timer();
|
extern void js_activate_timer(void);
|
||||||
extern void js_deactivate_timer();
|
extern void js_deactivate_timer(void);
|
||||||
extern void js_canvas_start_draw(void);
|
extern void js_canvas_start_draw(void);
|
||||||
extern void js_canvas_draw_update(int x, int y, int w, int h);
|
extern void js_canvas_draw_update(int x, int y, int w, int h);
|
||||||
extern void js_canvas_end_draw(void);
|
extern void js_canvas_end_draw(void);
|
||||||
@ -88,7 +88,7 @@ extern void js_canvas_remove_statusbar(void);
|
|||||||
extern void js_canvas_set_statusbar(const char *text);
|
extern void js_canvas_set_statusbar(const char *text);
|
||||||
extern bool js_canvas_get_preferred_size(int *wp, int *hp);
|
extern bool js_canvas_get_preferred_size(int *wp, int *hp);
|
||||||
extern void js_canvas_set_size(int w, int h);
|
extern void js_canvas_set_size(int w, int h);
|
||||||
extern double js_get_device_pixel_ratio();
|
extern double js_get_device_pixel_ratio(void);
|
||||||
|
|
||||||
extern void js_dialog_init(const char *title);
|
extern void js_dialog_init(const char *title);
|
||||||
extern void js_dialog_string(int i, const char *title, const char *initvalue);
|
extern void js_dialog_string(int i, const char *title, const char *initvalue);
|
||||||
@ -99,6 +99,26 @@ extern void js_dialog_launch(void);
|
|||||||
extern void js_dialog_cleanup(void);
|
extern void js_dialog_cleanup(void);
|
||||||
extern void js_focus_canvas(void);
|
extern void js_focus_canvas(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions are called from JavaScript, so their prototypes
|
||||||
|
* need to be kept in sync with emccpre.js.
|
||||||
|
*/
|
||||||
|
bool mouseup(int x, int y, int button);
|
||||||
|
bool mousedown(int x, int y, int button);
|
||||||
|
bool mousemove(int x, int y, int buttons);
|
||||||
|
bool key(int keycode, const char *key, const char *chr, int location,
|
||||||
|
bool shift, bool ctrl);
|
||||||
|
void timer_callback(double tplus);
|
||||||
|
void command(int n);
|
||||||
|
char *get_save_file(void);
|
||||||
|
void free_save_file(char *buffer);
|
||||||
|
void load_game(const char *buffer, int len);
|
||||||
|
void dlg_return_sval(int index, const char *val);
|
||||||
|
void dlg_return_ival(int index, int val);
|
||||||
|
void resize_puzzle(int w, int h);
|
||||||
|
void restore_puzzle_size(int w, int h);
|
||||||
|
void rescale_puzzle(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call JS to get the date, and use that to initialise our random
|
* Call JS to get the date, and use that to initialise our random
|
||||||
* number generator to invent the first game seed.
|
* number generator to invent the first game seed.
|
||||||
@ -129,6 +149,7 @@ void fatal(const char *fmt, ...)
|
|||||||
js_error_box(buf);
|
js_error_box(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUGGING
|
||||||
void debug_printf(const char *fmt, ...)
|
void debug_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@ -138,12 +159,13 @@ void debug_printf(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
js_debug(buf);
|
js_debug(buf);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function that makes it easy to test strings that might be
|
* Helper function that makes it easy to test strings that might be
|
||||||
* NULL.
|
* NULL.
|
||||||
*/
|
*/
|
||||||
int strnullcmp(const char *a, const char *b)
|
static int strnullcmp(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
if (a == NULL || b == NULL)
|
if (a == NULL || b == NULL)
|
||||||
return a != NULL ? +1 : b != NULL ? -1 : 0;
|
return a != NULL ? +1 : b != NULL ? -1 : 0;
|
||||||
@ -153,18 +175,18 @@ int strnullcmp(const char *a, const char *b)
|
|||||||
/*
|
/*
|
||||||
* HTMLish names for the colours allocated by the puzzle.
|
* HTMLish names for the colours allocated by the puzzle.
|
||||||
*/
|
*/
|
||||||
char **colour_strings;
|
static char **colour_strings;
|
||||||
int ncolours;
|
static int ncolours;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The global midend object.
|
* The global midend object.
|
||||||
*/
|
*/
|
||||||
midend *me;
|
static midend *me;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* Timing functions.
|
* Timing functions.
|
||||||
*/
|
*/
|
||||||
bool timer_active = false;
|
static bool timer_active = false;
|
||||||
void deactivate_timer(frontend *fe)
|
void deactivate_timer(frontend *fe)
|
||||||
{
|
{
|
||||||
js_deactivate_timer();
|
js_deactivate_timer();
|
||||||
@ -193,7 +215,7 @@ static int canvas_w, canvas_h;
|
|||||||
* Called when we resize as a result of changing puzzle settings
|
* Called when we resize as a result of changing puzzle settings
|
||||||
* or device pixel ratio.
|
* or device pixel ratio.
|
||||||
*/
|
*/
|
||||||
static void resize()
|
static void resize(void)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
bool user;
|
bool user;
|
||||||
@ -206,7 +228,7 @@ static void resize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Called from JS when the device pixel ratio changes */
|
/* Called from JS when the device pixel ratio changes */
|
||||||
void rescale_puzzle()
|
void rescale_puzzle(void)
|
||||||
{
|
{
|
||||||
resize();
|
resize();
|
||||||
midend_force_redraw(me);
|
midend_force_redraw(me);
|
||||||
@ -591,7 +613,7 @@ static char *js_text_fallback(void *handle, const char *const *strings,
|
|||||||
return dupstr(strings[0]); /* Emscripten has no trouble with UTF-8 */
|
return dupstr(strings[0]); /* Emscripten has no trouble with UTF-8 */
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct drawing_api js_drawing = {
|
static const struct drawing_api js_drawing = {
|
||||||
js_draw_text,
|
js_draw_text,
|
||||||
js_draw_rect,
|
js_draw_rect,
|
||||||
js_draw_line,
|
js_draw_line,
|
||||||
@ -618,9 +640,9 @@ const struct drawing_api js_drawing = {
|
|||||||
*/
|
*/
|
||||||
static game_params **presets;
|
static game_params **presets;
|
||||||
static int npresets;
|
static int npresets;
|
||||||
bool have_presets_dropdown;
|
static bool have_presets_dropdown;
|
||||||
|
|
||||||
void populate_js_preset_menu(int menuid, struct preset_menu *menu)
|
static void populate_js_preset_menu(int menuid, struct preset_menu *menu)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < menu->n_entries; i++) {
|
for (i = 0; i < menu->n_entries; i++) {
|
||||||
@ -635,7 +657,7 @@ void populate_js_preset_menu(int menuid, struct preset_menu *menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_appropriate_preset(void)
|
static void select_appropriate_preset(void)
|
||||||
{
|
{
|
||||||
if (have_presets_dropdown) {
|
if (have_presets_dropdown) {
|
||||||
int preset = midend_which_preset(me);
|
int preset = midend_which_preset(me);
|
||||||
|
Reference in New Issue
Block a user