Skip to content

Commit 33e54d0

Browse files
committed
[JExtract] Stop emitting $address() accessor et al
They weren't used.
1 parent 476087b commit 33e54d0

File tree

4 files changed

+0
-148
lines changed

4 files changed

+0
-148
lines changed

Samples/SwiftAndJavaJarSampleLib/src/test/java/com/example/swift/MySwiftLibraryTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@ public class MySwiftLibraryTest {
3030
@Test
3131
void call_helloWorld() {
3232
MySwiftLibrary.helloWorld();
33-
34-
assertNotNull(MySwiftLibrary.helloWorld$address());
3533
}
3634

3735
@Test
3836
void call_globalTakeInt() {
3937
MySwiftLibrary.globalTakeInt(12);
40-
41-
assertNotNull(MySwiftLibrary.globalTakeInt$address());
4238
}
4339

4440
@Test

Samples/SwiftKitSampleApp/src/test/java/com/example/swift/MySwiftLibraryTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ public class MySwiftLibraryTest {
3535
@Test
3636
void call_helloWorld() {
3737
MySwiftLibrary.helloWorld();
38-
39-
assertNotNull(MySwiftLibrary.helloWorld$address());
4038
}
4139

4240
@Test
4341
void call_globalTakeInt() {
4442
MySwiftLibrary.globalTakeInt(12);
45-
46-
assertNotNull(MySwiftLibrary.globalTakeInt$address());
4743
}
4844

4945
@Test

Sources/JExtractSwift/Swift2JavaTranslator+Printing.swift

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,6 @@ extension Swift2JavaTranslator {
472472
printMethodDowncallHandleForAddrDesc(&printer)
473473
}
474474

475-
printFunctionDescriptorMethod(&printer, decl: decl)
476-
printFunctionMethodHandleMethod(&printer, decl: decl)
477-
printFunctionAddressMethod(&printer, decl: decl)
478-
479475
// Render the basic "make the downcall" function
480476
if decl.hasParent {
481477
printFuncDowncallMethod(&printer, decl: decl, paramPassingStyle: .memorySegment)
@@ -485,73 +481,6 @@ extension Swift2JavaTranslator {
485481
}
486482
}
487483

488-
private func printFunctionAddressMethod(
489-
_ printer: inout CodePrinter,
490-
decl: ImportedFunc,
491-
accessorKind: VariableAccessorKind? = nil
492-
) {
493-
494-
let addrName = accessorKind.renderAddrFieldName
495-
let methodNameSegment = accessorKind.renderMethodNameSegment
496-
let snippet = decl.renderCommentSnippet ?? "* "
497-
498-
printer.print(
499-
"""
500-
/**
501-
* Address for:
502-
\(snippet)
503-
*/
504-
public static MemorySegment \(decl.baseIdentifier)\(methodNameSegment)$address() {
505-
return \(decl.baseIdentifier).\(addrName);
506-
}
507-
"""
508-
)
509-
}
510-
511-
private func printFunctionMethodHandleMethod(
512-
_ printer: inout CodePrinter,
513-
decl: ImportedFunc,
514-
accessorKind: VariableAccessorKind? = nil
515-
) {
516-
let handleName = accessorKind.renderHandleFieldName
517-
let methodNameSegment = accessorKind.renderMethodNameSegment
518-
let snippet = decl.renderCommentSnippet ?? "* "
519-
520-
printer.print(
521-
"""
522-
/**
523-
* Downcall method handle for:
524-
\(snippet)
525-
*/
526-
public static MethodHandle \(decl.baseIdentifier)\(methodNameSegment)$handle() {
527-
return \(decl.baseIdentifier).\(handleName);
528-
}
529-
"""
530-
)
531-
}
532-
533-
private func printFunctionDescriptorMethod(
534-
_ printer: inout CodePrinter,
535-
decl: ImportedFunc,
536-
accessorKind: VariableAccessorKind? = nil
537-
) {
538-
let descName = accessorKind.renderDescFieldName
539-
let methodNameSegment = accessorKind.renderMethodNameSegment
540-
let snippet = decl.renderCommentSnippet ?? "* "
541-
542-
printer.print(
543-
"""
544-
/**
545-
* Function descriptor for:
546-
\(snippet)
547-
*/
548-
public static FunctionDescriptor \(decl.baseIdentifier)\(methodNameSegment)$descriptor() {
549-
return \(decl.baseIdentifier).\(descName);
550-
}
551-
"""
552-
)
553-
}
554-
555484
public func printVariableDowncallMethods(_ printer: inout CodePrinter, _ decl: ImportedVariable) {
556485
printer.printSeparator(decl.identifier)
557486

@@ -574,9 +503,6 @@ extension Swift2JavaTranslator {
574503
log.warning("Skip print for \(accessorKind) of \(decl.identifier)!")
575504
continue
576505
}
577-
printFunctionDescriptorMethod(&printer, decl: accessor, accessorKind: accessorKind)
578-
printFunctionMethodHandleMethod(&printer, decl: accessor, accessorKind: accessorKind)
579-
printFunctionAddressMethod(&printer, decl: accessor, accessorKind: accessorKind)
580506
}
581507

582508
// Then print the actual downcall methods

Tests/JExtractSwiftTests/VariableImportTests.swift

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -66,72 +66,6 @@ final class VariableImportTests {
6666
}
6767
""",
6868
"""
69-
/**
70-
* Function descriptor for:
71-
* {@snippet lang=swift :
72-
* public var counterInt: Int
73-
* }
74-
*/
75-
public static FunctionDescriptor counterInt$get$descriptor() {
76-
return counterInt.DESC_GET;
77-
}
78-
""",
79-
"""
80-
/**
81-
* Downcall method handle for:
82-
* {@snippet lang=swift :
83-
* public var counterInt: Int
84-
* }
85-
*/
86-
public static MethodHandle counterInt$get$handle() {
87-
return counterInt.HANDLE_GET;
88-
}
89-
""",
90-
"""
91-
/**
92-
* Address for:
93-
* {@snippet lang=swift :
94-
* public var counterInt: Int
95-
* }
96-
*/
97-
public static MemorySegment counterInt$get$address() {
98-
return counterInt.ADDR_GET;
99-
}
100-
""",
101-
"""
102-
/**
103-
* Function descriptor for:
104-
* {@snippet lang=swift :
105-
* public var counterInt: Int
106-
* }
107-
*/
108-
public static FunctionDescriptor counterInt$set$descriptor() {
109-
return counterInt.DESC_SET;
110-
}
111-
""",
112-
"""
113-
/**
114-
* Downcall method handle for:
115-
* {@snippet lang=swift :
116-
* public var counterInt: Int
117-
* }
118-
*/
119-
public static MethodHandle counterInt$set$handle() {
120-
return counterInt.HANDLE_SET;
121-
}
122-
""",
123-
"""
124-
/**
125-
* Address for:
126-
* {@snippet lang=swift :
127-
* public var counterInt: Int
128-
* }
129-
*/
130-
public static MemorySegment counterInt$set$address() {
131-
return counterInt.ADDR_SET;
132-
}
133-
""",
134-
"""
13569
/**
13670
* Downcall to Swift:
13771
* {@snippet lang=swift :

0 commit comments

Comments
 (0)