From 76ce6c7836bde4eeed54b425d2077aeaca87ae23 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Thu, 15 Sep 2016 17:39:52 +0100 Subject: [PATCH] Added an unsupported type node to the AST. --- src/AST/ASTVisitor.cs | 11 +++++++- src/AST/CppTypePrinter.cs | 7 +++++- src/AST/Type.cs | 25 +++++++++++++++++++ .../Generators/CLI/CLITypePrinter.cs | 5 ++++ .../Generators/CSharp/CSharpTypePrinter.cs | 5 ++++ .../CheckVirtualOverrideReturnCovariance.cs | 5 ++++ 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index 6e644bce..6b4ce0ce 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace CppSharp.AST { @@ -278,6 +279,14 @@ namespace CppSharp.AST return true; } + public bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals) + { + if (!VisitType(type, quals)) + return false; + + return true; + } + #endregion #region Decl Visitors diff --git a/src/AST/CppTypePrinter.cs b/src/AST/CppTypePrinter.cs index b39a3870..4ddb3d95 100644 --- a/src/AST/CppTypePrinter.cs +++ b/src/AST/CppTypePrinter.cs @@ -227,7 +227,12 @@ namespace CppSharp.AST return quals.IsConst ? "const char*" : "char*"; throw new NotImplementedException(string.Format("Unhandled .NET type: {0}", type.Type)); - } + } + + public string VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals) + { + return string.Empty; + } public string VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals) { diff --git a/src/AST/Type.cs b/src/AST/Type.cs index 2a57313d..365c85e6 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -1054,6 +1054,30 @@ namespace CppSharp.AST } } + public class UnsupportedType : Type + { + public UnsupportedType() + { + } + + public UnsupportedType(UnsupportedType type) + : base(type) + { + } + + public string Description; + + public override T Visit(ITypeVisitor visitor, TypeQualifiers quals = new TypeQualifiers()) + { + return visitor.VisitUnsupportedType(this, quals); + } + + public override object Clone() + { + return new UnsupportedType(this); + } + } + #region Primitives /// @@ -1185,5 +1209,6 @@ namespace CppSharp.AST T VisitUnaryTransformType(UnaryTransformType unaryTransformType, TypeQualifiers quals); T VisitVectorType(VectorType vectorType, TypeQualifiers quals); T VisitCILType(CILType type, TypeQualifiers quals); + T VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals); } } diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index c89316bd..be7d32b6 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -340,6 +340,11 @@ namespace CppSharp.Generators.CLI return VisitPrimitiveType(type); } + public string VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals) + { + throw new NotImplementedException(); + } + public string VisitDeclaration(Declaration decl, TypeQualifiers quals) { return VisitDeclaration(decl); diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 0a3e38ce..bd1c56d0 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -842,6 +842,11 @@ namespace CppSharp.Generators.CSharp throw new NotImplementedException(); } + public CSharpTypePrinterResult VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals) + { + throw new NotImplementedException(); + } + public CSharpTypePrinterResult VisitFunctionTemplateSpecializationDecl(FunctionTemplateSpecialization specialization) { throw new NotImplementedException(); diff --git a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs index 5ba3ee3a..77cb8f00 100644 --- a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs +++ b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs @@ -186,6 +186,11 @@ namespace CppSharp.Passes return false; } + public bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals) + { + return false; + } + public bool VisitDeclaration(Declaration decl) { return false;