From 0c143f5b0c4471241cbed58b299c2ec3c135ceab Mon Sep 17 00:00:00 2001 From: triton Date: Tue, 22 Jan 2013 17:02:14 +0000 Subject: [PATCH] Added helper method to check and get primitive types out of pointer types. --- src/Bridge/Type.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Bridge/Type.cs b/src/Bridge/Type.cs index c4081c84..357b0f7c 100644 --- a/src/Bridge/Type.cs +++ b/src/Bridge/Type.cs @@ -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;