Created
November 21, 2014 11:16
-
-
Save tangrammer/f94222bd659c46367fed to your computer and use it in GitHub Desktop.
Almost working macro to get defrecord intercepted
This file contains hidden or 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
| (ns wrapper.in-process | |
| (require [wrapper.aop :refer :all]) | |
| (import [wrapper.core Example])) | |
| (defmacro protocol-impl [protocol-definition] | |
| ``(defrecord ~(symbol "my-wrapper") [~(symbol "e#")] | |
| ~@(let [[type# protocol-functions#] ~protocol-definition] | |
| (conj | |
| (map | |
| (fn [[function-name# function-args#]] | |
| `(~function-name# ~function-args# | |
| (~function-name# ~(symbol "e#") ~@(next function-args#)))) | |
| protocol-functions#) type#)) | |
| )) | |
| (protocol-impl (adapt-super-impls (first (get-methods (Example.))))) | |
| ;;=> (clojure.core/defrecord | |
| ;; my-wrapper | |
| ;; [e#] | |
| ;; wrapper.core.Welcome | |
| ;; (say_bye [this# a# b#] (say_bye e# a# b#)) | |
| ;; (greetings [this#] (greetings e#))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment