diff --git a/src/AST/Class.cs b/src/AST/Class.cs index a9601dd7..fbb874b7 100644 --- a/src/AST/Class.cs +++ b/src/AST/Class.cs @@ -245,6 +245,24 @@ namespace CppSharp.AST select rootBaseProperty).FirstOrDefault(); } + public Method GetMethodByName(string methodName) + { + var method = Methods.FirstOrDefault(m => m.Name == methodName); + if (method != null) + return method; + method = Methods.FirstOrDefault(m => m.Name == methodName); + if (method != null) + return method; + Declaration decl; + foreach (BaseClassSpecifier @base in Bases.Where(b => b.Type.IsTagDecl(out decl))) + { + method = @base.Class.GetMethodByName(methodName); + if (method != null) + return method; + } + return null; + } + public override T Visit(IDeclVisitor visitor) { return visitor.VisitClassDecl(this); diff --git a/src/AST/Function.cs b/src/AST/Function.cs index 60ef944c..32d2ded4 100644 --- a/src/AST/Function.cs +++ b/src/AST/Function.cs @@ -87,6 +87,7 @@ namespace CppSharp.AST CallingConvention = CallingConvention.Default; IsVariadic = false; IsInline = false; + Signature = string.Empty; } public Function(Function function) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 4bb0ca2d..8ebd8e68 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1324,13 +1324,15 @@ namespace CppSharp.Generators.CSharp if (hasReturn) Write("var _ret = "); - if (method.IsGenerated) + // HACK: because of the non-shared v-table entries bug we must look for the real method by name + Method m = ((Class) method.Namespace).GetMethodByName(method.Name); + if (m.IsGenerated) { WriteLine("target.{0}({1});", SafeIdentifier(method.Name), string.Join(", ", marshals)); } else { - InvokeProperty(method, marshals); + InvokeProperty(m, marshals); } if (hasReturn)