Browse Source

Changed the check whether to invoke a property in the v-tables to work around the non-shared methods in v-tables. Set the function signature to an empty string rather that null by default.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/105/head
Dimitar Dobrev 12 years ago
parent
commit
0e37a62726
  1. 18
      src/AST/Class.cs
  2. 1
      src/AST/Function.cs
  3. 6
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

18
src/AST/Class.cs

@ -245,6 +245,24 @@ namespace CppSharp.AST @@ -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<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitClassDecl(this);

1
src/AST/Function.cs

@ -87,6 +87,7 @@ namespace CppSharp.AST @@ -87,6 +87,7 @@ namespace CppSharp.AST
CallingConvention = CallingConvention.Default;
IsVariadic = false;
IsInline = false;
Signature = string.Empty;
}
public Function(Function function)

6
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1319,13 +1319,15 @@ namespace CppSharp.Generators.CSharp @@ -1319,13 +1319,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)

Loading…
Cancel
Save