@@ -2265,7 +2265,7 @@ CSProperty ImplementProtocolSubscriptEtter (WrappingResult wrapper,
2265
2265
List < CSLine > vtableAssignments , CSUsingPackages use , bool isSetter , CSProperty wrapperProp , string swiftLibraryPath )
2266
2266
{
2267
2267
CSDelegateTypeDecl etterDelegateDecl = DefineDelegateAndAddToVtable ( vtable , etterFunc , use ,
2268
- OverrideBuilder . VTableEntryIdentifier ( vtableEntryIndex ) , true ) ;
2268
+ OverrideBuilder . VTableEntryIdentifier ( vtableEntryIndex ) , ! protocolDecl . HasAssociatedTypes ) ;
2269
2269
vtable . Delegates . Add ( etterDelegateDecl ) ;
2270
2270
2271
2271
var etterWrapperFunc = FindProtocolWrapperFunction ( etterFunc , wrapper ) ;
@@ -2524,7 +2524,7 @@ int ImplementPropertyVtableForVirtualProperties (WrappingResult wrapper,
2524
2524
}
2525
2525
var wrapperProp = ImplementPropertyEtter ( wrapper , classDecl , subclassDecl , classContents , cl , picl , usedPinvokeNames , virtFuncs ,
2526
2526
getterFunc , tlSetter , vtableEntryIndex , vtableName , vtable , vtableAssignments , use ,
2527
- false , null , swiftLibraryPath ) ;
2527
+ false , null , swiftLibraryPath , null ) ;
2528
2528
2529
2529
if ( hasSetter ) {
2530
2530
wrapperProp = ImplementPropertyEtter ( wrapper , classDecl , subclassDecl , classContents , cl , picl , usedPinvokeNames , virtFuncs ,
@@ -2544,7 +2544,7 @@ CSProperty ImplementProtocolPropertyEtter (WrappingResult wrapper,
2544
2544
List < CSLine > vtableAssignments , CSUsingPackages use , bool isSetter , bool isObjC , CSProperty wrapperProp , string swiftLibraryPath )
2545
2545
{
2546
2546
var etterDelegateDecl = DefineDelegateAndAddToVtable ( vtable , etterFunc , use ,
2547
- OverrideBuilder . VTableEntryIdentifier ( vtableEntryIndex ) , true ) ;
2547
+ OverrideBuilder . VTableEntryIdentifier ( vtableEntryIndex ) , ! protocolDecl . HasAssociatedTypes ) ;
2548
2548
vtable . Delegates . Add ( etterDelegateDecl ) ;
2549
2549
2550
2550
var etterWrapperFunc = FindProtocolWrapperFunction ( etterFunc , wrapper ) ;
@@ -2561,7 +2561,7 @@ CSProperty ImplementProtocolPropertyEtter (WrappingResult wrapper,
2561
2561
piEtterName = Uniqueify ( piEtterName , usedPinvokeNames ) ;
2562
2562
usedPinvokeNames . Add ( piEtterName ) ;
2563
2563
2564
- string piEtterRef = PIClassName ( TypeMapper . GetDotNetNameForSwiftClassName ( protocolContents . Name ) ) + "." + piEtterName ;
2564
+ string piEtterRef = picl . Name + "." + piEtterName ;
2565
2565
var piGetter = TLFCompiler . CompileMethod ( etterWrapperFunc , use ,
2566
2566
PInvokeName ( wrapper . ModuleLibPath , swiftLibraryPath ) ,
2567
2567
etterWrapper . MangledName , piEtterName , true , true , false ) ;
@@ -2583,6 +2583,8 @@ CSProperty ImplementProtocolPropertyEtter (WrappingResult wrapper,
2583
2583
2584
2584
var usedIds = new List < string > { propName } ;
2585
2585
var marshal = new MarshalEngine ( use , usedIds , TypeMapper , wrapper . Module . SwiftCompilerVersion ) ;
2586
+ if ( protocolDecl . HasAssociatedTypes )
2587
+ marshal . GenericReferenceNamer = MakeAssociatedTypeNamer ( protocolDecl ) ;
2586
2588
2587
2589
var ifTest = kInterfaceImpl != CSConstant . Null ;
2588
2590
var ifBlock = new CSCodeBlock ( ) ;
@@ -2603,12 +2605,16 @@ CSProperty ImplementProtocolPropertyEtter (WrappingResult wrapper,
2603
2605
etterFunc , etterFunc . ReturnTypeSpec , wrapperProp . PropType , etterFunc . ParameterLists [ 0 ] [ 0 ] . TypeSpec , new CSSimpleType ( iface . Name . Name ) , false , wrapper , etterFunc . HasThrows ) ) ;
2604
2606
}
2605
2607
2606
- var ifElse = new CSIfElse ( ifTest , ifBlock , elseBlock ) ;
2607
- target . Add ( ifElse ) ;
2608
+ if ( protocolDecl . HasAssociatedTypes ) {
2609
+ target . AddRange ( elseBlock ) ;
2610
+ } else {
2611
+ var ifElse = new CSIfElse ( ifTest , ifBlock , elseBlock ) ;
2612
+ target . Add ( ifElse ) ;
2613
+ }
2608
2614
2609
2615
var recvr = ImplementVirtualPropertyStaticReceiver ( new CSSimpleType ( iface . Name . Name ) ,
2610
- proxyClass . Name . Name , etterDelegateDecl , use ,
2611
- etterFunc , wrapperProp , null , vtable . Name , isObjC ) ;
2616
+ proxyClass . ToCSType ( ) . ToString ( ) , etterDelegateDecl , use ,
2617
+ etterFunc , wrapperProp , null , vtable . Name , isObjC , protocolDecl . HasAssociatedTypes ) ;
2612
2618
proxyClass . Methods . Add ( recvr ) ;
2613
2619
2614
2620
vtableAssignments . Add ( CSAssignment . Assign ( String . Format ( "{0}.{1}" ,
@@ -2620,7 +2626,8 @@ CSProperty ImplementPropertyEtter (WrappingResult wrapper,
2620
2626
ClassDeclaration classDecl , ClassDeclaration subclassDecl ,
2621
2627
ClassContents classContents , CSClass cl , CSClass picl , List < string > usedPinvokeNames , List < FunctionDeclaration > virtFuncs ,
2622
2628
FunctionDeclaration etterFunc , TLFunction tlSetter , int vtableEntryIndex , string vtableName , CSStruct vtable ,
2623
- List < CSLine > vtableAssignments , CSUsingPackages use , bool isSetter , CSProperty wrapperProp , string swiftLibraryPath )
2629
+ List < CSLine > vtableAssignments , CSUsingPackages use , bool isSetter , CSProperty wrapperProp , string swiftLibraryPath ,
2630
+ Func < int , int , string > genericRenamer = null )
2624
2631
{
2625
2632
var swiftClassName = XmlToTLFunctionMapper . ToSwiftClassName ( subclassDecl ) ;
2626
2633
var tlEtter = XmlToTLFunctionMapper . ToTLFunction ( etterFunc , classContents ) ;
@@ -2647,7 +2654,8 @@ CSProperty ImplementPropertyEtter (WrappingResult wrapper,
2647
2654
2648
2655
var piGetter = TLFCompiler . CompileMethod ( etterWrapperFunc , use ,
2649
2656
PInvokeName ( wrapper . ModuleLibPath , swiftLibraryPath ) ,
2650
- etterWrapper . MangledName , piEtterName , true , true , false ) ; picl . Methods . Add ( piGetter ) ;
2657
+ etterWrapper . MangledName , piEtterName , true , true , false ) ;
2658
+ picl . Methods . Add ( piGetter ) ;
2651
2659
2652
2660
var superEtterFunc = subclassDecl . AllMethodsNoCDTor ( ) . Where ( fn =>
2653
2661
fn . Access == Accessibility . Internal && fn . IsProperty &&
@@ -2688,7 +2696,8 @@ CSProperty ImplementPropertyEtter (WrappingResult wrapper,
2688
2696
}
2689
2697
}
2690
2698
2691
- ImplementOverloadFromKnownWrapper ( cl , picl , usedPinvokeNames , swiftClassName , superEtterTlf , superEtterFunc , use , true , wrapper , swiftLibraryPath , superEtterFuncWrapper , "" , true ) ;
2699
+ ImplementOverloadFromKnownWrapper ( cl , picl , usedPinvokeNames , swiftClassName , superEtterTlf , superEtterFunc , use , true , wrapper , swiftLibraryPath , superEtterFuncWrapper , "" , true ,
2700
+ genericRenamer : genericRenamer ) ;
2692
2701
var propertyImplMethod = cl . Methods . Last ( ) ;
2693
2702
CSMethod protoListMethod = null ;
2694
2703
if ( returnIsProtocolList ) {
@@ -2714,7 +2723,7 @@ CSProperty ImplementPropertyEtter (WrappingResult wrapper,
2714
2723
}
2715
2724
2716
2725
var recvr = ImplementVirtualPropertyStaticReceiver ( cl . ToCSType ( ) , null , etterDelegateDecl , use , etterFunc ,
2717
- wrapperProp , protoListMethod , vtable . Name , classDecl . IsObjC ) ;
2726
+ wrapperProp , protoListMethod , vtable . Name , classDecl . IsObjC , false ) ;
2718
2727
cl . Methods . Add ( recvr ) ;
2719
2728
2720
2729
vtableAssignments . Add ( CSAssignment . Assign ( String . Format ( "{0}.{1}" ,
@@ -2844,7 +2853,7 @@ CSMethod ImplementVirtualSubscriptStaticReceiver (CSType thisType, string csProx
2844
2853
2845
2854
CSMethod ImplementVirtualPropertyStaticReceiver ( CSType thisType , string csProxyName , CSDelegateTypeDecl delType ,
2846
2855
CSUsingPackages use , FunctionDeclaration funcDecl , CSProperty prop , CSMethod protoListMethod ,
2847
- CSIdentifier vtableName , bool isObjC )
2856
+ CSIdentifier vtableName , bool isObjC , bool hasAssociatedTypes )
2848
2857
{
2849
2858
var returnType = funcDecl . IsGetter ? delType . Type : CSSimpleType . Void ;
2850
2859
CSParameterList pl = delType . Parameters ;
@@ -2863,7 +2872,7 @@ CSMethod ImplementVirtualPropertyStaticReceiver (CSType thisType, string csProxy
2863
2872
2864
2873
var bodyContents = marshaler . MarshalFromLambdaReceiverToCSProp ( prop , thisType , csProxyName ,
2865
2874
delType . Parameters ,
2866
- funcDecl , prop . PropType , isObjC ) ;
2875
+ funcDecl , prop . PropType , isObjC , hasAssociatedTypes ) ;
2867
2876
body . AddRange ( bodyContents ) ;
2868
2877
recvrName = "xamVtable_recv_" + ( funcDecl . IsGetter ? "get_" : "set_" ) + prop . Name . Name ;
2869
2878
}
@@ -2898,7 +2907,7 @@ CSLambda ImplementVirtualPropertyReceiver (CSType thisType, string csProxyName,
2898
2907
var marshaler = new MarshalEngineCSafeSwiftToCSharp ( use , usedIDs , TypeMapper ) ;
2899
2908
2900
2909
var bodyContents = marshaler . MarshalFromLambdaReceiverToCSProp ( prop , thisType , csProxyName , delType . Parameters ,
2901
- funcDecl , prop . PropType , isObjC ) ;
2910
+ funcDecl , prop . PropType , isObjC , false ) ;
2902
2911
var body = new CSCodeBlock ( bodyContents ) ;
2903
2912
return new CSLambda ( pl , body ) ;
2904
2913
}
@@ -5125,7 +5134,8 @@ CSIfElse InterfaceMethodRedirect (CSMethod publicMethod, IEnumerable<ICodeElemen
5125
5134
CSMethod ImplementOverloadFromKnownWrapper ( CSClass cl , CSClass picl , List < string > usedPinvokeNames , SwiftClassName classForPI ,
5126
5135
TLFunction methodToWrap , FunctionDeclaration funcToWrap , CSUsingPackages use , bool isFinal ,
5127
5136
WrappingResult wrapper , string swiftLibraryPath , TLFunction wrapperFunction ,
5128
- string homonymSuffix , bool forcePrivate = false , string alternativeName = null )
5137
+ string homonymSuffix , bool forcePrivate = false , string alternativeName = null ,
5138
+ Func < int , int , string > genericRenamer = null )
5129
5139
{
5130
5140
var wrapperFuncDecl = FindEquivalentFunctionDeclarationForWrapperFunction ( wrapperFunction , TypeMapper , wrapper ) ;
5131
5141
var pinvokeMethodName = PIMethodName ( classForPI , wrapperFunction . Name ) + homonymSuffix ;
@@ -5193,6 +5203,7 @@ CSMethod ImplementOverloadFromKnownWrapper (CSClass cl, CSClass picl, List<strin
5193
5203
} ;
5194
5204
5195
5205
var marshaler = new MarshalEngine ( use , localIdentifiers , TypeMapper , wrapper . Module . SwiftCompilerVersion ) ;
5206
+ marshaler . GenericReferenceNamer = genericRenamer ;
5196
5207
5197
5208
publicMethod . Body . AddRange ( marshaler . MarshalFunctionCall ( wrapperFuncDecl , false , pinvokeMethodRef ,
5198
5209
publicMethod . Parameters , funcToWrap , funcToWrap . ReturnTypeSpec , publicMethod . Type , instanceTypeSpec , cl . ToCSType ( ) ,
0 commit comments