From 1947c4d7f32272ec0c5b9295808cde4c9138995c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 19 Apr 2017 14:48:57 +0200 Subject: Fix warnings in preparation for splitting nif_helpers out --- c_src/esdl2.c | 6 +++--- c_src/esdl2.h | 8 +++++++- c_src/nif_helpers.c | 12 ++++++------ c_src/nif_helpers.h | 4 ++-- c_src/sdl.c | 4 ++-- c_src/sdl_events.c | 8 ++++---- c_src/sdl_hints.c | 2 +- c_src/sdl_power.c | 2 +- c_src/sdl_renderer.c | 8 ++++---- c_src/sdl_texture.c | 3 --- c_src/sdl_window.c | 10 ++++------ 11 files changed, 34 insertions(+), 33 deletions(-) (limited to 'c_src') diff --git a/c_src/esdl2.c b/c_src/esdl2.c index 430847f..1790dd7 100644 --- a/c_src/esdl2.c +++ b/c_src/esdl2.c @@ -20,7 +20,7 @@ NIF_RESOURCES(NIF_RES_DECL) static int loads = 0; -int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) +static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) { NIF_ATOMS(NIF_ATOM_INIT) NIF_RESOURCES(NIF_RES_INIT) @@ -32,7 +32,7 @@ int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) return 0; } -int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info) +static int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info) { *priv_data = *old_priv_data; @@ -41,7 +41,7 @@ int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM return 0; } -void unload(ErlNifEnv* env, void* priv_data) +static void unload(ErlNifEnv* env, void* priv_data) { if (loads == 1) nif_destroy_main_thread(priv_data); diff --git a/c_src/esdl2.h b/c_src/esdl2.h index df16664..10508ff 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -257,9 +257,15 @@ NIF_ATOMS(NIF_ATOM_H_DECL) NIF_RESOURCES(NIF_RES_H_DECL) NIF_FUNCTIONS(NIF_FUNCTION_H_DECL) +// Utility functions used across different files. + +NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_bool, SDL_bool) +NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_blend_mode, SDL_BlendMode) +NIF_ENUM_TO_ATOM_FUNCTION_DECL(blend_mode_to_atom, SDL_BlendMode) + // -- -ErlNifPid* get_callback_process(); +ErlNifPid* get_callback_process(void); #define sdl_error_tuple(env) \ enif_make_tuple2(env, \ diff --git a/c_src/nif_helpers.c b/c_src/nif_helpers.c index f1465da..0f98cd6 100644 --- a/c_src/nif_helpers.c +++ b/c_src/nif_helpers.c @@ -38,7 +38,7 @@ typedef struct { // Message. -nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlNifPid* pid) +static nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlNifPid* pid) { nif_thread_message* msg = (nif_thread_message*)enif_alloc(sizeof(nif_thread_message)); @@ -49,7 +49,7 @@ nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlN return msg; } -void nif_thread_message_free(nif_thread_message* msg) +static void nif_thread_message_free(nif_thread_message* msg) { enif_free(msg->from_pid); enif_free(msg->args); @@ -58,7 +58,7 @@ void nif_thread_message_free(nif_thread_message* msg) // Calls and casts. -ERL_NIF_TERM nif_thread_send(nif_thread_state* st, nif_thread_message* msg) +static ERL_NIF_TERM nif_thread_send(nif_thread_state* st, nif_thread_message* msg) { enif_mutex_lock(st->lock); @@ -107,7 +107,7 @@ ERL_NIF_TERM nif_thread_call(ErlNifEnv* env, ERL_NIF_TERM (*f)(ErlNifEnv*, nif_t // Main thread loop. -int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg) +static int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg) { enif_mutex_lock(st->lock); @@ -125,7 +125,7 @@ int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg) return 1; } -void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message* msg) +static void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message* msg) { if (msg->from_pid == NULL) { void (*cast)(nif_thread_arg*) = msg->function; @@ -143,7 +143,7 @@ void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message* nif_thread_message_free(msg); } -void* nif_main_thread(void* obj) +static void* nif_main_thread(void* obj) { ErlNifEnv* env = enif_alloc_env(); nif_thread_state* st = (nif_thread_state*)obj; diff --git a/c_src/nif_helpers.h b/c_src/nif_helpers.h index 8c1cfa4..111ea84 100644 --- a/c_src/nif_helpers.h +++ b/c_src/nif_helpers.h @@ -125,7 +125,7 @@ void nif_destroy_main_thread(void*); ERL_NIF_TERM nif_thread_cast(ErlNifEnv*, void (*f)(nif_thread_arg*), int a, ...); ERL_NIF_TERM nif_thread_call(ErlNifEnv*, ERL_NIF_TERM (*f)(ErlNifEnv*, nif_thread_arg*), int a, ...); -#define NIF_CAST_HANDLER(f) void f(nif_thread_arg* args) -#define NIF_CALL_HANDLER(f) ERL_NIF_TERM f(ErlNifEnv* env, nif_thread_arg* args) +#define NIF_CAST_HANDLER(f) static void f(nif_thread_arg* args) +#define NIF_CALL_HANDLER(f) static ERL_NIF_TERM f(ErlNifEnv* env, nif_thread_arg* args) #endif diff --git a/c_src/sdl.c b/c_src/sdl.c index 26a1d0e..94302bd 100644 --- a/c_src/sdl.c +++ b/c_src/sdl.c @@ -27,8 +27,8 @@ BASE_INIT_FLAGS(F) \ F(everything, SDL_INIT_EVERYTHING) -NIF_LIST_TO_FLAGS_FUNCTION(list_to_init_flags, Uint32, INIT_FLAGS) -NIF_FLAGS_TO_LIST_FUNCTION(init_flags_to_list, Uint32, BASE_INIT_FLAGS) +static NIF_LIST_TO_FLAGS_FUNCTION(list_to_init_flags, Uint32, INIT_FLAGS) +static NIF_FLAGS_TO_LIST_FUNCTION(init_flags_to_list, Uint32, BASE_INIT_FLAGS) // init diff --git a/c_src/sdl_events.c b/c_src/sdl_events.c index 1da0165..017802a 100644 --- a/c_src/sdl_events.c +++ b/c_src/sdl_events.c @@ -24,7 +24,7 @@ E(mouse_wheel, SDL_MOUSEWHEEL) \ E(quit, SDL_QUIT) -NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM) +static NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM) #define WINDOW_EVENT_ENUM(E) \ E(shown, SDL_WINDOWEVENT_SHOWN) \ @@ -42,7 +42,7 @@ NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM) E(focus_lost, SDL_WINDOWEVENT_FOCUS_LOST) \ E(close, SDL_WINDOWEVENT_CLOSE) -NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM) +static NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM) #define KEYMOD_FLAGS(F) \ F(left_shift, KMOD_LSHIFT) \ @@ -57,7 +57,7 @@ NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM) F(caps, KMOD_CAPS) \ F(mode, KMOD_MODE) -NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS) +static NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS) #define BUTTON_ENUM(E) \ E(left, SDL_BUTTON_LEFT) \ @@ -66,7 +66,7 @@ NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS) E(x1, SDL_BUTTON_X1) \ E(x2, SDL_BUTTON_X2) -NIF_ENUM_TO_ATOM_FUNCTION(button_to_atom, Uint8, BUTTON_ENUM) +static NIF_ENUM_TO_ATOM_FUNCTION(button_to_atom, Uint8, BUTTON_ENUM) // poll_event diff --git a/c_src/sdl_hints.c b/c_src/sdl_hints.c index fe4eceb..0342777 100644 --- a/c_src/sdl_hints.c +++ b/c_src/sdl_hints.c @@ -21,7 +21,7 @@ typedef struct esdl2_callback { char* function; } esdl2_callback; -void esdl2_hint_callback(void* userdata, const char* name, const char* oldValue, const char* newValue) +static void esdl2_hint_callback(void* userdata, const char* name, const char* oldValue, const char* newValue) { ErlNifEnv* env = enif_alloc_env(); esdl2_callback* callback = (esdl2_callback*)userdata; diff --git a/c_src/sdl_power.c b/c_src/sdl_power.c index c97e2f2..eb4cf4f 100644 --- a/c_src/sdl_power.c +++ b/c_src/sdl_power.c @@ -21,7 +21,7 @@ E(charging, SDL_POWERSTATE_CHARGING) \ E(charged, SDL_POWERSTATE_CHARGED) -NIF_ENUM_TO_ATOM_FUNCTION(power_state_to_atom, SDL_PowerState, POWER_STATE_ENUM) +static NIF_ENUM_TO_ATOM_FUNCTION(power_state_to_atom, SDL_PowerState, POWER_STATE_ENUM) // get_power_info diff --git a/c_src/sdl_renderer.c b/c_src/sdl_renderer.c index f5b6889..5344199 100644 --- a/c_src/sdl_renderer.c +++ b/c_src/sdl_renderer.c @@ -26,7 +26,7 @@ void dtor_Renderer(ErlNifEnv* env, void* obj) F(present_vsync, SDL_RENDERER_PRESENTVSYNC) \ F(target_texture, SDL_RENDERER_TARGETTEXTURE) -NIF_LIST_TO_FLAGS_FUNCTION(list_to_renderer_flags, Uint32, RENDERER_FLAGS) +static NIF_LIST_TO_FLAGS_FUNCTION(list_to_renderer_flags, Uint32, RENDERER_FLAGS) #define BLEND_MODE_ENUM(E) \ E(none, SDL_BLENDMODE_NONE) \ @@ -42,9 +42,9 @@ NIF_ENUM_TO_ATOM_FUNCTION(blend_mode_to_atom, SDL_BlendMode, BLEND_MODE_ENUM) F(horizontal, SDL_FLIP_HORIZONTAL) \ F(vertical, SDL_FLIP_VERTICAL) -NIF_LIST_TO_FLAGS_FUNCTION(list_to_flip_flags, SDL_RendererFlip, FLIP_FLAGS) +static NIF_LIST_TO_FLAGS_FUNCTION(list_to_flip_flags, SDL_RendererFlip, FLIP_FLAGS) -int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point) +static int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point) { ERL_NIF_TERM x, y; @@ -61,7 +61,7 @@ int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point) return 1; } -int map_to_rect(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Rect* rect) +static int map_to_rect(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Rect* rect) { ERL_NIF_TERM x, y, w, h; diff --git a/c_src/sdl_texture.c b/c_src/sdl_texture.c index 8606f37..425e0ec 100644 --- a/c_src/sdl_texture.c +++ b/c_src/sdl_texture.c @@ -14,9 +14,6 @@ #include "esdl2.h" -NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_blend_mode, SDL_BlendMode) -NIF_ENUM_TO_ATOM_FUNCTION_DECL(blend_mode_to_atom, SDL_BlendMode) - void dtor_Texture(ErlNifEnv* env, void* obj) { SDL_DestroyTexture(NIF_RES_GET(Texture, obj)); diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 96b3b3e..ef3647b 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -14,8 +14,6 @@ #include "esdl2.h" -NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_bool, SDL_bool) - void dtor_Window(ErlNifEnv* env, void* obj) { SDL_DestroyWindow(NIF_RES_GET(Window, obj)); @@ -37,21 +35,21 @@ void dtor_Window(ErlNifEnv* env, void* obj) F(foreign, SDL_WINDOW_FOREIGN) \ F(allow_high_dpi, SDL_WINDOW_ALLOW_HIGHDPI) -NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS) -NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS) +static NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS) +static NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS) #define WINDOW_POS_ENUM(E) \ E(centered, SDL_WINDOWPOS_CENTERED) \ E(undefined, SDL_WINDOWPOS_UNDEFINED) -NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_pos, int, WINDOW_POS_ENUM) +static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_pos, int, WINDOW_POS_ENUM) #define WINDOW_FULLSCREEN_ENUM(E) \ E(fullscreen, SDL_WINDOW_FULLSCREEN) \ E(fullscreen_desktop, SDL_WINDOW_FULLSCREEN_DESKTOP) \ E(windowed, 0) -NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_fullscreen, Uint32, WINDOW_FULLSCREEN_ENUM) +static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_fullscreen, Uint32, WINDOW_FULLSCREEN_ENUM) // create_window -- cgit v1.2.3