Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Preprocessing Wrappers * Change structure layout.
- Loading branch information
1 parent
57c618b
commit 6e994d7
Showing
6 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
sources/ClangSharp/Cursors/Preprocessings/InclusionDirective.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using ClangSharp.Interop; | ||
|
||
namespace ClangSharp | ||
{ | ||
public sealed class InclusionDirective : PreprocessingDirective | ||
{ | ||
internal InclusionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InclusionDirective) | ||
{ | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/ClangSharp/Cursors/Preprocessings/MacroDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using ClangSharp.Interop; | ||
|
||
namespace ClangSharp | ||
{ | ||
public sealed class MacroDefinitionRecord : PreprocessingDirective | ||
{ | ||
internal MacroDefinitionRecord(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroDefinition) | ||
{ | ||
} | ||
|
||
public bool IsMacroFunctionLike => Handle.IsMacroFunctionLike; | ||
|
||
public bool IsMacroBuiltIn => Handle.IsMacroBuiltIn; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
sources/ClangSharp/Cursors/Preprocessings/MacroExpansion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using ClangSharp.Interop; | ||
|
||
namespace ClangSharp | ||
{ | ||
public sealed class MacroExpansion : PreprocessedEntity | ||
{ | ||
internal MacroExpansion(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroExpansion) | ||
{ | ||
} | ||
|
||
public bool IsMacroBuiltIn => Handle.IsMacroBuiltIn; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using ClangSharp.Interop; | ||
|
||
namespace ClangSharp | ||
{ | ||
public class PreprocessedEntity : Cursor | ||
{ | ||
private protected PreprocessedEntity(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) | ||
{ | ||
} | ||
|
||
internal static new PreprocessedEntity Create(CXCursor handle) | ||
{ | ||
PreprocessedEntity result; | ||
|
||
switch (handle.Kind) | ||
{ | ||
case CXCursorKind.CXCursor_MacroDefinition: | ||
{ | ||
result = new MacroDefinitionRecord(handle); | ||
break; | ||
} | ||
|
||
case CXCursorKind.CXCursor_MacroExpansion: | ||
{ | ||
result = new MacroExpansion(handle); | ||
break; | ||
} | ||
|
||
case CXCursorKind.CXCursor_PreprocessingDirective: | ||
{ | ||
result = new PreprocessingDirective(handle); | ||
break; | ||
} | ||
|
||
case CXCursorKind.CXCursor_InclusionDirective: | ||
{ | ||
result = new InclusionDirective(handle); | ||
break; | ||
} | ||
|
||
default: | ||
{ | ||
Debug.WriteLine($"Unhandled preprocessing kind: {handle.KindSpelling}."); | ||
Debugger.Break(); | ||
|
||
result = new PreprocessedEntity(handle, handle.Kind); | ||
break; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using ClangSharp.Interop; | ||
|
||
namespace ClangSharp | ||
{ | ||
public class PreprocessingDirective : PreprocessedEntity | ||
{ | ||
internal PreprocessingDirective(CXCursor handle) : this(handle, CXCursorKind.CXCursor_PreprocessingDirective) | ||
{ | ||
} | ||
private protected PreprocessingDirective(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) | ||
{ | ||
} | ||
} | ||
} |