-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic support for reading documentation
- Loading branch information
1 parent
38ef66d
commit 2eaa12e
Showing
3 changed files
with
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System; | ||
|
||
namespace Core.Clang | ||
{ | ||
public sealed unsafe class Comment | ||
{ | ||
internal CXComment Struct { get; } | ||
|
||
private Comment(CXComment cxComment) | ||
{ | ||
Struct = cxComment; | ||
} | ||
|
||
internal static Comment Create(CXComment cxComment) | ||
{ | ||
return new Comment(cxComment); | ||
} | ||
|
||
public CommentKind Kind | ||
{ | ||
get | ||
{ | ||
return (CommentKind)NativeMethods.clang_Comment_getKind(Struct); | ||
} | ||
} | ||
|
||
public int GetNumChildren() | ||
{ | ||
return (int)NativeMethods.clang_Comment_getNumChildren(Struct); | ||
} | ||
|
||
public Comment GetChild(int index) | ||
{ | ||
CXComment cxComment = NativeMethods.clang_Comment_getChild(Struct, (uint)index); | ||
return Create(cxComment); | ||
} | ||
|
||
public string GetText() | ||
{ | ||
if (this.Kind != CommentKind.Text) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
CXString cxString = NativeMethods.clang_TextComment_getText(Struct); | ||
using (var str = new String(cxString)) | ||
{ | ||
return str.ToString(); | ||
} | ||
} | ||
|
||
public string GetParamName() | ||
{ | ||
if (this.Kind != CommentKind.ParamCommand) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
CXString cxString = NativeMethods.clang_ParamCommandComment_getParamName(Struct); | ||
using (var str = new String(cxString)) | ||
{ | ||
return str.ToString(); | ||
} | ||
} | ||
|
||
public string GetCommandName() | ||
{ | ||
if(this.Kind != CommentKind.BlockCommand) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
CXString cxString = NativeMethods.clang_BlockCommandComment_getCommandName(Struct); | ||
using (var str = new String(cxString)) | ||
{ | ||
return str.ToString(); | ||
} | ||
} | ||
} | ||
} |
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,20 @@ | ||
namespace Core.Clang | ||
{ | ||
[EnumMapping(typeof(CXCommentKind), Prefix = "CXComment_")] | ||
public enum CommentKind | ||
{ | ||
Null, | ||
Text, | ||
InlineCommand, | ||
HTMLStartTag, | ||
HTMLEndTag, | ||
Paragraph, | ||
BlockCommand, | ||
ParamCommand, | ||
TParamCommand, | ||
VerbatimBlockCommand, | ||
VerbatimBlockLine, | ||
VerbatimLine, | ||
FullComment, | ||
} | ||
} |
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