@@ -374,12 +374,12 @@ public override bool VisitClassDecl(Class @class)
374374 return true ;
375375 }
376376
377- if ( ! @class . IsDependent )
377+ if ( ! @class . IsDependent && ! @class . IsAbstractImpl )
378378 foreach ( var nestedTemplate in @class . Classes . Where (
379379 c => ! c . IsIncomplete && c . IsDependent ) )
380380 GenerateClassTemplateSpecializationInternal ( nestedTemplate ) ;
381381
382- if ( @class . IsTemplate )
382+ if ( @class . IsTemplate && ! @class . IsAbstractImpl )
383383 {
384384 if ( ! ( @class . Namespace is Class ) )
385385 GenerateClassTemplateSpecializationInternal ( @class ) ;
@@ -1206,7 +1206,8 @@ private static Property GetActualProperty(Property property, Class c)
12061206 if ( ! ( c is ClassTemplateSpecialization ) )
12071207 return property ;
12081208 return c . Properties . SingleOrDefault ( p => p . GetMethod != null &&
1209- p . GetMethod . InstantiatedFrom == property . GetMethod ) ;
1209+ p . GetMethod . InstantiatedFrom ==
1210+ ( property . GetMethod . OriginalFunction ?? property . GetMethod ) ) ;
12101211 }
12111212
12121213 private void GenerateFunctionInProperty ( Class @class , Method constituent ,
@@ -1487,6 +1488,9 @@ private void GenerateVariable(Class @class, Variable variable)
14871488
14881489 public List < VTableComponent > GetUniqueVTableMethodEntries ( Class @class )
14891490 {
1491+ if ( @class . IsDependent )
1492+ @class = @class . Specializations [ 0 ] ;
1493+
14901494 var uniqueEntries = new OrderedSet < VTableComponent > ( ) ;
14911495 var vTableMethodEntries = VTables . GatherVTableMethodEntries ( @class ) ;
14921496 foreach ( var entry in vTableMethodEntries . Where ( e => ! e . IsIgnored ( ) && ! e . Method . IsOperator ) )
@@ -1603,6 +1607,9 @@ private void AllocateNewVTables(Class @class, IList<VTableComponent> wrappedEntr
16031607
16041608 private void SaveOriginalVTablePointers ( Class @class )
16051609 {
1610+ if ( @class . IsDependent )
1611+ @class = @class . Specializations [ 0 ] ;
1612+
16061613 if ( Context . ParserOptions . IsMicrosoftAbi )
16071614 WriteLine ( "__OriginalVTables = new void*[] {{ {0} }};" ,
16081615 string . Join ( ", " ,
@@ -2086,13 +2093,14 @@ private void GenerateDisposeMethods(Class @class)
20862093 var classInternal = TypePrinter . PrintNative ( @class ) ;
20872094 if ( @class . IsDynamic && GetUniqueVTableMethodEntries ( @class ) . Count != 0 )
20882095 {
2096+ ClassLayout layout = ( @class . IsDependent ? @class . Specializations [ 0 ] : @class ) . Layout ;
20892097 if ( Context . ParserOptions . IsMicrosoftAbi )
2090- for ( var i = 0 ; i < @class . Layout . VTablePointers . Count ; i ++ )
2098+ for ( var i = 0 ; i < layout . VTablePointers . Count ; i ++ )
20912099 WriteLine ( $@ "(({ classInternal } *) { Helpers . InstanceIdentifier } )->{
2092- @class . Layout . VTablePointers [ i ] . Name } = new global::System.IntPtr(__OriginalVTables[{ i } ]);" ) ;
2100+ layout . VTablePointers [ i ] . Name } = new global::System.IntPtr(__OriginalVTables[{ i } ]);" ) ;
20932101 else
20942102 WriteLine ( $@ "(({ classInternal } *) { Helpers . InstanceIdentifier } )->{
2095- @class . Layout . VTablePointers [ 0 ] . Name } = new global::System.IntPtr(__OriginalVTables[0]);" ) ;
2103+ layout . VTablePointers [ 0 ] . Name } = new global::System.IntPtr(__OriginalVTables[0]);" ) ;
20962104 }
20972105 }
20982106
@@ -2157,13 +2165,13 @@ private void GenerateNativeConstructor(Class @class)
21572165 if ( ! @class . IsAbstractImpl )
21582166 {
21592167 PushBlock ( BlockKind . Method ) ;
2160- var printedClass = @class . Visit ( TypePrinter ) ;
2168+ TypePrinterResult printedClass = @class . Visit ( TypePrinter ) ;
21612169 WriteLine ( "internal static {0}{1} {2}(global::System.IntPtr native, bool skipVTables = false)" ,
21622170 @class . NeedsBase && ! @class . BaseClass . IsInterface ? "new " : string . Empty ,
21632171 printedClass , Helpers . CreateInstanceIdentifier ) ;
21642172 WriteOpenBraceAndIndent ( ) ;
21652173 var suffix = @class . IsAbstract ? "Internal" : string . Empty ;
2166- var ctorCall = $ "{ printedClass } { suffix } ";
2174+ var ctorCall = $ "{ printedClass . Type } { suffix } { printedClass . NameSuffix } ";
21672175 WriteLine ( "return new {0}(native.ToPointer(), skipVTables);" , ctorCall ) ;
21682176 UnindentAndWriteCloseBrace ( ) ;
21692177 PopBlock ( NewLineKind . BeforeNextBlock ) ;
@@ -2196,7 +2204,7 @@ private void GenerateNativeConstructor(Class @class)
21962204 WriteLine ( "{0} = new global::System.IntPtr(native);" , Helpers . InstanceIdentifier ) ;
21972205 var dtor = @class . Destructors . FirstOrDefault ( ) ;
21982206 var hasVTables = @class . IsDynamic && GetUniqueVTableMethodEntries ( @class ) . Count > 0 ;
2199- var setupVTables = ! @class . IsAbstractImpl && hasVTables && dtor != null && dtor . IsVirtual ;
2207+ var setupVTables = ! @class . IsAbstractImpl && hasVTables && dtor ? . IsVirtual == true ;
22002208 if ( setupVTables )
22012209 {
22022210 WriteLine ( "if (skipVTables)" ) ;
@@ -2224,7 +2232,7 @@ private void GenerateNativeConstructor(Class @class)
22242232 PopBlock ( NewLineKind . BeforeNextBlock ) ;
22252233 }
22262234
2227- public void GenerateNativeConstructorByValue ( Class @class , string returnType )
2235+ public void GenerateNativeConstructorByValue ( Class @class , TypePrinterResult returnType )
22282236 {
22292237 var @internal = TypePrinter . PrintNative ( @class . IsAbstractImpl ? @class . BaseClass : @class ) ;
22302238
@@ -2235,7 +2243,7 @@ public void GenerateNativeConstructorByValue(Class @class, string returnType)
22352243 returnType , Helpers . CreateInstanceIdentifier , @internal ) ;
22362244 WriteOpenBraceAndIndent ( ) ;
22372245 var suffix = @class . IsAbstract ? "Internal" : "" ;
2238- WriteLine ( $ "return new { returnType } { suffix } (native, skipVTables);") ;
2246+ WriteLine ( $ "return new { returnType . Type } { suffix } { returnType . NameSuffix } (native, skipVTables);") ;
22392247 UnindentAndWriteCloseBrace ( ) ;
22402248 PopBlock ( NewLineKind . BeforeNextBlock ) ;
22412249 }
@@ -2451,7 +2459,7 @@ private void GenerateMethodBody(Class @class, Method method,
24512459 if ( specialization != null )
24522460 {
24532461 var specializedMethod = @class . Methods . FirstOrDefault (
2454- m => m . InstantiatedFrom == method ) ;
2462+ m => m . InstantiatedFrom == ( method . OriginalFunction ?? method ) ) ;
24552463 if ( specializedMethod == null )
24562464 {
24572465 WriteLine ( $@ "throw new MissingMethodException(""Method {
@@ -2479,10 +2487,6 @@ private void GenerateMethodBody(Class @class, Method method,
24792487 {
24802488 GenerateOperator ( method , returnType ) ;
24812489 }
2482- else if ( method . SynthKind == FunctionSynthKind . AbstractImplCall )
2483- {
2484- GenerateVirtualFunctionCall ( method ) ;
2485- }
24862490 else if ( method . IsVirtual )
24872491 {
24882492 GenerateVirtualFunctionCall ( method ) ;
@@ -2752,12 +2756,6 @@ public void GenerateInternalFunctionCall(Function function,
27522756 public void GenerateFunctionCall ( string functionName , Function function ,
27532757 QualifiedType returnType = default ( QualifiedType ) )
27542758 {
2755- if ( function . IsPure )
2756- {
2757- WriteLine ( "throw new System.NotImplementedException();" ) ;
2758- return ;
2759- }
2760-
27612759 // ignored functions may get here from interfaces for secondary bases
27622760 if ( function . Ignore )
27632761 {
0 commit comments