Skip to content

Commit

Permalink
Mark enums as Sendable
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Apr 18, 2024
1 parent 20db5bc commit 82ca079
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 33 deletions.
2 changes: 1 addition & 1 deletion swiftwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace swiftwinrt
}
w.write("}\n");

w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable {}\n\n", get_full_swift_type_name(w, type));
w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable, ^@retroactive Sendable {}\n\n", get_full_swift_type_name(w, type));
}

static void write_guid_value(writer& w, std::vector<FixedArgSig> const& args)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_component/Sources/CWinRT/include/test_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -3408,6 +3408,9 @@ struct __x_ABI_Ctest__component_CStructWithIReference
__x_ABI_C__FIVector_1_IInspectable* value,
UINT32 index,
__x_ABI_Ctest__component_CIObjectHandler* callback);
HRESULT (STDMETHODCALLTYPE* VectorAsIterable)(__x_ABI_Ctest__component_CICollectionTesterStatics* This,
__x_ABI_C__FIVector_1_HSTRING* value,
__x_ABI_C__FIIterable_1_HSTRING** result);

END_INTERFACE
} __x_ABI_Ctest__component_CICollectionTesterStaticsVtbl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,5 @@ extension test_component.CollectionChange {
CollectionChange_ItemChanged
}
}
extension test_component.CollectionChange: @retroactive Hashable, @retroactive Codable {}
extension test_component.CollectionChange: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ extension test_component.AsyncStatus {
__x_ABI_CWindows_CFoundation_CAsyncStatus_Started
}
}
extension test_component.AsyncStatus: @retroactive Hashable, @retroactive Codable {}
extension test_component.AsyncStatus: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.PropertyType {
public static var empty : test_component.PropertyType {
Expand Down Expand Up @@ -855,5 +855,5 @@ extension test_component.PropertyType {
__x_ABI_CWindows_CFoundation_CPropertyType_OtherTypeArray
}
}
extension test_component.PropertyType: @retroactive Hashable, @retroactive Codable {}
extension test_component.PropertyType: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ extension test_component.PhotoOrientation {
__x_ABI_CWindows_CStorage_CFileProperties_CPhotoOrientation_Rotate90
}
}
extension test_component.PhotoOrientation: @retroactive Hashable, @retroactive Codable {}
extension test_component.PhotoOrientation: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.PropertyPrefetchOptions {
public static var none : test_component.PropertyPrefetchOptions {
Expand All @@ -808,7 +808,7 @@ extension test_component.PropertyPrefetchOptions {
__x_ABI_CWindows_CStorage_CFileProperties_CPropertyPrefetchOptions_BasicProperties
}
}
extension test_component.PropertyPrefetchOptions: @retroactive Hashable, @retroactive Codable {}
extension test_component.PropertyPrefetchOptions: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.ThumbnailMode {
public static var picturesView : test_component.ThumbnailMode {
Expand All @@ -830,7 +830,7 @@ extension test_component.ThumbnailMode {
__x_ABI_CWindows_CStorage_CFileProperties_CThumbnailMode_SingleItem
}
}
extension test_component.ThumbnailMode: @retroactive Hashable, @retroactive Codable {}
extension test_component.ThumbnailMode: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.ThumbnailOptions {
public static var none : test_component.ThumbnailOptions {
Expand All @@ -846,7 +846,7 @@ extension test_component.ThumbnailOptions {
__x_ABI_CWindows_CStorage_CFileProperties_CThumbnailOptions_UseCurrentScale
}
}
extension test_component.ThumbnailOptions: @retroactive Hashable, @retroactive Codable {}
extension test_component.ThumbnailOptions: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.ThumbnailType {
public static var image : test_component.ThumbnailType {
Expand All @@ -856,7 +856,7 @@ extension test_component.ThumbnailType {
__x_ABI_CWindows_CStorage_CFileProperties_CThumbnailType_Icon
}
}
extension test_component.ThumbnailType: @retroactive Hashable, @retroactive Codable {}
extension test_component.ThumbnailType: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.VideoOrientation {
public static var normal : test_component.VideoOrientation {
Expand All @@ -872,5 +872,5 @@ extension test_component.VideoOrientation {
__x_ABI_CWindows_CStorage_CFileProperties_CVideoOrientation_Rotate270
}
}
extension test_component.VideoOrientation: @retroactive Hashable, @retroactive Codable {}
extension test_component.VideoOrientation: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ extension test_component.CommonFileQuery {
__x_ABI_CWindows_CStorage_CSearch_CCommonFileQuery_OrderByDate
}
}
extension test_component.CommonFileQuery: @retroactive Hashable, @retroactive Codable {}
extension test_component.CommonFileQuery: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.CommonFolderQuery {
public static var defaultQuery : test_component.CommonFolderQuery {
Expand Down Expand Up @@ -586,7 +586,7 @@ extension test_component.CommonFolderQuery {
__x_ABI_CWindows_CStorage_CSearch_CCommonFolderQuery_GroupByType
}
}
extension test_component.CommonFolderQuery: @retroactive Hashable, @retroactive Codable {}
extension test_component.CommonFolderQuery: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.DateStackOption {
public static var none : test_component.DateStackOption {
Expand All @@ -599,7 +599,7 @@ extension test_component.DateStackOption {
__x_ABI_CWindows_CStorage_CSearch_CDateStackOption_Month
}
}
extension test_component.DateStackOption: @retroactive Hashable, @retroactive Codable {}
extension test_component.DateStackOption: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.FolderDepth {
public static var shallow : test_component.FolderDepth {
Expand All @@ -609,7 +609,7 @@ extension test_component.FolderDepth {
__x_ABI_CWindows_CStorage_CSearch_CFolderDepth_Deep
}
}
extension test_component.FolderDepth: @retroactive Hashable, @retroactive Codable {}
extension test_component.FolderDepth: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.IndexedState {
public static var unknown : test_component.IndexedState {
Expand All @@ -625,7 +625,7 @@ extension test_component.IndexedState {
__x_ABI_CWindows_CStorage_CSearch_CIndexedState_FullyIndexed
}
}
extension test_component.IndexedState: @retroactive Hashable, @retroactive Codable {}
extension test_component.IndexedState: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.IndexerOption {
public static var useIndexerWhenAvailable : test_component.IndexerOption {
Expand All @@ -641,5 +641,5 @@ extension test_component.IndexerOption {
__x_ABI_CWindows_CStorage_CSearch_CIndexerOption_OnlyUseIndexerAndOptimizeForIndexedProperties
}
}
extension test_component.IndexerOption: @retroactive Hashable, @retroactive Codable {}
extension test_component.IndexerOption: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ extension test_component.InputStreamOptions {
__x_ABI_CWindows_CStorage_CStreams_CInputStreamOptions_ReadAhead
}
}
extension test_component.InputStreamOptions: @retroactive Hashable, @retroactive Codable {}
extension test_component.InputStreamOptions: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.UnicodeEncoding {
public static var utf8 : test_component.UnicodeEncoding {
Expand All @@ -297,5 +297,5 @@ extension test_component.UnicodeEncoding {
__x_ABI_CWindows_CStorage_CStreams_CUnicodeEncoding_Utf16BE
}
}
extension test_component.UnicodeEncoding: @retroactive Hashable, @retroactive Codable {}
extension test_component.UnicodeEncoding: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ extension test_component.CreationCollisionOption {
__x_ABI_CWindows_CStorage_CCreationCollisionOption_OpenIfExists
}
}
extension test_component.CreationCollisionOption: @retroactive Hashable, @retroactive Codable {}
extension test_component.CreationCollisionOption: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.FileAccessMode {
public static var read : test_component.FileAccessMode {
Expand All @@ -1301,7 +1301,7 @@ extension test_component.FileAccessMode {
__x_ABI_CWindows_CStorage_CFileAccessMode_ReadWrite
}
}
extension test_component.FileAccessMode: @retroactive Hashable, @retroactive Codable {}
extension test_component.FileAccessMode: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.FileAttributes {
public static var normal : test_component.FileAttributes {
Expand All @@ -1323,7 +1323,7 @@ extension test_component.FileAttributes {
__x_ABI_CWindows_CStorage_CFileAttributes_LocallyIncomplete
}
}
extension test_component.FileAttributes: @retroactive Hashable, @retroactive Codable {}
extension test_component.FileAttributes: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.NameCollisionOption {
public static var generateUniqueName : test_component.NameCollisionOption {
Expand All @@ -1336,7 +1336,7 @@ extension test_component.NameCollisionOption {
__x_ABI_CWindows_CStorage_CNameCollisionOption_FailIfExists
}
}
extension test_component.NameCollisionOption: @retroactive Hashable, @retroactive Codable {}
extension test_component.NameCollisionOption: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.StorageDeleteOption {
public static var `default` : test_component.StorageDeleteOption {
Expand All @@ -1346,7 +1346,7 @@ extension test_component.StorageDeleteOption {
__x_ABI_CWindows_CStorage_CStorageDeleteOption_PermanentDelete
}
}
extension test_component.StorageDeleteOption: @retroactive Hashable, @retroactive Codable {}
extension test_component.StorageDeleteOption: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.StorageItemTypes {
public static var none : test_component.StorageItemTypes {
Expand All @@ -1359,7 +1359,7 @@ extension test_component.StorageItemTypes {
__x_ABI_CWindows_CStorage_CStorageItemTypes_Folder
}
}
extension test_component.StorageItemTypes: @retroactive Hashable, @retroactive Codable {}
extension test_component.StorageItemTypes: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.StorageLibraryChangeType {
public static var created : test_component.StorageLibraryChangeType {
Expand Down Expand Up @@ -1393,7 +1393,7 @@ extension test_component.StorageLibraryChangeType {
__x_ABI_CWindows_CStorage_CStorageLibraryChangeType_ChangeTrackingLost
}
}
extension test_component.StorageLibraryChangeType: @retroactive Hashable, @retroactive Codable {}
extension test_component.StorageLibraryChangeType: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.StorageOpenOptions {
public static var none : test_component.StorageOpenOptions {
Expand All @@ -1406,7 +1406,7 @@ extension test_component.StorageOpenOptions {
__x_ABI_CWindows_CStorage_CStorageOpenOptions_AllowReadersAndWriters
}
}
extension test_component.StorageOpenOptions: @retroactive Hashable, @retroactive Codable {}
extension test_component.StorageOpenOptions: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.StreamedFileFailureMode {
public static var failed : test_component.StreamedFileFailureMode {
Expand All @@ -1419,5 +1419,5 @@ extension test_component.StreamedFileFailureMode {
__x_ABI_CWindows_CStorage_CStreamedFileFailureMode_Incomplete
}
}
extension test_component.StreamedFileFailureMode: @retroactive Hashable, @retroactive Codable {}
extension test_component.StreamedFileFailureMode: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private var IID___x_ABI_Ctest__component_CICollectionTester: test_component.IID
}

private var IID___x_ABI_Ctest__component_CICollectionTesterStatics: test_component.IID {
.init(Data1: 0xB357268D, Data2: 0x1A80, Data3: 0x5A61, Data4: ( 0xB3,0xEF,0x13,0x22,0x4B,0xE0,0x63,0x10 ))// B357268D-1A80-5A61-B3EF-13224BE06310
.init(Data1: 0xA4C0D4B5, Data2: 0xEDA2, Data3: 0x55E5, Data4: ( 0xAD,0x0F,0xCE,0x1F,0x13,0xA9,0x81,0xCC ))// A4C0D4B5-EDA2-55E5-AD0F-CE1F13A981CC
}

private var IID___x_ABI_Ctest__component_CIDeferrableEventArgs: test_component.IID {
Expand Down Expand Up @@ -1086,6 +1086,17 @@ public enum __ABI_test_component {
}
}

internal func VectorAsIterableImpl(_ value: test_component.AnyIVector<String>?) throws -> test_component.AnyIIterable<String>? {
let (result) = try ComPtrs.initialize { resultAbi in
let valueWrapper = test_component.__x_ABI_C__FIVector_1_HSTRINGWrapper(value)
let _value = try! valueWrapper?.toABI { $0 }
_ = try perform(as: __x_ABI_Ctest__component_CICollectionTesterStatics.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.VectorAsIterable(pThis, _value, &resultAbi))
}
}
return test_component.__x_ABI_C__FIIterable_1_HSTRINGWrapper.unwrapFrom(abi: result)
}

}

public class IDeferrableEventArgs: test_component.IInspectable {
Expand Down
14 changes: 9 additions & 5 deletions tests/test_component/Sources/test_component/test_component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ public final class CollectionTester : WinRTClass {
try _ICollectionTesterStatics.GetObjectAtImpl(value, index, callback)
}

public static func vectorAsIterable(_ value: AnyIVector<String>!) throws -> AnyIIterable<String>! {
return try _ICollectionTesterStatics.VectorAsIterableImpl(value)
}

public func returnStoredStringVector() throws -> AnyIVector<String>! {
try _default.ReturnStoredStringVectorImpl()
}
Expand Down Expand Up @@ -1978,7 +1982,7 @@ extension test_component.Fruit {
__x_ABI_Ctest__component_CFruit_Pineapple
}
}
extension test_component.Fruit: @retroactive Hashable, @retroactive Codable {}
extension test_component.Fruit: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.Keywords {
public static var `as` : test_component.Keywords {
Expand Down Expand Up @@ -2108,7 +2112,7 @@ extension test_component.Keywords {
__x_ABI_Ctest__component_CKeywords_While
}
}
extension test_component.Keywords: @retroactive Hashable, @retroactive Codable {}
extension test_component.Keywords: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.Signed {
public static var first : test_component.Signed {
Expand All @@ -2121,7 +2125,7 @@ extension test_component.Signed {
__x_ABI_Ctest__component_CSigned_Third
}
}
extension test_component.Signed: @retroactive Hashable, @retroactive Codable {}
extension test_component.Signed: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.SwiftifiableNames {
public static var camelCase : test_component.SwiftifiableNames {
Expand All @@ -2143,7 +2147,7 @@ extension test_component.SwiftifiableNames {
__x_ABI_Ctest__component_CSwiftifiableNames_UUID
}
}
extension test_component.SwiftifiableNames: @retroactive Hashable, @retroactive Codable {}
extension test_component.SwiftifiableNames: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

extension test_component.Unsigned {
public static var first : test_component.Unsigned {
Expand All @@ -2156,5 +2160,5 @@ extension test_component.Unsigned {
__x_ABI_Ctest__component_CUnsigned_Third
}
}
extension test_component.Unsigned: @retroactive Hashable, @retroactive Codable {}
extension test_component.Unsigned: @retroactive Hashable, @retroactive Codable, @retroactive Sendable {}

0 comments on commit 82ca079

Please sign in to comment.