From 66363787b47e0a792867dfb24b0d753a82e68eee Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 29 Jan 2014 23:32:09 +0200 Subject: [PATCH] Stubbed support for pack expansions to avoid crashes in certain cases such as variadic templates. Signed-off-by: Dimitar Dobrev --- src/AST/ASTVisitor.cs | 5 +++++ src/AST/Type.cs | 9 +++++++++ src/Generator/Generators/CLI/CLITypePrinter.cs | 5 +++++ src/Generator/Generators/CSharp/CSharpTypePrinter.cs | 5 +++++ .../Passes/CheckVirtualOverrideReturnCovariance.cs | 5 +++++ src/Generator/Types/CppTypePrinter.cs | 5 +++++ src/Parser/Parser.cpp | 5 +++-- 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index e2d3e1f3..a7387c5a 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -217,6 +217,11 @@ namespace CppSharp.AST return true; } + public bool VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals) + { + return true; + } + public virtual bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals) { return true; diff --git a/src/AST/Type.cs b/src/AST/Type.cs index f41b3ca1..b81d6de0 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -786,6 +786,14 @@ namespace CppSharp.AST } } + public class PackExpansionType : Type + { + public override T Visit(ITypeVisitor visitor, TypeQualifiers quals = new TypeQualifiers()) + { + return visitor.VisitPackExpansionType(this, quals); + } + } + #region Primitives /// @@ -891,6 +899,7 @@ namespace CppSharp.AST TypeQualifiers quals); T VisitDependentNameType(DependentNameType dependent, TypeQualifiers quals); + T VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals); T VisitCILType(CILType type, TypeQualifiers quals); } } \ No newline at end of file diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index 5b6815b1..bb782510 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -259,6 +259,11 @@ namespace CppSharp.Generators.CLI throw new NotImplementedException(); } + public string VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals) + { + return string.Empty; + } + public string VisitCILType(CILType type, TypeQualifiers quals) { return type.Type.FullName.Replace(".", "::") + "^"; diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index fb4487a9..2c839dde 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -348,6 +348,11 @@ namespace CppSharp.Generators.CSharp throw new NotImplementedException(); } + public CSharpTypePrinterResult VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals) + { + return string.Empty; + } + public CSharpTypePrinterResult VisitCILType(CILType type, TypeQualifiers quals) { return type.Type.FullName; diff --git a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs index aa0f8a89..05ad5520 100644 --- a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs +++ b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs @@ -151,6 +151,11 @@ namespace CppSharp.Passes return false; } + public bool VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals) + { + return true; + } + public bool VisitCILType(CILType type, TypeQualifiers quals) { return false; diff --git a/src/Generator/Types/CppTypePrinter.cs b/src/Generator/Types/CppTypePrinter.cs index f6845f00..40f00b82 100644 --- a/src/Generator/Types/CppTypePrinter.cs +++ b/src/Generator/Types/CppTypePrinter.cs @@ -178,6 +178,11 @@ namespace CppSharp.Types throw new System.NotImplementedException(); } + public string VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals) + { + return string.Empty; + } + public string VisitCILType(CILType type, TypeQualifiers quals) { return string.Empty; diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index bc0e1ec8..e4a5d772 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -1653,8 +1653,9 @@ CppSharp::AST::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* } case Type::PackExpansion: { - // Ignored. - return nullptr; + // TODO: stubbed + Ty = gcnew CppSharp::AST::PackExpansionType(); + break; } default: {