Browse Source

Merge pull request #92 from sk-havok/req/unify_debug_output

Unify debugging output
pull/100/head
João Matos 12 years ago
parent
commit
a632806eff
  1. 1
      src/Core/Diagnostics.cs
  2. 11
      src/Generator/Driver.cs
  3. 4
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  4. 2
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  5. 4
      src/Generator/Generators/Template.cs
  6. 30
      src/Generator/Passes/CheckIgnoredDecls.cs
  7. 2
      src/Generator/Passes/FunctionToInstanceMethodPass.cs
  8. 2
      src/Generator/Passes/FunctionToStaticMethodPass.cs
  9. 5
      src/Generator/Passes/Pass.cs
  10. 4
      src/Generator/Utils/TestsUtils.cs

1
src/Core/Diagnostics.cs

@ -141,6 +141,7 @@ namespace CppSharp
public void Emit(DiagnosticInfo info) public void Emit(DiagnosticInfo info)
{ {
Console.WriteLine(info.Message); Console.WriteLine(info.Message);
System.Diagnostics.Debug.WriteLine(info.Message);
} }
} }
} }

11
src/Generator/Driver.cs

@ -272,26 +272,27 @@ namespace CppSharp
var driver = new Driver(options, new TextDiagnosticPrinter()); var driver = new Driver(options, new TextDiagnosticPrinter());
library.Setup(driver); library.Setup(driver);
driver.Setup(); driver.Setup();
var Log = driver.Diagnostics;
if (!options.Quiet) if (!options.Quiet)
Console.WriteLine("Parsing libraries..."); Log.EmitMessage("Parsing libraries...");
if (!driver.ParseLibraries()) if (!driver.ParseLibraries())
return; return;
if (!options.Quiet) if (!options.Quiet)
Console.WriteLine("Indexing library symbols..."); Log.EmitMessage("Indexing library symbols...");
driver.Symbols.IndexSymbols(); driver.Symbols.IndexSymbols();
if (!options.Quiet) if (!options.Quiet)
Console.WriteLine("Parsing code..."); Log.EmitMessage("Parsing code...");
if (!driver.ParseCode()) if (!driver.ParseCode())
return; return;
if (!options.Quiet) if (!options.Quiet)
Console.WriteLine("Processing code..."); Log.EmitMessage("Processing code...");
library.Preprocess(driver, driver.ASTContext); library.Preprocess(driver, driver.ASTContext);
@ -301,7 +302,7 @@ namespace CppSharp
library.Postprocess(driver, driver.ASTContext); library.Postprocess(driver, driver.ASTContext);
if (!options.Quiet) if (!options.Quiet)
Console.WriteLine("Generating code..."); Log.EmitMessage("Generating code...");
var outputs = driver.GenerateCode(); var outputs = driver.GenerateCode();

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

@ -371,7 +371,7 @@ namespace CppSharp.Generators.CLI
if (!baseClass.IsValueType || baseClass.Ignore) if (!baseClass.IsValueType || baseClass.Ignore)
{ {
Console.WriteLine("Ignored base class of value type '{0}'", Log.EmitMessage("Ignored base class of value type '{0}'",
baseClass.Name); baseClass.Name);
continue; continue;
} }
@ -612,7 +612,7 @@ namespace CppSharp.Generators.CLI
} }
else else
{ {
Console.WriteLine("Unhandled typedef type: {0}", typedef); Log.EmitMessage("Unhandled typedef type: {0}", typedef);
} }
return false; return false;

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

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

4
src/Generator/Generators/Template.cs

@ -216,6 +216,10 @@ namespace CppSharp.Generators
public Driver Driver { get; private set; } public Driver Driver { get; private set; }
public DriverOptions Options { get; private set; } public DriverOptions Options { get; private set; }
public TranslationUnit TranslationUnit { get; private set; } public TranslationUnit TranslationUnit { get; private set; }
public IDiagnosticConsumer Log
{
get { return Driver.Diagnostics; }
}
public Block RootBlock { get; private set; } public Block RootBlock { get; private set; }
public Block ActiveBlock { get; private set; } public Block ActiveBlock { get; private set; }

30
src/Generator/Passes/CheckIgnoredDecls.cs

@ -23,7 +23,7 @@ namespace CppSharp.Passes
if (decl.IsDependent) if (decl.IsDependent)
{ {
decl.ExplicityIgnored = true; decl.ExplicityIgnored = true;
Console.WriteLine("Decl '{0}' was ignored due to dependent context", Log.EmitMessage("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;
Console.WriteLine("Field '{0}' was ignored due to {1} type", Log.EmitMessage("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;
Console.WriteLine("Function '{0}' was ignored due to {1} return decl", Log.EmitMessage("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;
Console.WriteLine("Function '{0}' was ignored due to {1} param", Log.EmitMessage("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;
Console.WriteLine("Function '{0}' was ignored due to {1} param", Log.EmitMessage("Function '{0}' was ignored due to {1} param",
function.Name, msg); function.Name, msg);
return false; return false;
} }
@ -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;
Console.WriteLine("Typedef '{0}' was ignored due to {1} type", Log.EmitMessage("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;
Console.WriteLine("Property '{0}' was ignored due to {1} decl", Log.EmitMessage("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;
Console.WriteLine("Property '{0}' was ignored due to {1} type", Log.EmitMessage("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;
Console.WriteLine("Property '{0}' was ignored due to ignored getter", Log.EmitMessage("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;
Console.WriteLine("Property '{0}' was ignored due to ignored setter", Log.EmitMessage("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;
Console.WriteLine("Variable '{0}' was ignored due to {1} decl", Log.EmitMessage("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;
Console.WriteLine("Variable '{0}' was ignored due to {1} type", Log.EmitMessage("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;
Console.WriteLine("Event '{0}' was ignored due to {1} decl", Log.EmitMessage("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;
Console.WriteLine("Event '{0}' was ignored due to {1} param", Log.EmitMessage("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;
Console.WriteLine("Event '{0}' was ignored due to {1} param", Log.EmitMessage("Event '{0}' was ignored due to {1} param",
@event.Name, msg); @event.Name, msg);
return false; return false;
} }

2
src/Generator/Passes/FunctionToInstanceMethodPass.cs

@ -64,7 +64,7 @@ namespace CppSharp.Passes
@class.Methods.Add(method); @class.Methods.Add(method);
Console.WriteLine("Instance method: {0}::{1}", @class.Name, Log.EmitMessage("Instance method: {0}::{1}", @class.Name,
function.Name); function.Name);
return true; return true;

2
src/Generator/Passes/FunctionToStaticMethodPass.cs

@ -51,7 +51,7 @@ namespace CppSharp.Passes
@class.Methods.Add(method); @class.Methods.Add(method);
Console.WriteLine("Static method: {0}::{1}", @class.Name, Log.EmitMessage("Static method: {0}::{1}", @class.Name,
function.Name); function.Name);
return true; return true;

5
src/Generator/Passes/Pass.cs

@ -12,6 +12,11 @@ namespace CppSharp.Passes
public Driver Driver { get; set; } public Driver Driver { get; set; }
public ASTContext AstContext { get; set; } public ASTContext AstContext { get; set; }
public IDiagnosticConsumer Log
{
get { return Driver.Diagnostics; }
}
public virtual bool VisitLibrary(ASTContext context) public virtual bool VisitLibrary(ASTContext context)
{ {
AstContext = context; AstContext = context;

4
src/Generator/Utils/TestsUtils.cs

@ -62,7 +62,7 @@ namespace CppSharp.Utils
options.Quiet = true; options.Quiet = true;
options.IgnoreParseWarnings = true; options.IgnoreParseWarnings = true;
Console.WriteLine("Generating bindings for {0} in {1} mode", driver.Diagnostics.EmitMessage("Generating bindings for {0} in {1} mode",
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
@ -74,7 +74,7 @@ namespace CppSharp.Utils
options.IncludeDirs.Add(path); options.IncludeDirs.Add(path);
Console.WriteLine("Looking for tests in: {0}", path); driver.Diagnostics.EmitMessage("Looking for tests in: {0}", path);
var files = Directory.EnumerateFiles(path, "*.h"); var files = Directory.EnumerateFiles(path, "*.h");
foreach (var file in files) foreach (var file in files)
options.Headers.Add(Path.GetFileName(file)); options.Headers.Add(Path.GetFileName(file));

Loading…
Cancel
Save