Skip to content

Commit d70af94

Browse files
committed
Fix Swift bridge
1 parent 77ea6e2 commit d70af94

File tree

4 files changed

+98
-77
lines changed

4 files changed

+98
-77
lines changed

ClassDumpRuntime/Models/CDGenerationOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#import <Foundation/Foundation.h>
1010

1111
NS_HEADER_AUDIT_BEGIN(nullability)
12-
1312
/// Options with which a header file may be generated with
13+
NS_REFINED_FOR_SWIFT
1414
@interface CDGenerationOptions : NSObject <NSCopying>
1515
/// @c YES means hide properties and methods that are required by a protocol the type conforms to
1616
///

ClassDumpRuntime/Models/Reflections/CDClassModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NS_HEADER_AUDIT_BEGIN(nullability)
4949
- (CDSemanticString *)semanticLinesWithComments:(BOOL)comments synthesizeStrip:(BOOL)synthesizeStrip;
5050

5151
/// Generate an @c interface for the class
52-
- (CDSemanticString *)semanticLinesWithOptions:(CDGenerationOptions *)options;
52+
- (CDSemanticString *)semanticLinesWithOptions:(CDGenerationOptions *)options NS_REFINED_FOR_SWIFT;
5353

5454
/// Classes the class references in the declaration
5555
///

ClassDumpRuntime/Models/Reflections/CDProtocolModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NS_HEADER_AUDIT_BEGIN(nullability)
4949
- (CDSemanticString *)semanticLinesWithComments:(BOOL)comments synthesizeStrip:(BOOL)synthesizeStrip;
5050

5151
/// Generate an @c interface for the protocol
52-
- (CDSemanticString *)semanticLinesWithOptions:(CDGenerationOptions *)options;
52+
- (CDSemanticString *)semanticLinesWithOptions:(CDGenerationOptions *)options NS_REFINED_FOR_SWIFT;
5353

5454
/// Classes the protocol references in the declaration
5555
///
Lines changed: 95 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,98 @@
11
import Foundation
22
import ClassDumpRuntime
33

4-
//public struct CDGenerationOptions: Codable, Hashable, Identifiable {
5-
// public var stripProtocolConformance: Bool
6-
// public var stripOverrides: Bool
7-
// public var stripDuplicates: Bool
8-
// public var stripSynthesized: Bool
9-
// public var stripCtorMethod: Bool
10-
// public var stripDtorMethod: Bool
11-
// public var addSymbolImageComments: Bool
12-
// public var id: Self { self }
13-
//
14-
// public init(stripProtocolConformance: Bool = false, stripOverrides: Bool = false, stripDuplicates: Bool = false, stripSynthesized: Bool = false, stripCtorMethod: Bool = false, stripDtorMethod: Bool = false, addSymbolImageComments: Bool = false) {
15-
// self.stripProtocolConformance = stripProtocolConformance
16-
// self.stripOverrides = stripOverrides
17-
// self.stripDuplicates = stripDuplicates
18-
// self.stripSynthesized = stripSynthesized
19-
// self.stripCtorMethod = stripCtorMethod
20-
// self.stripDtorMethod = stripDtorMethod
21-
// self.addSymbolImageComments = addSymbolImageComments
22-
// }
23-
//
24-
//}
25-
//
26-
//extension CDGenerationOptions: ReferenceConvertible {
27-
// public typealias ReferenceType = __CDGenerationOptions
28-
//
29-
// public func _bridgeToObjectiveC() -> __CDGenerationOptions {
30-
// let options = __CDGenerationOptions()
31-
// options.stripProtocolConformance = stripProtocolConformance
32-
// options.stripOverrides = stripOverrides
33-
// options.stripSynthesized = stripSynthesized
34-
// options.stripCtorMethod = stripCtorMethod
35-
// options.stripDtorMethod = stripDtorMethod
36-
// options.addSymbolImageComments = addSymbolImageComments
37-
// return options
38-
// }
39-
//
40-
// public static func _forceBridgeFromObjectiveC(_ source: __CDGenerationOptions, result: inout CDGenerationOptions?) {
41-
// result = CDGenerationOptions(stripProtocolConformance: source.stripProtocolConformance, stripOverrides: source.stripOverrides, stripDuplicates: source.stripDuplicates, stripSynthesized: source.stripSynthesized, stripCtorMethod: source.stripCtorMethod, stripDtorMethod: source.stripDtorMethod, addSymbolImageComments: source.addSymbolImageComments)
42-
// }
43-
//
44-
// public static func _conditionallyBridgeFromObjectiveC(_ source: __CDGenerationOptions, result: inout CDGenerationOptions?) -> Bool {
45-
// _forceBridgeFromObjectiveC(source, result: &result)
46-
// return true
47-
// }
48-
//
49-
// public static func _unconditionallyBridgeFromObjectiveC(_ source: __CDGenerationOptions?) -> CDGenerationOptions {
50-
// if let source = source {
51-
// var result: CDGenerationOptions?
52-
// _forceBridgeFromObjectiveC(source, result: &result)
53-
// return result!
54-
// }
55-
// return CDGenerationOptions()
56-
// }
57-
//
58-
// public var description: String {
59-
// "\(self)"
60-
// }
61-
//
62-
// public var debugDescription: String {
63-
// description
64-
// }
65-
//}
66-
//
67-
//extension CDClassModel {
68-
// public func semanticLines(with options: CDGenerationOptions) -> CDSemanticString {
69-
// __semanticLines(with: options as __CDGenerationOptions)
70-
// }
71-
//}
72-
//
73-
//extension CDProtocolModel {
74-
// public func semanticLines(with options: CDGenerationOptions) -> CDSemanticString {
75-
// __semanticLines(with: options as __CDGenerationOptions)
76-
// }
77-
//}
4+
public struct CDGenerationOptions: Codable, Hashable, Identifiable {
5+
public var stripProtocolConformance: Bool
6+
public var stripOverrides: Bool
7+
public var stripDuplicates: Bool
8+
public var stripSynthesized: Bool
9+
public var stripCtorMethod: Bool
10+
public var stripDtorMethod: Bool
11+
public var addSymbolImageComments: Bool
12+
public var addIvarOffsetComments: Bool
13+
public var id: Self { self }
14+
15+
public init(
16+
stripProtocolConformance: Bool = false,
17+
stripOverrides: Bool = false,
18+
stripDuplicates: Bool = false,
19+
stripSynthesized: Bool = false,
20+
stripCtorMethod: Bool = false,
21+
stripDtorMethod: Bool = false,
22+
addSymbolImageComments: Bool = false,
23+
addIvarOffsetComments: Bool = false
24+
) {
25+
self.stripProtocolConformance = stripProtocolConformance
26+
self.stripOverrides = stripOverrides
27+
self.stripDuplicates = stripDuplicates
28+
self.stripSynthesized = stripSynthesized
29+
self.stripCtorMethod = stripCtorMethod
30+
self.stripDtorMethod = stripDtorMethod
31+
self.addSymbolImageComments = addSymbolImageComments
32+
self.addIvarOffsetComments = addIvarOffsetComments
33+
}
34+
35+
}
36+
37+
extension CDGenerationOptions: ReferenceConvertible {
38+
public typealias ReferenceType = __CDGenerationOptions
39+
40+
public func _bridgeToObjectiveC() -> __CDGenerationOptions {
41+
let options = __CDGenerationOptions()
42+
options.stripProtocolConformance = stripProtocolConformance
43+
options.stripOverrides = stripOverrides
44+
options.stripSynthesized = stripSynthesized
45+
options.stripCtorMethod = stripCtorMethod
46+
options.stripDtorMethod = stripDtorMethod
47+
options.addSymbolImageComments = addSymbolImageComments
48+
options.addIvarOffsetComments = addIvarOffsetComments
49+
return options
50+
}
51+
52+
public static func _forceBridgeFromObjectiveC(_ source: __CDGenerationOptions, result: inout CDGenerationOptions?) {
53+
result = CDGenerationOptions(
54+
stripProtocolConformance: source.stripProtocolConformance,
55+
stripOverrides: source.stripOverrides,
56+
stripDuplicates: source.stripDuplicates,
57+
stripSynthesized: source.stripSynthesized,
58+
stripCtorMethod: source.stripCtorMethod,
59+
stripDtorMethod: source.stripDtorMethod,
60+
addSymbolImageComments: source.addSymbolImageComments,
61+
addIvarOffsetComments: source.addIvarOffsetComments
62+
)
63+
}
64+
65+
public static func _conditionallyBridgeFromObjectiveC(_ source: __CDGenerationOptions, result: inout CDGenerationOptions?) -> Bool {
66+
_forceBridgeFromObjectiveC(source, result: &result)
67+
return true
68+
}
69+
70+
public static func _unconditionallyBridgeFromObjectiveC(_ source: __CDGenerationOptions?) -> CDGenerationOptions {
71+
if let source = source {
72+
var result: CDGenerationOptions?
73+
_forceBridgeFromObjectiveC(source, result: &result)
74+
return result!
75+
}
76+
return CDGenerationOptions()
77+
}
78+
79+
public var description: String {
80+
"\(self)"
81+
}
82+
83+
public var debugDescription: String {
84+
description
85+
}
86+
}
87+
88+
extension CDClassModel {
89+
public func semanticLines(with options: CDGenerationOptions) -> CDSemanticString {
90+
__semanticLines(with: options as __CDGenerationOptions)
91+
}
92+
}
93+
94+
extension CDProtocolModel {
95+
public func semanticLines(with options: CDGenerationOptions) -> CDSemanticString {
96+
__semanticLines(with: options as __CDGenerationOptions)
97+
}
98+
}

0 commit comments

Comments
 (0)