Browse Source

Added helper method to check and get primitive types out of pointer types.

pull/1/head
triton 13 years ago
parent
commit
0c143f5b0c
  1. 27
      src/Bridge/Type.cs

27
src/Bridge/Type.cs

@ -13,14 +13,37 @@ namespace Cxxi @@ -13,14 +13,37 @@ namespace Cxxi
{
}
public bool IsPrimitiveType(PrimitiveType primitive)
public bool IsPrimitiveType(out PrimitiveType primitive,
bool walkTypedefs = false)
{
var builtin = this as BuiltinType;
if (builtin != null)
return builtin.Type == primitive;
{
primitive = builtin.Type;
return true;
}
if (walkTypedefs)
{
var typedef = this as TypedefType;
if (typedef != null)
return typedef.Declaration.Type.IsPrimitiveType(out primitive, true);
}
primitive = PrimitiveType.Null;
return false;
}
public bool IsPrimitiveType(PrimitiveType primitive,
bool walkTypedefs = false)
{
PrimitiveType type;
if (!IsPrimitiveType(out type, walkTypedefs))
return false;
return primitive == type;
}
public bool IsEnumType()
{
var tag = this as TagType;

Loading…
Cancel
Save