-
-
Save mattdeboard/4010a4cc804b8e83bb56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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