Add support for named union members in c-layout

This commit is contained in:
Justin Tirrell 2024-10-10 11:56:28 -04:00
parent 3fb34923e1
commit 413d231d29

View file

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