Browse Source

Added support for decayed types which represent a pointer type decayed from an array or function type which have been added to latest Clang.

pull/12/merge
triton 12 years ago
parent
commit
acc5885594
  1. 8
      src/Bridge/ASTVisitor.cs
  2. 21
      src/Bridge/Type.cs
  3. 5
      src/Generator/Generators/CLI/CLITypePrinter.cs
  4. 5
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  5. 5
      src/Generator/Types/CppTypePrinter.cs
  6. 12
      src/Parser/Parser.cpp

8
src/Bridge/ASTVisitor.cs

@ -137,6 +137,14 @@ namespace CppSharp @@ -137,6 +137,14 @@ namespace CppSharp
return typedef.Declaration.Visit(this);
}
public bool VisitDecayedType(DecayedType decayed, TypeQualifiers quals)
{
if (!VisitType(decayed, quals))
return false;
return decayed.Decayed.Visit(this);
}
public virtual bool VisitTemplateSpecializationType(TemplateSpecializationType template,
TypeQualifiers quals)
{

21
src/Bridge/Type.cs

@ -311,6 +311,26 @@ namespace CppSharp @@ -311,6 +311,26 @@ namespace CppSharp
}
}
/// <summary>
/// Represents a pointer type decayed from an array or function type.
/// </summary>
public class DecayedType : Type
{
public DecayedType()
{
}
public QualifiedType Decayed;
public QualifiedType Original;
public QualifiedType Pointee;
public override T Visit<T>(ITypeVisitor<T> visitor, TypeQualifiers quals)
{
return visitor.VisitDecayedType(this, quals);
}
}
/// <summary>
/// Represents a template argument within a class template specialization.
/// </summary>
@ -515,6 +535,7 @@ namespace CppSharp @@ -515,6 +535,7 @@ namespace CppSharp
T VisitMemberPointerType(MemberPointerType member, TypeQualifiers quals);
T VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals);
T VisitTypedefType(TypedefType typedef, TypeQualifiers quals);
T VisitDecayedType(DecayedType decayed, TypeQualifiers quals);
T VisitTemplateSpecializationType(TemplateSpecializationType template,
TypeQualifiers quals);
T VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals);

5
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -194,6 +194,11 @@ namespace CppSharp.Generators.CLI @@ -194,6 +194,11 @@ namespace CppSharp.Generators.CLI
return decl.Type.Visit(this);
}
public string VisitDecayedType(DecayedType decayed, TypeQualifiers quals)
{
return decayed.Decayed.Visit(this);
}
public string VisitTemplateSpecializationType(TemplateSpecializationType template,
TypeQualifiers quals)
{

5
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -231,6 +231,11 @@ namespace CppSharp.Generators.CSharp @@ -231,6 +231,11 @@ namespace CppSharp.Generators.CSharp
return decl.Type.Visit(this);
}
public CSharpTypePrinterResult VisitDecayedType(DecayedType decayed, TypeQualifiers quals)
{
return decayed.Decayed.Visit(this);
}
public CSharpTypePrinterResult VisitTemplateSpecializationType(
TemplateSpecializationType template, TypeQualifiers quals)
{

5
src/Generator/Types/CppTypePrinter.cs

@ -94,6 +94,11 @@ namespace CppSharp.Types @@ -94,6 +94,11 @@ namespace CppSharp.Types
return "::" + typedef.Declaration.QualifiedOriginalName;
}
public string VisitDecayedType(DecayedType decayed, TypeQualifiers quals)
{
return decayed.Decayed.Visit(this);
}
public string VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals)
{
var decl = template.Template.TemplatedDecl;

12
src/Parser/Parser.cpp

@ -896,6 +896,18 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -896,6 +896,18 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
return Type;
}
case Type::Decayed:
{
auto DT = Type->getAs<clang::DecayedType>();
auto Next = TL->getNextTypeLoc();
auto Type = gcnew CppSharp::DecayedType();
Type->Decayed = GetQualifiedType(DT->getDecayedType(), WalkType(DT->getDecayedType(), &Next));
Type->Original = GetQualifiedType(DT->getOriginalType(), WalkType(DT->getOriginalType(), &Next));
Type->Pointee = GetQualifiedType(DT->getPointeeType(), WalkType(DT->getPointeeType(), &Next));
return Type;
}
case Type::Elaborated:
{
auto ET = Type->getAs<clang::ElaboratedType>();

Loading…
Cancel
Save