Browse Source

Fix forward include collector to consider value class semantics in function returns.

pull/1547/head
Joao Matos 5 years ago committed by João Matos
parent
commit
fc2a938713
  1. 12
      src/Generator/AST/ASTRecord.cs
  2. 2
      src/Generator/Generators/CLI/CLITypeReferences.cs

12
src/Generator/AST/ASTRecord.cs

@ -163,6 +163,18 @@ namespace CppSharp.Generators.AST
return false; return false;
} }
public static bool IsClassReturn(this ASTRecord record)
{
var ancestors = new Stack<object>();
if(!record.GetAncestors<Function>(ref ancestors))
return false;
var function = (Function)ancestors.Pop();
var tagType = function.ReturnType.Type.Desugar() as TagType;
return tagType?.Declaration is Class;
}
public static bool IsDelegate(this ASTRecord record) public static bool IsDelegate(this ASTRecord record)
{ {
var typedef = record.Object as TypedefDecl; var typedef = record.Object as TypedefDecl;

2
src/Generator/Generators/CLI/CLITypeReferences.cs

@ -164,7 +164,7 @@ namespace CppSharp.Generators.CLI
return false; return false;
return record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate() return record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate()
|| record.IsEnumNestedInClass(); || record.IsEnumNestedInClass() || record.IsClassReturn();
} }
public override bool VisitDeclaration(Declaration decl) public override bool VisitDeclaration(Declaration decl)

Loading…
Cancel
Save