From 01e4a7576ed89533a6ec78a3839c37ae06f309e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 8 Apr 2014 16:33:24 +0200 Subject: Add typespecs to the sdl module --- src/sdl.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/sdl.erl') diff --git a/src/sdl.erl b/src/sdl.erl index 1b8c6a6..b89de68 100644 --- a/src/sdl.erl +++ b/src/sdl.erl @@ -22,16 +22,26 @@ -export([stop_subsystems/1]). -export([is_started/1]). +-type error() :: {error, string()}. +-export_type([error/0]). + +-type subsystem() :: timer | audio | video | joystick | haptic + | game_controller | events | everything | no_parachute. + +-spec start() -> ok | error(). start() -> start([]). +-spec start([subsystem()]) -> ok | error(). start(Subsystems) -> esdl2:init(Subsystems), receive {'_nif_thread_ret_', Ret} -> Ret end. +-spec stop() -> ok. stop() -> esdl2:quit(). +-spec stop_on_exit() -> ok. stop_on_exit() -> Self = self(), spawn_link(fun() -> @@ -42,13 +52,16 @@ stop_on_exit() -> end), ok. +-spec start_subsystems([subsystem()]) -> ok | error(). start_subsystems(Subsystems) -> esdl2:init_subsystem(Subsystems), receive {'_nif_thread_ret_', Ret} -> Ret end. +-spec stop_subsystems([subsystem()]) -> ok. stop_subsystems(Subsystems) -> esdl2:quit_subsystem(Subsystems). +-spec is_started(subsystem()) -> boolean(). is_started(Subsystem) -> esdl2:was_init([Subsystem]), receive {'_nif_thread_ret_', Ret} -> Ret end. -- cgit v1.2.3