Add constants for byte orders

This commit is contained in:
Joshua Suskalo 2022-01-18 13:25:56 -06:00
parent 39e316f0a4
commit faca63b50c

View file

@ -21,6 +21,7 @@
(:require
[clojure.spec.alpha :as s])
(:import
(java.nio ByteOrder)
(jdk.incubator.foreign
Addressable
CLinker
@ -205,6 +206,24 @@
(map #(slice segment (* % size) size)
(range num-segments))))
(def big-endian
"The big-endian [[ByteOrder]].
See [[little-endian]], [[native-endian]]."
ByteOrder/BIG_ENDIAN)
(def little-endian
"The little-endian [[ByteOrder]].
See [[big-endian]], [[native-endian]]"
ByteOrder/LITTLE_ENDIAN)
(def native-endian
"The [[ByteOrder]] for the native endianness of the current hardware.
See [[big-endian]], [[little-endian]]."
(ByteOrder/nativeOrder))
(defn- type-dispatch
"Gets a type dispatch value from a (potentially composite) type."
[type]