Browse Source

Fixed the generated C# when a specialisation of a template used as a secondary base has an invalid function.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1033/head
Dimitar Dobrev 8 years ago
parent
commit
ce22a3cb21
  1. 6
      src/Generator/AST/Utils.cs
  2. 11
      src/Generator/Passes/MultipleInheritancePass.cs

6
src/Generator/AST/Utils.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CppSharp.AST.Extensions;
using CppSharp.Types;
@ -20,7 +19,10 @@ namespace CppSharp.AST @@ -20,7 +19,10 @@ namespace CppSharp.AST
public static bool CheckIgnoreMethod(Method method)
{
if (!method.IsGenerated) return true;
var originalClass = method.OriginalNamespace as Class;
if (!method.IsGenerated &&
(originalClass == null || method.IsInternal || !originalClass.IsInterface))
return true;
if (method.IsDependent && UsesAdditionalTypeParam(method))
return true;

11
src/Generator/Passes/MultipleInheritancePass.cs

@ -102,7 +102,8 @@ namespace CppSharp.Passes @@ -102,7 +102,8 @@ namespace CppSharp.Passes
@interface.Methods.AddRange(
from m in @base.Methods
where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && m.IsDeclared && !m.IsOperator
where !m.IsConstructor && !m.IsDestructor && !m.IsStatic &&
(m.IsGenerated || (m.IsInvalid && specialization != null)) && !m.IsOperator
select new Method(m) { Namespace = @interface, OriginalFunction = m });
@interface.Properties.AddRange(
@ -200,11 +201,11 @@ namespace CppSharp.Passes @@ -200,11 +201,11 @@ namespace CppSharp.Passes
foreach (var method in @interface.Methods.Where(
m => m.SynthKind != FunctionSynthKind.InterfaceDispose))
{
var existingImpl = @class.Methods.FirstOrDefault(
var existingImpl = @class.Methods.Find(
m => m.OriginalName == method.OriginalName &&
m.Parameters.Where(p => !p.Ignore).SequenceEqual(
method.Parameters.Where(p => !p.Ignore),
ParameterTypeComparer.Instance));
m.Parameters.Where(p => !p.Ignore).SequenceEqual(
method.Parameters.Where(p => !p.Ignore),
ParameterTypeComparer.Instance));
if (existingImpl != null)
{
if (existingImpl.OriginalFunction == null)

Loading…
Cancel
Save