@@ -38,7 +38,7 @@ package class FFMSwift2JavaGenerator: Swift2JavaGenerator {
3838 var thunkNameRegistry : ThunkNameRegistry = ThunkNameRegistry ( )
3939
4040 /// Cached Java translation result. 'nil' indicates failed translation.
41- var translatedDecls : [ ImportedFunc : TranslatedFunctionDecl ? ] = [ : ]
41+ var translatedDecls : [ ExtractedFunc : TranslatedFunctionDecl ? ] = [ : ]
4242
4343 /// Duplicate identifier tracking for the current batch of methods being generated.
4444 var currentJavaIdentifiers : JavaIdentifierFactory = JavaIdentifierFactory ( )
@@ -152,8 +152,8 @@ extension FFMSwift2JavaGenerator {
152152 ]
153153
154154 /// Returns the Java class name for a nominal type, applying known-type overrides
155- func javaClassName( for decl: ImportedNominalType ) -> String {
156- if decl. swiftNominal. knownTypeKind == . swiftJavaError {
155+ func javaClassName( for decl: ExtractedNominalType ) -> String {
156+ if decl. swiftNominal. isSwiftJavaErrorType {
157157 return JavaType . swiftJavaErrorException. className!
158158 }
159159 return decl. swiftNominal. name
@@ -171,13 +171,13 @@ extension FFMSwift2JavaGenerator {
171171
172172 /// Every imported public type becomes a public class in its own file in Java.
173173 package func writeExportedJavaSources( printer: inout CodePrinter ) throws {
174- let typesToExport : [ ( key: String , value: ImportedNominalType ) ]
174+ let typesToExport : [ ( key: String , value: ExtractedNominalType ) ]
175175 if let singleType = config. singleType {
176- typesToExport = analysis. importedTypes
176+ typesToExport = analysis. extractedTypes
177177 . filter { $0. key == singleType }
178178 . sorted ( by: { $0. key < $1. key } )
179179 } else {
180- typesToExport = analysis. importedTypes
180+ typesToExport = analysis. extractedTypes
181181 . sorted ( by: { $0. key < $1. key } )
182182 }
183183
@@ -227,24 +227,24 @@ extension FFMSwift2JavaGenerator {
227227 printImports ( & printer)
228228
229229 self . currentJavaIdentifiers = JavaIdentifierFactory (
230- self . analysis. importedGlobalFuncs + self . analysis. importedGlobalVariables
230+ self . analysis. extractedGlobalFuncs + self . analysis. extractedGlobalVariables
231231 )
232232
233233 printModuleClass ( & printer) { printer in
234234
235- for decl in analysis. importedGlobalVariables {
235+ for decl in analysis. extractedGlobalVariables {
236236 self . log. trace ( " Print imported decl: \( decl) " )
237237 printFunctionDowncallMethods ( & printer, decl)
238238 }
239239
240- for decl in analysis. importedGlobalFuncs {
240+ for decl in analysis. extractedGlobalFuncs {
241241 self . log. trace ( " Print imported decl: \( decl) " )
242242 printFunctionDowncallMethods ( & printer, decl)
243243 }
244244 }
245245 }
246246
247- func printImportedNominal( _ printer: inout CodePrinter , _ decl: ImportedNominalType ) {
247+ func printImportedNominal( _ printer: inout CodePrinter , _ decl: ExtractedNominalType ) {
248248 printHeader ( & printer)
249249 printPackage ( & printer)
250250 printImports ( & printer) // TODO: we could have some imports be driven from types used in the generated decl
@@ -253,7 +253,7 @@ extension FFMSwift2JavaGenerator {
253253 decl. initializers + decl. variables + decl. methods
254254 )
255255
256- let isErrorType = decl. swiftNominal. knownTypeKind == . swiftJavaError
256+ let isErrorType = decl. swiftNominal. isSwiftJavaErrorType
257257 self . currentSymbolLookup = isErrorType ? . swiftRuntime : . module
258258
259259 printNominal ( & printer, decl) { printer in
@@ -387,10 +387,10 @@ extension FFMSwift2JavaGenerator {
387387
388388 func printNominal(
389389 _ printer: inout CodePrinter ,
390- _ decl: ImportedNominalType ,
390+ _ decl: ExtractedNominalType ,
391391 body: ( inout CodePrinter ) -> Void ,
392392 ) {
393- let isErrorType = decl. swiftNominal. knownTypeKind == . swiftJavaError
393+ let isErrorType = decl. swiftNominal. isSwiftJavaErrorType
394394
395395 let baseClass : String
396396 let parentProtocol : String
@@ -425,8 +425,8 @@ extension FFMSwift2JavaGenerator {
425425
426426 /// Returns a closure that prints the constructor and related extras for special nominal types
427427 /// (e.g. error types), or `nil` for normal types that use the default layout + constructor
428- func getSpecialNominalConstructorPrinting( _ decl: ImportedNominalType ) -> ( ( inout CodePrinter ) -> Void ) ? {
429- if decl. swiftNominal. knownTypeKind == . swiftJavaError {
428+ func getSpecialNominalConstructorPrinting( _ decl: ExtractedNominalType ) -> ( ( inout CodePrinter ) -> Void ) ? {
429+ if decl. swiftNominal. isSwiftJavaErrorType {
430430 return { printer in
431431 // Error constructor: wrap the opaque pointer so it becomes a pointer-to-reference
432432 // (matching the convention used by normal class instance thunks)
@@ -449,8 +449,8 @@ extension FFMSwift2JavaGenerator {
449449
450450 /// Returns a closure that prints post-members extras for special nominal types
451451 /// (e.g. `fetchDescription` for error types), or `nil` for normal types that use `toString()`
452- func getSpecialNominalPostMembersPrinting( _ decl: ImportedNominalType ) -> ( ( inout CodePrinter ) -> Void ) ? {
453- if decl. swiftNominal. knownTypeKind == . swiftJavaError {
452+ func getSpecialNominalPostMembersPrinting( _ decl: ExtractedNominalType ) -> ( ( inout CodePrinter ) -> Void ) ? {
453+ if decl. swiftNominal. isSwiftJavaErrorType {
454454 return { printer in
455455 // Error types inherit toString() from Exception; print fetchDescription helper instead
456456 self . printSwiftJavaErrorFetchDescriptionMethod ( & printer, decl)
@@ -569,7 +569,7 @@ extension FFMSwift2JavaGenerator {
569569 )
570570 }
571571
572- private func printClassMemoryLayout( _ printer: inout CodePrinter , _ decl: ImportedNominalType ) {
572+ private func printClassMemoryLayout( _ printer: inout CodePrinter , _ decl: ExtractedNominalType ) {
573573 printer. print (
574574 """
575575 public static final GroupLayout $LAYOUT = (GroupLayout) SwiftValueWitnessTable.layoutOfSwiftType(TYPE_METADATA.$memorySegment());
@@ -582,7 +582,7 @@ extension FFMSwift2JavaGenerator {
582582
583583 func printToStringMethod(
584584 _ printer: inout CodePrinter ,
585- _ decl: ImportedNominalType ,
585+ _ decl: ExtractedNominalType ,
586586 ) {
587587 printer. print (
588588 """
@@ -599,7 +599,7 @@ extension FFMSwift2JavaGenerator {
599599 }
600600
601601 /// Print special helper methods for known types like Foundation.Data
602- func printSpecificTypeHelpers( _ printer: inout CodePrinter , _ decl: ImportedNominalType ) {
602+ func printSpecificTypeHelpers( _ printer: inout CodePrinter , _ decl: ExtractedNominalType ) {
603603 guard let knownType = decl. swiftNominal. knownTypeKind else {
604604 return
605605 }
@@ -615,7 +615,7 @@ extension FFMSwift2JavaGenerator {
615615 /// Print the `fetchDescription` static helper for SwiftJavaError.
616616 /// This calls the `errorDescription()` downcall to get the error message
617617 /// for the super constructor
618- func printSwiftJavaErrorFetchDescriptionMethod( _ printer: inout CodePrinter , _ decl: ImportedNominalType ) {
618+ func printSwiftJavaErrorFetchDescriptionMethod( _ printer: inout CodePrinter , _ decl: ExtractedNominalType ) {
619619 // Find the errorDescription method's thunk name
620620 let errorDescMethod = decl. methods. first { $0. name == " errorDescription " }
621621 guard let errorDescMethod, let _ = translatedDecl ( for: errorDescMethod) else {
0 commit comments