Browse Source

Fixed a crash when a comment contains regular text wrapped in <>.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/985/head
Dimitar Dobrev 8 years ago
parent
commit
0c78ba29f7
  1. 30
      src/Generator/Passes/CleanCommentsPass.cs
  2. 5
      tests/Native/AST.h

30
src/Generator/Passes/CleanCommentsPass.cs

@ -57,29 +57,23 @@ namespace CppSharp.Passes @@ -57,29 +57,23 @@ namespace CppSharp.Passes
{
for (int i = 0; i < comment.Content.Count; i++)
{
if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment)
if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment &&
i + 1 < comment.Content.Count &&
comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment)
{
if (i + 1 < comment.Content.Count &&
comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment)
{
TextComment com = (TextComment) comment.Content[i + 1];
com.Text = Helpers.RegexCommentCommandLeftover.Replace(com.Text, string.Empty);
}
var textComment = (TextComment) comment.Content[i + 1];
textComment.Text = Helpers.RegexCommentCommandLeftover.Replace(
textComment.Text, string.Empty);
}
}
bool tag = false;
foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment))
{
TextComment com = (TextComment) item;
if (Helpers.RegexTag.IsMatch(com.Text))
tag = true;
else if (tag)
com.Text = com.Text.Substring(1);
if (com.Text.StartsWith("<", StringComparison.Ordinal))
com.Text = $"{com.Text}{">"}";
else if (com.Text.StartsWith(">", StringComparison.Ordinal))
com.Text = com.Text.Substring(1);
var textComment = (TextComment) item;
if (textComment.Text.StartsWith("<", StringComparison.Ordinal))
textComment.Text = $"{textComment.Text}{">"}";
else if (textComment.Text.StartsWith(">", StringComparison.Ordinal))
textComment.Text = textComment.Text.Substring(1);
}
return true;
}

5
tests/Native/AST.h

@ -189,6 +189,11 @@ public: @@ -189,6 +189,11 @@ public:
* @since Added in version 3.0. Replaces `glfwCloseWindow`.
*/
void glfwDestroyWindow(int* window);
/**
* <sip:alice@example.net>
*/
class LinphoneAddress {};
};
template <typename T>

Loading…
Cancel
Save