Fixed fi macro.
This commit is contained in:
parent
45eb96960b
commit
cd5d092ed3
1 changed files with 14 additions and 9 deletions
|
@ -16,14 +16,19 @@
|
||||||
|
|
||||||
(defmacro fi
|
(defmacro fi
|
||||||
[interface args & code]
|
[interface args & code]
|
||||||
(let [interface-type (.getMapping *ns* interface)
|
(debug "interface:" interface)
|
||||||
|
(let [iface-ref (reflect/type-reflect interface)
|
||||||
|
bogus (debug "iface-ref:" iface-ref)
|
||||||
|
methods (filter #(instance? clojure.reflect.Method %) (:members iface-ref))
|
||||||
|
bogus (debug "methods:" (pr-str methods))
|
||||||
|
method-sym (:name (first methods))]
|
||||||
|
(debug "method-sym:" method-sym)
|
||||||
|
|
||||||
methods (-> (.getMethods interface-type)
|
(when-not (= (count methods) 1)
|
||||||
seq)
|
(throw (new Exception (str "can't take an interface with more then one method:" (pr-str methods)))))
|
||||||
method-sym (.getName (first methods))]
|
|
||||||
|
|
||||||
(when-not (= (count methods) 1)
|
(debug (pr-str `(proxy [~interface] []
|
||||||
(throw (new Exception "can't take an interface with more then one method.")))
|
(~method-sym ~args ~@code))))
|
||||||
|
|
||||||
`(proxy [~interface] []
|
`(proxy [~interface] []
|
||||||
(~method-sym ~args
|
(~method-sym ~args
|
||||||
|
@ -57,14 +62,14 @@
|
||||||
(defn by-id [root id]
|
(defn by-id [root id]
|
||||||
(try
|
(try
|
||||||
(cond
|
(cond
|
||||||
(not (instance? clojure.lang.IFn root)) (do (debug "Raw input confirmed. Starting.")
|
(not (instance? clojure.lang.IFn root)) (do (trace "Raw input confirmed. Starting.")
|
||||||
(by-id (sgzipper root) id))
|
(by-id (sgzipper root) id))
|
||||||
(zip/end? root) (do (debug "Search ended without result.")
|
(zip/end? root) (do (trace "Search ended without result.")
|
||||||
nil)
|
nil)
|
||||||
(nil? (zip/node root)) (by-id (zip/next root) id)
|
(nil? (zip/node root)) (by-id (zip/next root) id)
|
||||||
(= id (.getId (zip/node root))) (do (debug "Found item:" (zip/node root))
|
(= id (.getId (zip/node root))) (do (debug "Found item:" (zip/node root))
|
||||||
(zip/node root))
|
(zip/node root))
|
||||||
:else (do (info "id of" (zip/node root) "does not match, proceeding to" (zip/node (zip/next root)))
|
:else (do (trace "id of" (zip/node root) "does not match, proceeding to" (zip/node (zip/next root)))
|
||||||
(by-id (zip/next root) id)))
|
(by-id (zip/next root) id)))
|
||||||
(catch Exception e (error e))))
|
(catch Exception e (error e))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue