summaryrefslogtreecommitdiff
path: root/clojure/wordmonger/macros.clj
diff options
context:
space:
mode:
Diffstat (limited to 'clojure/wordmonger/macros.clj')
-rw-r--r--clojure/wordmonger/macros.clj25
1 files changed, 25 insertions, 0 deletions
diff --git a/clojure/wordmonger/macros.clj b/clojure/wordmonger/macros.clj
new file mode 100644
index 0000000..e0b6556
--- /dev/null
+++ b/clojure/wordmonger/macros.clj
@@ -0,0 +1,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))
+