From 413d231d2917172b75088e09ae7aa2d9e97191e2 Mon Sep 17 00:00:00 2001 From: Justin Tirrell Date: Thu, 10 Oct 2024 11:56:28 -0400 Subject: [PATCH] Add support for named union members in c-layout --- src/clj/coffi/mem.clj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index 955d821..c6609a4 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -1149,7 +1149,12 @@ (defmethod c-layout ::union [[_union types & {:as _opts} :as _type]] - (let [items (map c-layout types)] + (let [items (if (map? types) + (map + (fn [[field-name field]] + (.withName ^MemoryLayout (c-layout field) (name field-name))) + types) + (map c-layout types))] (MemoryLayout/unionLayout (into-array MemoryLayout items))))