Fix
This commit is contained in:
parent
8551817724
commit
ea88219ad6
1 changed files with 30 additions and 32 deletions
|
|
@ -27,41 +27,39 @@
|
||||||
(getProtocols [this]
|
(getProtocols [this]
|
||||||
protocols))]
|
protocols))]
|
||||||
(list 'fn [{:keys '[interfaces methods protocols]}]
|
(list 'fn [{:keys '[interfaces methods protocols]}]
|
||||||
`(cond ~'(empty? interfaces) ~prelude
|
`(cond ~'(empty? interfaces) ~prelude ~'(> (count interfaces)
|
||||||
~'(> (count interfaces)
|
1) (throw (new Exception "Babashka currently does not support reifying more than one interface."))
|
||||||
1)
|
|
||||||
(throw (new Exception "Babashka currently does not support reifying more than one interface."))
|
|
||||||
:else
|
:else
|
||||||
(case (.getName ~(with-meta '(first interfaces)
|
(case (.getName ~(with-meta '(first interfaces)
|
||||||
{:tag 'Class}))
|
{:tag 'Class}))
|
||||||
~@(mapcat
|
~@(mapcat
|
||||||
(fn [[clazz methods]]
|
(fn [[clazz methods]]
|
||||||
(list
|
(list
|
||||||
(str clazz)
|
(str clazz)
|
||||||
(concat prelude
|
(concat prelude
|
||||||
(cons clazz
|
(cons clazz
|
||||||
(mapcat
|
(mapcat
|
||||||
(fn [[meth arities]]
|
(fn [[meth arities]]
|
||||||
(map
|
(map
|
||||||
(fn [arity]
|
(fn [arity]
|
||||||
(list meth arity
|
(list meth arity
|
||||||
(list*
|
(list*
|
||||||
(list 'or (list 'get 'methods (list 'quote meth))
|
(list 'or (list 'get 'methods (list 'quote meth))
|
||||||
`(throw (new Exception (str "Not implemented: "
|
`(throw (new Exception (str "Not implemented: "
|
||||||
~(str meth)))))
|
~(str meth)))))
|
||||||
arity)))
|
arity)))
|
||||||
arities))
|
arities))
|
||||||
methods)))))
|
methods)))))
|
||||||
methods)))))
|
methods))))))
|
||||||
|
|
||||||
;; (require 'clojure.pprint)
|
;; (require 'clojure.pprint)
|
||||||
;; (clojure.pprint/pprint
|
;; (clojure.pprint/pprint
|
||||||
;; (macroexpand '(gen-reify-combos {java.nio.file.FileVisitor
|
;; (macroexpand '(gen-reify-combos {java.nio.file.FileVisitor
|
||||||
;; {preVisitDirectory [[this p attrs]]
|
;; {preVisitDirectory [[this p attrs]]
|
||||||
;; postVisitDirectory [[this p attrs]]
|
;; postVisitDirectory [[this p attrs]]
|
||||||
;; visitFile [[this p attrs]]}})))
|
;; visitFile [[this p attrs]]}})))
|
||||||
|
|
||||||
#_:clj-kondo/ignore)
|
#_:clj-kondo/ignore
|
||||||
(def reify-fn
|
(def reify-fn
|
||||||
(gen-reify-combos
|
(gen-reify-combos
|
||||||
{java.lang.Object
|
{java.lang.Object
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue