Skip to content

Commit

Permalink
Adding Attr, Decl, Expr, Stmt, and Type types for the full set of exp…
Browse files Browse the repository at this point in the history
…osed kinds
  • Loading branch information
tannergooding committed Nov 18, 2019
1 parent 08c7c2d commit 24e590d
Show file tree
Hide file tree
Showing 365 changed files with 3,152 additions and 1,529 deletions.
400 changes: 290 additions & 110 deletions sources/ClangSharp/Cursors/Attrs/Attr.cs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public class InheritableAttr : Attr
{
internal InheritableAttr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
internal InheritableAttr(CXCursor handle) : base(handle)
{
if ((CX_AttrKind.CX_AttrKind_LastInheritableAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstInheritableAttr))
{
throw new ArgumentException(nameof(handle));
}
}
}
}
9 changes: 7 additions & 2 deletions sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class InheritableParamAttr : InheritableAttr
public class InheritableParamAttr : InheritableAttr
{
internal InheritableParamAttr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
internal InheritableParamAttr(CXCursor handle) : base(handle)
{
if ((CX_AttrKind.CX_AttrKind_LastInheritableParamAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr))
{
throw new ArgumentException(nameof(handle));
}
}
}
}
18 changes: 18 additions & 0 deletions sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class ParameterABIAttr : InheritableParamAttr
{
internal ParameterABIAttr(CXCursor handle) : base(handle)
{
if ((CX_AttrKind.CX_AttrKind_LastParameterABIAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstParameterABIAttr))
{
throw new ArgumentException(nameof(handle));
}
}
}
}
18 changes: 18 additions & 0 deletions sources/ClangSharp/Cursors/Attrs/StmtAttr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class StmtAttr : Attr
{
internal StmtAttr(CXCursor handle) : base(handle)
{
if ((CX_AttrKind.CX_AttrKind_LastStmtAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstStmtAttr))
{
throw new ArgumentException(nameof(handle));
}
}
}
}
18 changes: 18 additions & 0 deletions sources/ClangSharp/Cursors/Attrs/TypeAttr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class TypeAttr : Attr
{
internal TypeAttr(CXCursor handle) : base(handle)
{
if ((CX_AttrKind.CX_AttrKind_LastTypeAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstTypeAttr))
{
throw new ArgumentException(nameof(handle));
}
}
}
}
4 changes: 2 additions & 2 deletions sources/ClangSharp/Cursors/Cursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public unsafe class Cursor : IEquatable<Cursor>
private readonly Lazy<List<Cursor>> _cursorChildren;
private readonly Lazy<TranslationUnit> _translationUnit;

private protected Cursor(CXCursor handle, CXCursorKind expectedKind)
private protected Cursor(CXCursor handle, CXCursorKind expectedCursorKind)
{
if (handle.kind != expectedKind)
if (handle.kind != expectedCursorKind)
{
throw new ArgumentException(nameof(handle));
}
Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp
{
public sealed class AccessSpecDecl : Decl
{
internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier)
internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier, CX_DeclKind.CX_DeclKind_AccessSpec)
{
}
}
Expand Down
13 changes: 13 additions & 0 deletions sources/ClangSharp/Cursors/Decls/BindingDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class BindingDecl : ValueDecl
{
internal BindingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Binding)
{
}
}
}
25 changes: 25 additions & 0 deletions sources/ClangSharp/Cursors/Decls/BlockDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ClangSharp
{
public sealed class BlockDecl : Decl, IDeclContext
{
private readonly Lazy<IReadOnlyList<Decl>> _decls;

internal BlockDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Block)
{
_decls = new Lazy<IReadOnlyList<Decl>>(() => CursorChildren.OfType<Decl>().ToList());
}

public IReadOnlyList<Decl> Decls => _decls.Value;

public IDeclContext LexicalParent => LexicalDeclContext;

public IDeclContext Parent => DeclContext;
}
}
13 changes: 13 additions & 0 deletions sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class BuiltinTemplateDecl : TemplateDecl
{
internal BuiltinTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_BuiltinTemplate)
{
}
}
}
2 changes: 1 addition & 1 deletion sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp
{
public sealed class CXXConstructorDecl : CXXMethodDecl
{
internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor)
internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor, CX_DeclKind.CX_DeclKind_CXXConstructor)
{
}

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp
{
public sealed class CXXConversionDecl : CXXMethodDecl
{
internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction)
internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction, CX_DeclKind.CX_DeclKind_CXXConversion)
{
}
}
Expand Down
13 changes: 13 additions & 0 deletions sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class CXXDeductionGuideDecl : FunctionDecl
{
internal CXXDeductionGuideDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_CXXDeductionGuide)
{
}
}
}
2 changes: 1 addition & 1 deletion sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp
{
public sealed class CXXDestructorDecl : CXXMethodDecl
{
internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor)
internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor, CX_DeclKind.CX_DeclKind_CXXDestructor)
{
}
}
Expand Down
9 changes: 7 additions & 2 deletions sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using System;
using ClangSharp.Interop;

namespace ClangSharp
{
public class CXXMethodDecl : FunctionDecl
{
internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod)
internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod, CX_DeclKind.CX_DeclKind_CXXMethod)
{
}

private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
{
if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod))
{
throw new ArgumentException(nameof(handle));
}
}

public bool IsConst => Handle.CXXMethod_IsConst;
Expand Down
11 changes: 10 additions & 1 deletion sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ public class CXXRecordDecl : RecordDecl
private readonly Lazy<IReadOnlyList<CXXMethodDecl>> _methods;
private readonly Lazy<IReadOnlyList<CXXBaseSpecifier>> _vbases;

internal CXXRecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
internal CXXRecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_CXXRecord)
{
}

private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
{
if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord))
{
throw new ArgumentException(nameof(handle));
}

_bases = new Lazy<IReadOnlyList<CXXBaseSpecifier>>(() => CursorChildren.OfType<CXXBaseSpecifier>().ToList());
_ctors = new Lazy<IReadOnlyList<CXXConstructorDecl>>(() => Methods.OfType<CXXConstructorDecl>().ToList());
_destructor = new Lazy<CXXDestructorDecl>(() => Methods.OfType<CXXDestructorDecl>().SingleOrDefault());
Expand Down
25 changes: 25 additions & 0 deletions sources/ClangSharp/Cursors/Decls/CapturedDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ClangSharp
{
public sealed class CapturedDecl : Decl, IDeclContext
{
private readonly Lazy<IReadOnlyList<Decl>> _decls;

internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured)
{
_decls = new Lazy<IReadOnlyList<Decl>>(() => CursorChildren.OfType<Decl>().ToList());
}

public IReadOnlyList<Decl> Decls => _decls.Value;

public IDeclContext LexicalParent => LexicalDeclContext;

public IDeclContext Parent => DeclContext;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class ClassScopeFunctionSpecializationDecl : Decl
{
internal ClassScopeFunctionSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization)
{
}
}
}
2 changes: 1 addition & 1 deletion sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp
{
public sealed class ClassTemplateDecl : RedeclarableTemplateDecl
{
internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate)
internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate, CX_DeclKind.CX_DeclKind_ClassTemplate)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class ClassTemplatePartialSpecializationDecl : ClassTemplateSpecia
{
private readonly Lazy<IReadOnlyList<NamedDecl>> _templateParameters;

internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization)
internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization, CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization)
{
_templateParameters = new Lazy<IReadOnlyList<NamedDecl>>(() => CursorChildren.Where((cursor) => (cursor is TemplateTypeParmDecl) || (cursor is NonTypeTemplateParmDecl) || (cursor is TemplateTemplateParmDecl)).Cast<NamedDecl>().ToList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,45 @@

using ClangSharp.Interop;
using System;
using System.Collections.Generic;

namespace ClangSharp
{
public class ClassTemplateSpecializationDecl : CXXRecordDecl
{
private readonly Lazy<ClassTemplateDecl> _specializedTemplate;
private readonly Lazy<IReadOnlyList<Type>> _templateArgs;

private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
internal ClassTemplateSpecializationDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization)
{
}

private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
{
if ((CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization))
{
throw new ArgumentException(nameof(handle));
}

_specializedTemplate = new Lazy<ClassTemplateDecl>(() => TranslationUnit.GetOrCreate<ClassTemplateDecl>(Handle.SpecializedCursorTemplate));
_templateArgs = new Lazy<IReadOnlyList<Type>>(() => {
var templateArgsSize = TemplateArgsSize;
var templateArgs = new List<Type>(templateArgsSize);
for (var index = 0; index < templateArgsSize; index++)
{
var templateArg = TypeForDecl.Handle.GetTemplateArgumentAsType((uint)index);
templateArgs.Add(TranslationUnit.GetOrCreate<Type>(templateArg));
}
return templateArgs;
});
}

public IReadOnlyList<Type> TemplateArgs => _templateArgs.Value;

public int TemplateArgsSize => TypeForDecl.Handle.NumTemplateArguments;

public ClassTemplateDecl SpecializedTemplate => _specializedTemplate.Value;
}
}
13 changes: 13 additions & 0 deletions sources/ClangSharp/Cursors/Decls/ConceptDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class ConceptDecl : TemplateDecl, IMergeable<ConceptDecl>
{
internal ConceptDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Concept)
{
}
}
}
13 changes: 13 additions & 0 deletions sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.

using ClangSharp.Interop;

namespace ClangSharp
{
public sealed class ConstructorUsingShadowDecl : UsingShadowDecl
{
internal ConstructorUsingShadowDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ConstructorUsingShadow)
{
}
}
}
Loading

0 comments on commit 24e590d

Please sign in to comment.