0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Add support for preconditions to defc and defcs macros.

This commit is contained in:
Andrey Antukh 2016-11-09 11:24:26 +01:00
parent 67ae149c36
commit 9fb13ba73d
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -30,8 +30,14 @@
(recur (assoc r :mixins mixins) (inc s) (first n) (rest n)))
(recur (assoc r :mixins [v]) (inc s) (first n) (rest n)))
(recur r (inc s) v n))
3 (let [sym (:name r)
func `(fn ~sym ~v ~(s/compile-html `(do ~@n)))]
3 (if (vector? v)
(recur (assoc r :args v) (inc s) (first n) (rest n))
(throw (ex-info "Invalid" {})))
4 (let [sym (:name r)
args (:args r)
func (if (map? v)
`(fn ~sym ~args ~v ~(s/compile-html `(do ~@n)))
`(fn ~sym ~args ~(s/compile-html `(do ~@(cons v n)))))]
[func (:doc r) (:mixins r) sym]))))
(defmacro defc