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]
|
(defn intern* [ns name val]
|
||||||
(throw-illegal "intern not supported in ClojureScript"))
|
(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]
|
(defn benchmark [iters afn]
|
||||||
(time
|
(time
|
||||||
(dotimes [_ iters]
|
(dotimes [_ iters]
|
||||||
|
|
@ -123,7 +113,7 @@
|
||||||
|
|
||||||
#+cljs
|
#+cljs
|
||||||
(defn exec-rich-select* [this params params-idx vals structure next-fn]
|
(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
|
#+clj
|
||||||
(defmacro exec-rich-transform* [this & args]
|
(defmacro exec-rich-transform* [this & args]
|
||||||
|
|
@ -133,7 +123,7 @@
|
||||||
|
|
||||||
#+cljs
|
#+cljs
|
||||||
(defn exec-rich-transform* [this params params-idx vals structure next-fn]
|
(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
|
#+clj
|
||||||
(defmacro exec-select* [this & args]
|
(defmacro exec-select* [this & args]
|
||||||
|
|
@ -143,7 +133,7 @@
|
||||||
|
|
||||||
#+cljs
|
#+cljs
|
||||||
(defn exec-select* [this structure next-fn]
|
(defn exec-select* [this structure next-fn]
|
||||||
(p/select* this structure next-fn))
|
(p/select* ^not-native this structure next-fn))
|
||||||
|
|
||||||
#+clj
|
#+clj
|
||||||
(defmacro exec-transform* [this & args]
|
(defmacro exec-transform* [this & args]
|
||||||
|
|
@ -153,7 +143,7 @@
|
||||||
|
|
||||||
#+cljs
|
#+cljs
|
||||||
(defn exec-transform* [this structure next-fn]
|
(defn exec-transform* [this structure next-fn]
|
||||||
(p/transform* this structure next-fn))
|
(p/transform* ^not-native this structure next-fn))
|
||||||
|
|
||||||
(def RichPathExecutor
|
(def RichPathExecutor
|
||||||
(->ExecutorFunctions
|
(->ExecutorFunctions
|
||||||
|
|
|
||||||
|
|
@ -303,49 +303,40 @@
|
||||||
([name]
|
([name]
|
||||||
`(declarepath ~name []))
|
`(declarepath ~name []))
|
||||||
([name params]
|
([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)
|
declared (declared-name name)
|
||||||
rargs [(gensym "params") (gensym "pidx") (gensym "vals")
|
rargs [(gensym "params") (gensym "pidx") (gensym "vals")
|
||||||
(gensym "structure") (gensym "next-fn")]]
|
(gensym "structure") (gensym "next-fn")]]
|
||||||
`(do
|
`(do
|
||||||
(declare ~declared)
|
(declare ~declared)
|
||||||
(def ~name
|
(def ~name
|
||||||
|
(let [nav# (reify RichNavigator
|
||||||
|
(~'rich-select* [this# ~@rargs]
|
||||||
|
(~select-exec ~declared ~@rargs))
|
||||||
|
(~'rich-transform* [this# ~@rargs]
|
||||||
|
(~transform-exec ~declared ~@rargs)
|
||||||
|
))]
|
||||||
(if (= ~num-params 0)
|
(if (= ~num-params 0)
|
||||||
(i/no-params-rich-compiled-path
|
(i/no-params-rich-compiled-path nav#)
|
||||||
(reify RichNavigator
|
(i/->ParamsNeededPath nav# ~num-params)
|
||||||
(~'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
|
|
||||||
)
|
|
||||||
))))))
|
|
||||||
|
|
||||||
;;TODO: continue refactoring from here *******
|
|
||||||
;;TODO: need to convert to use first-class navigators
|
|
||||||
(defmacro providepath [name apath]
|
(defmacro providepath [name apath]
|
||||||
`(let [comped# (i/comp-paths* ~apath)
|
`(let [comped# (i/comp-paths-internalized ~apath)
|
||||||
expected-params# (i/num-needed-params ~name)
|
expected-params# (i/num-needed-params ~name)
|
||||||
needed-params# (i/num-needed-params comped#)]
|
needed-params# (i/num-needed-params comped#)]
|
||||||
(if-not (= needed-params# expected-params#)
|
(if-not (= needed-params# expected-params#)
|
||||||
(i/throw-illegal "Invalid number of params in provided path, expected "
|
(i/throw-illegal "Invalid number of params in provided path, expected "
|
||||||
expected-params# " but got " needed-params#))
|
expected-params# " but got " needed-params#))
|
||||||
(def ~(declared-name name)
|
(def ~(declared-name name)
|
||||||
(i/coerce-compiled->rich-nav comped#)
|
(i/extract-rich-nav (i/coerce-compiled->rich-nav comped#))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(defmacro extend-protocolpath
|
(defmacro extend-protocolpath
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue