Browse Source

Removed leftovers in the comments from unsupported custom xml tags. (#912)

pull/913/head
Kimon Topouzidis 8 years ago committed by Dimitar Dobrev
parent
commit
910304b702
  1. 2
      src/Generator.Tests/AST/TestAST.cs
  2. 1
      src/Generator/Generators/CodeGenerator.cs
  3. 15
      src/Generator/Passes/CleanCommentsPass.cs
  4. 2
      tests/Native/AST.h

2
src/Generator.Tests/AST/TestAST.cs

@ -420,6 +420,7 @@ namespace CppSharp.Generator.Tests.AST @@ -420,6 +420,7 @@ namespace CppSharp.Generator.Tests.AST
/// </remarks>".Replace("\r", string.Empty), commentMethodDoxygen.Replace("\r", string.Empty));
var methodDoxygenCustomTags = @class.Methods.First(m => m.Name == "glfwDestroyWindow");
new CleanCommentsPass { }.VisitFull(methodDoxygenCustomTags.Comment.FullComment);
var commentMethodDoxygenCustomTag = methodDoxygenCustomTags.Comment.FullComment.CommentToString(CommentKind.BCPLSlash);
Assert.AreEqual(@"/// <summary>Destroys the specified window and its context.</summary>
/// <param name=""window"">The window to destroy.</param>
@ -431,6 +432,7 @@ namespace CppSharp.Generator.Tests.AST @@ -431,6 +432,7 @@ namespace CppSharp.Generator.Tests.AST
/// <para>The context of the specified window must not be current on any other</para>
/// <para>thread when this function is called.</para>
/// <para>This function must not be called from a callback.</para>
/// <para>This function must only be called from the main thread.</para>
/// <para>Added in version 3.0. Replaces `glfwCloseWindow`.</para>
/// </remarks>".Replace("\r", string.Empty), commentMethodDoxygenCustomTag.Replace("\r", string.Empty));
}

1
src/Generator/Generators/CodeGenerator.cs

@ -395,6 +395,7 @@ namespace CppSharp.Generators @@ -395,6 +395,7 @@ namespace CppSharp.Generators
public static class Helpers
{
public static Regex RegexTag = new Regex(@"^(<|</)[a-zA-Z][\w\-]*?>?$");
public static Regex RegexCommentCommandLeftover = new Regex(@"^\S*");
public static readonly string InternalStruct = Generator.GeneratedIdentifier("Internal");
public static readonly string InstanceField = Generator.GeneratedIdentifier("instance");
public static readonly string InstanceIdentifier = Generator.GeneratedIdentifier("Instance");

15
src/Generator/Passes/CleanCommentsPass.cs

@ -5,6 +5,7 @@ using System.Text; @@ -5,6 +5,7 @@ using System.Text;
using CppSharp.AST;
using CppSharp.Generators.CSharp;
using System.Text.RegularExpressions;
using CppSharp.Generators;
namespace CppSharp.Passes
{
@ -54,11 +55,23 @@ namespace CppSharp.Passes @@ -54,11 +55,23 @@ namespace CppSharp.Passes
public bool VisitParagraphCommand(ParagraphComment comment)
{
for (int i = 0; i < comment.Content.Count; i++)
{
if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment)
{
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);
}
}
}
bool tag = false;
foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment))
{
TextComment com = (TextComment) item;
if (Generators.Helpers.RegexTag.IsMatch(com.Text))
if (Helpers.RegexTag.IsMatch(com.Text))
tag = true;
else if (tag)
com.Text = com.Text.Substring(1);

2
tests/Native/AST.h

@ -184,6 +184,8 @@ public: @@ -184,6 +184,8 @@ public:
*
* @reentrancy This function must not be called from a callback.
*
* @thread_safety This function must only be called from the main thread.
*
* @since Added in version 3.0. Replaces `glfwCloseWindow`.
*/
void glfwDestroyWindow(int* window);

Loading…
Cancel
Save