diff src/clojureDemo/WiredDemo.clj @ 1:6d9bdaf919f7

added clojureDemo source
author Robert McIntyre <rlm@mit.edu>
date Fri, 20 Aug 2010 00:32:44 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojureDemo/WiredDemo.clj	Fri Aug 20 00:32:44 2010 -0400
     1.3 @@ -0,0 +1,40 @@
     1.4 +(ns clojureDemo.WiredDemo
     1.5 +(		
     1.6 + :gen-class
     1.7 + :implements [connections.WiredBox]
     1.8 + :methods [ [process [Object] void]]
     1.9 + :post-init register
    1.10 +)
    1.11 +)
    1.12 +   
    1.13 +
    1.14 +(defn -register [this]
    1.15 +
    1.16 +; translate:
    1.17 +; Connections.getPorts(this).addSignalProcessor("process");
    1.18 +; ---- to -----
    1.19 +
    1.20 +(println "ClojureBox  (register) : Register is run only when the object is created, like a constructor.")
    1.21 +
    1.22 +(. (connections.Connections/getPorts this) addSignalProcessor "process")
    1.23 +
    1.24 +
    1.25 +)
    1.26 +
    1.27 +
    1.28 +(defn -process [ _ _ ]
    1.29 +(println "ClojureBox (process) :  This is a LISP function, being called through Java, through the wiredBox metaphor.")
    1.30 +)
    1.31 +
    1.32 +
    1.33 +
    1.34 +
    1.35 +(
    1.36 +defn -getName [_]  "ClojureBox"
    1.37 +
    1.38 +; the [_] means that  the function gets an explicit "this" argument, like python,
    1.39 +; but we don't care about it.
    1.40 +
    1.41 +)
    1.42 +
    1.43 +