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

make internals public but behind spi #184

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions swiftwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,9 @@ namespace swiftwinrt
const bool isInitializer = factory_info.has_value() && (factory_info->activatable || factory_info->composable);
const bool composableFactory = factory_info.has_value() && factory_info->composable;

const bool internal = can_mark_internal(type.type());
auto name = w.write_temp("%", type);
auto baseClass = (is_delegate(type) || !type.type().Flags().WindowsRuntime()) ? "IUnknown" : "IInspectable";
w.write("% class %: %.% {\n",
internal ? "internal" : "public",
w.write("public class %: %.% {\n",
bind_type_abi(type),
w.support,
baseClass);
Expand Down Expand Up @@ -414,7 +412,7 @@ namespace swiftwinrt
}

w.write("% func %Impl(%) throws% {\n",
internal || is_exclusive(type) ? "internal" : "open",
is_exclusive(type) ? "public" : "open",
func_name,
written_params,
returnStatement);
Expand Down Expand Up @@ -1504,7 +1502,6 @@ vtable);
auto return_type = w.write_temp("%", bind<write_delegate_return_type>(invoke_method));
constexpr bool is_generic = std::is_same_v<T, generic_inst>;
auto access_level = is_generic ? "internal" : "public";

auto handlerType = w.write_temp("%", bind<write_swift_type_identifier>(type));
auto abi_guard = w.push_abi_types(is_generic);
w.write(format,
Expand Down Expand Up @@ -2327,14 +2324,15 @@ public init<Composable: ComposableImpl>(

bool use_iinspectable_vtable = type_name(overrides) == type_name(*default_interface);

auto format = R"(internal enum % : ComposableImpl {
internal typealias CABI = %
internal typealias SwiftABI = %
internal typealias Class = %
internal typealias SwiftProjection = WinRTClassWeakReference<Class>
internal enum Default : AbiInterface {
internal typealias CABI = %
internal typealias SwiftABI = %
auto format = R"(^@_spi(WinRTInternal)
public enum % : ComposableImpl {
public typealias CABI = %
public typealias SwiftABI = %
public typealias Class = %
public typealias SwiftProjection = WinRTClassWeakReference<Class>
public enum Default : AbiInterface {
public typealias CABI = %
public typealias SwiftABI = %
}
}
)";
Expand Down Expand Up @@ -2376,9 +2374,9 @@ public init<Composable: ComposableImpl>(
}));

if (compose)
{
auto modifier = parent.is_composable() ? "open" : "public";
w.write("internal typealias Composable = %\n", composableName);
{
w.write("@_spi(WinRTInternal)\n");
w.write("public typealias Composable = %\n", composableName);
}
}

Expand Down
4 changes: 4 additions & 0 deletions swiftwinrt/file_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ namespace swiftwinrt
}
else if (force)
{
if (ns.starts_with("__"))
{
w.write("@_spi(WinRTInternal)\n");
}
w.write("%public enum % {\n", i, ns);
guard.push("}\n");
i.additional_indentation++;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_app/DoubleDelegate+QueryInterface.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ctest_component
@_spi(WinRTImplements) import test_component
@_spi(WinRTImplements) @_spi(WinRTInternal) import test_component
import Foundation

extension DoubleDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Foundation
import Ctest_component

@_spi(WinRTInternal)
public enum __ABI_Windows_Data_Text {
}
extension __x_ABI_CWindows_CData_CText_CTextSegment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
import Foundation
import Ctest_component

@_spi(WinRTInternal)
public enum __IMPL_Windows_Data_Text {
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private var IID___x_ABI_C__FITypedEventHandler_2_TSender_TResult: test_component
.init(Data1: 0x9DE1C534, Data2: 0x6AE1, Data3: 0x11E0, Data4: ( 0x84,0xE1,0x18,0xA9,0x05,0xBC,0xC5,0x3F ))// 9DE1C534-6AE1-11E0-84E1-18A905BCC53F
}

@_spi(WinRTInternal)
public enum __ABI_Windows_Foundation {
public class IAsyncAction: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIAsyncAction }
Expand Down Expand Up @@ -354,7 +355,7 @@ public enum __ABI_Windows_Foundation {
public class IDeferral: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIDeferral }

internal func CompleteImpl() throws {
public func CompleteImpl() throws {
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIDeferral.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.Complete(pThis))
}
Expand All @@ -365,7 +366,7 @@ public enum __ABI_Windows_Foundation {
public class IDeferralFactory: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIDeferralFactory }

internal func CreateImpl(_ handler: test_component.DeferralCompletedHandler?) throws -> IDeferral {
public func CreateImpl(_ handler: test_component.DeferralCompletedHandler?) throws -> IDeferral {
let (result) = try ComPtrs.initialize { resultAbi in
let handlerWrapper = __ABI_Windows_Foundation.DeferralCompletedHandlerWrapper(handler)
let _handler = try! handlerWrapper?.toABI { $0 }
Expand Down Expand Up @@ -436,7 +437,7 @@ public enum __ABI_Windows_Foundation {
public class IMemoryBufferFactory: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIMemoryBufferFactory }

internal func CreateImpl(_ capacity: UInt32) throws -> IMemoryBuffer {
public func CreateImpl(_ capacity: UInt32) throws -> IMemoryBuffer {
let (value) = try ComPtrs.initialize { valueAbi in
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIMemoryBufferFactory.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.Create(pThis, capacity, &valueAbi))
Expand Down Expand Up @@ -994,7 +995,7 @@ public enum __ABI_Windows_Foundation {
public class IUriEscapeStatics: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIUriEscapeStatics }

internal func UnescapeComponentImpl(_ toUnescape: String) throws -> String {
public func UnescapeComponentImpl(_ toUnescape: String) throws -> String {
var value: HSTRING?
let _toUnescape = try! HString(toUnescape)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriEscapeStatics.self) { pThis in
Expand All @@ -1003,7 +1004,7 @@ public enum __ABI_Windows_Foundation {
return .init(from: value)
}

internal func EscapeComponentImpl(_ toEscape: String) throws -> String {
public func EscapeComponentImpl(_ toEscape: String) throws -> String {
var value: HSTRING?
let _toEscape = try! HString(toEscape)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriEscapeStatics.self) { pThis in
Expand All @@ -1017,79 +1018,79 @@ public enum __ABI_Windows_Foundation {
public class IUriRuntimeClass: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClass }

internal func get_AbsoluteUriImpl() throws -> String {
public func get_AbsoluteUriImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_AbsoluteUri(pThis, &value))
}
return .init(from: value)
}

internal func get_DisplayUriImpl() throws -> String {
public func get_DisplayUriImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_DisplayUri(pThis, &value))
}
return .init(from: value)
}

internal func get_DomainImpl() throws -> String {
public func get_DomainImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Domain(pThis, &value))
}
return .init(from: value)
}

internal func get_ExtensionImpl() throws -> String {
public func get_ExtensionImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Extension(pThis, &value))
}
return .init(from: value)
}

internal func get_FragmentImpl() throws -> String {
public func get_FragmentImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Fragment(pThis, &value))
}
return .init(from: value)
}

internal func get_HostImpl() throws -> String {
public func get_HostImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Host(pThis, &value))
}
return .init(from: value)
}

internal func get_PasswordImpl() throws -> String {
public func get_PasswordImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Password(pThis, &value))
}
return .init(from: value)
}

internal func get_PathImpl() throws -> String {
public func get_PathImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Path(pThis, &value))
}
return .init(from: value)
}

internal func get_QueryImpl() throws -> String {
public func get_QueryImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Query(pThis, &value))
}
return .init(from: value)
}

internal func get_QueryParsedImpl() throws -> test_component.WwwFormUrlDecoder? {
public func get_QueryParsedImpl() throws -> test_component.WwwFormUrlDecoder? {
let (ppWwwFormUrlDecoder) = try ComPtrs.initialize { ppWwwFormUrlDecoderAbi in
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_QueryParsed(pThis, &ppWwwFormUrlDecoderAbi))
Expand All @@ -1098,55 +1099,55 @@ public enum __ABI_Windows_Foundation {
return .from(abi: ppWwwFormUrlDecoder)
}

internal func get_RawUriImpl() throws -> String {
public func get_RawUriImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_RawUri(pThis, &value))
}
return .init(from: value)
}

internal func get_SchemeNameImpl() throws -> String {
public func get_SchemeNameImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_SchemeName(pThis, &value))
}
return .init(from: value)
}

internal func get_UserNameImpl() throws -> String {
public func get_UserNameImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_UserName(pThis, &value))
}
return .init(from: value)
}

internal func get_PortImpl() throws -> Int32 {
public func get_PortImpl() throws -> Int32 {
var value: INT32 = 0
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Port(pThis, &value))
}
return value
}

internal func get_SuspiciousImpl() throws -> Bool {
public func get_SuspiciousImpl() throws -> Bool {
var value: boolean = 0
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_Suspicious(pThis, &value))
}
return .init(from: value)
}

internal func EqualsImpl(_ pUri: test_component.Uri?) throws -> Bool {
public func EqualsImpl(_ pUri: test_component.Uri?) throws -> Bool {
var value: boolean = 0
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.Equals(pThis, RawPointer(pUri), &value))
}
return .init(from: value)
}

internal func CombineUriImpl(_ relativeUri: String) throws -> test_component.Uri? {
public func CombineUriImpl(_ relativeUri: String) throws -> test_component.Uri? {
let (instance) = try ComPtrs.initialize { instanceAbi in
let _relativeUri = try! HString(relativeUri)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClass.self) { pThis in
Expand All @@ -1161,7 +1162,7 @@ public enum __ABI_Windows_Foundation {
public class IUriRuntimeClassFactory: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory }

internal func CreateUriImpl(_ uri: String) throws -> IUriRuntimeClass {
public func CreateUriImpl(_ uri: String) throws -> IUriRuntimeClass {
let (instance) = try ComPtrs.initialize { instanceAbi in
let _uri = try! HString(uri)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassFactory.self) { pThis in
Expand All @@ -1171,7 +1172,7 @@ public enum __ABI_Windows_Foundation {
return IUriRuntimeClass(instance!)
}

internal func CreateWithRelativeUriImpl(_ baseUri: String, _ relativeUri: String) throws -> IUriRuntimeClass {
public func CreateWithRelativeUriImpl(_ baseUri: String, _ relativeUri: String) throws -> IUriRuntimeClass {
let (instance) = try ComPtrs.initialize { instanceAbi in
let _baseUri = try! HString(baseUri)
let _relativeUri = try! HString(relativeUri)
Expand All @@ -1187,15 +1188,15 @@ public enum __ABI_Windows_Foundation {
public class IUriRuntimeClassWithAbsoluteCanonicalUri: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri }

internal func get_AbsoluteCanonicalUriImpl() throws -> String {
public func get_AbsoluteCanonicalUriImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_AbsoluteCanonicalUri(pThis, &value))
}
return .init(from: value)
}

internal func get_DisplayIriImpl() throws -> String {
public func get_DisplayIriImpl() throws -> String {
var value: HSTRING?
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIUriRuntimeClassWithAbsoluteCanonicalUri.self) { pThis in
try CHECKED(pThis.pointee.lpVtbl.pointee.get_DisplayIri(pThis, &value))
Expand Down Expand Up @@ -1273,7 +1274,7 @@ public enum __ABI_Windows_Foundation {
public class IWwwFormUrlDecoderRuntimeClass: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass }

internal func GetFirstValueByNameImpl(_ name: String) throws -> String {
public func GetFirstValueByNameImpl(_ name: String) throws -> String {
var phstrValue: HSTRING?
let _name = try! HString(name)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClass.self) { pThis in
Expand All @@ -1287,7 +1288,7 @@ public enum __ABI_Windows_Foundation {
public class IWwwFormUrlDecoderRuntimeClassFactory: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClassFactory }

internal func CreateWwwFormUrlDecoderImpl(_ query: String) throws -> IWwwFormUrlDecoderRuntimeClass {
public func CreateWwwFormUrlDecoderImpl(_ query: String) throws -> IWwwFormUrlDecoderRuntimeClass {
let (instance) = try ComPtrs.initialize { instanceAbi in
let _query = try! HString(query)
_ = try perform(as: __x_ABI_CWindows_CFoundation_CIWwwFormUrlDecoderRuntimeClassFactory.self) { pThis in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Foundation
import Ctest_component

@_spi(WinRTInternal)
public enum __IMPL_Windows_Foundation {
public enum IAsyncActionBridge : AbiInterfaceBridge {
public typealias CABI = __x_ABI_CWindows_CFoundation_CIAsyncAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private var IID___x_ABI_C__FVectorChangedEventHandler_1_T: test_component.IID {
.init(Data1: 0x0C051752, Data2: 0x9FBF, Data3: 0x4C70, Data4: ( 0xAA,0x0C,0x0E,0x4C,0x82,0xD9,0xA7,0x61 ))// 0C051752-9FBF-4C70-AA0C-0E4C82D9A761
}

@_spi(WinRTInternal)
public enum __ABI_Windows_Foundation_Collections {
public class IPropertySet: test_component.IInspectable {
override public class var IID: test_component.IID { IID___x_ABI_CWindows_CFoundation_CCollections_CIPropertySet }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Foundation
import Ctest_component

@_spi(WinRTInternal)
public enum __IMPL_Windows_Foundation_Collections {
public enum IPropertySetBridge : AbiInterfaceBridge {
public typealias CABI = __x_ABI_CWindows_CFoundation_CCollections_CIPropertySet
Expand Down
Loading
Loading