Browse Source

Fix debug output not being generated when AST element had no comment.

Also debug text cleaning moved to CodeGenerator.cs and is done when printing bindings. New lines are not stripped out, instead each line is prepended with "// DEBUG: ". Now debug info is properly formatted, easy to read and full.
pull/1022/head
Rokas Kupstys 8 years ago
parent
commit
9ea1821cb3
  1. 12
      src/Generator/Generators/CodeGenerator.cs
  2. 1
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  3. 14
      src/Generator/Utils/Utils.cs

12
src/Generator/Generators/CodeGenerator.cs

@ -83,22 +83,18 @@ namespace CppSharp.Generators @@ -83,22 +83,18 @@ namespace CppSharp.Generators
public virtual void GenerateDeclarationCommon(Declaration decl)
{
if (decl.Comment != null)
{
GenerateComment(decl.Comment);
GenerateDebug(decl);
}
}
public virtual void GenerateDebug(Declaration decl)
{
if (Options.GenerateDebugOutput && !string.IsNullOrWhiteSpace(decl.DebugText))
{
char[] newLineChars = {'\r', '\n'};
var text = decl.DebugText;
var index = text.IndexOfAny(newLineChars);
if (index >= 0)
text = text.Substring(0, index);
WriteLine("// DEBUG: " + text);
var debugText = decl.DebugText;
debugText = Regex.Replace(debugText.Trim(), "\r?\n", "\n// DEBUG: ");
WriteLine($"// DEBUG: {debugText}");
}
}

1
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -53,7 +53,6 @@ namespace CppSharp.Passes @@ -53,7 +53,6 @@ namespace CppSharp.Passes
(method == null || method.Kind == CXXMethodKind.Normal))
decl.Name = CheckName(decl.Name);
StringHelpers.CleanupText(ref decl.DebugText);
return true;
}

14
src/Generator/Utils/Utils.cs

@ -43,20 +43,6 @@ namespace CppSharp @@ -43,20 +43,6 @@ namespace CppSharp
return ss[0]; // all strings identical
}
public static void CleanupText(ref string debugText)
{
// Strip off newlines from the debug text.
if (string.IsNullOrWhiteSpace(debugText))
{
debugText = string.Empty;
return;
}
// TODO: Make this transformation in the output.
debugText = Regex.Replace(debugText, " {2,}", " ");
debugText = debugText.Replace("\n", "");
}
public static string[] SplitCamelCase(string input)
{
var str = Regex.Replace(input, "([A-Z])", " $1", RegexOptions.Compiled);

Loading…
Cancel
Save