Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ca72b2ef7 | ||
|
|
5e120d3240 | ||
|
|
2761f73b0d | ||
|
|
9344b38494 | ||
|
|
e7f0b18716 | ||
|
|
7baae299a6 | ||
|
|
67a8c8d4cf | ||
|
|
e4ba7ef56f | ||
|
|
0655f39dc9 |
2 changed files with 45 additions and 26 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit b74cdc1f7f1e9a9136a7439b828f02f22251b901
|
Subproject commit 32801896e4d9533b3b61453b4ebb813042c59e5c
|
||||||
|
|
@ -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,13 +9,25 @@
|
||||||
"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?]]
|
||||||
|
(let [prelude '[reify]
|
||||||
|
prelude (if protocols?
|
||||||
|
(conj prelude
|
||||||
|
'sci.impl.types.IReified
|
||||||
|
'(getInterfaces [this]
|
||||||
|
interfaces)
|
||||||
|
'(getMethods [this]
|
||||||
|
methods)
|
||||||
|
'(getProtocols [this]
|
||||||
|
protocols))
|
||||||
|
prelude)]
|
||||||
(assoc opts
|
(assoc opts
|
||||||
(set (map (fn [[class _]]
|
(cond-> (set (map #(list 'quote %)
|
||||||
(list 'quote class))
|
(map first classes)))
|
||||||
classes))
|
protocols?
|
||||||
(list 'fn ['methods]
|
(conj (list 'quote 'sci.impl.types.IReified)))
|
||||||
(list* 'reify
|
(list 'fn ['interfaces 'methods 'protocols]
|
||||||
|
(concat prelude
|
||||||
(mapcat
|
(mapcat
|
||||||
(fn [[clazz methods]]
|
(fn [[clazz methods]]
|
||||||
(cons clazz
|
(cons clazz
|
||||||
|
|
@ -24,14 +37,20 @@
|
||||||
(fn [arity]
|
(fn [arity]
|
||||||
(list meth arity
|
(list meth arity
|
||||||
(list*
|
(list*
|
||||||
(list 'get-in 'methods
|
(list 'get 'methods (list 'quote meth))
|
||||||
[(list 'quote clazz) (list 'quote meth)])
|
|
||||||
arity)))
|
arity)))
|
||||||
arities))
|
arities))
|
||||||
methods)))
|
methods)))
|
||||||
classes)))))
|
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]]}})))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue