From 413d231d2917172b75088e09ae7aa2d9e97191e2 Mon Sep 17 00:00:00 2001 From: Justin Tirrell Date: Thu, 10 Oct 2024 11:56:28 -0400 Subject: [PATCH 1/2] 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)))) From abfe6145ba44a102d2d79bc9725e7983fd51e0ea Mon Sep 17 00:00:00 2001 From: Justin Tirrell Date: Thu, 10 Oct 2024 12:09:46 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 204cbc0..1dd71af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). ## [Unreleased] +### Added +- Add support for named union members in c-layout ## [1.0.486] - 2024-10-04 ### Fixed