Browse Source

Add TypeQualifiersMode to Type and implement in C++ type printer.

pull/1514/head
Joao Matos 5 years ago committed by João Matos
parent
commit
5e74bc351f
  1. 13
      src/AST/Type.cs
  2. 13
      src/Generator/Generators/C/CppTypePrinter.cs

13
src/AST/Type.cs

@ -36,6 +36,12 @@ namespace CppSharp.AST @@ -36,6 +36,12 @@ namespace CppSharp.AST
public abstract object Clone();
}
public enum TypeQualifiersMode : byte
{
Default,
Native
}
/// <summary>
/// Represents C++ type qualifiers.
/// </summary>
@ -44,10 +50,11 @@ namespace CppSharp.AST @@ -44,10 +50,11 @@ namespace CppSharp.AST
public bool IsConst;
public bool IsVolatile;
public bool IsRestrict;
public TypeQualifiersMode Mode;
public override int GetHashCode() =>
IsConst.GetHashCode() ^ IsVolatile.GetHashCode() ^
IsRestrict.GetHashCode();
IsRestrict.GetHashCode() ^ Mode.GetHashCode();
}
/// <summary>
@ -68,8 +75,8 @@ namespace CppSharp.AST @@ -68,8 +75,8 @@ namespace CppSharp.AST
Qualifiers = qualifiers;
}
public Type Type { get; set; }
public TypeQualifiers Qualifiers { get; set; }
public Type Type;
public TypeQualifiers Qualifiers;
public T Visit<T>(ITypeVisitor<T> visitor)
{

13
src/Generator/Generators/C/CppTypePrinter.cs

@ -433,6 +433,19 @@ namespace CppSharp.Generators.C @@ -433,6 +433,19 @@ namespace CppSharp.Generators.C
throw new NotImplementedException();
}
public override TypePrinterResult VisitQualifiedType(QualifiedType type)
{
if (type.Qualifiers.Mode == TypeQualifiersMode.Native)
{
PushContext(TypePrinterContextKind.Native);
var result = base.VisitQualifiedType(type);
PopContext();
return result;
}
return base.VisitQualifiedType(type);
}
public TypePrinterResult GetDeclName(Declaration declaration,
TypePrintScopeKind scope)
{

Loading…
Cancel
Save