fixed #48
This commit is contained in:
parent
f500a4bfa3
commit
2ad873da11
4 changed files with 30 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
## 0.9.2 (unreleased)
|
||||
* Added VOID selector which navigates nowhere
|
||||
* Better syntax checking for defpath
|
||||
* Fixed bug in protocol paths (#48)
|
||||
|
||||
## 0.9.1
|
||||
* Fixed reflection in protocol path code
|
||||
|
|
|
|||
|
|
@ -597,6 +597,7 @@
|
|||
m (-> protpath-prot :sigs keys first)]
|
||||
(doseq [[atype apath] extensions]
|
||||
;;TODO: validate that the path has the correct number of args (or none at all)
|
||||
(let [p (comp-paths* apath)]
|
||||
(extend atype protpath-prot {m (fn [_] p)})
|
||||
(let [p (comp-paths* apath)
|
||||
rp (assoc p :transform-fns (coerce-tfns-rich (:transform-fns p)))]
|
||||
(extend atype protpath-prot {m (fn [_] rp)})
|
||||
))))
|
||||
|
|
|
|||
|
|
@ -210,7 +210,6 @@
|
|||
m (-> name (str "-retrieve") symbol)
|
||||
num-params (count params)
|
||||
ssym (gensym "structure")
|
||||
sargs [ssym (gensym "next-fn")]
|
||||
rargs [(gensym "params") (gensym "pidx") (gensym "vals") ssym (gensym "next-fn")]
|
||||
retrieve `(~m ~ssym)
|
||||
]
|
||||
|
|
@ -220,16 +219,16 @@
|
|||
(if (= ~num-params 0)
|
||||
(no-params-compiled-path
|
||||
(->TransformFunctions
|
||||
StructurePathExecutor
|
||||
(fn ~sargs
|
||||
RichPathExecutor
|
||||
(fn ~rargs
|
||||
(let [path# ~retrieve
|
||||
selector# (compiled-selector path#)]
|
||||
(selector# ~@sargs)
|
||||
(selector# ~@rargs)
|
||||
))
|
||||
(fn ~sargs
|
||||
(fn ~rargs
|
||||
(let [path# ~retrieve
|
||||
transformer# (compiled-transformer path#)]
|
||||
(transformer# ~@sargs)
|
||||
(transformer# ~@rargs)
|
||||
))))
|
||||
(->ParamsNeededPath
|
||||
(->TransformFunctions
|
||||
|
|
|
|||
|
|
@ -639,3 +639,24 @@
|
|||
inc
|
||||
data)))
|
||||
))
|
||||
|
||||
|
||||
#+clj
|
||||
(do
|
||||
(defprotocolpath CustomWalker [])
|
||||
(extend-protocolpath CustomWalker
|
||||
Object nil
|
||||
clojure.lang.PersistentHashMap [(s/keypath :a) CustomWalker]
|
||||
clojure.lang.PersistentArrayMap [(s/keypath :a) CustomWalker]
|
||||
clojure.lang.PersistentVector [s/ALL CustomWalker]
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
#+clj
|
||||
(deftest mixed-rich-regular-protocolpath
|
||||
(is (= [1 2 3 11 21 22 25]
|
||||
(s/select [CustomWalker number?] [{:a [1 2 :c [3]]} [[[[[[11]]] 21 [22 :c 25]]]]])))
|
||||
(is (= [2 3 [[[4]] :b 0] {:a 4 :b 10}]
|
||||
(s/transform [CustomWalker number?] inc [1 2 [[[3]] :b -1] {:a 3 :b 10}])))
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue