diff options
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 15 | ||||
-rw-r--r-- | c_src/nif_helpers.h | 16 |
2 files changed, 18 insertions, 13 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 04695eb..6dbc43f 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -20,12 +20,15 @@ // List of atoms used by this NIF. #define NIF_ATOMS(A) \ + A(accelerated) \ A(add) \ A(allow_high_dpi) \ + A(audio) \ A(blend) \ A(borderless) \ A(button) \ A(caps) \ + A(centered) \ A(charged) \ A(charging) \ A(close) \ @@ -33,6 +36,8 @@ A(enter) \ A(error) \ A(event) \ + A(events) \ + A(everything) \ A(exposed) \ A(false) \ A(focus_gained) \ @@ -40,11 +45,14 @@ A(foreign) \ A(fullscreen) \ A(fullscreen_desktop) \ + A(game_controller) \ A(h) \ + A(haptic) \ A(hidden) \ A(horizontal) \ A(input_focus) \ A(input_grabbed) \ + A(joystick) \ A(key_down) \ A(key_up) \ A(leave) \ @@ -66,10 +74,12 @@ A(mouse_wheel) \ A(moved) \ A(no_battery) \ + A(no_parachute) \ A(none) \ A(num) \ A(on_battery) \ A(opengl) \ + A(present_vsync) \ A(quit) \ A(repeat) \ A(resizable) \ @@ -83,19 +93,24 @@ A(scancode) \ A(shown) \ A(size_changed) \ + A(software) \ A(state) \ A(sym) \ + A(target_texture) \ A(touch) \ A(true) \ + A(timer) \ A(timestamp) \ A(type) \ A(undefined) \ A(unknown) \ A(vertical) \ + A(video) \ A(w) \ A(which) \ A(window) \ A(window_id) \ + A(windowed) \ A(x) \ A(x1) \ A(x2) \ diff --git a/c_src/nif_helpers.h b/c_src/nif_helpers.h index 915cb2e..ab61998 100644 --- a/c_src/nif_helpers.h +++ b/c_src/nif_helpers.h @@ -68,21 +68,16 @@ // Function generators. -#define NIF_ATOM_TO_FLAG(a, f) if (!strcmp(buf, #a)) *flags |= f; else +#define NIF_ATOM_TO_FLAG(a, f) if (enif_is_identical(atom_ ## a, head)) *flags |= f; else #define NIF_LIST_TO_FLAGS_FUNCTION(f, type, flags_list) \ int f(ErlNifEnv* env, ERL_NIF_TERM list, type* flags) \ { \ - int i; \ - char buf[MAX_ATOM_LENGTH]; \ ERL_NIF_TERM head; \ \ if (!enif_is_list(env, list)) \ return 0; \ \ while (enif_get_list_cell(env, list, &head, &list)) { \ - if (!enif_get_atom(env, head, buf, MAX_ATOM_LENGTH, ERL_NIF_LATIN1)) \ - return 0; \ - \ flags_list(NIF_ATOM_TO_FLAG) /* else */ return 0; \ } \ \ @@ -98,15 +93,10 @@ return list; \ } -#define NIF_ATOM_TO_ENUM(a, e) if (!strcmp(buf, #a)) { *val = e; return 1; } +#define NIF_ATOM_TO_ENUM(a, e) if (enif_is_identical(atom_ ## a, atom)) { *val = e; return 1; } #define NIF_ATOM_TO_ENUM_FUNCTION(f, type, enum_list) \ - int f(ErlNifEnv* env, ERL_NIF_TERM a, type* val) \ + int f(ErlNifEnv* env, ERL_NIF_TERM atom, type* val) \ { \ - char buf[MAX_ATOM_LENGTH]; \ - \ - if (!enif_get_atom(env, a, buf, MAX_ATOM_LENGTH, ERL_NIF_LATIN1)) \ - return 0; \ - \ enum_list(NIF_ATOM_TO_ENUM) \ \ return 0; \ |