Browse Source

Added visitor support for typedef name declarations and unify type alias and typedef implementations.

pull/818/head
Joao Matos 9 years ago
parent
commit
7daf556fb7
  1. 15
      src/AST/ASTVisitor.cs
  2. 5
      src/AST/CppTypePrinter.cs
  3. 1
      src/AST/Declaration.cs
  4. 5
      src/Generator.Tests/AST/TestAST.cs
  5. 2
      src/Generator/Generators/CSharp/CSharpSources.cs
  6. 9
      src/Generator/Generators/CodeGenerator.cs
  7. 5
      src/Generator/Generators/TypePrinter.cs

15
src/AST/ASTVisitor.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace CppSharp.AST namespace CppSharp.AST
{ {
@ -389,7 +390,7 @@ namespace CppSharp.AST
return parameter.Type.Visit(this, parameter.QualifiedType.Qualifiers); return parameter.Type.Visit(this, parameter.QualifiedType.Qualifiers);
} }
public virtual bool VisitTypedefDecl(TypedefDecl typedef) public bool VisitTypedefNameDecl(TypedefNameDecl typedef)
{ {
if (!VisitDeclaration(typedef)) if (!VisitDeclaration(typedef))
return false; return false;
@ -397,12 +398,14 @@ namespace CppSharp.AST
return typedef.Type.Visit(this, typedef.QualifiedType.Qualifiers); return typedef.Type.Visit(this, typedef.QualifiedType.Qualifiers);
} }
public bool VisitTypeAliasDecl(TypeAlias typeAlias) public virtual bool VisitTypedefDecl(TypedefDecl typedef)
{ {
if (!VisitDeclaration(typeAlias)) return VisitTypedefNameDecl(typedef);
return false; }
return typeAlias.Type.Visit(this, typeAlias.QualifiedType.Qualifiers); public bool VisitTypeAliasDecl(TypeAlias typeAlias)
{
return VisitTypedefNameDecl(typeAlias);
} }
public virtual bool VisitEnumDecl(Enumeration @enum) public virtual bool VisitEnumDecl(Enumeration @enum)

5
src/AST/CppTypePrinter.cs

@ -442,6 +442,11 @@ namespace CppSharp.AST
nonTypeTemplateParameter.DefaultArgument.String); nonTypeTemplateParameter.DefaultArgument.String);
} }
public string VisitTypedefNameDecl(TypedefNameDecl typedef)
{
throw new NotImplementedException();
}
public virtual string VisitTypeAliasTemplateDecl(TypeAliasTemplate typeAliasTemplate) public virtual string VisitTypeAliasTemplateDecl(TypeAliasTemplate typeAliasTemplate)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

1
src/AST/Declaration.cs

@ -372,6 +372,7 @@ namespace CppSharp.AST
T VisitFunctionDecl(Function function); T VisitFunctionDecl(Function function);
T VisitMethodDecl(Method method); T VisitMethodDecl(Method method);
T VisitParameterDecl(Parameter parameter); T VisitParameterDecl(Parameter parameter);
T VisitTypedefNameDecl(TypedefNameDecl typedef);
T VisitTypedefDecl(TypedefDecl typedef); T VisitTypedefDecl(TypedefDecl typedef);
T VisitTypeAliasDecl(TypeAlias typeAlias); T VisitTypeAliasDecl(TypeAlias typeAlias);
T VisitEnumDecl(Enumeration @enum); T VisitEnumDecl(Enumeration @enum);

5
src/Generator.Tests/AST/TestAST.cs

@ -206,6 +206,11 @@ namespace CppSharp.Generator.Tests.AST
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public bool VisitTypedefNameDecl(TypedefNameDecl typedef)
{
throw new NotImplementedException();
}
} }
#endregion #endregion

2
src/Generator/Generators/CSharp/CSharpSources.cs

@ -2999,7 +2999,7 @@ namespace CppSharp.Generators.CSharp
#endregion #endregion
public override bool VisitTypedefDecl(TypedefDecl typedef) public override bool VisitTypedefNameDecl(TypedefNameDecl typedef)
{ {
if (!typedef.IsGenerated) if (!typedef.IsGenerated)
return false; return false;

9
src/Generator/Generators/CodeGenerator.cs

@ -90,14 +90,19 @@ namespace CppSharp.Generators
throw new NotImplementedException(); throw new NotImplementedException();
} }
public virtual bool VisitTypedefDecl(TypedefDecl typedef) public virtual bool VisitTypedefNameDecl(TypedefNameDecl typedef)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public virtual bool VisitTypedefDecl(TypedefDecl typedef)
{
return VisitTypedefNameDecl(typedef);
}
public virtual bool VisitTypeAliasDecl(TypeAlias typeAlias) public virtual bool VisitTypeAliasDecl(TypeAlias typeAlias)
{ {
throw new NotImplementedException(); return VisitTypedefNameDecl(typeAlias);
} }
public virtual bool VisitEnumDecl(Enumeration @enum) public virtual bool VisitEnumDecl(Enumeration @enum)

5
src/Generator/Generators/TypePrinter.cs

@ -274,6 +274,11 @@ namespace CppSharp.Generators
throw new NotImplementedException(); throw new NotImplementedException();
} }
public TypePrinterResult VisitTypedefNameDecl(TypedefNameDecl typedef)
{
throw new NotImplementedException();
}
public virtual TypePrinterResult VisitTypedefType(TypedefType typedef, public virtual TypePrinterResult VisitTypedefType(TypedefType typedef,
TypeQualifiers quals) TypeQualifiers quals)
{ {

Loading…
Cancel
Save