aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-08 16:33:24 +0200
committerLoïc Hoguin <[email protected]>2014-04-08 16:33:24 +0200
commit01e4a7576ed89533a6ec78a3839c37ae06f309e8 (patch)
tree1fe90137e2ced1517ed30a081d30a21f4e89efac
parentc62f79fc3266ba7c21ed4ada84d16aab771f0d02 (diff)
downloadesdl2-01e4a7576ed89533a6ec78a3839c37ae06f309e8.tar.gz
esdl2-01e4a7576ed89533a6ec78a3839c37ae06f309e8.tar.bz2
esdl2-01e4a7576ed89533a6ec78a3839c37ae06f309e8.zip
Add typespecs to the sdl module
-rw-r--r--src/sdl.erl13
1 files changed, 13 insertions, 0 deletions
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.