Use big-endian stuff as an example

This commit is contained in:
Joshua Suskalo 2022-01-18 15:49:29 -06:00
parent 0ad6308846
commit 95ff261189

View file

@ -589,8 +589,8 @@ Handles](#unwrapped-native-handles).
Convenience functions are provided to both read and write all primitive types Convenience functions are provided to both read and write all primitive types
and addresses, including byte order. and addresses, including byte order.
As an example, when wrapping a function that returns an array of floats, the As an example, when wrapping a function that returns an array of big-endian
following code might be used. floats, the following code might be used.
``` clojure ``` clojure
(let [function-handle (ffi/make-downcall "returns_float_array" [::mem/pointer] ::mem/int) (let [function-handle (ffi/make-downcall "returns_float_array" [::mem/pointer] ::mem/int)
@ -608,7 +608,9 @@ following code might be used.
index 0] index 0]
(if (>= index num-floats) (if (>= index num-floats)
(persistent! floats) (persistent! floats)
(recur (conj! floats (mem/read-float floats-slice (unchecked-multiply-int index float-size))) (recur (conj! floats (mem/read-float floats-slice
(unchecked-multiply-int index float-size)
mem/big-endian))
(inc index))))] (inc index))))]
(release-floats floats-addr) (release-floats floats-addr)
ret)))) ret))))