From a9101ece645d7bf6e73ea3475b063091b0a61167 Mon Sep 17 00:00:00 2001 From: triton Date: Tue, 16 Jun 2015 23:55:50 +0100 Subject: [PATCH] Rename the diagnostic emit overloads so they're more uniform. --- src/Core/Diagnostics.cs | 8 +++---- src/Generator.Tests/GeneratorTest.cs | 6 ++--- src/Generator/Driver.cs | 22 +++++++++---------- .../Passes/CheckDuplicatedNamesPass.cs | 4 ++-- .../Passes/CheckVTableComponentsPass.cs | 2 +- src/Generator/Passes/FindSymbolsPass.cs | 2 +- .../Passes/ResolveIncompleteDeclsPass.cs | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Core/Diagnostics.cs b/src/Core/Diagnostics.cs index c49115c6..fa559288 100644 --- a/src/Core/Diagnostics.cs +++ b/src/Core/Diagnostics.cs @@ -49,7 +49,7 @@ namespace CppSharp consumer.Emit(diagInfo); } - public static void EmitMessage(this IDiagnosticConsumer consumer, + public static void Message(this IDiagnosticConsumer consumer, string msg, params object[] args) { var diagInfo = new DiagnosticInfo @@ -61,7 +61,7 @@ namespace CppSharp consumer.Emit(diagInfo); } - public static void EmitWarning(this IDiagnosticConsumer consumer, + public static void Warning(this IDiagnosticConsumer consumer, string msg, params object[] args) { var diagInfo = new DiagnosticInfo @@ -73,7 +73,7 @@ namespace CppSharp consumer.Emit(diagInfo); } - public static void EmitError(this IDiagnosticConsumer consumer, + public static void Error(this IDiagnosticConsumer consumer, string msg, params object[] args) { var diagInfo = new DiagnosticInfo @@ -85,7 +85,7 @@ namespace CppSharp consumer.Emit(diagInfo); } - public static void EmitError(this IDiagnosticConsumer consumer, + public static void Error(this IDiagnosticConsumer consumer, string msg) { var diagInfo = new DiagnosticInfo diff --git a/src/Generator.Tests/GeneratorTest.cs b/src/Generator.Tests/GeneratorTest.cs index 7d6318bf..544aeca9 100644 --- a/src/Generator.Tests/GeneratorTest.cs +++ b/src/Generator.Tests/GeneratorTest.cs @@ -34,8 +34,8 @@ namespace CppSharp.Utils options.Quiet = true; options.IgnoreParseWarnings = true; - driver.Diagnostics.EmitMessage(""); - driver.Diagnostics.EmitMessage("Generating bindings for {0} ({1})", + driver.Diagnostics.Message(""); + driver.Diagnostics.Message("Generating bindings for {0} ({1})", options.LibraryName, options.GeneratorKind.ToString()); // Workaround for CLR which does not check for .dll if the @@ -57,7 +57,7 @@ namespace CppSharp.Utils foreach (var header in headersPaths) options.addSystemIncludeDirs(header); - driver.Diagnostics.EmitMessage("Looking for tests in: {0}", path); + driver.Diagnostics.Message("Looking for tests in: {0}", path); var files = Directory.EnumerateFiles(path, "*.h"); foreach (var file in files) options.Headers.Add(Path.GetFileName(file)); diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index a8896d5a..141d8450 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -90,13 +90,13 @@ namespace CppSharp switch (result.Kind) { case ParserResultKind.Success: - Diagnostics.EmitMessage("Parsed '{0}'", file); + Diagnostics.Message("Parsed '{0}'", file); break; case ParserResultKind.Error: - Diagnostics.EmitError("Error parsing '{0}'", file); + Diagnostics.Error("Error parsing '{0}'", file); break; case ParserResultKind.FileNotFound: - Diagnostics.EmitError("File '{0}' was not found", file); + Diagnostics.Error("File '{0}' was not found", file); break; } @@ -111,7 +111,7 @@ namespace CppSharp if (diag.Level == ParserDiagnosticLevel.Note) continue; - Diagnostics.EmitMessage("{0}({1},{2}): {3}: {4}", + Diagnostics.Message("{0}({1},{2}): {3}: {4}", diag.FileName, diag.LineNumber, diag.ColumnNumber, diag.Level.ToString().ToLower(), diag.Message); } @@ -326,7 +326,7 @@ namespace CppSharp foreach (var template in output.Templates) { var fileRelativePath = string.Format("{0}.{1}", fileBase, template.FileExtension); - Diagnostics.EmitMessage("Generated '{0}'", fileRelativePath); + Diagnostics.Message("Generated '{0}'", fileRelativePath); var file = Path.Combine(outputPath, fileRelativePath); File.WriteAllText(file, template.Generate()); @@ -378,7 +378,7 @@ namespace CppSharp var errors = compilerResults.Errors.Cast(); foreach (var error in errors.Where(error => !error.IsWarning)) - Diagnostics.EmitError(error.ToString()); + Diagnostics.Error(error.ToString()); if (compilerResults.Errors.Count == 0) { @@ -415,18 +415,18 @@ namespace CppSharp Log.Level = DiagnosticKind.Debug; if (!options.Quiet) - Log.EmitMessage("Parsing libraries..."); + Log.Message("Parsing libraries..."); if (!driver.ParseLibraries()) return; if (!options.Quiet) - Log.EmitMessage("Indexing library symbols..."); + Log.Message("Indexing library symbols..."); driver.Symbols.IndexSymbols(); if (!options.Quiet) - Log.EmitMessage("Parsing code..."); + Log.Message("Parsing code..."); driver.BuildParseOptions(); @@ -434,7 +434,7 @@ namespace CppSharp return; if (!options.Quiet) - Log.EmitMessage("Processing code..."); + Log.Message("Processing code..."); library.Preprocess(driver, driver.ASTContext); @@ -444,7 +444,7 @@ namespace CppSharp library.Postprocess(driver, driver.ASTContext); if (!options.Quiet) - Log.EmitMessage("Generating code..."); + Log.Message("Generating code..."); var outputs = driver.GenerateCode(); diff --git a/src/Generator/Passes/CheckDuplicatedNamesPass.cs b/src/Generator/Passes/CheckDuplicatedNamesPass.cs index 0e626b55..1785c708 100644 --- a/src/Generator/Passes/CheckDuplicatedNamesPass.cs +++ b/src/Generator/Passes/CheckDuplicatedNamesPass.cs @@ -76,12 +76,12 @@ namespace CppSharp.Passes if (function.IsOperator) { // TODO: turn into a method; append the original type (say, "signed long") of the last parameter to the type so that the user knows which overload is called - Driver.Diagnostics.EmitWarning("Duplicate operator {0} ignored", function.Name); + Driver.Diagnostics.Warning("Duplicate operator {0} ignored", function.Name); function.ExplicitlyIgnore(); } else if (method != null && method.IsConstructor) { - Driver.Diagnostics.EmitWarning("Duplicate constructor {0} ignored", function.Name); + Driver.Diagnostics.Warning("Duplicate constructor {0} ignored", function.Name); function.ExplicitlyIgnore(); } else diff --git a/src/Generator/Passes/CheckVTableComponentsPass.cs b/src/Generator/Passes/CheckVTableComponentsPass.cs index 07988fbb..7307cbe3 100644 --- a/src/Generator/Passes/CheckVTableComponentsPass.cs +++ b/src/Generator/Passes/CheckVTableComponentsPass.cs @@ -22,7 +22,7 @@ namespace CppSharp.Passes if (vfptr.Layout.Components.Count == uniqueEntries.Count) continue; - Driver.Diagnostics.EmitWarning( + Driver.Diagnostics.Warning( "Class '{0}' found with duplicated vftable components", @class.Name); vfptr.Layout.Components = uniqueEntries.ToList(); diff --git a/src/Generator/Passes/FindSymbolsPass.cs b/src/Generator/Passes/FindSymbolsPass.cs index 543b9f9b..b87a989f 100644 --- a/src/Generator/Passes/FindSymbolsPass.cs +++ b/src/Generator/Passes/FindSymbolsPass.cs @@ -28,7 +28,7 @@ namespace CppSharp.Passes if (!Driver.Symbols.FindSymbol(ref symbol)) { - Driver.Diagnostics.EmitWarning("Symbol not found: {0}", symbol); + Driver.Diagnostics.Warning("Symbol not found: {0}", symbol); return false; } diff --git a/src/Generator/Passes/ResolveIncompleteDeclsPass.cs b/src/Generator/Passes/ResolveIncompleteDeclsPass.cs index 9ceee5a2..95cf8754 100644 --- a/src/Generator/Passes/ResolveIncompleteDeclsPass.cs +++ b/src/Generator/Passes/ResolveIncompleteDeclsPass.cs @@ -52,7 +52,7 @@ namespace CppSharp.Passes if (@enum.CompleteDeclaration == null) { @enum.GenerationKind = GenerationKind.Internal; - Driver.Diagnostics.EmitWarning("Unresolved declaration: {0}", @enum.Name); + Driver.Diagnostics.Warning("Unresolved declaration: {0}", @enum.Name); } Out: