From faca63b50c2d4bbe4c937103f0ec9d1f027844fb Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Tue, 18 Jan 2022 13:25:56 -0600 Subject: [PATCH] Add constants for byte orders --- src/clj/coffi/mem.clj | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index e647268..a2a20c1 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -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]