parameterized paths working for cljs
This commit is contained in:
parent
5cb0a8e4f0
commit
ffaaf06f9f
3 changed files with 19 additions and 9 deletions
|
|
@ -132,8 +132,6 @@
|
|||
params. The return value is an executable selector."}
|
||||
bind-params* i/bind-params*)
|
||||
|
||||
|
||||
|
||||
;; Built-in pathing and context operations
|
||||
|
||||
(def ALL (i/->AllStructurePath))
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
(defn gensyms [amt]
|
||||
(vec (repeatedly amt gensym)))
|
||||
|
||||
(defmacro define-ParamsNeededPath [fn-type]
|
||||
(defmacro define-ParamsNeededPath [fn-type invoke-name var-arity-impl]
|
||||
(let [a (with-meta (gensym "array") {:tag 'objects})
|
||||
impls (for [i (range 21)
|
||||
:let [args (vec (gensyms i))
|
||||
setters (for [j (range i)] `(aset ~a ~j ~(get args j)))]]
|
||||
`(~'invoke [this# ~@args]
|
||||
`(~invoke-name [this# ~@args]
|
||||
(let [~a (object-array ~i)]
|
||||
~@setters
|
||||
(com.rpl.specter.impl/bind-params* this# ~a 0)
|
||||
|
|
@ -16,6 +16,5 @@
|
|||
`(defrecord ~'ParamsNeededPath [~'transform-fns ~'num-needed-params]
|
||||
~fn-type
|
||||
~@impls
|
||||
(~'applyTo [this# args#]
|
||||
(let [a# (object-array args#)]
|
||||
(com.rpl.specter.impl/bind-params* this# a# 0))))))
|
||||
~var-arity-impl
|
||||
)))
|
||||
|
|
|
|||
|
|
@ -83,10 +83,23 @@
|
|||
|
||||
#?(
|
||||
:clj
|
||||
(dh/define-ParamsNeededPath clojure.lang.IFn)
|
||||
(dh/define-ParamsNeededPath
|
||||
clojure.lang.IFn
|
||||
invoke
|
||||
(applyTo [this args]
|
||||
(let [a (object-array args)]
|
||||
(com.rpl.specter.impl/bind-params* this a 0))))
|
||||
|
||||
:cljs
|
||||
(dh/define-ParamsNeededPath cljs.core/IFn)
|
||||
(define-ParamsNeededPath
|
||||
cljs.core/IFn
|
||||
-invoke
|
||||
(-invoke [this p01 p02 p03 p04 p05 p06 p07 p08 p09 p10
|
||||
p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
|
||||
rest]
|
||||
;;TODO: fill this in for cljs
|
||||
(println "Var arity version in cljs!")
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue