Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created August 5, 2012 07:25
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 mattdeboard/4010a4cc804b8e83bb56 to your computer and use it in GitHub Desktop.
Save mattdeboard/4010a4cc804b8e83bb56 to your computer and use it in GitHub Desktop.
(defn proxy-meta
"Returns an anonymous class instance, constructed with the file on the path
indicated by `infile', annotated with metadata indicating the filename used to
construct the instance. Optional `moremeta' is a single map containing any
additional metadata to add to the instance."
[infile & [moremeta]]
(let [metadata (merge {:filename infile} moremeta)]
(proxy [PdfReader clojure.lang.IObj] [infile]
(withMeta [newmeta] (proxy-meta infile newmeta))
(meta [] metadata))))
(defmacro proxy-foo [class]
`(fn make# [infile# & [moremeta#]]
(let [metadata# (merge {:filename infile#} moremeta#)]
(proxy [~class clojure.lang.IObj] [infile#]
(withMeta [newmeta#] (make# infile# newmeta#))
(meta [] metadata#)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment