From 8f19fb094712dd6a871136c8522e0cf87fb3025e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 20 Oct 2015 03:26:40 +0200 Subject: Implement sdl:which_subsystems/0 --- c_src/sdl.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'c_src') diff --git a/c_src/sdl.c b/c_src/sdl.c index 835b0f6..26a1d0e 100644 --- a/c_src/sdl.c +++ b/c_src/sdl.c @@ -14,17 +14,21 @@ #include "esdl2.h" -#define INIT_FLAGS(F) \ +#define BASE_INIT_FLAGS(F) \ F(timer, SDL_INIT_TIMER) \ F(audio, SDL_INIT_AUDIO) \ F(video, SDL_INIT_VIDEO) \ F(joystick, SDL_INIT_JOYSTICK) \ F(haptic, SDL_INIT_HAPTIC) \ F(game_controller, SDL_INIT_GAMECONTROLLER) \ - F(events, SDL_INIT_EVENTS) \ + F(events, SDL_INIT_EVENTS) + +#define INIT_FLAGS(F) \ + 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) // init @@ -105,23 +109,16 @@ NIF_FUNCTION(set_main_ready) } // was_init -// @todo Implement the case where we want to receive a list of everything init. NIF_CALL_HANDLER(thread_was_init) { - if (SDL_WasInit((long)args[0])) - return atom_true; - - return atom_false; + return init_flags_to_list(env, SDL_WasInit((long)args[0])); } NIF_FUNCTION(was_init) { - unsigned int length; Uint32 flags = 0; - BADARG_IF(!enif_get_list_length(env, argv[0], &length)); - BADARG_IF(length == 0); BADARG_IF(!list_to_init_flags(env, argv[0], &flags)); return nif_thread_call(env, thread_was_init, 1, flags); -- cgit v1.2.3