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."}
|
params. The return value is an executable selector."}
|
||||||
bind-params* i/bind-params*)
|
bind-params* i/bind-params*)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; Built-in pathing and context operations
|
;; Built-in pathing and context operations
|
||||||
|
|
||||||
(def ALL (i/->AllStructurePath))
|
(def ALL (i/->AllStructurePath))
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
(defn gensyms [amt]
|
(defn gensyms [amt]
|
||||||
(vec (repeatedly amt gensym)))
|
(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})
|
(let [a (with-meta (gensym "array") {:tag 'objects})
|
||||||
impls (for [i (range 21)
|
impls (for [i (range 21)
|
||||||
:let [args (vec (gensyms i))
|
:let [args (vec (gensyms i))
|
||||||
setters (for [j (range i)] `(aset ~a ~j ~(get args j)))]]
|
setters (for [j (range i)] `(aset ~a ~j ~(get args j)))]]
|
||||||
`(~'invoke [this# ~@args]
|
`(~invoke-name [this# ~@args]
|
||||||
(let [~a (object-array ~i)]
|
(let [~a (object-array ~i)]
|
||||||
~@setters
|
~@setters
|
||||||
(com.rpl.specter.impl/bind-params* this# ~a 0)
|
(com.rpl.specter.impl/bind-params* this# ~a 0)
|
||||||
|
|
@ -16,6 +16,5 @@
|
||||||
`(defrecord ~'ParamsNeededPath [~'transform-fns ~'num-needed-params]
|
`(defrecord ~'ParamsNeededPath [~'transform-fns ~'num-needed-params]
|
||||||
~fn-type
|
~fn-type
|
||||||
~@impls
|
~@impls
|
||||||
(~'applyTo [this# args#]
|
~var-arity-impl
|
||||||
(let [a# (object-array args#)]
|
)))
|
||||||
(com.rpl.specter.impl/bind-params* this# a# 0))))))
|
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,23 @@
|
||||||
|
|
||||||
#?(
|
#?(
|
||||||
:clj
|
: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
|
: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