Skip to content

Commit 697a4c4

Browse files
committed
WIP
1 parent bb47a73 commit 697a4c4

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

Sources/JExtractSwift/Swift2JavaVisitor.swift

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ final class Swift2JavaVisitor: SyntaxVisitor {
195195
}
196196

197197
do {
198-
let supportedAccessors = supportedAccessorKinds(varDecl: node, binding: binding)
198+
let supportedAccessors = node.supportedAccessorKinds(binding: binding)
199199
if supportedAccessors.contains(.get) {
200200
try importAccessor(kind: .getter)
201201
}
@@ -272,47 +272,3 @@ extension DeclSyntaxProtocol where Self: WithModifiersSyntax & WithAttributesSyn
272272
return true
273273
}
274274
}
275-
276-
277-
struct SupportedAccessorKinds: OptionSet {
278-
var rawValue: UInt8
279-
280-
static var get: Self = .init(rawValue: 1 << 0)
281-
static var set: Self = .init(rawValue: 1 << 1)
282-
}
283-
284-
private func supportedAccessorKinds(varDecl: VariableDeclSyntax, binding: PatternBindingSyntax) -> SupportedAccessorKinds {
285-
if varDecl.bindingSpecifier == .keyword(.let) {
286-
return [.get]
287-
}
288-
289-
if let accessorBlock = binding.accessorBlock {
290-
switch accessorBlock.accessors {
291-
case .getter:
292-
return [.get]
293-
case .accessors(let accessors):
294-
var hasGetter = false
295-
var hasSetter = false
296-
297-
for accessor in accessors {
298-
switch accessor.accessorSpecifier {
299-
case .keyword(.get), .keyword(._read), .keyword(.unsafeAddress):
300-
hasGetter = true
301-
case .keyword(.set), .keyword(._modify), .keyword(.unsafeMutableAddress):
302-
hasSetter = true
303-
default: // Ignore willSet/didSet and unknown accessors.
304-
break
305-
}
306-
}
307-
308-
switch (hasGetter, hasSetter) {
309-
case (true, true): return [.get, .set]
310-
case (true, false): return [.get]
311-
case (false, true): return [.set]
312-
case (false, false): break
313-
}
314-
}
315-
}
316-
317-
return [.get, .set]
318-
}

Tests/JExtractSwiftTests/FunctionLoweringTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class FunctionLoweringTests {
2626
expectedCDecl: """
2727
@_cdecl("c_f")
2828
public func c_f(_ x: Int, _ y: Float, _ z_pointer: UnsafeRawPointer, _ z_count: Int) {
29-
f(x: x, y: y, z: UnsafeBufferPointer<Bool>(start: z_pointer.assumingMemoryBound(to: Bool.self),count: z_count))
29+
f(x: x, y: y, z: UnsafeBufferPointer<Bool>(start: z_pointer.assumingMemoryBound(to: Bool.self), count: z_count))
3030
}
3131
""",
3232
expectedCFunction: "void c_f(ptrdiff_t x, float y, const void *z_pointer, ptrdiff_t z_count)"

0 commit comments

Comments
 (0)