From 3800ccf996cea043a88d5781c19ef12a1bbaba0c Mon Sep 17 00:00:00 2001 From: triton Date: Mon, 4 Feb 2013 23:34:02 +0000 Subject: [PATCH] Added a pretty simple diagnostic system so we can provide improved diagnostics to clients. --- src/Generator/Diagnostics.cs | 32 ++++++++++++++++++++++++++++++++ src/Generator/Driver.cs | 3 +++ 2 files changed, 35 insertions(+) create mode 100644 src/Generator/Diagnostics.cs diff --git a/src/Generator/Diagnostics.cs b/src/Generator/Diagnostics.cs new file mode 100644 index 00000000..392e41b1 --- /dev/null +++ b/src/Generator/Diagnostics.cs @@ -0,0 +1,32 @@ +using System; + +namespace Cxxi +{ + public enum DiagnosticKind + { + Message, + Warning, + Error + } + + public struct DiagnosticInfo + { + public string Message; + public string File; + public int Line; + public int Column; + } + + public interface IDiagnosticConsumer + { + void Emit(DiagnosticKind kind, DiagnosticInfo info); + } + + public class TextDiagnosticPrinter : IDiagnosticConsumer + { + public void Emit(DiagnosticKind kind, DiagnosticInfo info) + { + Console.WriteLine(info.Message); + } + } +} diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 084243e6..0c4ea643 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -10,6 +10,7 @@ namespace Cxxi { private readonly Options options; private readonly ILibrary transform; + private readonly IDiagnosticConsumer diagnostics; private readonly TypeMapDatabase typeDatabase; private Library library; @@ -17,6 +18,8 @@ namespace Cxxi { this.options = options; this.transform = transform; + this.diagnostics = new TextDiagnosticPrinter(); + typeDatabase = new TypeMapDatabase(); typeDatabase.SetupTypeMaps(); }