You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: www/CallbacksAndClosures.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,17 @@ Callbacks and Closures
2
2
======================
3
3
4
4
Callback declarations consist of a simple interface that extends the Callback interface and implements a callback method (or defines a single method of arbitrary name). Callbacks are implemented by wrapping a Java object method in a little bit of C glue code. The simplest usage resembles using anonymous inner classes to register event listeners. Following is an example of callback usage:
5
-
5
+
6
6
// Original C declarations
7
-
typedef void (*sig_t)(int);
8
-
sig_t signal(sig_t);
7
+
typedef void (*sig_t) (int);
8
+
sig_t signal(int sig, sig_t func);
9
+
int SIGUSR1 = 30;
9
10
10
11
// Equivalent JNA mappings
11
12
public interface CLibrary extends Library {
12
13
int SIGUSR1 = 30;
13
14
interface sig_t extends Callback {
14
-
void invoke(int signal);
15
+
void invoke(int signal);
15
16
}
16
17
sig_t signal(int sig, sig_t fn);
17
18
int raise(int sig);
@@ -32,7 +33,7 @@ Callback declarations consist of a simple interface that extends the Callback in
32
33
...
33
34
34
35
Here is a more involved example, using the Win32 APIs to enumerate all native windows:
35
-
36
+
36
37
// Original C declarations
37
38
typedef int (__stdcall *WNDENUMPROC)(void*,void*);
0 commit comments