-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedos-iosApple iOSApple iOSos-tvosApple tvOSApple tvOS
Milestone
Description
Our current interop implementation only allows SwiftSelf (representing the self parameter in Swift instance methods) to be specified as the first parameter in function signatures. This design choice leads to issues when interfacing with Swift instance methods that accept additional parameters.
Let's consider following example
@frozen public struct SampleStruct
{
public var x1: Int
public var x2: Int
public func addWithExtraArgs(x3: Float, x4: Float) -> Float {
return Float(x1 + x2) + x3 + x4
}
}
addWithExtraArgs
results in the following LLVM-IR:
define protected swiftcc float @"output.SampleStruct.addWithExtraArgs(x3: Swift.Float, x4: Swift.Float) -> Swift.Float"(float %0, float %1, i64 %2, i64 %3) ...
SampleStruct
is expected to be lowered into two i64
which are passed as last parameters.
This would correspond to following csharp signature:
static extern void AddWithExtraArgs(float a, float b, SwiftSelf<SampleStruct> struct)
We should either allow SwiftSelf<T>
argument to be specified as the last parameter or we should reorder the parameters in runtime.
\cc: @kotlarmilos, @jakobbotsch, @amanasifkhalid, @matouskozak
matouskozak
Metadata
Metadata
Assignees
Labels
area-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedos-iosApple iOSApple iOSos-tvosApple tvOSApple tvOS
Type
Projects
Status
No status