Skip to content

Instantly share code, notes, and snippets.

@zerg000000
Created February 23, 2013 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerg000000/5020022 to your computer and use it in GitHub Desktop.
Save zerg000000/5020022 to your computer and use it in GitHub Desktop.
; copy from https://github.com/daveray/seesaw/blob/develop/src/seesaw/options.clj
(defrecord Option [name setter getter examples])
(defmacro bean-option
[name-arg target-type & [set-conv get-conv examples]]
(let [[option-name bean-property-name] (split-bean-option-name name-arg)
target (gensym "target")]
`(Option. ~option-name
(fn [~(with-meta target {:tag target-type}) value#]
(. ~target ~(setter-name bean-property-name) (~(or set-conv `identity) value#)))
(fn [~(with-meta target {:tag target-type})]
(~(or get-conv `identity) (. ~target ~(getter-name bean-property-name))))
~examples)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment