Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
added fix-mname (converts kw to method name)
  • Loading branch information
rosado committed Sep 13, 2009
1 parent f315255 commit 1c6640c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/rosado/processing/applet.clj
Expand Up @@ -10,12 +10,23 @@
(binding [*applet* this#]
(apply ~f args#)))))

(defn- fix-mname
"Changes :method-name to :methodName."
[[mname fun]]
(let [mname (name mname)
mr (re-matcher #"\-[a-zA-z]" mname)
replace-fn (comp #(.replaceFirst mr %) toupper #(.substring % 1))
fixed-name (if-let [matched (re-find mr)]
(replace-fn matched)
mname)]
[(keyword fixed-name) fun]))

(defmacro defapplet
"Define an applet. Takes an app-name and a map of options."
[app-name & opts]
(let [options (assoc (apply hash-map opts) :name (str app-name))
fns (dissoc options :name :title :size)
methods (reduce with-binding {} fns)]
methods (reduce with-binding {} (into {} (map fix-mname fns)))]
`(def ~app-name
(let [frame# (atom nil)
prx# (proxy [processing.core.PApplet
Expand Down

0 comments on commit 1c6640c

Please sign in to comment.