Improve sorting; remove enum-function distinction

Both enums and functions are now stored under a single <add> element.
Their ordering is now maintained by sorting over all possible
attributes.
This commit is contained in:
Stefanos A. 2013-10-29 19:35:35 +01:00
parent 784d60b556
commit 51cb1f02db

View file

@ -140,13 +140,21 @@ namespace CHeaderToXML
using (var writer = XmlWriter.Create(out_stream, settings)) using (var writer = XmlWriter.Create(out_stream, settings))
{ {
new XElement("signatures", var output = new XElement("signatures");
new XElement("add", foreach (var api in sigs.SelectMany(s => s))
entries.Values.OrderBy(s => s.Attribute("name").Value), // only enums {
sigs.SelectMany(s => s).Where(s => s.Name.LocalName == "function") // only functions output.Add(
.OrderBy(s => s.Attribute("extension").Value) new XElement("add",
.ThenBy(s => s.Attribute("name").Value) new XAttribute("name", api.Attribute("name").Value),
)).WriteTo(writer); api.Elements()
.OrderBy(s => s.Name.LocalName)
.ThenBy(s => (string)s.Attribute("value") ?? String.Empty)
.ThenBy(s => (string)s.Attribute("name") ?? String.Empty)
.ThenBy(s => (string)s.Attribute("version") ?? String.Empty)
.ThenBy(s => (string)s.Attribute("extension") ?? String.Empty)
));
}
output.WriteTo(writer);
writer.Flush(); writer.Flush();
writer.Close(); writer.Close();
} }