Skip to content

Commit

Permalink
remove makefromabi file
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbrix committed Jan 24, 2025
1 parent 1ffd224 commit 1adf5a2
Show file tree
Hide file tree
Showing 12 changed files with 672 additions and 691 deletions.
2 changes: 1 addition & 1 deletion swiftwinrt/Resources/Support/MakeFromAbi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Foundation
// simples than we want
public protocol MakeFromAbi {
associatedtype SwiftType
static func from(abi: SUPPORT_MODULE.IInspectable) -> SwiftType?
static func from(abi: SUPPORT_MODULE.IInspectable) -> SwiftType
}

func make(typeName: SwiftTypeName, from abi: SUPPORT_MODULE.IInspectable) -> Any? {
Expand Down
4 changes: 2 additions & 2 deletions swiftwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ bind_bridge_fullname(type));
{
fromAbi = w.write_temp("let swiftAbi: %.% = try! abi.QueryInterface()\n", abi_namespace(type),
type.swift_type_name());
fromAbi += w.write_temp(" return %.from(abi: RawPointer(swiftAbi))", bind_bridge_fullname(type));
fromAbi += w.write_temp(" return %.from(abi: RawPointer(swiftAbi))!", bind_bridge_fullname(type));
swiftType = w.write_temp("%", bind<write_swift_interface_existential_identifier>(type));
}
else if (is_class(&type))
Expand All @@ -1229,7 +1229,7 @@ bind_bridge_fullname(type));
w.write(R"(^@_spi(WinRTInternal)
public class %Maker: MakeFromAbi {
public typealias SwiftType = %
public static func from(abi: %.IInspectable) -> SwiftType? {
public static func from(abi: %.IInspectable) -> SwiftType {
%
}
}
Expand Down
21 changes: 4 additions & 17 deletions swiftwinrt/file_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ namespace swiftwinrt

w.write("%", w.filter.bind_each<write_struct_bridgeable>(members.structs));

// MakeFromAbi has to be in impl file (or main file) otherwise they get stripped away
w.write("%", w.filter.bind_each<write_make_from_abi>(members.interfaces));
w.write("%", w.filter.bind_each<write_make_from_abi>(members.classes));

w.swap();
write_preamble(w, /* swift_code: */ true);

Expand Down Expand Up @@ -274,21 +278,4 @@ namespace swiftwinrt
write_preamble(w, /* swift_code: */ true);
w.save_file("Generics");
}

static void write_module_make_from_abi(std::string_view const& module, type_cache const& members, include_only_used_filter const& filter)
{
writer w;
w.filter = filter;
w.support = settings.support;
w.c_mod = settings.get_c_module_name();
w.type_namespace = module;
w.swift_module = module;
w.cache = members.cache;
w.write("%", w.filter.bind_each<write_make_from_abi>(members.interfaces));
w.write("%", w.filter.bind_each<write_make_from_abi>(members.classes));

w.swap();
write_preamble(w, /* swift_code: */ true);
w.save_file("MakeFromAbi");
}
}
1 change: 0 additions & 1 deletion swiftwinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ Where <spec> is one or more of:
// amount of code that is generated.
auto types = mdCache.compile_namespaces(namespaces, mf);
write_module_generics(module, types, mf);
write_module_make_from_abi(module, types, mf);
});

if (module == settings.support)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,87 @@ extension TimeSpan: WinRTBridgeable {
}
}

@_spi(WinRTInternal)
public class IAsyncActionMaker: MakeFromAbi {
public typealias SwiftType = AnyIAsyncAction
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IAsyncAction = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IAsyncActionBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IAsyncInfoMaker: MakeFromAbi {
public typealias SwiftType = AnyIAsyncInfo
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IAsyncInfo = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IAsyncInfoBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IClosableMaker: MakeFromAbi {
public typealias SwiftType = AnyIClosable
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IClosable = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IClosableBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IMemoryBufferMaker: MakeFromAbi {
public typealias SwiftType = AnyIMemoryBuffer
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IMemoryBuffer = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IMemoryBufferBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IMemoryBufferReferenceMaker: MakeFromAbi {
public typealias SwiftType = AnyIMemoryBufferReference
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IMemoryBufferReference = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IMemoryBufferReferenceBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStringableMaker: MakeFromAbi {
public typealias SwiftType = AnyIStringable
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IStringable = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IStringableBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IWwwFormUrlDecoderEntryMaker: MakeFromAbi {
public typealias SwiftType = AnyIWwwFormUrlDecoderEntry
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation.IWwwFormUrlDecoderEntry = try! abi.QueryInterface()
return __IMPL_Windows_Foundation.IWwwFormUrlDecoderEntryBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class DeferralMaker: MakeFromAbi {
public typealias SwiftType = Deferral
public static func from(abi: test_component.IInspectable) -> SwiftType {
return Deferral(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class MemoryBufferMaker: MakeFromAbi {
public typealias SwiftType = MemoryBuffer
public static func from(abi: test_component.IInspectable) -> SwiftType {
return MemoryBuffer(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class UriMaker: MakeFromAbi {
public typealias SwiftType = Uri
public static func from(abi: test_component.IInspectable) -> SwiftType {
return Uri(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class WwwFormUrlDecoderMaker: MakeFromAbi {
public typealias SwiftType = WwwFormUrlDecoder
public static func from(abi: test_component.IInspectable) -> SwiftType {
return WwwFormUrlDecoder(fromAbi: abi)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,40 @@ public enum __IMPL_Windows_Foundation_Collections {
}

}
@_spi(WinRTInternal)
public class IPropertySetMaker: MakeFromAbi {
public typealias SwiftType = AnyIPropertySet
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation_Collections.IPropertySet = try! abi.QueryInterface()
return __IMPL_Windows_Foundation_Collections.IPropertySetBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IVectorChangedEventArgsMaker: MakeFromAbi {
public typealias SwiftType = AnyIVectorChangedEventArgs
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Foundation_Collections.IVectorChangedEventArgs = try! abi.QueryInterface()
return __IMPL_Windows_Foundation_Collections.IVectorChangedEventArgsBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class PropertySetMaker: MakeFromAbi {
public typealias SwiftType = PropertySet
public static func from(abi: test_component.IInspectable) -> SwiftType {
return PropertySet(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StringMapMaker: MakeFromAbi {
public typealias SwiftType = StringMap
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StringMap(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class ValueSetMaker: MakeFromAbi {
public typealias SwiftType = ValueSet
public static func from(abi: test_component.IInspectable) -> SwiftType {
return ValueSet(fromAbi: abi)
}
}
144 changes: 144 additions & 0 deletions tests/test_component/Sources/test_component/Windows.Storage+Impl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,147 @@ public enum __IMPL_Windows_Storage {
}

}
@_spi(WinRTInternal)
public class IStorageFileMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageFile
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageFile = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageFileBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageFile2Maker: MakeFromAbi {
public typealias SwiftType = AnyIStorageFile2
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageFile2 = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageFile2Bridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageFilePropertiesWithAvailabilityMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageFilePropertiesWithAvailability
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageFilePropertiesWithAvailability = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageFilePropertiesWithAvailabilityBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageFolderMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageFolder
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageFolder = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageFolderBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageFolder2Maker: MakeFromAbi {
public typealias SwiftType = AnyIStorageFolder2
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageFolder2 = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageFolder2Bridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageItemMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageItem
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageItem = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageItemBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageItem2Maker: MakeFromAbi {
public typealias SwiftType = AnyIStorageItem2
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageItem2 = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageItem2Bridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageItemPropertiesMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageItemProperties
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageItemProperties = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageItemPropertiesBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageItemProperties2Maker: MakeFromAbi {
public typealias SwiftType = AnyIStorageItemProperties2
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageItemProperties2 = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageItemProperties2Bridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStorageItemPropertiesWithProviderMaker: MakeFromAbi {
public typealias SwiftType = AnyIStorageItemPropertiesWithProvider
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStorageItemPropertiesWithProvider = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStorageItemPropertiesWithProviderBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class IStreamedFileDataRequestMaker: MakeFromAbi {
public typealias SwiftType = AnyIStreamedFileDataRequest
public static func from(abi: test_component.IInspectable) -> SwiftType {
let swiftAbi: __ABI_Windows_Storage.IStreamedFileDataRequest = try! abi.QueryInterface()
return __IMPL_Windows_Storage.IStreamedFileDataRequestBridge.from(abi: RawPointer(swiftAbi))!
}
}
@_spi(WinRTInternal)
public class StorageFileMaker: MakeFromAbi {
public typealias SwiftType = StorageFile
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageFile(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageFolderMaker: MakeFromAbi {
public typealias SwiftType = StorageFolder
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageFolder(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageLibraryChangeMaker: MakeFromAbi {
public typealias SwiftType = StorageLibraryChange
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageLibraryChange(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageLibraryChangeReaderMaker: MakeFromAbi {
public typealias SwiftType = StorageLibraryChangeReader
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageLibraryChangeReader(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageLibraryChangeTrackerMaker: MakeFromAbi {
public typealias SwiftType = StorageLibraryChangeTracker
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageLibraryChangeTracker(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageProviderMaker: MakeFromAbi {
public typealias SwiftType = StorageProvider
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageProvider(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StorageStreamTransactionMaker: MakeFromAbi {
public typealias SwiftType = StorageStreamTransaction
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StorageStreamTransaction(fromAbi: abi)
}
}
@_spi(WinRTInternal)
public class StreamedFileDataRequestMaker: MakeFromAbi {
public typealias SwiftType = StreamedFileDataRequest
public static func from(abi: test_component.IInspectable) -> SwiftType {
return StreamedFileDataRequest(fromAbi: abi)
}
}
Loading

0 comments on commit 1adf5a2

Please sign in to comment.