diff --git a/src/Bridge/Type.cs b/src/Bridge/Type.cs index f3fe41a0..8dcbaa8f 100644 --- a/src/Bridge/Type.cs +++ b/src/Bridge/Type.cs @@ -13,8 +13,7 @@ namespace Cxxi { } - public bool IsPrimitiveType(out PrimitiveType primitive, - bool walkTypedefs = false) + public bool IsPrimitiveType(out PrimitiveType primitive) { var builtin = this as BuiltinType; if (builtin != null) @@ -23,22 +22,14 @@ namespace Cxxi 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) + public bool IsPrimitiveType(PrimitiveType primitive) { PrimitiveType type; - if (!IsPrimitiveType(out type, walkTypedefs)) + if (!IsPrimitiveType(out type)) return false; return primitive == type; diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index 063e2662..7a3925a8 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -43,7 +43,7 @@ namespace Cxxi.Generators.CLI { var pointee = pointer.Pointee; - if (pointee.IsPrimitiveType(PrimitiveType.Void, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(PrimitiveType.Void)) { Context.Return.Write("IntPtr({0})", Context.ReturnVarName); return true; @@ -57,7 +57,7 @@ namespace Cxxi.Generators.CLI } PrimitiveType primitive; - if (pointee.IsPrimitiveType(out primitive, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(out primitive)) { Context.Return.Write("IntPtr({0})", Context.ReturnVarName); return true; @@ -325,11 +325,9 @@ namespace Cxxi.Generators.CLI { var pointee = pointer.Pointee; - var isVoidPtr = pointee.IsPrimitiveType(PrimitiveType.Void, - walkTypedefs: true); + var isVoidPtr = pointee.Desugar().IsPrimitiveType(PrimitiveType.Void); - var isUInt8Ptr = pointee.IsPrimitiveType(PrimitiveType.UInt8, - walkTypedefs: true); + var isUInt8Ptr = pointee.Desugar().IsPrimitiveType(PrimitiveType.UInt8); if (isVoidPtr || isUInt8Ptr) { @@ -416,7 +414,7 @@ namespace Cxxi.Generators.CLI } PrimitiveType primitive; - if (decl.Type.IsPrimitiveType(out primitive, walkTypedefs: true)) + if (decl.Type.Desugar().IsPrimitiveType(out primitive)) { Context.Return.Write("({0})", typedef.Declaration.Name); } diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index ad1a2292..62f2f596 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -131,7 +131,7 @@ namespace Cxxi.Generators.CLI } PrimitiveType primitive; - if (pointee.IsPrimitiveType(out primitive, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(out primitive)) { return "System::IntPtr"; } diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 4decb793..db243629 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -68,7 +68,7 @@ namespace Cxxi.Generators.CSharp { var pointee = pointer.Pointee; - if (pointee.IsPrimitiveType(PrimitiveType.Void, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(PrimitiveType.Void)) { Context.Return.Write("new IntPtr({0})", Context.ReturnVarName); return true; @@ -82,7 +82,7 @@ namespace Cxxi.Generators.CSharp } PrimitiveType primitive; - if (pointee.IsPrimitiveType(out primitive, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(out primitive)) { Context.Return.Write("new IntPtr({0})", Context.ReturnVarName); return true; @@ -273,11 +273,9 @@ namespace Cxxi.Generators.CSharp { var pointee = pointer.Pointee; - var isVoidPtr = pointee.IsPrimitiveType(PrimitiveType.Void, - walkTypedefs: true); + var isVoidPtr = pointee.Desugar().IsPrimitiveType(PrimitiveType.Void); - var isUInt8Ptr = pointee.IsPrimitiveType(PrimitiveType.UInt8, - walkTypedefs: true); + var isUInt8Ptr = pointee.Desugar().IsPrimitiveType(PrimitiveType.UInt8); if (isVoidPtr || isUInt8Ptr) { @@ -373,7 +371,7 @@ namespace Cxxi.Generators.CSharp } PrimitiveType primitive; - if (decl.Type.IsPrimitiveType(out primitive, walkTypedefs: true)) + if (decl.Type.Desugar().IsPrimitiveType(out primitive)) { Context.Return.Write("({0})", typedef.Declaration.Name); } diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 166f6c45..e3723abf 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -109,8 +109,8 @@ namespace Cxxi.Generators.CSharp var isManagedContext = ContextKind == CSharpTypePrinterContextKind.Managed; - if (pointee.IsPrimitiveType(PrimitiveType.Void, walkTypedefs: true) || - pointee.IsPrimitiveType(PrimitiveType.UInt8, walkTypedefs: true)) + if (pointee.Desugar().IsPrimitiveType(PrimitiveType.Void) || + pointee.Desugar().IsPrimitiveType(PrimitiveType.UInt8)) { return isManagedContext ? "string" : "System.IntPtr"; }