diff --git a/.editorconfig b/.editorconfig index 41910da..de9e37d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -46,6 +46,9 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = true csharp_space_between_method_call_name_and_opening_parenthesis = true csharp_space_after_keywords_in_control_flow_statements = true +# spaces before [] +csharp_space_before_open_square_brackets = true + # Newline settings csharp_new_line_before_open_brace = types,methods csharp_new_line_before_else = true diff --git a/src/Gir.Tests/BitFieldTests.cs b/src/Gir.Tests/BitFieldTests.cs index 201dade..1b83221 100644 --- a/src/Gir.Tests/BitFieldTests.cs +++ b/src/Gir.Tests/BitFieldTests.cs @@ -1,7 +1,4 @@ -using System.IO; -using System.Linq; -using System.Text; - + using NUnit.Framework; namespace Gir.Tests @@ -10,10 +7,10 @@ namespace Gir.Tests public class BitFieldTests : GenerationTestBase { [Test] - public void GenerateDocumentationWhenCompatFalse() + public void GenerateDocumentationWhenCompatFalse () { - var result = GenerateType(Pango, "FontMask"); - Assert.AreEqual(@"namespace Pango + var result = GenerateType (Pango, "FontMask"); + Assert.AreEqual (@"namespace Pango { /// /// The bits in a #PangoFontMask correspond to fields in a @@ -48,11 +45,11 @@ public enum FontMask } [Test] - public void GenerateNoDocumentationWhenCompatTrue() + public void GenerateNoDocumentationWhenCompatTrue () { - var result = GenerateType(Pango, "FontMask", compat: true); + var result = GenerateType (Pango, "FontMask", compat: true); - Assert.AreEqual(@"namespace Pango + Assert.AreEqual (@"namespace Pango { [Flags] public enum FontMask diff --git a/src/Gir.Tests/ClassTests.cs b/src/Gir.Tests/ClassTests.cs index 053990f..1efd191 100644 --- a/src/Gir.Tests/ClassTests.cs +++ b/src/Gir.Tests/ClassTests.cs @@ -1,5 +1,4 @@ -using System; - + using NUnit.Framework; namespace Gir.Tests @@ -8,14 +7,14 @@ namespace Gir.Tests public class ClassTests : GenerationTestBase { [Test] - public void TestClassIsGenerated() + public void TestClassIsGenerated () { // Test is incomplete, as record is not fully generated atm. - var result = GenerateType(Gio2, "BufferedOutputStream"); + var result = GenerateType (Gio2, "BufferedOutputStream"); // Need to map pointers at symbol level. - Assert.AreEqual(@"namespace Gio + Assert.AreEqual (@"namespace Gio { /// /// Buffered output stream implements #GFilterOutputStream and provides diff --git a/src/Gir.Tests/EnumerationTests.cs b/src/Gir.Tests/EnumerationTests.cs index 42078b5..c4e55e2 100644 --- a/src/Gir.Tests/EnumerationTests.cs +++ b/src/Gir.Tests/EnumerationTests.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; + using NUnit.Framework; namespace Gir.Tests @@ -12,9 +9,9 @@ public class Enumeration : GenerationTestBase [Test] public void PangoAlignmentIsGenerated () { - var result = GenerateType(Pango, "Alignment"); + var result = GenerateType (Pango, "Alignment"); - Assert.AreEqual(@"namespace Pango + Assert.AreEqual (@"namespace Pango { /// /// A #PangoAlignment describes how to align the lines of a #PangoLayout within the diff --git a/src/Gir.Tests/FunctionTests.cs b/src/Gir.Tests/FunctionTests.cs index 0b00b7e..faf980d 100644 --- a/src/Gir.Tests/FunctionTests.cs +++ b/src/Gir.Tests/FunctionTests.cs @@ -1,4 +1,4 @@ -using System; + using NUnit.Framework; namespace Gir.Tests @@ -7,12 +7,12 @@ namespace Gir.Tests public class FunctionTests : GenerationTestBase { [Test] - public void TestRecordFunctionIsGenerated() + public void TestRecordFunctionIsGenerated () { // Test is incomplete, as record is not fully generated atm. - var result = GenerateMember(GLib, "ByteArray", "append"); + var result = GenerateMember (GLib, "ByteArray", "append"); - Assert.AreEqual(@"static extern void g_byte_array_append PARAMS + Assert.AreEqual (@"static extern void g_byte_array_append PARAMS /// /// Adds the given bytes to the end of the #GByteArray. diff --git a/src/Gir.Tests/GenerationOptionsTests.cs b/src/Gir.Tests/GenerationOptionsTests.cs index 4845e4b..19d6223 100644 --- a/src/Gir.Tests/GenerationOptionsTests.cs +++ b/src/Gir.Tests/GenerationOptionsTests.cs @@ -1,5 +1,4 @@ -using System.Linq; - + using NUnit.Framework; namespace Gir.Tests @@ -8,11 +7,11 @@ namespace Gir.Tests public class GenerationOptionsTests : GenerationTestBase { [Test] - public void GenerateDocumentationWhenCompatFalse() + public void GenerateDocumentationWhenCompatFalse () { - var result = GenerateType(Pango, "Alignment"); + var result = GenerateType (Pango, "Alignment"); - Assert.AreEqual(@"namespace Pango + Assert.AreEqual (@"namespace Pango { /// /// A #PangoAlignment describes how to align the lines of a #PangoLayout within the @@ -35,11 +34,11 @@ public enum Alignment } [Test] - public void GenerateNoDocumentationWhenCompatTrue() + public void GenerateNoDocumentationWhenCompatTrue () { - var result = GenerateType(Pango, "Alignment", compat: true); + var result = GenerateType (Pango, "Alignment", compat: true); - Assert.AreEqual(@"namespace Pango + Assert.AreEqual (@"namespace Pango { public enum Alignment { diff --git a/src/Gir.Tests/GenerationTestBase.cs b/src/Gir.Tests/GenerationTestBase.cs index bdef5c2..dda62cc 100644 --- a/src/Gir.Tests/GenerationTestBase.cs +++ b/src/Gir.Tests/GenerationTestBase.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using System.Text; + using NUnit.Framework; namespace Gir.Tests @@ -20,88 +21,88 @@ public abstract class GenerationTestBase static IEnumerable GetResourceStreams (string name = null) { - var assembly = Assembly.GetExecutingAssembly(); + var assembly = Assembly.GetExecutingAssembly (); - var names = assembly.GetManifestResourceNames(); + var names = assembly.GetManifestResourceNames (); foreach (var resName in names) { - if (string.IsNullOrEmpty (resName) || resName.EndsWith(name + ".gir", StringComparison.OrdinalIgnoreCase)) - yield return assembly.GetManifestResourceStream(resName); + if (string.IsNullOrEmpty (resName) || resName.EndsWith (name + ".gir", StringComparison.OrdinalIgnoreCase)) + yield return assembly.GetManifestResourceStream (resName); } } static string GetIncludeDirectory () { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestFiles"); + return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "TestFiles"); } - static protected IEnumerable>> ParseAllGirFiles() + static protected IEnumerable>> ParseAllGirFiles () { - foreach (var stream in GetResourceStreams()) { + foreach (var stream in GetResourceStreams ()) { var repos = ParseGirStream (stream, out Repository mainRepository); - - yield return new Tuple>(mainRepository, repos); + + yield return new Tuple> (mainRepository, repos); } } static protected Stream GetGIRFile (string name) { - return GetResourceStreams(name).Single(); + return GetResourceStreams (name).Single (); } static protected IEnumerable ParseGirFile (string name, out Repository mainRepository) { - return ParseGirStream(GetGIRFile(name), out mainRepository); + return ParseGirStream (GetGIRFile (name), out mainRepository); } static protected IEnumerable ParseGirStream (Stream gir, out Repository mainRepository) { - return Parser.Parse(gir, GetIncludeDirectory(), out mainRepository); + return Parser.Parse (gir, GetIncludeDirectory (), out mainRepository); } - protected static string GetGenerationResult(GenerationOptions opts) + protected static string GetGenerationResult (GenerationOptions opts) { var ms = (MemoryStream)opts.RedirectStream; - return Encoding.UTF8.GetString(ms.ToArray()); + return Encoding.UTF8.GetString (ms.ToArray ()); } - protected static GenerationOptions GetOptions(IEnumerable repositories, Repository mainRepository, bool compat = false) + protected static GenerationOptions GetOptions (IEnumerable repositories, Repository mainRepository, bool compat = false) { - return new GenerationOptions("", repositories, mainRepository, compat, new MemoryStream ()); + return new GenerationOptions ("", repositories, mainRepository, compat, new MemoryStream ()); } protected static void GenerateType (Repository repo, GenerationOptions opts, string typeName) { - repo.GetGeneratables().First(x => x.Name == typeName).Generate(opts); + repo.GetGeneratables ().First (x => x.Name == typeName).Generate (opts); } - protected static void GenerateMember(Repository repo, GenerationOptions opts, string typeName, string memberName) + protected static void GenerateMember (Repository repo, GenerationOptions opts, string typeName, string memberName) { - var type = repo.GetGeneratables().First(x => x.Name == typeName); + var type = repo.GetGeneratables ().First (x => x.Name == typeName); - using (var writer = type.GetWriter(opts)) { - type.GenerateMembers(writer, x => x.Name == memberName); + using (var writer = type.GetWriter (opts)) { + type.GenerateMembers (writer, x => x.Name == memberName); } } protected static string GenerateType (string girFile, string typeName, bool compat = false) { - var repositories = ParseGirFile(girFile, out var mainRepository); - var opts = GetOptions(repositories, mainRepository, compat); - - GenerateType(mainRepository, opts, typeName); + var repositories = ParseGirFile (girFile, out var mainRepository); + var opts = GetOptions (repositories, mainRepository, compat); + + GenerateType (mainRepository, opts, typeName); - return GetGenerationResult(opts); + return GetGenerationResult (opts); } - protected static string GenerateMember(string girFile, string typeName, string memberName, bool compat = false) + protected static string GenerateMember (string girFile, string typeName, string memberName, bool compat = false) { - var repositories = ParseGirFile(girFile, out var mainRepository); - var opts = GetOptions(repositories, mainRepository, compat); + var repositories = ParseGirFile (girFile, out var mainRepository); + var opts = GetOptions (repositories, mainRepository, compat); - GenerateMember(mainRepository, opts, typeName, memberName); + GenerateMember (mainRepository, opts, typeName, memberName); - return GetGenerationResult(opts); + return GetGenerationResult (opts); } } } diff --git a/src/Gir.Tests/InterfaceTests.cs b/src/Gir.Tests/InterfaceTests.cs index 6983bc5..a4b9668 100644 --- a/src/Gir.Tests/InterfaceTests.cs +++ b/src/Gir.Tests/InterfaceTests.cs @@ -1,5 +1,4 @@ -using System; - + using NUnit.Framework; namespace Gir.Tests @@ -8,13 +7,13 @@ namespace Gir.Tests public class InterfaceTests : GenerationTestBase { [Test] - public void TestClassIsGenerated() + public void TestClassIsGenerated () { // Test is incomplete, as record is not fully generated atm. - var result = GenerateType(Gio2, "Seekable"); + var result = GenerateType (Gio2, "Seekable"); // Need to map pointers at symbol level. - Assert.AreEqual(@"namespace Gio + Assert.AreEqual (@"namespace Gio { /// /// #GSeekable is implemented by streams (implementations of diff --git a/src/Gir.Tests/RecordTests.cs b/src/Gir.Tests/RecordTests.cs index 3bf28be..b8ac487 100644 --- a/src/Gir.Tests/RecordTests.cs +++ b/src/Gir.Tests/RecordTests.cs @@ -1,4 +1,4 @@ -using System; + using NUnit.Framework; namespace Gir.Tests @@ -7,14 +7,14 @@ namespace Gir.Tests public class RecordTests : GenerationTestBase { [Test] - public void TestRecordIsGenerated() + public void TestRecordIsGenerated () { // Test is incomplete, as record is not fully generated atm. - var result = GenerateType(GLib, "ByteArray"); + var result = GenerateType (GLib, "ByteArray"); // Need to map pointers at symbol level. - Assert.AreEqual(@"namespace GLib + Assert.AreEqual (@"namespace GLib { ///Contains the public fields of a GByteArray. public struct ByteArray @@ -191,11 +191,11 @@ static void Unref PARAMS public void CanGenerateActionIfaceRecord () { // Test is incomplete, as record is not fully generated atm. - var result = GenerateType(Atk1, "ActionIface"); + var result = GenerateType (Atk1, "ActionIface"); // Need to map pointers at symbol level. - Assert.AreEqual(@"namespace Atk + Assert.AreEqual (@"namespace Atk { }", result); } diff --git a/src/Gir.Tests/SymbolTableTests.cs b/src/Gir.Tests/SymbolTableTests.cs index f18e0f8..fe0d682 100644 --- a/src/Gir.Tests/SymbolTableTests.cs +++ b/src/Gir.Tests/SymbolTableTests.cs @@ -10,27 +10,27 @@ public class SymbolTableTests : GenerationTestBase [Test] public void TestAliasMapping () { - var repo = ParseGirFile(GLib, out var mainRepository); - var opts = GetOptions(repo, mainRepository); + var repo = ParseGirFile (GLib, out var mainRepository); + var opts = GetOptions (repo, mainRepository); - Assert.AreEqual(opts.SymbolTable["guint8"], opts.SymbolTable["GDateDay"]); + Assert.AreEqual (opts.SymbolTable ["guint8"], opts.SymbolTable ["GDateDay"]); } - [TestCase(Gdk3, 2)] - [TestCase(GLib, 0)] - [TestCase(Gtk3, 2)] - [TestCase(Pango, 2)] - public void TestSymbolTableErrorsTracker(string girFile, int errorCount) + [TestCase (Gdk3, 2)] + [TestCase (GLib, 0)] + [TestCase (Gtk3, 2)] + [TestCase (Pango, 2)] + public void TestSymbolTableErrorsTracker (string girFile, int errorCount) { - var repo = ParseGirFile(girFile, out var mainRepository); - var opts = GetOptions(repo, mainRepository); + var repo = ParseGirFile (girFile, out var mainRepository); + var opts = GetOptions (repo, mainRepository); var stats = opts.Statistics.Errors.ToArray (); // FUTURE: This should be 0. - Assert.AreEqual(errorCount, stats.Length); + Assert.AreEqual (errorCount, stats.Length); foreach (var error in stats) { - Console.WriteLine(error.Message); + Console.WriteLine (error.Message); } } @@ -40,29 +40,29 @@ public void NoAliasTypeAfterProcessing () foreach (var tpl in ParseAllGirFiles ()) { var repo = tpl.Item2; var mainRepository = tpl.Item1; - - var opts = GetOptions(repo, mainRepository); - Assert.AreEqual(0, opts.SymbolTable.OfType().Count()); + var opts = GetOptions (repo, mainRepository); + + Assert.AreEqual (0, opts.SymbolTable.OfType ().Count ()); } } [Test] public void VoidPointerWorks () { - var repo = ParseGirFile(GLib, out var mainRepository); - var opts = GetOptions(repo, mainRepository); + var repo = ParseGirFile (GLib, out var mainRepository); + var opts = GetOptions (repo, mainRepository); - Assert.AreEqual("gpointer", opts.SymbolTable["void*"].CType); + Assert.AreEqual ("gpointer", opts.SymbolTable ["void*"].CType); } - + [Test] public void CanResolveIncludedFiles () { - var repo = ParseGirFile(Gtk3, out var mainRepository); - var opts = GetOptions(repo, mainRepository); + var repo = ParseGirFile (Gtk3, out var mainRepository); + var opts = GetOptions (repo, mainRepository); - Assert.NotNull(opts.SymbolTable["GdkPixbufError"]); + Assert.NotNull (opts.SymbolTable ["GdkPixbufError"]); } } } diff --git a/src/Gir.Tests/Test.cs b/src/Gir.Tests/Test.cs index 5488efa..733db77 100644 --- a/src/Gir.Tests/Test.cs +++ b/src/Gir.Tests/Test.cs @@ -6,7 +6,7 @@ namespace Gir.Tests public class ParserTests : GenerationTestBase { [Test] - public void CanLoadGirFiles() + public void CanLoadGirFiles () { foreach (var repo in ParseAllGirFiles ()) { // Should not throw. diff --git a/src/Gir/Error.cs b/src/Gir/Error.cs index 4893c9e..90dd39b 100644 --- a/src/Gir/Error.cs +++ b/src/Gir/Error.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public abstract class Error diff --git a/src/Gir/Generation/Array.cs b/src/Gir/Generation/Array.cs index 9491533..0d214fb 100644 --- a/src/Gir/Generation/Array.cs +++ b/src/Gir/Generation/Array.cs @@ -1,10 +1,9 @@ -using System; - + namespace Gir { public partial class Array : IGeneratable { - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { } diff --git a/src/Gir/Generation/Bitfield.cs b/src/Gir/Generation/Bitfield.cs index 3a4efdb..3bd9970 100644 --- a/src/Gir/Generation/Bitfield.cs +++ b/src/Gir/Generation/Bitfield.cs @@ -1,35 +1,33 @@ -using System; -using System.IO; - + namespace Gir { public partial class Bitfield : IGeneratable, IDocumented, IEnumFormatter { - public string FormatValue(string value) + public string FormatValue (string value) { - int intValue = int.Parse(value); + int intValue = int.Parse (value); // Maybe pad with leading zeroes based on the value? - return string.Format("0x{0:X}", intValue); + return string.Format ("0x{0:X}", intValue); } - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { using (var writer = this.GetWriter (opts)) { - writer.WriteLine("namespace " + opts.Namespace.Name); - writer.WriteLine("{"); - using (writer.Indent()) { - this.GenerateDocumentation(writer); - writer.WriteLine("[Flags]"); - writer.WriteLine("public enum " + Name); - writer.WriteLine("{"); + writer.WriteLine ("namespace " + opts.Namespace.Name); + writer.WriteLine ("{"); + using (writer.Indent ()) { + this.GenerateDocumentation (writer); + writer.WriteLine ("[Flags]"); + writer.WriteLine ("public enum " + Name); + writer.WriteLine ("{"); - using (writer.Indent()) { - this.GenerateMembers(writer); + using (writer.Indent ()) { + this.GenerateMembers (writer); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } } } diff --git a/src/Gir/Generation/Class.cs b/src/Gir/Generation/Class.cs index f83d8f6..f76972a 100644 --- a/src/Gir/Generation/Class.cs +++ b/src/Gir/Generation/Class.cs @@ -1,28 +1,27 @@ -using System; -using System.Linq; +using System.Linq; namespace Gir { public partial class Class : IGeneratable, IDocumented { - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { - using (var writer = this.GetWriter(opts)) { - writer.WriteLine("namespace " + opts.Namespace.Name); - writer.WriteLine("{"); - using (writer.Indent()) { - this.GenerateDocumentation(writer); + using (var writer = this.GetWriter (opts)) { + writer.WriteLine ("namespace " + opts.Namespace.Name); + writer.WriteLine ("{"); + using (writer.Indent ()) { + this.GenerateDocumentation (writer); - var inheritanceList = string.Join(", ", Implements.Select(x => x.Name).ToArray()); - writer.WriteLine($"public class {Name} : {inheritanceList}"); - writer.WriteLine("{"); + var inheritanceList = string.Join (", ", Implements.Select (x => x.Name).ToArray ()); + writer.WriteLine ($"public class {Name} : {inheritanceList}"); + writer.WriteLine ("{"); - using (writer.Indent()) { - this.GenerateMembers(writer); + using (writer.Indent ()) { + this.GenerateMembers (writer); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } } diff --git a/src/Gir/Generation/Constant.cs b/src/Gir/Generation/Constant.cs index 2027f7b..7407c91 100644 --- a/src/Gir/Generation/Constant.cs +++ b/src/Gir/Generation/Constant.cs @@ -1,10 +1,9 @@ -using System; - + namespace Gir { public partial class Constant : IGeneratable { - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { } } diff --git a/src/Gir/Generation/Constructor.cs b/src/Gir/Generation/Constructor.cs index 5e222a3..5d5ecc5 100644 --- a/src/Gir/Generation/Constructor.cs +++ b/src/Gir/Generation/Constructor.cs @@ -5,12 +5,12 @@ public partial class Constructor : ICallable, IDocumented { public string Modifiers => string.Empty; - public void Generate(IGeneratable parent, IndentWriter writer) + public void Generate (IGeneratable parent, IndentWriter writer) { - this.GenerateConstructor(parent, writer); + this.GenerateConstructor (parent, writer); } - public bool NewlineAfterGeneration(GenerationOptions opts) + public bool NewlineAfterGeneration (GenerationOptions opts) { return true; } diff --git a/src/Gir/Generation/Enumeration.cs b/src/Gir/Generation/Enumeration.cs index 5a036f3..f0956f5 100644 --- a/src/Gir/Generation/Enumeration.cs +++ b/src/Gir/Generation/Enumeration.cs @@ -1,26 +1,24 @@ -using System; -using System.IO; - + namespace Gir { public partial class Enumeration : IGeneratable, IDocumented { - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { - using (var writer = this.GetWriter(opts)) { - writer.WriteLine("namespace " + opts.Namespace.Name); - writer.WriteLine("{"); - using (writer.Indent()) { - this.GenerateDocumentation(writer); - writer.WriteLine("public enum " + Name); - writer.WriteLine("{"); + using (var writer = this.GetWriter (opts)) { + writer.WriteLine ("namespace " + opts.Namespace.Name); + writer.WriteLine ("{"); + using (writer.Indent ()) { + this.GenerateDocumentation (writer); + writer.WriteLine ("public enum " + Name); + writer.WriteLine ("{"); - using (writer.Indent()) { - this.GenerateMembers(writer); + using (writer.Indent ()) { + this.GenerateMembers (writer); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } } } diff --git a/src/Gir/Generation/Field.cs b/src/Gir/Generation/Field.cs index 6f8bf34..d206c40 100644 --- a/src/Gir/Generation/Field.cs +++ b/src/Gir/Generation/Field.cs @@ -1,20 +1,20 @@ -using System; + namespace Gir { public partial class Field : IMemberGeneratable, IDocumented { - public void Generate(IGeneratable parent, IndentWriter writer) + public void Generate (IGeneratable parent, IndentWriter writer) { // Simple uncorrect gen for now - var managedType = this.GetSymbol(writer.Options); + var managedType = this.GetSymbol (writer.Options); // We need something that will tell us the equivalent C# type // including the number of pointers. // For now, generate normal info. - writer.WriteLine($"{managedType.CSharpType} {Name};"); + writer.WriteLine ($"{managedType.CSharpType} {Name};"); } - public bool NewlineAfterGeneration(GenerationOptions opts) => true; + public bool NewlineAfterGeneration (GenerationOptions opts) => true; } } diff --git a/src/Gir/Generation/Function.cs b/src/Gir/Generation/Function.cs index 3bc546b..1110c76 100644 --- a/src/Gir/Generation/Function.cs +++ b/src/Gir/Generation/Function.cs @@ -1,15 +1,15 @@ -using System; + namespace Gir { public partial class Function : ICallable { public string Modifiers => "static"; - public void Generate(IGeneratable parent, IndentWriter writer) + public void Generate (IGeneratable parent, IndentWriter writer) { - this.GenerateCallableDefinition(writer); + this.GenerateCallableDefinition (writer); } - public bool NewlineAfterGeneration(GenerationOptions opts) => true; + public bool NewlineAfterGeneration (GenerationOptions opts) => true; } } diff --git a/src/Gir/Generation/IGeneratable.cs b/src/Gir/Generation/IGeneratable.cs index f7a3309..2df361e 100644 --- a/src/Gir/Generation/IGeneratable.cs +++ b/src/Gir/Generation/IGeneratable.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Gir { @@ -9,7 +7,7 @@ public interface IGeneratable { string Name { get; } //void Process(); - void Generate(GenerationOptions opts); + void Generate (GenerationOptions opts); } // IDocumented might end up being added to IGeneratable/IMemberGeneratable @@ -22,8 +20,8 @@ public interface IDocumented public interface IMemberGeneratable { string Name { get; } - bool NewlineAfterGeneration(GenerationOptions opts); - void Generate(IGeneratable parent, IndentWriter writer); + bool NewlineAfterGeneration (GenerationOptions opts); + void Generate (IGeneratable parent, IndentWriter writer); } public interface ICallable : IMemberGeneratable, IDocumented diff --git a/src/Gir/Generation/IGeneratableExtensions.cs b/src/Gir/Generation/IGeneratableExtensions.cs index a52bdc2..8b7eb9b 100644 --- a/src/Gir/Generation/IGeneratableExtensions.cs +++ b/src/Gir/Generation/IGeneratableExtensions.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; namespace Gir { @@ -10,74 +9,74 @@ public static class IGeneratableExtensions { const string CSharpFileExtension = ".cs"; - public static IndentWriter GetWriter(this IGeneratable gen, GenerationOptions opts) + public static IndentWriter GetWriter (this IGeneratable gen, GenerationOptions opts) { - var path = Path.Combine(opts.DirectoryPath, gen.Name + CSharpFileExtension); - return IndentWriter.OpenWrite(path, opts); + var path = Path.Combine (opts.DirectoryPath, gen.Name + CSharpFileExtension); + return IndentWriter.OpenWrite (path, opts); } - public static void GenerateDocumentation(this IDocumented gen, IndentWriter writer) + public static void GenerateDocumentation (this IDocumented gen, IndentWriter writer) { if (gen.Doc is null) return; - writer.WriteDocumentation(gen.Doc, gen is ReturnValue ? "returns" : "summary"); + writer.WriteDocumentation (gen.Doc, gen is ReturnValue ? "returns" : "summary"); } - public static void GenerateMembers(this IGeneratable gen, IndentWriter writer, Func where = null) + public static void GenerateMembers (this IGeneratable gen, IndentWriter writer, Func where = null) { - var array = gen.GetMemberGeneratables().Where(x => where == null || where(x)).ToArray(); + var array = gen.GetMemberGeneratables ().Where (x => where == null || where (x)).ToArray (); for (int i = 0; i < array.Length; ++i) { - var member = array[i]; + var member = array [i]; // Generate pinvoke signature for a method if (member is ICallable callable) - callable.GenerateImport(gen, writer); + callable.GenerateImport (gen, writer); // Generate documentation is a member supports it. if (member is IDocumented doc) - doc.GenerateDocumentation(writer); + doc.GenerateDocumentation (writer); // Call the main member generation implementation. - member.Generate(gen, writer); + member.Generate (gen, writer); - if (i != array.Length - 1 && member.NewlineAfterGeneration(writer.Options)) - writer.WriteLine(); + if (i != array.Length - 1 && member.NewlineAfterGeneration (writer.Options)) + writer.WriteLine (); } } - static void GenerateImport(this ICallable callable, IGeneratable parent, IndentWriter writer) + static void GenerateImport (this ICallable callable, IGeneratable parent, IndentWriter writer) { - var retType = GetReturnCSharpType(callable, writer); + var retType = GetReturnCSharpType (callable, writer); - writer.WriteLine($"static extern {retType} {callable.CIdentifier} PARAMS"); - writer.WriteLine(); + writer.WriteLine ($"static extern {retType} {callable.CIdentifier} PARAMS"); + writer.WriteLine (); } - static string GetReturnCSharpType(this ICallable callable, IndentWriter writer) + static string GetReturnCSharpType (this ICallable callable, IndentWriter writer) { // This can also be array - return callable.ReturnValue?.Type?.GetSymbol(writer.Options).CSharpType ?? "void"; + return callable.ReturnValue?.Type?.GetSymbol (writer.Options).CSharpType ?? "void"; } - public static void GenerateCallableDefinition(this ICallable callable, IndentWriter writer) + public static void GenerateCallableDefinition (this ICallable callable, IndentWriter writer) { - callable.ReturnValue.GenerateDocumentation(writer); + callable.ReturnValue.GenerateDocumentation (writer); - writer.WriteIndent(); - if (!string.IsNullOrEmpty(callable.Modifiers)) - writer.Write(callable.Modifiers + " "); + writer.WriteIndent (); + if (!string.IsNullOrEmpty (callable.Modifiers)) + writer.Write (callable.Modifiers + " "); - var returnType = callable.GetReturnCSharpType(writer); + var returnType = callable.GetReturnCSharpType (writer); // generate ReturnValue then Parameters - writer.Write(string.Format("{0} {1} {2}", returnType, callable.Name.ToCSharp (), "PARAMS")); - writer.WriteLine(); + writer.Write (string.Format ("{0} {1} {2}", returnType, callable.Name.ToCSharp (), "PARAMS")); + writer.WriteLine (); } - public static void GenerateConstructor(this ICallable callable, IGeneratable parent, IndentWriter writer) + public static void GenerateConstructor (this ICallable callable, IGeneratable parent, IndentWriter writer) { - callable.ReturnValue.GenerateDocumentation(writer); + callable.ReturnValue.GenerateDocumentation (writer); var modifier = ""; if (parent is Class) { @@ -87,34 +86,34 @@ public static void GenerateConstructor(this ICallable callable, IGeneratable par modifier = "protected "; } - var (typesAndNames, names) = BuildParameters(callable.Parameters); + var (typesAndNames, names) = BuildParameters (callable.Parameters); // FIXME, should check to see if it is deprecated - writer.WriteLine($"{modifier}{parent.Name}({typesAndNames}) : base ({names})"); - writer.WriteLine("{"); - writer.WriteLine("}"); + writer.WriteLine ($"{modifier}{parent.Name}({typesAndNames}) : base ({names})"); + writer.WriteLine ("{"); + writer.WriteLine ("}"); } - public static (string both, string names) BuildParameters(List parameters) + public static (string both, string names) BuildParameters (List parameters) { // PERF: Use an array as the string[] overload of Join is way more efficient than the IEnumerable one. - var typeAndName = new string[parameters.Count]; - var parameterNames = new string[parameters.Count]; + var typeAndName = new string [parameters.Count]; + var parameterNames = new string [parameters.Count]; for (int i = 0; i < parameters.Count; ++i) { - var parameter = parameters[i]; - typeAndName[i] = parameter.Type.Name + " " + parameter.Name; - parameterNames[i] = parameter.Name; + var parameter = parameters [i]; + typeAndName [i] = parameter.Type.Name + " " + parameter.Name; + parameterNames [i] = parameter.Name; } - string parameterString = string.Join(", ", typeAndName); - string baseParams = string.Join(", ", parameterNames); + string parameterString = string.Join (", ", typeAndName); + string baseParams = string.Join (", ", parameterNames); return (parameterString, baseParams); } - static IEnumerable GetMemberGeneratables(this IGeneratable gen) + static IEnumerable GetMemberGeneratables (this IGeneratable gen) { - return Utils.GetAllCollectionMembers(gen); + return Utils.GetAllCollectionMembers (gen); } } } diff --git a/src/Gir/Generation/IndentWriter.cs b/src/Gir/Generation/IndentWriter.cs index 07d4b34..636a78d 100644 --- a/src/Gir/Generation/IndentWriter.cs +++ b/src/Gir/Generation/IndentWriter.cs @@ -12,22 +12,22 @@ public class IndentWriter : IDisposable public static IndentWriter OpenWrite (string path, GenerationOptions opts) { - var toStream = opts.RedirectStream ?? File.Open(path, FileMode.Create); - var sw = new StreamWriter(toStream); + var toStream = opts.RedirectStream ?? File.Open (path, FileMode.Create); + var sw = new StreamWriter (toStream); - return new IndentWriter(sw) { + return new IndentWriter (sw) { Options = opts, }; } - public IndentWriter(TextWriter tw) + public IndentWriter (TextWriter tw) { writer = tw; } public void Dispose () { - writer?.Dispose(); + writer?.Dispose (); writer = null; } @@ -36,62 +36,62 @@ public IndentWriter WriteDocumentation (Documentation doc, string tag) if (!Options.GenerateDocumentation) return this; - var text = doc.Text.Split('\n'); + var text = doc.Text.Split ('\n'); if (text.Length == 1) { - WriteIndent(); - return Write($"///<{tag}>").Write(text[0]).Write($"").WriteLine (); + WriteIndent (); + return Write ($"///<{tag}>").Write (text [0]).Write ($"").WriteLine (); } - WriteLine($"///<{tag}>"); + WriteLine ($"///<{tag}>"); foreach (var line in text) - WriteLine("/// " + line); - return WriteLine($"///"); + WriteLine ("/// " + line); + return WriteLine ($"///"); } - public IndentWriter WriteIndent() + public IndentWriter WriteIndent () { - writer.Write(new String('\t', indent)); + writer.Write (new string ('\t', indent)); return this; } - public IndentWriter Write(string s) + public IndentWriter Write (string s) { - writer.Write(s); + writer.Write (s); return this; } - public IndentWriter WriteLine() + public IndentWriter WriteLine () { - writer.WriteLine(); + writer.WriteLine (); return this; } - public IndentWriter WriteLine(string s) + public IndentWriter WriteLine (string s) { - return WriteIndent().Write(s).WriteLine (); + return WriteIndent ().Write (s).WriteLine (); } - public IndentWriter WriteLineAndIndent(string s) + public IndentWriter WriteLineAndIndent (string s) { - WriteLine(s); - Indent(); + WriteLine (s); + Indent (); return this; } - public IndentWriter WriteLineAndUnindent(string s) + public IndentWriter WriteLineAndUnindent (string s) { - Unindent(); - WriteLine(s); + Unindent (); + WriteLine (s); return this; } - public IDisposable Indent() + public IDisposable Indent () { indent++; - return new IndentDisposable(this); + return new IndentDisposable (this); } - public void Unindent() + public void Unindent () { indent--; } diff --git a/src/Gir/Generation/Interface.cs b/src/Gir/Generation/Interface.cs index 9d06c9f..fd5f9d8 100644 --- a/src/Gir/Generation/Interface.cs +++ b/src/Gir/Generation/Interface.cs @@ -1,26 +1,25 @@ -using System; - + namespace Gir { public partial class Interface : IGeneratable, IDocumented { // TODO, We should probably add 'I' to 'Name' unless in compat mode - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { - using (var writer = this.GetWriter(opts)) { - writer.WriteLine("namespace " + opts.Namespace.Name); - writer.WriteLine("{"); - using (writer.Indent()) { - this.GenerateDocumentation(writer); - writer.WriteLine($"public interface {Name}"); - writer.WriteLine("{"); + using (var writer = this.GetWriter (opts)) { + writer.WriteLine ("namespace " + opts.Namespace.Name); + writer.WriteLine ("{"); + using (writer.Indent ()) { + this.GenerateDocumentation (writer); + writer.WriteLine ($"public interface {Name}"); + writer.WriteLine ("{"); - using (writer.Indent()) { - this.GenerateMembers(writer); + using (writer.Indent ()) { + this.GenerateMembers (writer); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } } } diff --git a/src/Gir/Generation/Member.cs b/src/Gir/Generation/Member.cs index bc0ef00..a3d2ec4 100644 --- a/src/Gir/Generation/Member.cs +++ b/src/Gir/Generation/Member.cs @@ -1,22 +1,22 @@ -using System; + namespace Gir { public partial class Member : IMemberGeneratable, IDocumented { - public bool NewlineAfterGeneration(GenerationOptions opts) => opts.GenerateDocumentation; + public bool NewlineAfterGeneration (GenerationOptions opts) => opts.GenerateDocumentation; - public void Generate(IGeneratable parent, IndentWriter writer) + public void Generate (IGeneratable parent, IndentWriter writer) { string value = Value; if (parent is IEnumFormatter formatter) - value = formatter.FormatValue(value); + value = formatter.FormatValue (value); - writer.WriteLine(Name.ToCSharp() + " = " + value + ","); + writer.WriteLine (Name.ToCSharp () + " = " + value + ","); } } public interface IEnumFormatter { - string FormatValue(string value); + string FormatValue (string value); } } diff --git a/src/Gir/Generation/Method.cs b/src/Gir/Generation/Method.cs index b4f2924..52a62ef 100644 --- a/src/Gir/Generation/Method.cs +++ b/src/Gir/Generation/Method.cs @@ -1,15 +1,15 @@ -using System; + namespace Gir { public partial class Method : ICallable { public string Modifiers => string.Empty; - public void Generate(IGeneratable parent, IndentWriter writer) + public void Generate (IGeneratable parent, IndentWriter writer) { - this.GenerateCallableDefinition(writer); + this.GenerateCallableDefinition (writer); } - public bool NewlineAfterGeneration(GenerationOptions opts) => true; + public bool NewlineAfterGeneration (GenerationOptions opts) => true; } } diff --git a/src/Gir/Generation/Namespace.cs b/src/Gir/Generation/Namespace.cs index c4fe310..bae2f86 100644 --- a/src/Gir/Generation/Namespace.cs +++ b/src/Gir/Generation/Namespace.cs @@ -4,6 +4,6 @@ namespace Gir { public partial class Namespace { - public IEnumerable GetGeneratables() => Utils.GetAllCollectionMembers(this); + public IEnumerable GetGeneratables () => Utils.GetAllCollectionMembers (this); } } diff --git a/src/Gir/Generation/Record.cs b/src/Gir/Generation/Record.cs index 3ef6cbf..dd5ec37 100644 --- a/src/Gir/Generation/Record.cs +++ b/src/Gir/Generation/Record.cs @@ -1,24 +1,24 @@ -using System; + namespace Gir { public partial class Record : IGeneratable, IDocumented { - public void Generate(GenerationOptions opts) + public void Generate (GenerationOptions opts) { - using (var writer = this.GetWriter(opts)) { - writer.WriteLine("namespace " + opts.Namespace.Name); - writer.WriteLine("{"); - using (writer.Indent()) { - this.GenerateDocumentation(writer); - writer.WriteLine("public struct " + Name); - writer.WriteLine("{"); + using (var writer = this.GetWriter (opts)) { + writer.WriteLine ("namespace " + opts.Namespace.Name); + writer.WriteLine ("{"); + using (writer.Indent ()) { + this.GenerateDocumentation (writer); + writer.WriteLine ("public struct " + Name); + writer.WriteLine ("{"); - using (writer.Indent()) { - this.GenerateMembers(writer); + using (writer.Indent ()) { + this.GenerateMembers (writer); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } - writer.WriteLine("}"); + writer.WriteLine ("}"); } } } diff --git a/src/Gir/Generation/Repository.cs b/src/Gir/Generation/Repository.cs index 82c9f86..4f145b4 100644 --- a/src/Gir/Generation/Repository.cs +++ b/src/Gir/Generation/Repository.cs @@ -4,6 +4,6 @@ namespace Gir { public partial class Repository { - public IEnumerable GetGeneratables() => Namespace.GetGeneratables(); + public IEnumerable GetGeneratables () => Namespace.GetGeneratables (); } } diff --git a/src/Gir/GenerationOptions.cs b/src/Gir/GenerationOptions.cs index 236bf44..e5948b2 100644 --- a/src/Gir/GenerationOptions.cs +++ b/src/Gir/GenerationOptions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -8,7 +7,7 @@ namespace Gir public sealed class GenerationOptions { public SymbolTable SymbolTable { get; } - public Statistics Statistics { get; } = new Statistics(); + public Statistics Statistics { get; } = new Statistics (); #region Generation information public string DirectoryPath { get; } @@ -31,16 +30,16 @@ public sealed class GenerationOptions #endregion - public GenerationOptions(string dir, IEnumerable allRepos, Repository repo, bool compat = false, Stream redirectStream = null, bool win64Longs = false) + public GenerationOptions (string dir, IEnumerable allRepos, Repository repo, bool compat = false, Stream redirectStream = null, bool win64Longs = false) { DirectoryPath = dir; Repository = repo; this.compat = compat; RedirectStream = redirectStream; - SymbolTable = new SymbolTable(Statistics, win64Longs); - SymbolTable.AddTypes(allRepos.SelectMany (x => x.GetSymbols ())); - SymbolTable.ProcessAliases(); + SymbolTable = new SymbolTable (Statistics, win64Longs); + SymbolTable.AddTypes (allRepos.SelectMany (x => x.GetSymbols ())); + SymbolTable.ProcessAliases (); } } } diff --git a/src/Gir/Marshal/Alias.cs b/src/Gir/Marshal/Alias.cs index c004301..02185f1 100644 --- a/src/Gir/Marshal/Alias.cs +++ b/src/Gir/Marshal/Alias.cs @@ -1,9 +1,10 @@ using System; + namespace Gir { public partial class Alias : ISymbol { - public string CSharpType => throw new NotSupportedException(); - public string DefaultValue => throw new NotSupportedException(); + public string CSharpType => throw new NotSupportedException (); + public string DefaultValue => throw new NotSupportedException (); } } diff --git a/src/Gir/Marshal/Bitfield.cs b/src/Gir/Marshal/Bitfield.cs index de0e587..62f7802 100644 --- a/src/Gir/Marshal/Bitfield.cs +++ b/src/Gir/Marshal/Bitfield.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public partial class Bitfield : ISymbol diff --git a/src/Gir/Marshal/Class.cs b/src/Gir/Marshal/Class.cs index 7fd8054..59b1c52 100644 --- a/src/Gir/Marshal/Class.cs +++ b/src/Gir/Marshal/Class.cs @@ -5,6 +5,6 @@ public partial class Class : ISymbol { public string CSharpType => Name; - public string DefaultValue => throw new System.NotImplementedException(); + public string DefaultValue => throw new System.NotImplementedException (); } } diff --git a/src/Gir/Marshal/Enumeration.cs b/src/Gir/Marshal/Enumeration.cs index 23e7d82..64addc5 100644 --- a/src/Gir/Marshal/Enumeration.cs +++ b/src/Gir/Marshal/Enumeration.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public partial class Enumeration : ISymbol diff --git a/src/Gir/Marshal/Field.cs b/src/Gir/Marshal/Field.cs index 881441c..f96dccd 100644 --- a/src/Gir/Marshal/Field.cs +++ b/src/Gir/Marshal/Field.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public partial class Field : IHasType diff --git a/src/Gir/Marshal/IHasType.cs b/src/Gir/Marshal/IHasType.cs index 4651de2..a01605a 100644 --- a/src/Gir/Marshal/IHasType.cs +++ b/src/Gir/Marshal/IHasType.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public interface IHasType @@ -8,9 +8,9 @@ public interface IHasType public static class IHasTypeExtensions { - public static ISymbol GetSymbol(this IHasType type, GenerationOptions opts) + public static ISymbol GetSymbol (this IHasType type, GenerationOptions opts) { - return opts.SymbolTable[type.Type.CType]; + return opts.SymbolTable [type.Type.CType]; } } } diff --git a/src/Gir/Marshal/IPassByValue.cs b/src/Gir/Marshal/IPassByValue.cs index 8c7ae03..58d13af 100644 --- a/src/Gir/Marshal/IPassByValue.cs +++ b/src/Gir/Marshal/IPassByValue.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public interface IPassByValue diff --git a/src/Gir/Marshal/ISymbol.cs b/src/Gir/Marshal/ISymbol.cs index edbdc02..cee8c87 100644 --- a/src/Gir/Marshal/ISymbol.cs +++ b/src/Gir/Marshal/ISymbol.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public interface ISymbol diff --git a/src/Gir/Marshal/ISymbolExtensions.cs b/src/Gir/Marshal/ISymbolExtensions.cs index 36144a3..31af2f3 100644 --- a/src/Gir/Marshal/ISymbolExtensions.cs +++ b/src/Gir/Marshal/ISymbolExtensions.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public static class ISymbolExtensions diff --git a/src/Gir/Marshal/Interface.cs b/src/Gir/Marshal/Interface.cs index 92fdd34..0b0b63a 100644 --- a/src/Gir/Marshal/Interface.cs +++ b/src/Gir/Marshal/Interface.cs @@ -6,6 +6,6 @@ public partial class Interface : ISymbol { public string CSharpType => "I" + Name; - public string DefaultValue => throw new NotImplementedException(); + public string DefaultValue => throw new NotImplementedException (); } } diff --git a/src/Gir/Marshal/Namespace.cs b/src/Gir/Marshal/Namespace.cs index 570fded..f588d2d 100644 --- a/src/Gir/Marshal/Namespace.cs +++ b/src/Gir/Marshal/Namespace.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Gir { public partial class Namespace { - public IEnumerable GetSymbols() => Utils.GetAllCollectionMembers (this); + public IEnumerable GetSymbols () => Utils.GetAllCollectionMembers (this); } } diff --git a/src/Gir/Marshal/Primitive.cs b/src/Gir/Marshal/Primitive.cs index e45f79f..6b7a9cd 100644 --- a/src/Gir/Marshal/Primitive.cs +++ b/src/Gir/Marshal/Primitive.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public class Primitive : ISymbol @@ -9,7 +9,7 @@ public class Primitive : ISymbol public string ByValueMarshalType => CSharpType; - public Primitive(string ctype, string csharpType, string defaultValue) + public Primitive (string ctype, string csharpType, string defaultValue) { CType = ctype; CSharpType = csharpType; diff --git a/src/Gir/Marshal/Record.cs b/src/Gir/Marshal/Record.cs index b3748cf..876964e 100644 --- a/src/Gir/Marshal/Record.cs +++ b/src/Gir/Marshal/Record.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public partial class Record : ISymbol diff --git a/src/Gir/Marshal/Repository.cs b/src/Gir/Marshal/Repository.cs index 0608f99..205b054 100644 --- a/src/Gir/Marshal/Repository.cs +++ b/src/Gir/Marshal/Repository.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Gir { public partial class Repository { - public IEnumerable GetSymbols() => Namespace.GetSymbols(); + public IEnumerable GetSymbols () => Namespace.GetSymbols (); } } diff --git a/src/Gir/Marshal/SymbolTable.Builtin.cs b/src/Gir/Marshal/SymbolTable.Builtin.cs index d9f215d..5090d61 100644 --- a/src/Gir/Marshal/SymbolTable.Builtin.cs +++ b/src/Gir/Marshal/SymbolTable.Builtin.cs @@ -1,12 +1,12 @@ -using System; + namespace Gir { public partial class SymbolTable { // Only call this, not the ones below. - void RegisterBuiltIn(bool nativeWin64) + void RegisterBuiltIn (bool nativeWin64) { - RegisterPrimitives(nativeWin64); + RegisterPrimitives (nativeWin64); //AddType(new MarshalGen("time_t", "System.DateTime", "IntPtr", "GLib.Marshaller.DateTimeTotime_t ({0})", "GLib.Marshaller.time_tToDateTime ({0})")); //AddType(new StringMarshalGen("gfilename", "string", "IntPtr", "GLib.Marshaller.StringToFilenamePtr({0})", "GLib.Marshaller.FilenamePtrToStringGFree({0})")); @@ -16,58 +16,59 @@ void RegisterBuiltIn(bool nativeWin64) void RegisterPrimitives (bool nativeWin64) { - AddType(new Primitive("void", "void", string.Empty)); - AddType(new Primitive("gpointer", "IntPtr", "IntPtr.Zero")); - AddType(new Primitive("gboolean", "bool", "false")); - AddType(new Primitive("gint", "int", "0")); - AddType(new Primitive("guint", "uint", "0")); - AddType(new Primitive("int", "int", "0")); - AddType(new Primitive("unsigned", "uint", "0")); - AddType(new Primitive("unsigned int", "uint", "0")); - AddType(new Primitive("gshort", "short", "0")); - AddType(new Primitive("gushort", "ushort", "0")); - AddType(new Primitive("short", "short", "0")); - AddType(new Primitive("guchar", "byte", "0")); - AddType(new Primitive("unsigned char", "byte", "0")); - AddType(new Primitive("guint1", "bool", "false")); - AddType(new Primitive("uint1", "bool", "false")); - AddType(new Primitive("gint8", "sbyte", "0")); - AddType(new Primitive("guint8", "byte", "0")); - AddType(new Primitive("gint16", "short", "0")); - AddType(new Primitive("guint16", "ushort", "0")); - AddType(new Primitive("gint32", "int", "0")); - AddType(new Primitive("guint32", "uint", "0")); - AddType(new Primitive("gint64", "long", "0")); - AddType(new Primitive("guint64", "ulong", "0")); - AddType(new Primitive("long long", "long", "0")); - AddType(new Primitive("gfloat", "float", "0.0")); - AddType(new Primitive("float", "float", "0.0")); - AddType(new Primitive("gdouble", "double", "0.0")); - AddType(new Primitive("double", "double", "0.0")); - AddType(new Primitive("goffset", "long", "0")); + AddType (new Primitive ("void", "void", string.Empty)); + AddType (new Primitive ("gpointer", "IntPtr", "IntPtr.Zero")); + AddType (new Primitive ("gboolean", "bool", "false")); + AddType (new Primitive ("gint", "int", "0")); + AddType (new Primitive ("guint", "uint", "0")); + AddType (new Primitive ("int", "int", "0")); + AddType (new Primitive ("unsigned", "uint", "0")); + AddType (new Primitive ("unsigned int", "uint", "0")); + AddType (new Primitive ("gshort", "short", "0")); + AddType (new Primitive ("gushort", "ushort", "0")); + AddType (new Primitive ("short", "short", "0")); + AddType (new Primitive ("guchar", "byte", "0")); + AddType (new Primitive ("unsigned char", "byte", "0")); + AddType (new Primitive ("guint1", "bool", "false")); + AddType (new Primitive ("uint1", "bool", "false")); + AddType (new Primitive ("gint8", "sbyte", "0")); + AddType (new Primitive ("guint8", "byte", "0")); + AddType (new Primitive ("gint16", "short", "0")); + AddType (new Primitive ("guint16", "ushort", "0")); + AddType (new Primitive ("gint32", "int", "0")); + AddType (new Primitive ("guint32", "uint", "0")); + AddType (new Primitive ("gint64", "long", "0")); + AddType (new Primitive ("guint64", "ulong", "0")); + AddType (new Primitive ("long long", "long", "0")); + AddType (new Primitive ("gfloat", "float", "0.0")); + AddType (new Primitive ("float", "float", "0.0")); + AddType (new Primitive ("gdouble", "double", "0.0")); + AddType (new Primitive ("double", "double", "0.0")); + AddType (new Primitive ("goffset", "long", "0")); - AddType(new Primitive("ssize_t", "IntPtr", "IntPtr.Zero")); - AddType(new Primitive("gssize", "IntPtr", "IntPtr.Zero")); - AddType(new Primitive("size_t", "UIntPtr", "UIntPtr.Zero")); - AddType(new Primitive("gsize", "UIntPtr", "UIntPtr.Zero")); + AddType (new Primitive ("ssize_t", "IntPtr", "IntPtr.Zero")); + AddType (new Primitive ("gssize", "IntPtr", "IntPtr.Zero")); + AddType (new Primitive ("size_t", "UIntPtr", "UIntPtr.Zero")); + AddType (new Primitive ("gsize", "UIntPtr", "UIntPtr.Zero")); - RegisterLongTypes(nativeWin64); + RegisterLongTypes (nativeWin64); } - void RegisterLongTypes(bool nativeWin64) + void RegisterLongTypes (bool nativeWin64) { if (nativeWin64) { - AddType(new Primitive("long", "int", "0")); - AddType(new Primitive("glong", "int", "0")); - AddType(new Primitive("ulong", "uint", "0")); - AddType(new Primitive("gulong", "uint", "0")); - AddType(new Primitive("unsigned long", "uint", "0")); - } else { - AddType(new Primitive("long", "IntPtr", "IntPtr.Zero")); - AddType(new Primitive("glong", "IntPtr", "IntPtr.Zero")); - AddType(new Primitive("ulong", "UIntPtr", "UIntPtr.Zero")); - AddType(new Primitive("gulong", "UIntPtr", "IntPtr.Zero")); - AddType(new Primitive("unsigned long", "UIntPtr", "IntPtr.Zero")); + AddType (new Primitive ("long", "int", "0")); + AddType (new Primitive ("glong", "int", "0")); + AddType (new Primitive ("ulong", "uint", "0")); + AddType (new Primitive ("gulong", "uint", "0")); + AddType (new Primitive ("unsigned long", "uint", "0")); + } + else { + AddType (new Primitive ("long", "IntPtr", "IntPtr.Zero")); + AddType (new Primitive ("glong", "IntPtr", "IntPtr.Zero")); + AddType (new Primitive ("ulong", "UIntPtr", "UIntPtr.Zero")); + AddType (new Primitive ("gulong", "UIntPtr", "IntPtr.Zero")); + AddType (new Primitive ("unsigned long", "UIntPtr", "IntPtr.Zero")); } } } diff --git a/src/Gir/Marshal/SymbolTable.RegistrationError.cs b/src/Gir/Marshal/SymbolTable.RegistrationError.cs index 1019715..436fa3e 100644 --- a/src/Gir/Marshal/SymbolTable.RegistrationError.cs +++ b/src/Gir/Marshal/SymbolTable.RegistrationError.cs @@ -1,4 +1,4 @@ -using System; + namespace Gir { public partial class SymbolTable @@ -8,12 +8,12 @@ class AliasRegistrationError : Error { readonly Alias alias; - public AliasRegistrationError(Alias alias) + public AliasRegistrationError (Alias alias) { this.alias = alias; } - public override string Message => string.Format("Alias {0} pointing to non-registered {1}, setting to 'void'", alias.CType, alias.Type.CType); + public override string Message => string.Format ("Alias {0} pointing to non-registered {1}, setting to 'void'", alias.CType, alias.Type.CType); string DebuggerDisplay => $"{alias.CType} alias failure to {alias.Type.CType}"; } diff --git a/src/Gir/Marshal/SymbolTable.cs b/src/Gir/Marshal/SymbolTable.cs index 3e5578b..d9d4a3b 100644 --- a/src/Gir/Marshal/SymbolTable.cs +++ b/src/Gir/Marshal/SymbolTable.cs @@ -7,20 +7,20 @@ namespace Gir { public partial class SymbolTable : IEnumerable { - readonly Dictionary typeMap = new Dictionary(); + readonly Dictionary typeMap = new Dictionary (); Statistics statistics; - public SymbolTable(Statistics statistics, bool nativeWin64) + public SymbolTable (Statistics statistics, bool nativeWin64) { this.statistics = statistics; - RegisterBuiltIn(nativeWin64); + RegisterBuiltIn (nativeWin64); } public void AddTypes (IEnumerable symbols) { foreach (var symbol in symbols) - AddType(symbol); + AddType (symbol); } public void AddType (ISymbol symbol) @@ -37,8 +37,8 @@ public void AddType (ISymbol symbol) // if (symbol.CType == null) return; - typeMap[symbol.CType] = symbol; - statistics.RegisterType(symbol); + typeMap [symbol.CType] = symbol; + statistics.RegisterType (symbol); } const string constPrefix = "const "; @@ -50,32 +50,33 @@ static string TrimConstAndPointer (string type) } // Look for the first pointer symbol - int end = type.IndexOf('*', start, type.Length - start); + int end = type.IndexOf ('*', start, type.Length - start); if (end == -1) { end = type.Length; - } else if (type.IndexOf ("void", start, StringComparison.Ordinal) == 0) { + } + else if (type.IndexOf ("void", start, StringComparison.Ordinal) == 0) { // Special case in case of pointers for void*, // otherwise we'll get void from the symbol table return "gpointer"; } - return type.Substring(start, end - start); + return type.Substring (start, end - start); } - public ISymbol this[string type] { + public ISymbol this [string type] { get { - var actualType = TrimConstAndPointer(type); + var actualType = TrimConstAndPointer (type); - return typeMap[actualType]; + return typeMap [actualType]; } } public void ProcessAliases () { - var copy = typeMap.ToDictionary(x => x.Key, x => x.Value); + var copy = typeMap.ToDictionary (x => x.Key, x => x.Value); foreach (var kvp in copy) { if (kvp.Value is Alias alias) { - typeMap[kvp.Key] = Dealias(alias); + typeMap [kvp.Key] = Dealias (alias); } } } @@ -84,23 +85,23 @@ ISymbol Dealias (Alias original) { ISymbol target = original; while (target is Alias alias) { - var toType = TrimConstAndPointer(alias.Type.CType); - if (!typeMap.TryGetValue(toType, out target)) { - statistics.RegisterError(new AliasRegistrationError(alias)); - return this["void"]; + var toType = TrimConstAndPointer (alias.Type.CType); + if (!typeMap.TryGetValue (toType, out target)) { + statistics.RegisterError (new AliasRegistrationError (alias)); + return this ["void"]; } } return target; } - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator () { - return typeMap.Values.GetEnumerator(); + return typeMap.Values.GetEnumerator (); } - IEnumerator IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator () { - return GetEnumerator(); + return GetEnumerator (); } } } diff --git a/src/Gir/Marshal/Type.cs b/src/Gir/Marshal/Type.cs index e14a405..93fbbec 100644 --- a/src/Gir/Marshal/Type.cs +++ b/src/Gir/Marshal/Type.cs @@ -1,11 +1,11 @@ -using System; + namespace Gir { public partial class Type { public ISymbol GetSymbol (GenerationOptions opts) { - return opts.SymbolTable[CType]; + return opts.SymbolTable [CType]; } } } diff --git a/src/Gir/Model/Alias.cs b/src/Gir/Model/Alias.cs index 2650e74..cc297da 100644 --- a/src/Gir/Model/Alias.cs +++ b/src/Gir/Model/Alias.cs @@ -4,16 +4,16 @@ namespace Gir { public partial class Alias : IDocumented { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type; } } \ No newline at end of file diff --git a/src/Gir/Model/Array.cs b/src/Gir/Model/Array.cs index 8cf547a..bd41dcf 100644 --- a/src/Gir/Model/Array.cs +++ b/src/Gir/Model/Array.cs @@ -4,19 +4,19 @@ namespace Gir { public partial class Array { - [XmlAttribute("fixed-size")] + [XmlAttribute ("fixed-size")] public int FixedSize; - [XmlAttribute("length")] + [XmlAttribute ("length")] public int Length; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("zero-terminated")] + [XmlAttribute ("zero-terminated")] public bool ZeroTerminated; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Bitfield.cs b/src/Gir/Model/Bitfield.cs index 18feb78..8093dec 100644 --- a/src/Gir/Model/Bitfield.cs +++ b/src/Gir/Model/Bitfield.cs @@ -5,34 +5,34 @@ namespace Gir { public partial class Bitfield { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlAttribute("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetType; - [XmlAttribute("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeName; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("member")] + [XmlElement ("member")] public List Members; - [XmlElement("function")] + [XmlElement ("function")] public List Function; } } \ No newline at end of file diff --git a/src/Gir/Model/CInclude.cs b/src/Gir/Model/CInclude.cs index 3898574..affff39 100644 --- a/src/Gir/Model/CInclude.cs +++ b/src/Gir/Model/CInclude.cs @@ -4,7 +4,7 @@ namespace Gir { public partial class CInclude { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; } } \ No newline at end of file diff --git a/src/Gir/Model/Callback.cs b/src/Gir/Model/Callback.cs index 0c9fb7c..26b2297 100644 --- a/src/Gir/Model/Callback.cs +++ b/src/Gir/Model/Callback.cs @@ -5,33 +5,33 @@ namespace Gir { public partial class Callback { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("throws")] + [XmlAttribute ("throws")] public bool Throws; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType; - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Class.cs b/src/Gir/Model/Class.cs index a0a37a7..cafab54 100644 --- a/src/Gir/Model/Class.cs +++ b/src/Gir/Model/Class.cs @@ -5,80 +5,76 @@ namespace Gir { public partial class Class { - [XmlAttribute("abstract")] + [XmlAttribute ("abstract")] public bool Abstract; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("parent")] + [XmlAttribute ("parent")] public string Parent; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CSymbolPrefix; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlAttribute("fundamental", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("fundamental", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public bool Fundamental; - [XmlAttribute("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetType; - [XmlAttribute("get-value-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-value-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetValueFunct; - [XmlAttribute("ref-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("ref-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibRefFunc; - [XmlAttribute("set-value-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("set-value-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibSetValueFunc; - [XmlAttribute("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeName; - [XmlAttribute("type-struct", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-struct", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeStruct; - [XmlAttribute("unref-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("unref-func", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibUnrefFunc; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("implements")] + [XmlElement ("implements")] public List Implements; - [XmlElement("constructor")] + [XmlElement ("constructor")] public List Constructors; - [XmlElement("field")] + [XmlElement ("field")] public List Fields; - [XmlElement("property")] + [XmlElement ("property")] public List Properties; - [XmlElement("union")] + [XmlElement ("union")] public List Unions; - [XmlElement("method")] + [XmlElement ("method")] public List Methods; - [XmlElement("virtual-method")] + [XmlElement ("virtual-method")] public List VirtualMethods; - [XmlElement("function")] + [XmlElement ("function")] public List Functions; - [XmlElement("signal", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlElement ("signal", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public List Signals; - - public Class() - { - } } } \ No newline at end of file diff --git a/src/Gir/Model/Constant.cs b/src/Gir/Model/Constant.cs index 2e96687..0f832a1 100644 --- a/src/Gir/Model/Constant.cs +++ b/src/Gir/Model/Constant.cs @@ -4,28 +4,28 @@ namespace Gir { public partial class Constant : IDocumented { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("value")] + [XmlAttribute ("value")] public string Value; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type; } } \ No newline at end of file diff --git a/src/Gir/Model/Constructor.cs b/src/Gir/Model/Constructor.cs index 06b7d19..69dbfae 100644 --- a/src/Gir/Model/Constructor.cs +++ b/src/Gir/Model/Constructor.cs @@ -1,47 +1,46 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Xml.Serialization; namespace Gir { public partial class Constructor { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("shadowed-by")] + [XmlAttribute ("shadowed-by")] public string ShadowedBy; - [XmlAttribute("shadows")] + [XmlAttribute ("shadows")] public string Shadows; - [XmlAttribute("throws")] + [XmlAttribute ("throws")] public bool Throws; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CIdentifier { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } } } diff --git a/src/Gir/Model/Direction.cs b/src/Gir/Model/Direction.cs index 23ba4ed..e241cb4 100644 --- a/src/Gir/Model/Direction.cs +++ b/src/Gir/Model/Direction.cs @@ -1,15 +1,14 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public enum Direction { - [XmlEnum("out")] + [XmlEnum ("out")] Out, - [XmlEnum("in")] + [XmlEnum ("in")] In, - [XmlEnum("inout")] + [XmlEnum ("inout")] InOut } } diff --git a/src/Gir/Model/Enumeration.cs b/src/Gir/Model/Enumeration.cs index d706a6c..d441ab8 100644 --- a/src/Gir/Model/Enumeration.cs +++ b/src/Gir/Model/Enumeration.cs @@ -5,31 +5,31 @@ namespace Gir { public partial class Enumeration { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlAttribute("error-domain", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("error-domain", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibErrorDomain; - [XmlAttribute("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetType; - [XmlAttribute("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeName; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("member")] + [XmlElement ("member")] public List Members; - [XmlElement("function")] + [XmlElement ("function")] public List Function; } } \ No newline at end of file diff --git a/src/Gir/Model/Field.cs b/src/Gir/Model/Field.cs index 21f0a68..ce4ebb8 100644 --- a/src/Gir/Model/Field.cs +++ b/src/Gir/Model/Field.cs @@ -1,32 +1,31 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public partial class Field { - [XmlAttribute("bits")] + [XmlAttribute ("bits")] public int Bits; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("private")] + [XmlAttribute ("private")] public bool Private; - [XmlAttribute("readable")] + [XmlAttribute ("readable")] public bool Readable; - [XmlAttribute("writable")] + [XmlAttribute ("writable")] public bool Writable; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type { get; set; } } } diff --git a/src/Gir/Model/Function.cs b/src/Gir/Model/Function.cs index 4077029..ef5342c 100644 --- a/src/Gir/Model/Function.cs +++ b/src/Gir/Model/Function.cs @@ -5,45 +5,45 @@ namespace Gir { public partial class Function { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("moved-to")] + [XmlAttribute ("moved-to")] public string MovedTo; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("shadowed-by")] + [XmlAttribute ("shadowed-by")] public string ShadowedBy; - [XmlAttribute("shadows")] + [XmlAttribute ("shadows")] public string Shadows; - [XmlAttribute("throws")] + [XmlAttribute ("throws")] public bool Throws; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CIdentifier { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Implements.cs b/src/Gir/Model/Implements.cs index c9b30f2..46eb116 100644 --- a/src/Gir/Model/Implements.cs +++ b/src/Gir/Model/Implements.cs @@ -1,11 +1,10 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public partial class Implements { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; } } diff --git a/src/Gir/Model/Include.cs b/src/Gir/Model/Include.cs index 280299f..b67bba7 100644 --- a/src/Gir/Model/Include.cs +++ b/src/Gir/Model/Include.cs @@ -6,10 +6,10 @@ namespace Gir [Serializable] public partial class Include { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version { get; set; } public string GirName => $"{Name}-{Version}.gir"; diff --git a/src/Gir/Model/InstanceParameter.cs b/src/Gir/Model/InstanceParameter.cs index 1aced49..f304c60 100644 --- a/src/Gir/Model/InstanceParameter.cs +++ b/src/Gir/Model/InstanceParameter.cs @@ -1,6 +1,4 @@ -using System; -using System.Xml.Serialization; - + namespace Gir { public partial class InstanceParameter : Parameter diff --git a/src/Gir/Model/Interface.cs b/src/Gir/Model/Interface.cs index a0be723..30b1270 100644 --- a/src/Gir/Model/Interface.cs +++ b/src/Gir/Model/Interface.cs @@ -5,46 +5,46 @@ namespace Gir { public partial class Interface { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CSymbolPrefix; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlAttribute("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetType; - [XmlAttribute("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeName; - [XmlAttribute("type-struct", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-struct", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeStruct; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("prerequisite")] + [XmlElement ("prerequisite")] public List Prerequisites; - [XmlElement("property")] + [XmlElement ("property")] public List Properties; - [XmlElement("method")] + [XmlElement ("method")] public List Methods; - [XmlElement("virtual-method")] + [XmlElement ("virtual-method")] public List VirtualMethods; - [XmlElement("function")] + [XmlElement ("function")] public List Functions; - [XmlElement("signal", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlElement ("signal", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public List Signals; } diff --git a/src/Gir/Model/Member.cs b/src/Gir/Model/Member.cs index 81622b5..2b955dc 100644 --- a/src/Gir/Model/Member.cs +++ b/src/Gir/Model/Member.cs @@ -4,19 +4,19 @@ namespace Gir { public partial class Member { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("value")] + [XmlAttribute ("value")] public string Value; - [XmlAttribute("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CIdentifier; - [XmlAttribute("nick", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("nick", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibNick; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Method.cs b/src/Gir/Model/Method.cs index e5aecab..0f8377f 100644 --- a/src/Gir/Model/Method.cs +++ b/src/Gir/Model/Method.cs @@ -5,45 +5,45 @@ namespace Gir { public partial class Method { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("moved-to")] + [XmlAttribute ("moved-to")] public string MovedTo; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("shadowed-by")] + [XmlAttribute ("shadowed-by")] public string ShadowedBy; - [XmlAttribute("shadows")] + [XmlAttribute ("shadows")] public string Shadows; - [XmlAttribute("throws")] + [XmlAttribute ("throws")] public bool Throws; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("identifier", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CIdentifier { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Namespace.cs b/src/Gir/Model/Namespace.cs index fe570c9..7d74bba 100644 --- a/src/Gir/Model/Namespace.cs +++ b/src/Gir/Model/Namespace.cs @@ -1,55 +1,54 @@ -using System; +using System.Collections.Generic; using System.Xml; -using System.Collections.Generic; using System.Xml.Serialization; namespace Gir { public partial class Namespace { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version { get; set; } - [XmlAttribute("shared-library")] + [XmlAttribute ("shared-library")] public string SharedLibrary { get; set; } - [XmlAttribute("identifier-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("identifier-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string IdentifierPrefix { get; set; } - [XmlAttribute("symbol-prefixes", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("symbol-prefixes", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string SymbolPrefixes { get; set; } - [XmlElement("alias")] + [XmlElement ("alias")] public List Aliases { get; set; } - [XmlElement("record")] + [XmlElement ("record")] public List Records { get; set; } - [XmlElement("class")] + [XmlElement ("class")] public List Classes { get; set; } - [XmlElement("constant")] + [XmlElement ("constant")] public List Constants { get; set; } - [XmlElement("interface")] + [XmlElement ("interface")] public List Interfaces { get; set; } - [XmlElement("callback")] + [XmlElement ("callback")] public List Callbacks { get; set; } - [XmlElement("function")] + [XmlElement ("function")] public List Functions { get; set; } - [XmlElement("union")] + [XmlElement ("union")] public List Unions { get; set; } - [XmlElement("enumeration")] + [XmlElement ("enumeration")] public List Enumerations { get; set; } - [XmlElement("bitfield")] + [XmlElement ("bitfield")] public List Bitfields { get; set; } } } diff --git a/src/Gir/Model/Package.cs b/src/Gir/Model/Package.cs index 149af7f..1936efb 100644 --- a/src/Gir/Model/Package.cs +++ b/src/Gir/Model/Package.cs @@ -4,7 +4,7 @@ namespace Gir { public partial class Package { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } } } \ No newline at end of file diff --git a/src/Gir/Model/Parameter.cs b/src/Gir/Model/Parameter.cs index f932cd7..5dfc6a5 100644 --- a/src/Gir/Model/Parameter.cs +++ b/src/Gir/Model/Parameter.cs @@ -1,52 +1,50 @@ -using System; -using System.Runtime.ConstrainedExecution; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { - [XmlInclude(typeof(InstanceParameter))] + [XmlInclude (typeof (InstanceParameter))] public partial class Parameter { - [XmlAttribute("allow-none")] + [XmlAttribute ("allow-none")] public bool AllowNone; - [XmlAttribute("caller-allocates")] + [XmlAttribute ("caller-allocates")] public bool CallerAllocates; - [XmlAttribute("closure")] + [XmlAttribute ("closure")] public int Closure; - [XmlAttribute("destroy")] + [XmlAttribute ("destroy")] public int Destroy; - [XmlAttribute("direction")] + [XmlAttribute ("direction")] public Direction Direction; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("nullable")] + [XmlAttribute ("nullable")] public bool Nullable; - [XmlAttribute("optional")] + [XmlAttribute ("optional")] public bool Optional; - [XmlAttribute("skip")] + [XmlAttribute ("skip")] public bool Skip; - [XmlAttribute("transfer-ownership")] + [XmlAttribute ("transfer-ownership")] public TransferOwnership TransferOwnership; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type; - [XmlElement("varargs")] + [XmlElement ("varargs")] public Varargs Varargs; - public bool IsPointer => Type.CType.EndsWith("*"); + public bool IsPointer => Type.CType.EndsWith ("*", System.StringComparison.Ordinal); public bool IsArray => Type.Array != null; } diff --git a/src/Gir/Model/Prerequisite.cs b/src/Gir/Model/Prerequisite.cs index 753069e..b61bd9d 100644 --- a/src/Gir/Model/Prerequisite.cs +++ b/src/Gir/Model/Prerequisite.cs @@ -4,7 +4,7 @@ namespace Gir { public partial class Prerequisite { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; } } \ No newline at end of file diff --git a/src/Gir/Model/Property.cs b/src/Gir/Model/Property.cs index 995201a..3cbb04a 100644 --- a/src/Gir/Model/Property.cs +++ b/src/Gir/Model/Property.cs @@ -1,44 +1,43 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public partial class Property { - [XmlAttribute("construct")] + [XmlAttribute ("construct")] public bool Construct; - [XmlAttribute("construct-only")] + [XmlAttribute ("construct-only")] public bool ConstructOnly; - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("readable")] + [XmlAttribute ("readable")] public bool Readable; - [XmlAttribute("transfer-ownership")] + [XmlAttribute ("transfer-ownership")] public TransferOwnership TransferOwnership; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("writable")] + [XmlAttribute ("writable")] public bool Writable; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type; } } diff --git a/src/Gir/Model/Record.cs b/src/Gir/Model/Record.cs index 9767110..0b84eb3 100644 --- a/src/Gir/Model/Record.cs +++ b/src/Gir/Model/Record.cs @@ -5,58 +5,58 @@ namespace Gir { public partial class Record { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("disguised")] + [XmlAttribute ("disguised")] public bool Disguised; - [XmlAttribute("foreign")] + [XmlAttribute ("foreign")] public bool Foreign; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name { get; set; } - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("symbol-prefix", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CSymbolPrefix; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlAttribute("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("get-type", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibGetType; - [XmlAttribute("is-gtype-struct-for", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("is-gtype-struct-for", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibIsGTypeStructFor; - [XmlAttribute("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] + [XmlAttribute ("type-name", Namespace = "http://www.gtk.org/introspection/glib/1.0")] public string GLibTypeName; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("field")] + [XmlElement ("field")] public List Fields; - [XmlElement("union")] + [XmlElement ("union")] public List Unions; - [XmlElement("constructor")] + [XmlElement ("constructor")] public List Constructors; - [XmlElement("method")] + [XmlElement ("method")] public List Methods; - [XmlElement("function")] + [XmlElement ("function")] public List Function; } } \ No newline at end of file diff --git a/src/Gir/Model/Repository.cs b/src/Gir/Model/Repository.cs index 3cc60c0..199b290 100644 --- a/src/Gir/Model/Repository.cs +++ b/src/Gir/Model/Repository.cs @@ -1,32 +1,31 @@ using System; -using System.Xml.Serialization; using System.Collections.Generic; -using System.Collections; +using System.Xml.Serialization; namespace Gir { [Serializable] - [XmlRoot("repository", Namespace = "http://www.gtk.org/introspection/core/1.0")] + [XmlRoot ("repository", Namespace = "http://www.gtk.org/introspection/core/1.0")] public partial class Repository { - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version { get; set; } - [XmlElement("include")] + [XmlElement ("include")] public List Includes { get; set; } - [XmlElement("package")] + [XmlElement ("package")] public Package Package { get; set; } - [XmlElement("include", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlElement ("include", Namespace = "http://www.gtk.org/introspection/c/1.0")] public CInclude CInclude { get; set; } - [XmlElement("namespace")] + [XmlElement ("namespace")] public Namespace Namespace { get; set; } public string GirName => $"{Namespace.Name}-{Namespace.Version}.gir"; - public override string ToString() + public override string ToString () { return $"{Package.Name}"; } diff --git a/src/Gir/Model/ReturnValue.cs b/src/Gir/Model/ReturnValue.cs index 89f000f..efcec4d 100644 --- a/src/Gir/Model/ReturnValue.cs +++ b/src/Gir/Model/ReturnValue.cs @@ -1,23 +1,22 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public partial class ReturnValue : IDocumented { - [XmlAttribute("nullable")] + [XmlAttribute ("nullable")] public bool Nullable; - [XmlAttribute("transfer-ownership")] + [XmlAttribute ("transfer-ownership")] public TransferOwnership TransferOwnership; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("type")] + [XmlElement ("type")] public Type Type; - [XmlElement("array")] + [XmlElement ("array")] public Array Array; } } diff --git a/src/Gir/Model/Scope.cs b/src/Gir/Model/Scope.cs index 3c36767..25ba8e8 100644 --- a/src/Gir/Model/Scope.cs +++ b/src/Gir/Model/Scope.cs @@ -1,15 +1,14 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace Gir { public enum Scope { - [XmlEnum("call")] + [XmlEnum ("call")] Call, - [XmlEnum("async")] + [XmlEnum ("async")] Async, - [XmlEnum("notified")] + [XmlEnum ("notified")] Notified } } diff --git a/src/Gir/Model/Signal.cs b/src/Gir/Model/Signal.cs index 777554b..7f756c9 100644 --- a/src/Gir/Model/Signal.cs +++ b/src/Gir/Model/Signal.cs @@ -5,45 +5,45 @@ namespace Gir { public partial class Signal { - [XmlAttribute("action")] + [XmlAttribute ("action")] public string Action; - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("detailed")] + [XmlAttribute ("detailed")] public bool Detailed; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("no-hooks")] + [XmlAttribute ("no-hooks")] public bool NoHooks; - [XmlAttribute("no-recurse")] + [XmlAttribute ("no-recurse")] public bool NoRecurse; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlAttribute("when")] + [XmlAttribute ("when")] public string When; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } } diff --git a/src/Gir/Model/TransferOwnership.cs b/src/Gir/Model/TransferOwnership.cs index 2184688..f29d147 100644 --- a/src/Gir/Model/TransferOwnership.cs +++ b/src/Gir/Model/TransferOwnership.cs @@ -4,13 +4,13 @@ namespace Gir { public enum TransferOwnership { - [XmlEnum("full")] + [XmlEnum ("full")] Full, - [XmlEnum("none")] + [XmlEnum ("none")] None, - [XmlEnum("container")] + [XmlEnum ("container")] Container, - [XmlEnum("floating")] + [XmlEnum ("floating")] Floating } } \ No newline at end of file diff --git a/src/Gir/Model/Type.cs b/src/Gir/Model/Type.cs index 9072f0d..32398f3 100644 --- a/src/Gir/Model/Type.cs +++ b/src/Gir/Model/Type.cs @@ -4,13 +4,13 @@ namespace Gir { public partial class Type { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType; - [XmlElement("array")] + [XmlElement ("array")] public Array Array; } } \ No newline at end of file diff --git a/src/Gir/Model/Union.cs b/src/Gir/Model/Union.cs index d503a0d..e9d419f 100644 --- a/src/Gir/Model/Union.cs +++ b/src/Gir/Model/Union.cs @@ -5,22 +5,22 @@ namespace Gir { public partial class Union { - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] + [XmlAttribute ("type", Namespace = "http://www.gtk.org/introspection/c/1.0")] public string CType { get; set; } - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("field")] + [XmlElement ("field")] public List Fields; - [XmlElement("method")] + [XmlElement ("method")] public List Methods; - [XmlElement("record")] + [XmlElement ("record")] public List Records; } } \ No newline at end of file diff --git a/src/Gir/Model/VirtualMethod.cs b/src/Gir/Model/VirtualMethod.cs index 4036aa2..61f84ba 100644 --- a/src/Gir/Model/VirtualMethod.cs +++ b/src/Gir/Model/VirtualMethod.cs @@ -5,36 +5,36 @@ namespace Gir { public partial class VirtualMethod { - [XmlAttribute("deprecated")] + [XmlAttribute ("deprecated")] public bool Deprecated; - [XmlAttribute("deprecated-version")] + [XmlAttribute ("deprecated-version")] public string DeprecatedVersion; - [XmlAttribute("introspectable")] + [XmlAttribute ("introspectable")] public bool Introspectable; - [XmlAttribute("invoker")] + [XmlAttribute ("invoker")] public string Invoker; - [XmlAttribute("name")] + [XmlAttribute ("name")] public string Name; - [XmlAttribute("throws")] + [XmlAttribute ("throws")] public bool Throws; - [XmlAttribute("version")] + [XmlAttribute ("version")] public string Version; - [XmlElement("doc")] + [XmlElement ("doc")] public Documentation Doc { get; set; } - [XmlElement("return-value")] + [XmlElement ("return-value")] public ReturnValue ReturnValue { get; set; } - [XmlArray("parameters")] - [XmlArrayItem("parameter", Type = typeof(Parameter))] - [XmlArrayItem("instance-parameter", Type = typeof(InstanceParameter))] + [XmlArray ("parameters")] + [XmlArrayItem ("parameter", Type = typeof (Parameter))] + [XmlArrayItem ("instance-parameter", Type = typeof (InstanceParameter))] public List Parameters { get; set; } } diff --git a/src/Gir/Parser.cs b/src/Gir/Parser.cs index d32bb0e..7f7ff1a 100644 --- a/src/Gir/Parser.cs +++ b/src/Gir/Parser.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -7,18 +6,18 @@ namespace Gir { public static class Parser { - - public static IEnumerable Parse(string fileName, string includeDir, out Repository mainRepository) + + public static IEnumerable Parse (string fileName, string includeDir, out Repository mainRepository) { using (var fs = File.OpenRead (fileName)) { return Parse (fs, includeDir, out mainRepository); } } - public static IEnumerable Parse(Stream s, string includeDir, out Repository mainRepository) + public static IEnumerable Parse (Stream s, string includeDir, out Repository mainRepository) { - var serializer = new System.Xml.Serialization.XmlSerializer(typeof(Repository)); - mainRepository = (Repository)serializer.Deserialize(s); + var serializer = new System.Xml.Serialization.XmlSerializer (typeof (Repository)); + mainRepository = (Repository)serializer.Deserialize (s); var repositories = ParseRecursive (mainRepository, includeDir, new Dictionary ()).ToList (); return repositories; @@ -26,18 +25,18 @@ public static IEnumerable Parse(Stream s, string includeDir, out Rep public static IEnumerable ParseRecursive (Repository repository, string includeDir, Dictionary resolvedRepositories) { - if (!resolvedRepositories.ContainsKey(repository.GirName)) { - resolvedRepositories[repository.GirName] = repository; - + if (!resolvedRepositories.ContainsKey (repository.GirName)) { + resolvedRepositories [repository.GirName] = repository; + yield return repository; foreach (var include in repository.Includes) { - using (var fs = File.OpenRead (Path.Combine(includeDir, include.GirName))) { - var serializer = new System.Xml.Serialization.XmlSerializer(typeof(Repository)); - var repo = (Repository)serializer.Deserialize(fs); + using (var fs = File.OpenRead (Path.Combine (includeDir, include.GirName))) { + var serializer = new System.Xml.Serialization.XmlSerializer (typeof (Repository)); + var repo = (Repository)serializer.Deserialize (fs); + - - foreach (var incRepo in ParseRecursive(repo, includeDir, resolvedRepositories)) { + foreach (var incRepo in ParseRecursive (repo, includeDir, resolvedRepositories)) { yield return incRepo; } } diff --git a/src/Gir/Program.cs b/src/Gir/Program.cs index c608917..262c0a6 100644 --- a/src/Gir/Program.cs +++ b/src/Gir/Program.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; namespace Gir { @@ -30,33 +29,33 @@ static string GetDefaultSearchDirectory () } } - public static int Main(string[] args) + public static int Main (string[] args) { if (args.Length < 1) { - Console.WriteLine("Usage: gir.exe "); + Console.WriteLine ("Usage: gir.exe "); return 0; } - var opt = new OptionSet(); + var opt = new OptionSet (); foreach (string arg in args) - ParseArg(opt, arg); + ParseArg (opt, arg); - opt.AllRepositories = Parser.Parse(args[0], opt.IncludeSearchDirectory, out opt.GenerationRepository); + opt.AllRepositories = Parser.Parse (args [0], opt.IncludeSearchDirectory, out opt.GenerationRepository); //GenerationInfo gen_info = null; //if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "") //gen_info = new GenerationInfo(dir, custom_dir, assembly_name, glue_filename, glue_includes, gluelib_name); - var genOpts = new GenerationOptions(opt.OutputDirectory, opt.AllRepositories, opt.GenerationRepository, false); + var genOpts = new GenerationOptions (opt.OutputDirectory, opt.AllRepositories, opt.GenerationRepository, false); + + if (!Directory.Exists (opt.OutputDirectory)) + Directory.CreateDirectory (opt.OutputDirectory); - if (!Directory.Exists(opt.OutputDirectory)) - Directory.CreateDirectory(opt.OutputDirectory); - foreach (IGeneratable gen in opt.GenerationRepository.GetGeneratables ()) { - gen.Generate(genOpts); + gen.Generate (genOpts); } - genOpts.Statistics.ReportStatistics(); + genOpts.Statistics.ReportStatistics (); return 0; } @@ -64,34 +63,34 @@ public static int Main(string[] args) const string customAssemblyNameArg = "--assembly-name="; const string customIncludeDirArg = "--include-dir="; - static void ParseArg(OptionSet opt, string arg) + static void ParseArg (OptionSet opt, string arg) { - if (arg.StartsWith(customOutputDir)) { - opt.OutputDirectory = arg.Substring(customOutputDir.Length); + if (arg.StartsWith (customOutputDir)) { + opt.OutputDirectory = arg.Substring (customOutputDir.Length); return; } - if (arg.StartsWith("--customdir=")) { - opt.custom_dir = arg.Substring(12); + if (arg.StartsWith ("--customdir=")) { + opt.custom_dir = arg.Substring (12); return; } - if (arg.StartsWith(customAssemblyNameArg)) { - opt.CustomGeneratedAssemblyName = arg.Substring(customAssemblyNameArg.Length); + if (arg.StartsWith (customAssemblyNameArg)) { + opt.CustomGeneratedAssemblyName = arg.Substring (customAssemblyNameArg.Length); return; } - if (arg.StartsWith("--glue-filename=")) { - opt.glue_filename = arg.Substring(16); + if (arg.StartsWith ("--glue-filename=")) { + opt.glue_filename = arg.Substring (16); return; } - if (arg.StartsWith("--glue-includes=")) { - opt.glue_includes = arg.Substring(16); + if (arg.StartsWith ("--glue-includes=")) { + opt.glue_includes = arg.Substring (16); return; } - if (arg.StartsWith("--gluelib-name=")) { - opt.gluelib_name = arg.Substring(15); + if (arg.StartsWith ("--gluelib-name=")) { + opt.gluelib_name = arg.Substring (15); return; } - if (arg.StartsWith(customIncludeDirArg)) { - opt.IncludeSearchDirectory = arg.Substring(customIncludeDirArg.Length); + if (arg.StartsWith (customIncludeDirArg)) { + opt.IncludeSearchDirectory = arg.Substring (customIncludeDirArg.Length); return; } } diff --git a/src/Gir/Statistics.cs b/src/Gir/Statistics.cs index 6e59f94..3ecfb1b 100644 --- a/src/Gir/Statistics.cs +++ b/src/Gir/Statistics.cs @@ -6,26 +6,26 @@ namespace Gir { public class Statistics { - readonly Dictionary RegisteredCount = new Dictionary(); + readonly Dictionary RegisteredCount = new Dictionary (); // Bucket errors by the same kind to make for easy reviewing of error output - readonly Dictionary> RegisteredErrors = new Dictionary>(); + readonly Dictionary> RegisteredErrors = new Dictionary> (); - public void ReportStatistics() + public void ReportStatistics () { foreach (var line in GetStatistics ()) { - Console.WriteLine(line); + Console.WriteLine (line); } foreach (var line in GetErrorsContent ()) { - Console.Error.WriteLine(line); + Console.Error.WriteLine (line); } } public IEnumerable GetStatistics () { foreach (var kvp in RegisteredCount) { - yield return string.Format("Registered {0} {1}s", kvp.Value.ToString(), kvp.Key); + yield return string.Format ("Registered {0} {1}s", kvp.Value.ToString (), kvp.Key); } } @@ -35,7 +35,7 @@ public IEnumerable GetErrorsContent () yield return kvp.Key.ToString (); foreach (var error in kvp.Value) { - yield return string.Format("\t{0}", error.Message); + yield return string.Format ("\t{0}", error.Message); } } } @@ -44,18 +44,18 @@ public IEnumerable GetErrorsContent () public void RegisterType (ISymbol symbol) { - var type = symbol.GetType(); - RegisteredCount.TryGetValue(type, out int count); - RegisteredCount[type] = ++count; + var type = symbol.GetType (); + RegisteredCount.TryGetValue (type, out int count); + RegisteredCount [type] = ++count; } public void RegisterError (Error error) { - var type = error.GetType(); - if (!RegisteredErrors.TryGetValue(type, out var list)) { - RegisteredErrors[type] = list = new List(); + var type = error.GetType (); + if (!RegisteredErrors.TryGetValue (type, out var list)) { + RegisteredErrors [type] = list = new List (); } - list.Add(error); + list.Add (error); } } } diff --git a/src/Gir/Utils.cs b/src/Gir/Utils.cs index 68db958..ed29d50 100644 --- a/src/Gir/Utils.cs +++ b/src/Gir/Utils.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -10,10 +9,10 @@ namespace Gir public static class Utils { // Perf - maybe cache this? - public static string ToCSharp(this string cname) + public static string ToCSharp (this string cname) { // Capitalize the first letter, and parse for underscores, capitalizing the letters after them - var sb = new StringBuilder(cname.Length); + var sb = new StringBuilder (cname.Length); bool isUpper = true; foreach (var c in cname) { @@ -22,43 +21,43 @@ public static string ToCSharp(this string cname) continue; } - sb.Append(isUpper ? char.ToUpper(c) : c); + sb.Append (isUpper ? char.ToUpper (c) : c); isUpper = false; } - return sb.ToString(); + return sb.ToString (); } internal static IEnumerable GetAllCollectionMembers (object container) { // This doesn't yield things like: - foreach (var collection in GetCollectionsOf(container)) { + foreach (var collection in GetCollectionsOf (container)) { foreach (var item in collection) yield return (T)item; } } - static IEnumerable GetCollectionsOf(object obj) + static IEnumerable GetCollectionsOf (object obj) { - var type = obj.GetType(); + var type = obj.GetType (); - foreach (var field in type.GetFields().Where(x => IsCollectionOf(x.FieldType))) { - yield return (ICollection)field.GetValue(obj); + foreach (var field in type.GetFields ().Where (x => IsCollectionOf (x.FieldType))) { + yield return (ICollection)field.GetValue (obj); } - foreach (var prop in type.GetProperties().Where(x => IsCollectionOf(x.PropertyType))) { - yield return (ICollection)prop.GetValue(obj); + foreach (var prop in type.GetProperties ().Where (x => IsCollectionOf (x.PropertyType))) { + yield return (ICollection)prop.GetValue (obj); } } static bool IsCollectionOf (System.Type t) { - foreach (var @interface in t.GetInterfaces()) { - if (!@interface.IsGenericType || !@interface.GetGenericTypeDefinition ().IsAssignableFrom (typeof(ICollection<>))) + foreach (var @interface in t.GetInterfaces ()) { + if (!@interface.IsGenericType || !@interface.GetGenericTypeDefinition ().IsAssignableFrom (typeof (ICollection<>))) continue; - var args = @interface.GetGenericArguments(); - bool isOfT = typeof(T).IsAssignableFrom(args[0]); + var args = @interface.GetGenericArguments (); + bool isOfT = typeof (T).IsAssignableFrom (args [0]); if (isOfT) return true; } @@ -68,12 +67,12 @@ static bool IsCollectionOf (System.Type t) internal static IEnumerable GetTypesImplementing () { - var assembly = Assembly.GetExecutingAssembly(); + var assembly = Assembly.GetExecutingAssembly (); var implementors = assembly .DefinedTypes // Filter out all the types implementing the interface - .Where(type => typeof(T).IsAssignableFrom(type)); + .Where (type => typeof (T).IsAssignableFrom (type)); return implementors; } }