have defnav generate every method as a helper function as well (with name <name>-<method-name>, takes params as initial arguments followed by regular method arguments (except for 'this')
This commit is contained in:
parent
a765d1af50
commit
a35cacae67
1 changed files with 12 additions and 2 deletions
|
|
@ -255,9 +255,19 @@
|
|||
(let [afn# (fn [~structure-sym] ~@impl)]
|
||||
(i/filter-transform afn# structure# next-fn#)))))
|
||||
|
||||
(defn- helper-name [name method-name]
|
||||
(symbol (str name "-" method-name)))
|
||||
|
||||
(defmacro defnav [name & body]
|
||||
`(def ~name (nav ~@body)))
|
||||
(defmacro defnav [name params & impls]
|
||||
;; remove the "this" param for the helper
|
||||
(let [helpers (for [[mname [_ & mparams] & mbody] impls]
|
||||
`(defn ~(helper-name name mname) [~@params ~@mparams] ~@mbody))
|
||||
decls (for [[mname & _] impls]
|
||||
`(declare ~(helper-name name mname)))]
|
||||
`(do
|
||||
~@decls
|
||||
~@helpers
|
||||
(def ~name (nav ~params ~@impls)))))
|
||||
|
||||
(defmacro defcollector [name & body]
|
||||
`(def ~name (collector ~@body)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue