Skip to content

Commit 8269473

Browse files
authored
Merge pull request #239 from rintaro/jextract-re-lowering-fix
[jextract] Update for review feedback
2 parents c5b9bf3 + 9f4a192 commit 8269473

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

Sources/JExtractSwift/CDeclLowering/Swift2JavaTranslator+FunctionLowering.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ extension Swift2JavaTranslator {
5050
}
5151

5252
/// Lower the given variable decl to a C-compatible entrypoint,
53-
/// providing all of the mappings between the parameter and result types
54-
/// of the original function and its `@_cdecl` counterpart.
53+
/// providing the mappings between the `self` and value type of the variable
54+
/// and its `@_cdecl` counterpart.
5555
@_spi(Testing)
5656
public func lowerFunctionSignature(
5757
_ decl: VariableDeclSyntax,
@@ -297,7 +297,7 @@ struct CdeclLowering {
297297
}
298298
}
299299

300-
/// Lower a Swift result type to cdecl parameters and return type.
300+
/// Lower a Swift result type to cdecl out parameters and return type.
301301
///
302302
/// - Parameters:
303303
/// - type: The return type.

Sources/JExtractSwift/SwiftTypes/SwiftFunctionSignature.swift

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,26 +227,17 @@ extension VariableDeclSyntax {
227227
case .getter:
228228
return [.get]
229229
case .accessors(let accessors):
230-
var hasGetter = false
231-
var hasSetter = false
232-
233230
for accessor in accessors {
234-
switch accessor.accessorSpecifier {
235-
case .keyword(.get), .keyword(._read), .keyword(.unsafeAddress):
236-
hasGetter = true
237-
case .keyword(.set), .keyword(._modify), .keyword(.unsafeMutableAddress):
238-
hasSetter = true
231+
switch accessor.accessorSpecifier.tokenKind {
232+
// Existence of any write accessor or observer implies this supports read/write.
233+
case .keyword(.set), .keyword(._modify), .keyword(.unsafeMutableAddress),
234+
.keyword(.willSet), .keyword(.didSet):
235+
return [.get, .set]
239236
default: // Ignore willSet/didSet and unknown accessors.
240237
break
241238
}
242239
}
243-
244-
switch (hasGetter, hasSetter) {
245-
case (true, true): return [.get, .set]
246-
case (true, false): return [.get]
247-
case (false, true): return [.set]
248-
case (false, false): break
249-
}
240+
return [.get]
250241
}
251242
}
252243

0 commit comments

Comments
 (0)