Fix reflection warnings
This commit is contained in:
parent
4c108b7010
commit
30891c35ab
1 changed files with 6 additions and 9 deletions
|
|
@ -146,13 +146,13 @@
|
||||||
"Clones the content of `segment` into a new segment of the same size."
|
"Clones the content of `segment` into a new segment of the same size."
|
||||||
([segment] (clone-segment segment (connected-scope)))
|
([segment] (clone-segment segment (connected-scope)))
|
||||||
([segment scope]
|
([segment scope]
|
||||||
(doto (alloc (.byteSize ^MemorySegment segment) scope)
|
(doto ^MemorySegment (alloc (.byteSize ^MemorySegment segment) scope)
|
||||||
(.copyFrom ^MemorySegment segment))))
|
(.copyFrom ^MemorySegment segment))))
|
||||||
|
|
||||||
(defn slice-segments
|
(defn slice-segments
|
||||||
"Constructs a lazy seq of `size`-length memory segments, sliced from `segment`."
|
"Constructs a lazy seq of `size`-length memory segments, sliced from `segment`."
|
||||||
[segment size]
|
[segment size]
|
||||||
(let [num-segments (quot (.byteSize segment) size)]
|
(let [num-segments (quot (.byteSize ^MemorySegment segment) size)]
|
||||||
(map #(slice segment (* % size) size)
|
(map #(slice segment (* % size) size)
|
||||||
(range num-segments))))
|
(range num-segments))))
|
||||||
|
|
||||||
|
|
@ -242,10 +242,7 @@
|
||||||
(defn size-of
|
(defn size-of
|
||||||
"The size in bytes of the given `type`."
|
"The size in bytes of the given `type`."
|
||||||
[type]
|
[type]
|
||||||
(let [layout ^MemoryLayout (c-layout type)]
|
(.byteSize ^MemoryLayout (c-layout type)))
|
||||||
(.byteSize
|
|
||||||
(cond-> layout
|
|
||||||
(qualified-keyword? layout) ^MemoryLayout c-layout))))
|
|
||||||
|
|
||||||
(defn alloc-instance
|
(defn alloc-instance
|
||||||
"Allocates a memory segment for the given `type`."
|
"Allocates a memory segment for the given `type`."
|
||||||
|
|
@ -505,7 +502,7 @@
|
||||||
(defmethod c-layout ::struct
|
(defmethod c-layout ::struct
|
||||||
[[_struct fields]]
|
[[_struct fields]]
|
||||||
(let [fields (for [[field-name field] fields]
|
(let [fields (for [[field-name field] fields]
|
||||||
(.withName (c-layout field)
|
(.withName ^MemoryLayout (c-layout field)
|
||||||
(name field-name)))]
|
(name field-name)))]
|
||||||
(MemoryLayout/structLayout
|
(MemoryLayout/structLayout
|
||||||
(into-array MemoryLayout fields))))
|
(into-array MemoryLayout fields))))
|
||||||
|
|
@ -520,7 +517,7 @@
|
||||||
(serialize-into
|
(serialize-into
|
||||||
(get obj field) type
|
(get obj field) type
|
||||||
(slice segment offset size) scope)
|
(slice segment offset size) scope)
|
||||||
(recur (+ offset size) (rest fields))))))
|
(recur (long (+ offset size)) (rest fields))))))
|
||||||
|
|
||||||
(defmethod deserialize-from ::struct
|
(defmethod deserialize-from ::struct
|
||||||
[segment [_struct fields]]
|
[segment [_struct fields]]
|
||||||
|
|
@ -531,7 +528,7 @@
|
||||||
(let [[field type] (first fields)
|
(let [[field type] (first fields)
|
||||||
size (size-of type)]
|
size (size-of type)]
|
||||||
(recur
|
(recur
|
||||||
(+ offset size)
|
(long (+ offset size))
|
||||||
(rest fields)
|
(rest fields)
|
||||||
(assoc obj field (deserialize-from
|
(assoc obj field (deserialize-from
|
||||||
(slice segment offset size)
|
(slice segment offset size)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue