Move to multimethod implementations for deserialize*
This commit is contained in:
parent
c43ff5a848
commit
53f72bdb49
1 changed files with 39 additions and 5 deletions
|
|
@ -567,11 +567,41 @@
|
||||||
;; TODO(Joshua): For performance, turn this into a bunch of specific defmethods
|
;; TODO(Joshua): For performance, turn this into a bunch of specific defmethods
|
||||||
(defmethod deserialize* :default
|
(defmethod deserialize* :default
|
||||||
[obj type]
|
[obj type]
|
||||||
(if (primitive-type type)
|
|
||||||
obj
|
|
||||||
(throw (ex-info "Attempted to deserialize a non-primitive type with primitive methods"
|
(throw (ex-info "Attempted to deserialize a non-primitive type with primitive methods"
|
||||||
{:type type
|
{:type type
|
||||||
:segment obj}))))
|
:segment obj})))
|
||||||
|
|
||||||
|
(defmethod deserialize* ::byte
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::short
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::int
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::long
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::long-long
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::char
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::float
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
|
(defmethod deserialize* ::double
|
||||||
|
[obj _type]
|
||||||
|
obj)
|
||||||
|
|
||||||
(defmethod deserialize* ::pointer
|
(defmethod deserialize* ::pointer
|
||||||
[addr type]
|
[addr type]
|
||||||
|
|
@ -581,6 +611,10 @@
|
||||||
(second type))
|
(second type))
|
||||||
addr)))
|
addr)))
|
||||||
|
|
||||||
|
(defmethod deserialize* ::void
|
||||||
|
[_obj _type]
|
||||||
|
nil)
|
||||||
|
|
||||||
(defn deserialize
|
(defn deserialize
|
||||||
"Deserializes an arbitrary type.
|
"Deserializes an arbitrary type.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue