Merge pull request #13 from jjttjj/develop

Support named union members in c-layout
This commit is contained in:
Joshua Suskalo 2024-10-10 16:14:46 -05:00 committed by GitHub
commit bb4dc5d389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -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/). 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] ## [Unreleased]
### Added
- Add support for named union members in c-layout
## [1.0.486] - 2024-10-04 ## [1.0.486] - 2024-10-04
### Fixed ### Fixed

View file

@ -1149,7 +1149,12 @@
(defmethod c-layout ::union (defmethod c-layout ::union
[[_union types & {:as _opts} :as _type]] [[_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 (MemoryLayout/unionLayout
(into-array MemoryLayout items)))) (into-array MemoryLayout items))))