From 7c62207613af099d75e6f79b9f71468b3b36fe9f Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Tue, 18 Jan 2022 14:15:18 -0600 Subject: [PATCH] Allow non-native byte orders on primitives --- src/clj/coffi/mem.clj | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index 5ac5b6f..868d41a 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -604,32 +604,44 @@ byte-layout) (defmethod c-layout ::short - [_type] - short-layout) + [type] + (if (sequential? type) + (.withOrder short-layout (second type)) + short-layout)) (defmethod c-layout ::int - [_type] - int-layout) + [type] + (if (sequential? type) + (.withOrder int-layout (second type)) + int-layout)) (defmethod c-layout ::long - [_type] - long-layout) + [type] + (if (sequential? type) + (.withOrder long-layout (second type)) + long-layout)) (defmethod c-layout ::long-long - [_type] - long-long-layout) + [type] + (if (sequential? type) + (.withOrder long-long-layout (second type)) + long-long-layout)) (defmethod c-layout ::char [_type] char-layout) (defmethod c-layout ::float - [_type] - float-layout) + [type] + (if (sequential? type) + (.withOrder float-layout (second type)) + float-layout)) (defmethod c-layout ::double - [_type] - double-layout) + [type] + (if (sequential? type) + (.withOrder double-layout (second type)) + double-layout)) (defmethod c-layout ::pointer [_type]