Skip to content

Commit 90baedc

Browse files
committed
Remove swiftDemangledMangledName; we'll use names derived from source code
1 parent 347c915 commit 90baedc

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Sources/JExtractSwift/ImportedDecls.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public struct ImportedTypeName: Hashable {
8686
public var swiftTypeName: String
8787

8888
public var swiftMangledName: String = ""
89-
public var swiftDemangledMangledName: String = ""
9089

9190
public var javaType: JavaType
9291

@@ -124,7 +123,8 @@ public struct ImportedFunc: ImportedDecl, CustomStringConvertible {
124123
public var parentName: ImportedTypeName?
125124
public var hasParent: Bool { parentName != nil }
126125

127-
public var identifier: String // FIXME: this is init(cap:name:) complete swift identifier; change that to be base
126+
/// This is a full name such as init(cap:name:).
127+
public var identifier: String
128128

129129
public var baseIdentifier: String {
130130
guard let idx = identifier.firstIndex(of: "(") else {
@@ -133,6 +133,16 @@ public struct ImportedFunc: ImportedDecl, CustomStringConvertible {
133133
return String(identifier[..<idx])
134134
}
135135

136+
/// A display name to use to refer to the Swift declaration with its
137+
/// enclosing type.
138+
public var displayName: String {
139+
if let parentName {
140+
return "\(parentName.swiftTypeName).\(identifier)"
141+
}
142+
143+
return identifier
144+
}
145+
136146
public var returnType: ImportedTypeName
137147
public var parameters: [ImportedParam]
138148

@@ -173,7 +183,6 @@ public struct ImportedFunc: ImportedDecl, CustomStringConvertible {
173183
}
174184

175185
public var swiftMangledName: String = ""
176-
public var swiftDemangledMangledName: String = ""
177186

178187
public var swiftDeclRaw: String? = nil
179188

Sources/JExtractSwift/Swift2JavaTranslator+Printing.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,8 @@ extension Swift2JavaTranslator {
502502
printer.print(
503503
"""
504504
/**
505-
* Demangled representation:
506505
* {@snippet lang = Swift:
507-
* \(decl.swiftDemangledMangledName)
506+
* \(decl.displayName)
508507
* }
509508
*/
510509
public static final MemorySegment ADDR = \(swiftModuleName).findOrThrow("\(decl.swiftMangledName)");

Sources/JExtractSwift/SwiftDylib.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ package struct SwiftDylib { // FIXME: remove this entire utility; replace with
4646
if let name = names.first {
4747
log.trace("Selected mangled name for '\(decl.name.javaType.description)': \(name)")
4848
decl.name.swiftMangledName = name.mangledName
49-
decl.name.swiftDemangledMangledName = name.descriptiveName
5049
}
5150

5251
return decl
@@ -64,7 +63,6 @@ package struct SwiftDylib { // FIXME: remove this entire utility; replace with
6463
if let name = names.first {
6564
log.trace("Selected mangled name for '\(decl.identifier)': \(name)")
6665
decl.swiftMangledName = name.mangledName
67-
decl.swiftDemangledMangledName = name.descriptiveName
6866
}
6967

7068
return decl
@@ -85,7 +83,6 @@ package struct SwiftDylib { // FIXME: remove this entire utility; replace with
8583
if let name = names.first {
8684
log.trace("Selected mangled name for '\(decl.identifier)': \(name)")
8785
decl.swiftMangledName = name.mangledName
88-
decl.swiftDemangledMangledName = name.descriptiveName
8986
}
9087

9188
return decl
@@ -103,7 +100,6 @@ package struct SwiftDylib { // FIXME: remove this entire utility; replace with
103100
if let name = names.first {
104101
log.trace("Selected mangled name: \(name)")
105102
decl.swiftMangledName = name.mangledName
106-
decl.swiftDemangledMangledName = name.descriptiveName
107103
}
108104

109105
return decl

0 commit comments

Comments
 (0)