Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate structs as Sendable #163

Merged
merged 1 commit into from
Apr 17, 2024
Merged

Conversation

tristanlabelle
Copy link
Contributor

@tristanlabelle tristanlabelle commented Apr 17, 2024

Structs are Sendable by definition:

Structs are always passed and returned by value. Struct fields may only be primitives, enums, structs, strings, and IReference (the latter two being the only two heap-allocated field types).
https://learn.microsoft.com/en-us/uwp/winrt-cref/winrt-type-system#structs

Not written on that doc page, but validated by midlrt is that IReference<T>'s in structs must be to value types, not to delegates, so the transitive closure of all types referenced by structs will always be sendable.

     delegate void SomeDelegate();
        struct OhNoNotInHere
        {
            Windows.Foundation.IReference<SomeDelegate> DelegateReference;
        };
test_component.idl(483) : error MIDL5105 : [msg]T in IReference<T> must be a value type when IReference is used as a struct field. [context]: test_component.SomeDelegate [ Field 'DelegateReference' of Struct 'test_component.OhNoNotInHere'  ]

Fixes #162

Copy link
Contributor

@jeffdav jeffdav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: ❤️

@tristanlabelle tristanlabelle merged commit 20db5bc into main Apr 17, 2024
1 check passed
@tristanlabelle tristanlabelle deleted the tristan/struct-Sendable branch April 17, 2024 20:27
kendalharland pushed a commit that referenced this pull request Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add @Sendable conformance to generated types.
3 participants