Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2012 00:03
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 anonymous/1592051 to your computer and use it in GitHub Desktop.
Save anonymous/1592051 to your computer and use it in GitHub Desktop.
(import [javax.xml.ws WebServiceRef])
(defprotocol IGood (good [this]))
(deftype Good [] IGood (^{WebServiceRef {:name "Bob" :type String}} good [this] "a good example"))
(defmacro defc [name & actions]
(let [iname (symbol (str "I" name))]
`(do
(defprotocol ~iname
~@(for [[m as & fs] actions]
`(~m [~'this ~@as])))
(deftype ~name []
~iname
~@(for [[m as & fs] actions]
`(~(with-meta m {WebServiceRef {:name "Bob" :type String} }) [~'this ~@as] ~@fs))))))
(macroexpand-1 '(defc Bad (bad [] "a bad example")))
(defc Bad (bad [] "a bad example"))
(-> Good (.getMethod "good" nil) (.getAnnotations) (seq))
(-> Bad (.getMethod "bad" nil) (.getAnnotations) (seq))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment