Skip to content

Commit d2326a3

Browse files
committed
Added processing of type aliases.
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent 6ed05c2 commit d2326a3

File tree

8 files changed

+21
-9
lines changed

8 files changed

+21
-9
lines changed

src/AST/ASTContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public IEnumerable<Function> FindFunction(string name)
9191
}
9292

9393
/// Finds an existing typedef in the library modules.
94-
public IEnumerable<TypedefDecl> FindTypedef(string name)
94+
public IEnumerable<TypedefNameDecl> FindTypedef(string name)
9595
{
9696
return TranslationUnits.Select(module => module.FindTypedef(name))
9797
.Where(type => type != null);

src/AST/ASTVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public virtual bool VisitTemplateSpecializationType(TemplateSpecializationType t
180180
}
181181
}
182182

183-
if (template.IsDependent)
183+
if (template.IsDependent && template.Template != null)
184184
return template.Template.Visit(this);
185185

186186
var specialization = template.GetClassTemplateSpecialization();

src/AST/Namespace.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public DeclIterator<Template> Templates
3939
get { return new DeclIterator<Template>(Declarations); }
4040
}
4141

42-
public DeclIterator<TypedefDecl> Typedefs
42+
public DeclIterator<TypedefNameDecl> Typedefs
4343
{
44-
get { return new DeclIterator<TypedefDecl>(Declarations); }
44+
get { return new DeclIterator<TypedefNameDecl>(Declarations); }
4545
}
4646

4747
public DeclIterator<Variable> Variables
@@ -356,7 +356,7 @@ public ClassTemplate FindClassTemplateByUSR(string usr)
356356
.FirstOrDefault(t => t.USR == usr);
357357
}
358358

359-
public TypedefDecl FindTypedef(string name, bool createDecl = false)
359+
public TypedefNameDecl FindTypedef(string name, bool createDecl = false)
360360
{
361361
var entries = name.Split(new string[] { "::" },
362362
StringSplitOptions.RemoveEmptyEntries).ToList();
@@ -367,7 +367,7 @@ public TypedefDecl FindTypedef(string name, bool createDecl = false)
367367

368368
if (typeDef == null && createDecl)
369369
{
370-
typeDef = new TypedefDecl() { Name = name, Namespace = this };
370+
typeDef = new TypedefDecl { Name = name, Namespace = this };
371371
Typedefs.Add(typeDef);
372372
}
373373

src/Generator.Tests/QueryHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static Enumeration Enum(this ASTContext context, string name)
2525
return context.FindEnum(name).First();
2626
}
2727

28-
public static TypedefDecl Typedef(this ASTContext context, string name)
28+
public static TypedefNameDecl Typedef(this ASTContext context, string name)
2929
{
3030
return context.FindTypedef(name).First();
3131
}

src/Generator/Generators/CLI/CLIHeaders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ private void GenerateEquals(Function method, Class @class)
754754
}
755755
}
756756

757-
public bool GenerateTypedef(TypedefDecl typedef)
757+
public bool GenerateTypedef(TypedefNameDecl typedef)
758758
{
759759
if (!typedef.IsGenerated)
760760
return false;

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,7 @@ select string.Format("{0}{1} {2}", GetParameterUsage(param.Usage),
30043004

30053005
#endregion
30063006

3007-
public bool GenerateTypedef(TypedefDecl typedef)
3007+
public bool GenerateTypedef(TypedefNameDecl typedef)
30083008
{
30093009
if (!typedef.IsGenerated)
30103010
return false;

src/Parser/ASTConverter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,13 @@ public void VisitDeclContext(DeclarationContext ctx, AST.DeclarationContext _ctx
976976
_ctx.Typedefs.Add(_decl);
977977
}
978978

979+
for (uint i = 0; i < ctx.TypeAliasesCount; ++i)
980+
{
981+
var decl = ctx.getTypeAliases(i);
982+
var _decl = Visit(decl) as AST.TypeAlias;
983+
_ctx.Typedefs.Add(_decl);
984+
}
985+
979986
for (uint i = 0; i < ctx.VariablesCount; ++i)
980987
{
981988
var decl = ctx.getVariables(i);

tests/CSharp/CSharp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,3 +1025,8 @@ class DLL_API TestString
10251025
const wchar_t* unicodeConst;
10261026
wchar_t* unicode;
10271027
};
1028+
1029+
void decltypeFunctionPointer();
1030+
1031+
using funcPtr = decltype(&decltypeFunctionPointer);
1032+
void usesDecltypeFunctionPointer(funcPtr func);

0 commit comments

Comments
 (0)