From 1d2a572836fad75060f65d8e676b4dc804a0f009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Matos?= Date: Tue, 1 Mar 2016 18:14:42 +0000 Subject: [PATCH] Extracted array type ignore code from CheckIgnoredDecls to TypeIgnoreChecker. --- src/Generator/Passes/CheckIgnoredDecls.cs | 12 ---------- src/Generator/Types/Types.cs | 27 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 25e76cdb..037f08a5 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -341,18 +341,6 @@ namespace CppSharp.Passes return true; } - Class @class; - var arrayType = type as ArrayType; - PrimitiveType primitive; - if (arrayType != null && arrayType.SizeType == ArrayType.ArraySize.Constant && - !arrayType.Type.IsPrimitiveType(out primitive) && - !arrayType.Type.Desugar().IsPointerToPrimitiveType() && - !(arrayType.Type.Desugar().TryGetClass(out @class) && @class.IsRefType)) - { - msg = "unsupported"; - return true; - } - msg = null; return false; } diff --git a/src/Generator/Types/Types.cs b/src/Generator/Types/Types.cs index 0bd40b49..1000198d 100644 --- a/src/Generator/Types/Types.cs +++ b/src/Generator/Types/Types.cs @@ -109,6 +109,33 @@ namespace CppSharp Ignore(); return base.VisitTemplateSpecializationType(template, quals); } + + public override bool VisitArrayType(ArrayType array, TypeQualifiers quals) + { + TypeMap typeMap; + if (TypeMapDatabase.FindTypeMap(array, out typeMap) && typeMap.IsIgnored) + { + Ignore(); + return false; + } + + if (array.SizeType != ArrayType.ArraySize.Constant) + return true; + + var arrayElemType = array.Type.Desugar(); + + Class @class; + if (arrayElemType.TryGetClass(out @class) && @class.IsRefType) + return true; + + PrimitiveType primitive; + if (arrayElemType.IsPrimitiveType(out primitive) || + arrayElemType.IsPointerToPrimitiveType()) + return true; + + Ignore(); + return false; + } } }