Added maps as form of arguments for the build macro.

This commit is contained in:
Daniel Ziltener 2013-08-28 19:05:12 +00:00
parent 303caf455f
commit 82f84222de
2 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,9 @@
(defproject clojurefx "0.1.0-SNAPSHOT"
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.<br/>
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen."
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
**This is not yet on clojars, but it will be there soon. Until then, clone it and install locally.**"
:url "https://www.github.com/zilti/clojurefx"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}

View File

@ -90,11 +90,21 @@ Don't use this yourself; See the macros \"build\" and \"deffx\" below.
(symbol (str k "." (camel (name builder))))))))))
(defmacro build
"This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). Example: (build button (text \"Close me.\") (cancelButton true))."
"This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). You can also use a map, so it is possible to compose the arguments for the builder over time.
**Examples:**
* `(build button (text \"Close me.\") (cancelButton true))`
* `(build button {:text \"Close me.\" :cancelButton true})`"
[what & args]
`(.. ~(get-qualified what) create
~@args
build))
(if (and (= 1 (count args))
(map? (first args)))
`(build ~what ~@(for [entry# (keys (first args))]
`(~(symbol (name entry#)) ~((first args) entry#))))
`(.. ~(get-qualified what) create
~@args
build)))
(defmacro deffx
"Uses build and assigns the result to a symbol."