Browse Source

Cleaned up the default diagnostics output to be more concise.

pull/131/head
triton 12 years ago
parent
commit
b808117566
  1. 5
      src/Core/Diagnostics.cs
  2. 8
      src/Generator/Driver.cs
  3. 2
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  4. 2
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  5. 2
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  6. 36
      src/Generator/Passes/CheckIgnoredDecls.cs
  7. 3
      src/Generator/Passes/FieldToPropertyPass.cs
  8. 3
      src/Generator/Utils/TestsUtils.cs

5
src/Core/Diagnostics.cs

@ -138,8 +138,13 @@ namespace CppSharp
public class TextDiagnosticPrinter : IDiagnosticConsumer public class TextDiagnosticPrinter : IDiagnosticConsumer
{ {
public bool Verbose;
public void Emit(DiagnosticInfo info) public void Emit(DiagnosticInfo info)
{ {
if (info.Kind == DiagnosticKind.Debug && !Verbose)
return;
Console.WriteLine(info.Message); Console.WriteLine(info.Message);
System.Diagnostics.Debug.WriteLine(info.Message); System.Diagnostics.Debug.WriteLine(info.Message);
} }

8
src/Generator/Driver.cs

@ -324,10 +324,14 @@ namespace CppSharp
public static void Run(ILibrary library) public static void Run(ILibrary library)
{ {
var options = new DriverOptions(); var options = new DriverOptions();
var driver = new Driver(options, new TextDiagnosticPrinter());
var Log = new TextDiagnosticPrinter();
var driver = new Driver(options, Log);
library.Setup(driver); library.Setup(driver);
driver.Setup(); driver.Setup();
var Log = driver.Diagnostics;
Log.Verbose = driver.Options.Verbose;
if (!options.Quiet) if (!options.Quiet)
Log.EmitMessage("Parsing libraries..."); Log.EmitMessage("Parsing libraries...");

2
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -613,7 +613,7 @@ namespace CppSharp.Generators.CLI
} }
else else
{ {
Log.EmitMessage("Unhandled typedef type: {0}", typedef); Log.Debug("Unresolved typedef type: {0}", typedef);
} }
return false; return false;

2
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -2258,7 +2258,7 @@ namespace CppSharp.Generators.CSharp
} }
else else
{ {
Log.EmitWarning("Unhandled typedef type: {0}", typedef); Log.Debug("Unresolved typedef type: {0}", typedef);
return false; return false;
} }

2
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -53,7 +53,7 @@ namespace CppSharp.Passes
} }
if (function.IsAmbiguous) if (function.IsAmbiguous)
Driver.Diagnostics.EmitWarning("Found ambiguous overload: {0}", Driver.Diagnostics.Debug("Found ambiguous overload: {0}",
function.QualifiedOriginalName); function.QualifiedOriginalName);
return true; return true;

36
src/Generator/Passes/CheckIgnoredDecls.cs

@ -23,7 +23,7 @@ namespace CppSharp.Passes
if (decl.IsDependent) if (decl.IsDependent)
{ {
decl.ExplicityIgnored = true; decl.ExplicityIgnored = true;
Log.EmitMessage("Decl '{0}' was ignored due to dependent context", Log.Debug("Decl '{0}' was ignored due to dependent context",
decl.Name); decl.Name);
} }
@ -43,7 +43,7 @@ namespace CppSharp.Passes
field.ExplicityIgnored = true; field.ExplicityIgnored = true;
Log.EmitMessage("Field '{0}' was ignored due to {1} type", Log.Debug("Field '{0}' was ignored due to {1} type",
field.Name, msg); field.Name, msg);
return true; return true;
@ -60,7 +60,7 @@ namespace CppSharp.Passes
if (HasInvalidType(ret.Type, out msg)) if (HasInvalidType(ret.Type, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicityIgnored = true;
Log.EmitMessage("Function '{0}' was ignored due to {1} return decl", Log.Debug("Function '{0}' was ignored due to {1} return decl",
function.Name, msg); function.Name, msg);
return false; return false;
} }
@ -70,7 +70,7 @@ namespace CppSharp.Passes
if (HasInvalidDecl(param, out msg)) if (HasInvalidDecl(param, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicityIgnored = true;
Log.EmitMessage("Function '{0}' was ignored due to {1} param", Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg); function.Name, msg);
return false; return false;
} }
@ -78,7 +78,7 @@ namespace CppSharp.Passes
if (HasInvalidType(param.Type, out msg)) if (HasInvalidType(param.Type, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicityIgnored = true;
Log.EmitMessage("Function '{0}' was ignored due to {1} param", Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg); function.Name, msg);
return false; return false;
} }
@ -90,7 +90,7 @@ namespace CppSharp.Passes
if (retClass == null) if (retClass == null)
{ {
function.ExplicityIgnored = true; function.ExplicityIgnored = true;
Driver.Diagnostics.EmitWarning( Log.Debug(
"Function '{0}' was ignored due to an indirect return param not of a tag type", "Function '{0}' was ignored due to an indirect return param not of a tag type",
function.Name); function.Name);
return false; return false;
@ -121,7 +121,7 @@ namespace CppSharp.Passes
Class ignoredBase; Class ignoredBase;
if (HasIgnoredBaseClass(method, @class, out ignoredBase)) if (HasIgnoredBaseClass(method, @class, out ignoredBase))
{ {
Driver.Diagnostics.EmitMessage( Log.Debug(
"Virtual method '{0}' was ignored due to ignored base '{1}'", "Virtual method '{0}' was ignored due to ignored base '{1}'",
method.QualifiedOriginalName, ignoredBase.Name); method.QualifiedOriginalName, ignoredBase.Name);
@ -134,7 +134,7 @@ namespace CppSharp.Passes
var baseOverride = @class.GetRootBaseMethod(method); var baseOverride = @class.GetRootBaseMethod(method);
if (baseOverride != null && baseOverride.Ignore) if (baseOverride != null && baseOverride.Ignore)
{ {
Driver.Diagnostics.EmitMessage( Log.Debug(
"Virtual method '{0}' was ignored due to ignored override '{1}'", "Virtual method '{0}' was ignored due to ignored override '{1}'",
method.QualifiedOriginalName, baseOverride.Name); method.QualifiedOriginalName, baseOverride.Name);
@ -182,7 +182,7 @@ namespace CppSharp.Passes
if (HasInvalidType(typedef.Type, out msg)) if (HasInvalidType(typedef.Type, out msg))
{ {
typedef.ExplicityIgnored = true; typedef.ExplicityIgnored = true;
Log.EmitMessage("Typedef '{0}' was ignored due to {1} type", Log.Debug("Typedef '{0}' was ignored due to {1} type",
typedef.Name, msg); typedef.Name, msg);
return false; return false;
} }
@ -199,7 +199,7 @@ namespace CppSharp.Passes
if (HasInvalidDecl(property, out msg)) if (HasInvalidDecl(property, out msg))
{ {
property.ExplicityIgnored = true; property.ExplicityIgnored = true;
Log.EmitMessage("Property '{0}' was ignored due to {1} decl", Log.Debug("Property '{0}' was ignored due to {1} decl",
property.Name, msg); property.Name, msg);
return false; return false;
} }
@ -207,7 +207,7 @@ namespace CppSharp.Passes
if (HasInvalidType(property.Type, out msg)) if (HasInvalidType(property.Type, out msg))
{ {
property.ExplicityIgnored = true; property.ExplicityIgnored = true;
Log.EmitMessage("Property '{0}' was ignored due to {1} type", Log.Debug("Property '{0}' was ignored due to {1} type",
property.Name, msg); property.Name, msg);
return false; return false;
} }
@ -215,7 +215,7 @@ namespace CppSharp.Passes
if (property.GetMethod != null && !VisitFunctionDecl(property.GetMethod)) if (property.GetMethod != null && !VisitFunctionDecl(property.GetMethod))
{ {
property.ExplicityIgnored = true; property.ExplicityIgnored = true;
Log.EmitMessage("Property '{0}' was ignored due to ignored getter", Log.Debug("Property '{0}' was ignored due to ignored getter",
property.Name, msg); property.Name, msg);
return false; return false;
} }
@ -223,7 +223,7 @@ namespace CppSharp.Passes
if (property.SetMethod != null && !VisitFunctionDecl(property.SetMethod)) if (property.SetMethod != null && !VisitFunctionDecl(property.SetMethod))
{ {
property.ExplicityIgnored = true; property.ExplicityIgnored = true;
Log.EmitMessage("Property '{0}' was ignored due to ignored setter", Log.Debug("Property '{0}' was ignored due to ignored setter",
property.Name, msg); property.Name, msg);
return false; return false;
} }
@ -240,7 +240,7 @@ namespace CppSharp.Passes
if (HasInvalidDecl(variable, out msg)) if (HasInvalidDecl(variable, out msg))
{ {
variable.ExplicityIgnored = true; variable.ExplicityIgnored = true;
Log.EmitMessage("Variable '{0}' was ignored due to {1} decl", Log.Debug("Variable '{0}' was ignored due to {1} decl",
variable.Name, msg); variable.Name, msg);
return false; return false;
} }
@ -248,7 +248,7 @@ namespace CppSharp.Passes
if (HasInvalidType(variable.Type, out msg)) if (HasInvalidType(variable.Type, out msg))
{ {
variable.ExplicityIgnored = true; variable.ExplicityIgnored = true;
Log.EmitMessage("Variable '{0}' was ignored due to {1} type", Log.Debug("Variable '{0}' was ignored due to {1} type",
variable.Name, msg); variable.Name, msg);
return false; return false;
} }
@ -265,7 +265,7 @@ namespace CppSharp.Passes
if (HasInvalidDecl(@event, out msg)) if (HasInvalidDecl(@event, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicityIgnored = true;
Log.EmitMessage("Event '{0}' was ignored due to {1} decl", Log.Debug("Event '{0}' was ignored due to {1} decl",
@event.Name, msg); @event.Name, msg);
return false; return false;
} }
@ -275,7 +275,7 @@ namespace CppSharp.Passes
if (HasInvalidDecl(param, out msg)) if (HasInvalidDecl(param, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicityIgnored = true;
Log.EmitMessage("Event '{0}' was ignored due to {1} param", Log.Debug("Event '{0}' was ignored due to {1} param",
@event.Name, msg); @event.Name, msg);
return false; return false;
} }
@ -283,7 +283,7 @@ namespace CppSharp.Passes
if (HasInvalidType(param.Type, out msg)) if (HasInvalidType(param.Type, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicityIgnored = true;
Log.EmitMessage("Event '{0}' was ignored due to {1} param", Log.Debug("Event '{0}' was ignored due to {1} param",
@event.Name, msg); @event.Name, msg);
return false; return false;
} }

3
src/Generator/Passes/FieldToPropertyPass.cs

@ -41,8 +41,7 @@ namespace CppSharp.Passes
}; };
@class.Properties.Add(prop); @class.Properties.Add(prop);
Driver.Diagnostics.EmitMessage(DiagnosticId.PropertySynthetized, Log.Debug("Property created from field: {0}::{1}", @class.Name, field.Name);
"Property created from field: {0}::{1}", @class.Name, field.Name);
field.ExplicityIgnored = true; field.ExplicityIgnored = true;

3
src/Generator/Utils/TestsUtils.cs

@ -62,7 +62,8 @@ namespace CppSharp.Utils
options.Quiet = true; options.Quiet = true;
options.IgnoreParseWarnings = true; options.IgnoreParseWarnings = true;
driver.Diagnostics.EmitMessage("Generating bindings for {0} in {1} mode", driver.Diagnostics.EmitMessage("");
driver.Diagnostics.EmitMessage("Generating bindings for {0} ({1})",
options.LibraryName, options.GeneratorKind.ToString()); options.LibraryName, options.GeneratorKind.ToString());
// Workaround for CLR which does not check for .dll if the // Workaround for CLR which does not check for .dll if the

Loading…
Cancel
Save