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 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))))