summaryrefslogtreecommitdiff
path: root/clojure/wordmonger/macros.clj
blob: e0b6556611a84b74c9e16f66760e859d75aef226 (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
(defmacro color [name]
  (let [long-name# (str "SWT/COLOR_" (.toUpperCase name))]
    `(.getSystemColor *display* ~(symbol long-name#))))

(defmacro nary-or [first & rest]
  (if rest
    `(bit-or ~first (nary-or ~@rest))
    first))

(defmacro unless [condition & body]
  `(when (not ~condition) ~@body))

(defmacro async [body]
  `(.asyncExec *display* (proxy [Runnable] []
                           (run [] ~@body))))

(defmacro random [radix]
  `(.nextInt (java.util.Random.) ~radix))

(defn downcase [string]
  (.toLowerCase string))

(defn upcase [string]
  (.toUpperCase string))