Add function for arbitrary type data to go with base type
This commit is contained in:
parent
1461dbcf81
commit
fb6dfe69d2
1 changed files with 14 additions and 7 deletions
|
|
@ -143,6 +143,13 @@
|
||||||
::double CLinker/C_DOUBLE
|
::double CLinker/C_DOUBLE
|
||||||
::pointer CLinker/C_POINTER})
|
::pointer CLinker/C_POINTER})
|
||||||
|
|
||||||
|
(defn- type-dispatch
|
||||||
|
"Gets a type dispatch value from a (potentially composite) type."
|
||||||
|
[type]
|
||||||
|
(cond
|
||||||
|
(qualified-keyword? type) type
|
||||||
|
(list? type) (keyword (first type))))
|
||||||
|
|
||||||
(defmulti c-layout
|
(defmulti c-layout
|
||||||
"Gets the layout object for a given `type`.
|
"Gets the layout object for a given `type`.
|
||||||
|
|
||||||
|
|
@ -150,7 +157,7 @@
|
||||||
layout (see [[c-prim-layout]]).
|
layout (see [[c-prim-layout]]).
|
||||||
|
|
||||||
Otherwise, it should return a [[GroupLayout]] for the given type."
|
Otherwise, it should return a [[GroupLayout]] for the given type."
|
||||||
(fn [type] type))
|
type-dispatch)
|
||||||
|
|
||||||
(defmethod c-layout :default
|
(defmethod c-layout :default
|
||||||
[type]
|
[type]
|
||||||
|
|
@ -168,7 +175,7 @@
|
||||||
deserialization.
|
deserialization.
|
||||||
|
|
||||||
Returns nil for any type which does not have a primitive representation."
|
Returns nil for any type which does not have a primitive representation."
|
||||||
(fn [type] type))
|
type-dispatch)
|
||||||
|
|
||||||
(defmethod primitive-type :default
|
(defmethod primitive-type :default
|
||||||
[type]
|
[type]
|
||||||
|
|
@ -193,7 +200,7 @@
|
||||||
|
|
||||||
(defmulti java-layout
|
(defmulti java-layout
|
||||||
"Gets the Java class to an argument of this type for a method handle."
|
"Gets the Java class to an argument of this type for a method handle."
|
||||||
(fn [type] type))
|
type-dispatch)
|
||||||
|
|
||||||
(defmethod java-layout :default
|
(defmethod java-layout :default
|
||||||
[type]
|
[type]
|
||||||
|
|
@ -226,7 +233,7 @@
|
||||||
(fn
|
(fn
|
||||||
#_{:clj-kondo/ignore [:unused-binding]}
|
#_{:clj-kondo/ignore [:unused-binding]}
|
||||||
[obj type scope]
|
[obj type scope]
|
||||||
type))
|
(type-dispatch type)))
|
||||||
|
|
||||||
(defmethod serialize* :default
|
(defmethod serialize* :default
|
||||||
[obj type _scope]
|
[obj type _scope]
|
||||||
|
|
@ -250,7 +257,7 @@
|
||||||
(fn
|
(fn
|
||||||
#_{:clj-kondo/ignore [:unused-binding]}
|
#_{:clj-kondo/ignore [:unused-binding]}
|
||||||
[obj type segment scope]
|
[obj type segment scope]
|
||||||
type))
|
(type-dispatch type)))
|
||||||
|
|
||||||
(defmethod serialize* ::c-string
|
(defmethod serialize* ::c-string
|
||||||
[obj _type scope]
|
[obj _type scope]
|
||||||
|
|
@ -319,7 +326,7 @@
|
||||||
(fn
|
(fn
|
||||||
#_{:clj-kondo/ignore [:unused-binding]}
|
#_{:clj-kondo/ignore [:unused-binding]}
|
||||||
[segment type]
|
[segment type]
|
||||||
type))
|
(type-dispatch type)))
|
||||||
|
|
||||||
(defmethod deserialize-from ::byte
|
(defmethod deserialize-from ::byte
|
||||||
[segment _type]
|
[segment _type]
|
||||||
|
|
@ -365,7 +372,7 @@
|
||||||
(fn
|
(fn
|
||||||
#_{:clj-kondo/ignore [:unused-binding]}
|
#_{:clj-kondo/ignore [:unused-binding]}
|
||||||
[obj type]
|
[obj type]
|
||||||
type))
|
(type-dispatch type)))
|
||||||
|
|
||||||
(defmethod deserialize* :default
|
(defmethod deserialize* :default
|
||||||
[obj _type]
|
[obj _type]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue