Browse Source

Move helper methods in Property out from class and into extension class PropertyExtensions

pull/209/head
Øystein Krog 12 years ago
parent
commit
fb127211ec
  1. 13
      src/AST/Property.cs
  2. 20
      src/AST/PropertyExtensions.cs

13
src/AST/Property.cs

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST.Extensions;
namespace CppSharp.AST namespace CppSharp.AST
{ {
@ -106,17 +105,5 @@ namespace CppSharp.AST
return visitor.VisitProperty(this); return visitor.VisitProperty(this);
} }
public bool IsInRefTypeAndBackedByValueClassField()
{
if (Field == null || ((Class) Namespace).IsRefType)
return false;
Type type;
Field.Type.IsPointerTo(out type);
type = type ?? Field.Type;
Class decl;
return type.IsTagDecl(out decl) && decl.IsValueType;
}
} }
} }

20
src/AST/PropertyExtensions.cs

@ -0,0 +1,20 @@
using CppSharp.AST.Extensions;
namespace CppSharp.AST
{
public static class PropertyExtensions
{
public static bool IsInRefTypeAndBackedByValueClassField(this Property p)
{
if (p.Field == null || ((Class) p.Namespace).IsRefType)
return false;
Type type;
p.Field.Type.IsPointerTo(out type);
type = type ?? p.Field.Type;
Class decl;
return type.IsTagDecl(out decl) && decl.IsValueType;
}
}
}
Loading…
Cancel
Save