Fix custom-readers var declaration
This commit is contained in:
parent
5a623870fe
commit
e5ccd25848
1 changed files with 4 additions and 4 deletions
|
|
@ -466,7 +466,9 @@
|
||||||
|
|
||||||
(def ^:private class-method-sig (into-array Class [IPersistentMap]))
|
(def ^:private class-method-sig (into-array Class [IPersistentMap]))
|
||||||
|
|
||||||
(declare ^:dynamic *custom-readers*)
|
(def ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])}" nil)
|
||||||
|
(defn swap-custom-readers! [f] (alter-var-root #'*custom-readers* f))
|
||||||
|
|
||||||
(defn- read-custom! [type-id in]
|
(defn- read-custom! [type-id in]
|
||||||
(if-let [custom-reader (get *custom-readers* type-id)]
|
(if-let [custom-reader (get *custom-readers* type-id)]
|
||||||
(try
|
(try
|
||||||
|
|
@ -756,9 +758,6 @@
|
||||||
(.writeShort ~out ~(coerce-custom-type-id custom-type-id))))
|
(.writeShort ~out ~(coerce-custom-type-id custom-type-id))))
|
||||||
~@body)))
|
~@body)))
|
||||||
|
|
||||||
(def ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])}" nil)
|
|
||||||
(defn swap-custom-readers! [f] (alter-var-root #'*custom-readers* f))
|
|
||||||
|
|
||||||
(defmacro extend-thaw
|
(defmacro extend-thaw
|
||||||
"Extends Nippy to support thawing of a custom type with given id:
|
"Extends Nippy to support thawing of a custom type with given id:
|
||||||
(extend-thaw :foo/my-type [data-input] ; Keyword id
|
(extend-thaw :foo/my-type [data-input] ; Keyword id
|
||||||
|
|
@ -780,6 +779,7 @@
|
||||||
~@body))))))
|
~@body))))))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
*custom-readers*
|
||||||
(defrecord MyType [data])
|
(defrecord MyType [data])
|
||||||
(extend-freeze MyType 1 [x out] (.writeUTF out (:data x)))
|
(extend-freeze MyType 1 [x out] (.writeUTF out (:data x)))
|
||||||
(extend-thaw 1 [in] (->MyType (.readUTF in)))
|
(extend-thaw 1 [in] (->MyType (.readUTF in)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue