-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Swift language features] Add support for passing bound generics to swift functions #2970
Comments
Isn't it already working? For array I think you need to add the manual projection to type database. <entity managedNameSpace="Swift.Runtime" managedTypeName="SwiftArray">
<typedeclaration kind="struct" name="Array`1" module="Swift" mangledName="sSa" frozen="false" blittable ="false"/>
</entity> |
I tried to add it as a test, but the method emitter is missing marshalling of generic types: public static Int32 sumArray( SwiftArray<Int32> array)
{
try
{
var result = PInvoke_sumArray(array);
return result;
}
finally
{
}
}
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })]
[DllImport("./libHelloLibrary.dylib", EntryPoint = "$s12HelloLibrary8sumArray5arrays5Int32VSayAEG_tF")]
private static extern Int32 PInvoke_sumArray( SwiftArray<Int32> array);
public static SwiftArray<Int32> getArray( Int32 a, Int32 b)
{
try
{
var result = PInvoke_getArray(a, b);
return result;
}
finally
{
}
}
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })]
[DllImport("./libHelloLibrary.dylib", EntryPoint = "$s12HelloLibrary8getArray1a1bSays5Int32VGAF_AFtF")]
private static extern SwiftArray<Int32> PInvoke_getArray( Int32 a, Int32 b); |
Ok, I understand. Is this necessary for milestone 1? Passing bound (or closed) generic types is going to be a challenge. |
Not needed, we can wrap it for the M1. |
This is a complex issue. To support passing bound generics into Swift functions, we need to correctly lower them when the generics and their parameters are frozen. So far, we have identified two approaches to address this problem: Per-Instantiation Helper Structs (as described in binding-generics.md): Generic Helper Structs (proposed by @jkoritzinsky): |
|
Description
We want to support the following:
Sub tasks:
The text was updated successfully, but these errors were encountered: