cljs tests passing
This commit is contained in:
parent
4005aca92e
commit
33d19ebd1d
2 changed files with 24 additions and 43 deletions
|
|
@ -91,16 +91,6 @@
|
|||
(defn intern* [ns name val]
|
||||
(throw-illegal "intern not supported in ClojureScript"))
|
||||
|
||||
;; so that macros.clj compiles appropriately when
|
||||
;; run in cljs (this code isn't called in that case)
|
||||
#+cljs
|
||||
(defn gen-uuid-str []
|
||||
(throw-illegal "Cannot get UUID in Javascript"))
|
||||
|
||||
#+clj
|
||||
(defn gen-uuid-str []
|
||||
(str (java.util.UUID/randomUUID)))
|
||||
|
||||
(defn benchmark [iters afn]
|
||||
(time
|
||||
(dotimes [_ iters]
|
||||
|
|
@ -123,7 +113,7 @@
|
|||
|
||||
#+cljs
|
||||
(defn exec-rich-select* [this params params-idx vals structure next-fn]
|
||||
(rich-select* this params params-idx vals structure next-fn))
|
||||
(rich-select* ^not-native this params params-idx vals structure next-fn))
|
||||
|
||||
#+clj
|
||||
(defmacro exec-rich-transform* [this & args]
|
||||
|
|
@ -133,7 +123,7 @@
|
|||
|
||||
#+cljs
|
||||
(defn exec-rich-transform* [this params params-idx vals structure next-fn]
|
||||
(rich-select* this params params-idx vals structure next-fn))
|
||||
(rich-transform* ^not-native this params params-idx vals structure next-fn))
|
||||
|
||||
#+clj
|
||||
(defmacro exec-select* [this & args]
|
||||
|
|
@ -143,7 +133,7 @@
|
|||
|
||||
#+cljs
|
||||
(defn exec-select* [this structure next-fn]
|
||||
(p/select* this structure next-fn))
|
||||
(p/select* ^not-native this structure next-fn))
|
||||
|
||||
#+clj
|
||||
(defmacro exec-transform* [this & args]
|
||||
|
|
@ -153,7 +143,7 @@
|
|||
|
||||
#+cljs
|
||||
(defn exec-transform* [this structure next-fn]
|
||||
(p/transform* this structure next-fn))
|
||||
(p/transform* ^not-native this structure next-fn))
|
||||
|
||||
(def RichPathExecutor
|
||||
(->ExecutorFunctions
|
||||
|
|
|
|||
|
|
@ -303,49 +303,40 @@
|
|||
([name]
|
||||
`(declarepath ~name []))
|
||||
([name params]
|
||||
(let [num-params (count params)
|
||||
(let [platform (if (contains? &env :locals) :cljs :clj)
|
||||
select-exec (if (= platform :clj)
|
||||
`i/exec-rich-select*
|
||||
`i/rich-select*)
|
||||
transform-exec (if (= platform :clj)
|
||||
`i/exec-rich-transform*
|
||||
`i/rich-transform*)
|
||||
num-params (count params)
|
||||
declared (declared-name name)
|
||||
rargs [(gensym "params") (gensym "pidx") (gensym "vals")
|
||||
(gensym "structure") (gensym "next-fn")]]
|
||||
`(do
|
||||
(declare ~declared)
|
||||
(def ~name
|
||||
(if (= ~num-params 0)
|
||||
(i/no-params-rich-compiled-path
|
||||
(reify RichNavigator
|
||||
(~'rich-select* [this# ~@rargs]
|
||||
(let [inav# (i/compiled-path-rich-nav ~declared)]
|
||||
(i/exec-rich-select* inav# ~@rargs)
|
||||
))
|
||||
(~'rich-transform* [this# ~@rargs]
|
||||
(let [inav# (i/compiled-path-rich-nav ~declared)]
|
||||
(i/exec-rich-transform* inav# ~@rargs)
|
||||
))))
|
||||
(i/->ParamsNeededPath
|
||||
(reify RichNavigator
|
||||
(~'rich-select* [this# ~@rargs]
|
||||
(let [inav# (i/params-needed-nav ~declared)]
|
||||
(i/exec-rich-select* inav# ~@rargs)
|
||||
))
|
||||
(~'rich-transform* [this# ~@rargs]
|
||||
(let [inav# (i/params-needed-nav ~declared)]
|
||||
(i/exec-rich-transform* inav# ~@rargs)
|
||||
)))
|
||||
~num-params
|
||||
)
|
||||
))))))
|
||||
(let [nav# (reify RichNavigator
|
||||
(~'rich-select* [this# ~@rargs]
|
||||
(~select-exec ~declared ~@rargs))
|
||||
(~'rich-transform* [this# ~@rargs]
|
||||
(~transform-exec ~declared ~@rargs)
|
||||
))]
|
||||
(if (= ~num-params 0)
|
||||
(i/no-params-rich-compiled-path nav#)
|
||||
(i/->ParamsNeededPath nav# ~num-params)
|
||||
)))))))
|
||||
|
||||
;;TODO: continue refactoring from here *******
|
||||
;;TODO: need to convert to use first-class navigators
|
||||
(defmacro providepath [name apath]
|
||||
`(let [comped# (i/comp-paths* ~apath)
|
||||
`(let [comped# (i/comp-paths-internalized ~apath)
|
||||
expected-params# (i/num-needed-params ~name)
|
||||
needed-params# (i/num-needed-params comped#)]
|
||||
(if-not (= needed-params# expected-params#)
|
||||
(i/throw-illegal "Invalid number of params in provided path, expected "
|
||||
expected-params# " but got " needed-params#))
|
||||
(def ~(declared-name name)
|
||||
(i/coerce-compiled->rich-nav comped#)
|
||||
(i/extract-rich-nav (i/coerce-compiled->rich-nav comped#))
|
||||
)))
|
||||
|
||||
(defmacro extend-protocolpath
|
||||
|
|
|
|||
Loading…
Reference in a new issue