add error message for invalid type usage
This commit is contained in:
parent
cf2decedcd
commit
020e10264f
1 changed files with 33 additions and 31 deletions
|
|
@ -1919,8 +1919,10 @@
|
||||||
This creates needed serialization and deserialization implementations for the new type."
|
This creates needed serialization and deserialization implementations for the new type."
|
||||||
{:style/indent [:defn]}
|
{:style/indent [:defn]}
|
||||||
[typename members]
|
[typename members]
|
||||||
|
(let [invalid-typenames (filter #(try (c-layout (first %)) nil (catch Exception e (first %))) (partition 2 members))]
|
||||||
(cond
|
(cond
|
||||||
(odd? (count members)) (throw (Exception. "uneven amount of members supplied. members have to be typed and are required to be supplied in the form of `typename member-name`. the typename has to be coffi typename, like `:coffi.mem/int` or `[:coffi.mem/array :coffi.mem/byte 3]`"))
|
(odd? (count members)) (throw (Exception. "uneven amount of members supplied. members have to be typed and are required to be supplied in the form of `typename member-name`. the typename has to be coffi typename, like `:coffi.mem/int` or `[:coffi.mem/array :coffi.mem/byte 3]`"))
|
||||||
|
(seq invalid-typenames) (throw (Exception. (str "invalid typename/s " (print-str invalid-typenames) ". typename has to be coffi typename, like `:coffi.mem/int` or `[:coffi.mem/array :coffi.mem/byte 3]`")))
|
||||||
:else
|
:else
|
||||||
(let [coffi-typename (keyword (str *ns*) (str typename))
|
(let [coffi-typename (keyword (str *ns*) (str typename))
|
||||||
typed-symbols (->>
|
typed-symbols (->>
|
||||||
|
|
@ -1949,6 +1951,6 @@
|
||||||
(defmethod clojure.core/print-method ~typename [~'obj ~'writer] (print-simple (into {} ~'obj) ~'writer))
|
(defmethod clojure.core/print-method ~typename [~'obj ~'writer] (print-simple (into {} ~'obj) ~'writer))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue