-
Notifications
You must be signed in to change notification settings - Fork 3
/
timer-wrapper.dylan
66 lines (53 loc) · 1.85 KB
/
timer-wrapper.dylan
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module: uv
author: Bruce Mitchener <[email protected]>
copyright: MIT
define C-subtype <%uv-timer> (<%uv-handle>) end;
define class <uv-timer> (<uv-handle>) end;
define inline C-function %uv-timer-init
parameter loop :: <uv-loop>;
parameter timer :: <%uv-timer>;
result xxx :: <C-int>;
c-name: "uv_timer_init";
end;
define inline C-function %uv-timer-start
parameter timer :: <%uv-timer>;
parameter callback :: <C-function-pointer>;
parameter timeout :: <C-int>; // XXX: This should be a 64 bit value
parameter repeat :: <C-int>; // XXX: This should be a 64 bit value
result xxx :: <C-int>;
c-name: "uv_dylan_timer_start";
end;
define inline function uv-timer-start
(timer :: <uv-timer>, callback :: <function>, timeout :: <integer>, repeat :: <integer>)
=> (result :: <integer>)
timer.callback := callback;
%uv-timer-start(timer.raw-handle, %invoke-callback, timeout, repeat)
end;
define inline C-function %uv-timer-stop
parameter timer :: <%uv-timer>;
result xxx :: <C-int>;
c-name: "uv_timer_stop";
end;
define inline function uv-timer-stop (timer :: <uv-timer>) => (_)
%uv-timer-stop(timer.raw-handle)
end;
define inline C-function %uv-timer-again
parameter timer :: <%uv-timer>;
result xxx :: <C-int>;
c-name: "uv_timer_again";
end;
define inline function uv-timer-again (timer :: <uv-timer>) => (_)
%uv-timer-again(timer.raw-handle)
end;
// XXX: hook up something for uv_timer_set_repeat and uv_timer_get_repeat
define inline C-function %uv-dylan-timer-new
result timer :: <%uv-timer>;
c-name: "uv_dylan_timer_new";
end;
define sealed domain make (singleton(<uv-timer>));
define sealed domain initialize (singleton(<uv-timer>));
define sealed method initialize (timer :: <uv-timer>, #key loop = uv-default-loop())
timer.raw-handle := %uv-dylan-timer-new();
next-method();
%uv-timer-init(loop, timer.raw-handle);
end;