Browse Source

Added processing of type aliases.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/696/head
Dimitar Dobrev 9 years ago
parent
commit
d2326a3883
  1. 2
      src/AST/ASTContext.cs
  2. 2
      src/AST/ASTVisitor.cs
  3. 8
      src/AST/Namespace.cs
  4. 2
      src/Generator.Tests/QueryHelpers.cs
  5. 2
      src/Generator/Generators/CLI/CLIHeaders.cs
  6. 2
      src/Generator/Generators/CSharp/CSharpSources.cs
  7. 7
      src/Parser/ASTConverter.cs
  8. 5
      tests/CSharp/CSharp.h

2
src/AST/ASTContext.cs

@ -91,7 +91,7 @@ namespace CppSharp.AST @@ -91,7 +91,7 @@ namespace CppSharp.AST
}
/// Finds an existing typedef in the library modules.
public IEnumerable<TypedefDecl> FindTypedef(string name)
public IEnumerable<TypedefNameDecl> FindTypedef(string name)
{
return TranslationUnits.Select(module => module.FindTypedef(name))
.Where(type => type != null);

2
src/AST/ASTVisitor.cs

@ -180,7 +180,7 @@ namespace CppSharp.AST @@ -180,7 +180,7 @@ namespace CppSharp.AST
}
}
if (template.IsDependent)
if (template.IsDependent && template.Template != null)
return template.Template.Visit(this);
var specialization = template.GetClassTemplateSpecialization();

8
src/AST/Namespace.cs

@ -39,9 +39,9 @@ namespace CppSharp.AST @@ -39,9 +39,9 @@ namespace CppSharp.AST
get { return new DeclIterator<Template>(Declarations); }
}
public DeclIterator<TypedefDecl> Typedefs
public DeclIterator<TypedefNameDecl> Typedefs
{
get { return new DeclIterator<TypedefDecl>(Declarations); }
get { return new DeclIterator<TypedefNameDecl>(Declarations); }
}
public DeclIterator<Variable> Variables
@ -356,7 +356,7 @@ namespace CppSharp.AST @@ -356,7 +356,7 @@ namespace CppSharp.AST
.FirstOrDefault(t => t.USR == usr);
}
public TypedefDecl FindTypedef(string name, bool createDecl = false)
public TypedefNameDecl FindTypedef(string name, bool createDecl = false)
{
var entries = name.Split(new string[] { "::" },
StringSplitOptions.RemoveEmptyEntries).ToList();
@ -367,7 +367,7 @@ namespace CppSharp.AST @@ -367,7 +367,7 @@ namespace CppSharp.AST
if (typeDef == null && createDecl)
{
typeDef = new TypedefDecl() { Name = name, Namespace = this };
typeDef = new TypedefDecl { Name = name, Namespace = this };
Typedefs.Add(typeDef);
}

2
src/Generator.Tests/QueryHelpers.cs

@ -25,7 +25,7 @@ namespace CppSharp.Generator.Tests @@ -25,7 +25,7 @@ namespace CppSharp.Generator.Tests
return context.FindEnum(name).First();
}
public static TypedefDecl Typedef(this ASTContext context, string name)
public static TypedefNameDecl Typedef(this ASTContext context, string name)
{
return context.FindTypedef(name).First();
}

2
src/Generator/Generators/CLI/CLIHeaders.cs

@ -754,7 +754,7 @@ namespace CppSharp.Generators.CLI @@ -754,7 +754,7 @@ namespace CppSharp.Generators.CLI
}
}
public bool GenerateTypedef(TypedefDecl typedef)
public bool GenerateTypedef(TypedefNameDecl typedef)
{
if (!typedef.IsGenerated)
return false;

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

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

7
src/Parser/ASTConverter.cs

@ -976,6 +976,13 @@ namespace CppSharp @@ -976,6 +976,13 @@ namespace CppSharp
_ctx.Typedefs.Add(_decl);
}
for (uint i = 0; i < ctx.TypeAliasesCount; ++i)
{
var decl = ctx.getTypeAliases(i);
var _decl = Visit(decl) as AST.TypeAlias;
_ctx.Typedefs.Add(_decl);
}
for (uint i = 0; i < ctx.VariablesCount; ++i)
{
var decl = ctx.getVariables(i);

5
tests/CSharp/CSharp.h

@ -1025,3 +1025,8 @@ public: @@ -1025,3 +1025,8 @@ public:
const wchar_t* unicodeConst;
wchar_t* unicode;
};
void decltypeFunctionPointer();
using funcPtr = decltype(&decltypeFunctionPointer);
void usesDecltypeFunctionPointer(funcPtr func);

Loading…
Cancel
Save