sci: update to new reify config
This commit is contained in:
parent
0fae952d4d
commit
1391f028bf
1 changed files with 44 additions and 25 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
(ns babashka.impl.reify
|
(ns babashka.impl.reify
|
||||||
{:no-doc true}
|
{:no-doc true}
|
||||||
(:require [clojure.math.combinatorics :as combo]))
|
(:require [clojure.math.combinatorics :as combo]
|
||||||
|
[sci.impl.types]))
|
||||||
|
|
||||||
(set! *warn-on-reflection* false)
|
(set! *warn-on-reflection* false)
|
||||||
|
|
||||||
|
|
@ -8,33 +9,51 @@
|
||||||
"Generates pre-compiled reify combinations"
|
"Generates pre-compiled reify combinations"
|
||||||
[methods]
|
[methods]
|
||||||
(let [subsets (rest (combo/subsets (seq methods)))]
|
(let [subsets (rest (combo/subsets (seq methods)))]
|
||||||
(reduce (fn [opts classes]
|
(reduce (fn [opts [classes protocols?]]
|
||||||
(assoc opts
|
(let [prelude '[reify]
|
||||||
(set (map (fn [[class _]]
|
prelude (if protocols?
|
||||||
(list 'quote class))
|
(conj prelude
|
||||||
classes))
|
'sci.impl.types.IReified
|
||||||
(list 'fn ['methods]
|
'(getInterfaces [this]
|
||||||
(list* 'reify
|
interfaces)
|
||||||
(mapcat
|
'(getMethods [this]
|
||||||
(fn [[clazz methods]]
|
methods)
|
||||||
(cons clazz
|
'(getProtocols [this]
|
||||||
(mapcat
|
protocols))
|
||||||
(fn [[meth arities]]
|
prelude)]
|
||||||
(map
|
(assoc opts
|
||||||
(fn [arity]
|
(cond-> (set (map #(list 'quote %)
|
||||||
(list meth arity
|
(map first classes)))
|
||||||
(list*
|
protocols?
|
||||||
(list 'get-in 'methods
|
(conj (list 'quote 'sci.impl.types.IReified)))
|
||||||
[(list 'quote clazz) (list 'quote meth)])
|
(list 'fn ['interfaces 'methods 'protocols]
|
||||||
arity)))
|
(concat prelude
|
||||||
arities))
|
(mapcat
|
||||||
methods)))
|
(fn [[clazz methods]]
|
||||||
classes)))))
|
(cons clazz
|
||||||
|
(mapcat
|
||||||
|
(fn [[meth arities]]
|
||||||
|
(map
|
||||||
|
(fn [arity]
|
||||||
|
(list meth arity
|
||||||
|
(list*
|
||||||
|
(list 'get 'methods (list 'quote meth))
|
||||||
|
arity)))
|
||||||
|
arities))
|
||||||
|
methods)))
|
||||||
|
classes))))))
|
||||||
{}
|
{}
|
||||||
subsets)))
|
(concat (map (fn [subset bool]
|
||||||
|
[subset bool])
|
||||||
|
subsets
|
||||||
|
(repeat true))
|
||||||
|
(map (fn [subset bool]
|
||||||
|
[subset bool])
|
||||||
|
subsets
|
||||||
|
(repeat false))))))
|
||||||
|
|
||||||
#_(prn (macroexpand '(gen-reify-combos
|
#_(prn (macroexpand '(gen-reify-combos
|
||||||
{java.io.FileFilter {accept [[this f]]}})))
|
{java.io.FileFilter {accept [[this f]]}})))
|
||||||
|
|
||||||
#_:clj-kondo/ignore
|
#_:clj-kondo/ignore
|
||||||
(def reify-opts
|
(def reify-opts
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue