rlm@1
|
1 (ns clojureDemo.WiredDemo
|
rlm@1
|
2 (
|
rlm@1
|
3 :gen-class
|
rlm@1
|
4 :implements [connections.WiredBox]
|
rlm@1
|
5 :methods [ [process [Object] void]]
|
rlm@1
|
6 :post-init register
|
rlm@1
|
7 )
|
rlm@1
|
8 )
|
rlm@1
|
9
|
rlm@1
|
10
|
rlm@1
|
11 (defn -register [this]
|
rlm@1
|
12
|
rlm@1
|
13 ; translate:
|
rlm@1
|
14 ; Connections.getPorts(this).addSignalProcessor("process");
|
rlm@1
|
15 ; ---- to -----
|
rlm@1
|
16
|
rlm@1
|
17 (println "ClojureBox (register) : Register is run only when the object is created, like a constructor.")
|
rlm@1
|
18
|
rlm@1
|
19 (. (connections.Connections/getPorts this) addSignalProcessor "process")
|
rlm@1
|
20
|
rlm@1
|
21
|
rlm@1
|
22 )
|
rlm@1
|
23
|
rlm@1
|
24
|
rlm@1
|
25 (defn -process [ _ _ ]
|
rlm@1
|
26 (println "ClojureBox (process) : This is a LISP function, being called through Java, through the wiredBox metaphor.")
|
rlm@1
|
27 )
|
rlm@1
|
28
|
rlm@1
|
29
|
rlm@1
|
30
|
rlm@1
|
31
|
rlm@1
|
32 (
|
rlm@1
|
33 defn -getName [_] "ClojureBox"
|
rlm@1
|
34
|
rlm@1
|
35 ; the [_] means that the function gets an explicit "this" argument, like python,
|
rlm@1
|
36 ; but we don't care about it.
|
rlm@1
|
37
|
rlm@1
|
38 )
|
rlm@1
|
39
|
rlm@1
|
40
|