Skip to content

Commit

Permalink
add more depends
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbrix committed Jan 23, 2024
1 parent 225d6c5 commit 2b57859
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
6 changes: 4 additions & 2 deletions swiftwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ bind_bridge_fullname(type));
static std::string modifier_for(typedef_base const& type_definition, interface_info const& iface, member_type member_type = member_type::property_or_method);
static void write_interface_impl_members(writer& w, interface_info const& info, typedef_base const& type_definition)
{
w.add_depends(type_definition);
bool is_class = swiftwinrt::is_class(&type_definition);

if (!info.is_default || (!is_class && info.base))
Expand Down Expand Up @@ -2056,7 +2057,8 @@ public init<Composable: ComposableImpl>(
static std::string modifier_for(typedef_base const& type_definition, interface_info const& iface, member_type member)
{
std::string modifier;
const bool isClass = is_class(&type_definition);
auto classType = dynamic_cast<const class_type*>(&type_definition);
const bool isClass = classType != nullptr;
if (isClass)
{
if (iface.overridable)
Expand All @@ -2073,7 +2075,7 @@ public init<Composable: ComposableImpl>(
modifier = "fileprivate ";
}

if (iface.attributed && isClass && member == member_type::property_or_method)
if (iface.attributed && isClass && classType->is_composable() && member == member_type::property_or_method)
{
modifier.append("class ");
}
Expand Down
60 changes: 30 additions & 30 deletions tests/test_component/Sources/test_component/test_component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public typealias SwiftifiableNames = __x_ABI_Ctest__component_CSwiftifiableNames
public typealias Unsigned = __x_ABI_Ctest__component_CUnsigned
public final class AsyncMethods {
private static let _IAsyncMethodsStatics: __ABI_test_component.IAsyncMethodsStatics = try! RoGetActivationFactory(HString("test_component.AsyncMethods"))
public class func getCompletedAsync(_ result: Int32) -> AnyIAsyncOperation<Int32>! {
public static func getCompletedAsync(_ result: Int32) -> AnyIAsyncOperation<Int32>! {
return try! _IAsyncMethodsStatics.GetCompletedAsyncImpl(result)
}

public class func getCompletedWithErrorAsync(_ errorCode: HRESULT) -> AnyIAsyncOperation<Int32>! {
public static func getCompletedWithErrorAsync(_ errorCode: HRESULT) -> AnyIAsyncOperation<Int32>! {
return try! _IAsyncMethodsStatics.GetCompletedWithErrorAsyncImpl(errorCode)
}

public class func getPendingAsync() -> AsyncOperationInt! {
public static func getPendingAsync() -> AsyncOperationInt! {
return try! _IAsyncMethodsStatics.GetPendingAsyncImpl()
}

Expand Down Expand Up @@ -629,28 +629,28 @@ public final class Class : WinRTClass, IBasic {
}

private static let _IClassStatics: __ABI_test_component.IClassStatics = try! RoGetActivationFactory(HString("test_component.Class"))
public class func staticTest() {
public static func staticTest() {
try! _IClassStatics.StaticTestImpl()
}

public class func staticTestReturn() -> Int32 {
public static func staticTestReturn() -> Int32 {
return try! _IClassStatics.StaticTestReturnImpl()
}

public class func takeBaseAndGiveToCallbackAsObject(_ base: Base!, _ callback: test_component.InObjectDelegate!) {
public static func takeBaseAndGiveToCallbackAsObject(_ base: Base!, _ callback: test_component.InObjectDelegate!) {
try! _IClassStatics.TakeBaseAndGiveToCallbackAsObjectImpl(base, callback)
}

public class var staticProperty : Int32 {
public static var staticProperty : Int32 {
get { try! _IClassStatics.get_StaticPropertyImpl() }
}

private static let _IClassStatics2: __ABI_test_component.IClassStatics2 = try! RoGetActivationFactory(HString("test_component.Class"))
public class func staticTestReturnFloat() -> Float {
public static func staticTestReturnFloat() -> Float {
return try! _IClassStatics2.StaticTestReturnFloatImpl()
}

public class var staticPropertyFloat : Float {
public static var staticPropertyFloat : Float {
get { try! _IClassStatics2.get_StaticPropertyFloatImpl() }
set { try! _IClassStatics2.put_StaticPropertyFloatImpl(newValue) }
}
Expand Down Expand Up @@ -832,23 +832,23 @@ public final class CollectionTester : WinRTClass {
}

private static let _ICollectionTesterStatics: __ABI_test_component.ICollectionTesterStatics = try! RoGetActivationFactory(HString("test_component.CollectionTester"))
public class func inMap(_ value: AnyIMap<String, String>!) -> String {
public static func inMap(_ value: AnyIMap<String, String>!) -> String {
return try! _ICollectionTesterStatics.InMapImpl(value)
}

public class func inMapView(_ value: AnyIMapView<String, String>!) -> String {
public static func inMapView(_ value: AnyIMapView<String, String>!) -> String {
return try! _ICollectionTesterStatics.InMapViewImpl(value)
}

public class func inVector(_ value: AnyIVector<String>!) -> String {
public static func inVector(_ value: AnyIVector<String>!) -> String {
return try! _ICollectionTesterStatics.InVectorImpl(value)
}

public class func inVectorView(_ value: AnyIVectorView<String>!) -> String {
public static func inVectorView(_ value: AnyIVectorView<String>!) -> String {
return try! _ICollectionTesterStatics.InVectorViewImpl(value)
}

public class func getObjectAt(_ value: AnyIVector<Any?>!, _ index: UInt32, _ callback: ObjectHandler!) {
public static func getObjectAt(_ value: AnyIVector<Any?>!, _ index: UInt32, _ callback: ObjectHandler!) {
try! _ICollectionTesterStatics.GetObjectAtImpl(value, index, callback)
}

Expand Down Expand Up @@ -929,7 +929,7 @@ public final class Derived : test_component.Base {
}

private static let _IDerivedStatics: __ABI_test_component.IDerivedStatics = try! RoGetActivationFactory(HString("test_component.Derived"))
override public class func createFromString(_ value: String) -> Derived! {
override public static func createFromString(_ value: String) -> Derived! {
return try! _IDerivedStatics.CreateFromStringImpl(value)
}

Expand Down Expand Up @@ -1087,43 +1087,43 @@ public final class NoopClosable : WinRTClass, test_component.IClosable {

public final class NullValues {
private static let _INullValuesStatics: __ABI_test_component.INullValuesStatics = try! RoGetActivationFactory(HString("test_component.NullValues"))
public class func isObjectNull(_ value: Any!) -> Bool {
public static func isObjectNull(_ value: Any!) -> Bool {
return try! _INullValuesStatics.IsObjectNullImpl(value)
}

public class func isInterfaceNull(_ value: test_component.AnyIClosable!) -> Bool {
public static func isInterfaceNull(_ value: test_component.AnyIClosable!) -> Bool {
return try! _INullValuesStatics.IsInterfaceNullImpl(value)
}

public class func isGenericInterfaceNull(_ value: AnyIVector<String>!) -> Bool {
public static func isGenericInterfaceNull(_ value: AnyIVector<String>!) -> Bool {
return try! _INullValuesStatics.IsGenericInterfaceNullImpl(value)
}

public class func isClassNull(_ value: NoopClosable!) -> Bool {
public static func isClassNull(_ value: NoopClosable!) -> Bool {
return try! _INullValuesStatics.IsClassNullImpl(value)
}

public class func isDelegateNull(_ value: VoidToVoidDelegate!) -> Bool {
public static func isDelegateNull(_ value: VoidToVoidDelegate!) -> Bool {
return try! _INullValuesStatics.IsDelegateNullImpl(value)
}

public class func getNullObject() -> Any! {
public static func getNullObject() -> Any! {
return try! _INullValuesStatics.GetNullObjectImpl()
}

public class func getNullInterface() -> test_component.AnyIClosable! {
public static func getNullInterface() -> test_component.AnyIClosable! {
return try! _INullValuesStatics.GetNullInterfaceImpl()
}

public class func getNullGenericInterface() -> AnyIVector<String>! {
public static func getNullGenericInterface() -> AnyIVector<String>! {
return try! _INullValuesStatics.GetNullGenericInterfaceImpl()
}

public class func getNullClass() -> NoopClosable! {
public static func getNullClass() -> NoopClosable! {
return try! _INullValuesStatics.GetNullClassImpl()
}

public class func getNullDelegate() -> VoidToVoidDelegate! {
public static func getNullDelegate() -> VoidToVoidDelegate! {
return try! _INullValuesStatics.GetNullDelegateImpl()
}

Expand Down Expand Up @@ -1157,7 +1157,7 @@ public final class Simple : WinRTClass {
}

private static let _ISimpleStatics: __ABI_test_component.ISimpleStatics = try! RoGetActivationFactory(HString("test_component.Simple"))
public class func fireStaticEvent() {
public static func fireStaticEvent() {
try! _ISimpleStatics.FireStaticEventImpl()
}

Expand Down Expand Up @@ -1275,19 +1275,19 @@ public final class Simple : WinRTClass {

public final class StaticClass {
private static let _IStaticClassStatics: __ABI_test_component.IStaticClassStatics = try! RoGetActivationFactory(HString("test_component.StaticClass"))
public class func inEnum(_ value: Signed) -> String {
public static func inEnum(_ value: Signed) -> String {
return try! _IStaticClassStatics.InEnumImpl(value)
}

public class func inNonBlittableStruct(_ value: NonBlittableStruct) -> String {
public static func inNonBlittableStruct(_ value: NonBlittableStruct) -> String {
return try! _IStaticClassStatics.InNonBlittableStructImpl(value)
}

public class func takeBase(_ base: Base!) {
public static func takeBase(_ base: Base!) {
try! _IStaticClassStatics.TakeBaseImpl(base)
}

public class var enumProperty : Fruit {
public static var enumProperty : Fruit {
get { try! _IStaticClassStatics.get_EnumPropertyImpl() }
set { try! _IStaticClassStatics.put_EnumPropertyImpl(newValue) }
}
Expand Down

0 comments on commit 2b57859

Please sign in to comment.