blob: a84866754482bd366661ad231a759a9bda3bf369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use types::c;
// Returned when an error occurs in an SDL function.
export type error = !str;
// Converts an SDL error into a human-friendly string.
export fn strerror(err: error) str = {
return err: str;
};
@symbol("SDL_GetError") fn SDL_GetError() const *c::char;
export fn wrapvoid(ret: int) (void | error) = {
wrapint(ret)?;
};
export fn wrapint(ret: int) (int | error) = {
if (ret < 0) {
return c::tostr(SDL_GetError()): error;
};
return ret;
};
export fn wrapptr(ret: nullable *opaque) (*opaque | error) = {
match (ret) {
case let v: *opaque =>
return v;
case null =>
return c::tostr(SDL_GetError()): error;
};
};
|