Maintain api version information on converted signatures

Signatures were split into 4 APIs before (gl, glcore, gles1, gles2).
However, gles2 contains bindings for both version 2.0 and 3.0. The
version information is now maintained, which allows us to cut down on
the number of generated enumerations.
This commit is contained in:
Stefanos A 2013-11-03 20:30:43 +01:00
parent 2d33b10e1a
commit 08823f5d5b
2 changed files with 25 additions and 13 deletions

View file

@ -62,10 +62,12 @@ namespace CHeaderToXML
foreach (var e in ParseEnums(input).Concat(ParseFunctions(input)))
{
var name = e.Attribute("name").Value;
if (!elements.ContainsKey(name))
elements.Add(name, e);
var version = (e.Attribute("version") ?? new XAttribute("version", String.Empty)).Value;
var key = name + version;
if (!elements.ContainsKey(key))
elements.Add(key, e);
else
elements[name].Add(e.Elements());
elements[key].Add(e.Elements());
}
return elements.Values;
@ -196,7 +198,7 @@ namespace CHeaderToXML
foreach (var api in APIs.Values)
{
var apiname = api.Attribute("name").Value;
var apiname = api.Attribute("name").Value;
// Mark deprecated enums
foreach (var token in feature.Elements("remove").Elements("enum"))
@ -265,13 +267,20 @@ namespace CHeaderToXML
foreach (var apiname in apinames)
{
i++;
if (!APIs.ContainsKey(apiname))
APIs.Add(apiname, new XElement("api", new XAttribute("name", apiname)));
var api = APIs[apiname];
var cmd_category = category;
var cmd_version = version.Length > i ? version[i] : version[0];
var key = apiname + cmd_version;
if (!APIs.ContainsKey(key))
APIs.Add(
key,
new XElement(
"api",
new XAttribute("name", apiname),
new XAttribute("version", cmd_version)));
var api = APIs[key];
foreach (var command in feature.Elements("require").Elements("command"))
{
var cmd_name = TrimName(command.Attribute("name").Value);
@ -292,11 +301,11 @@ namespace CHeaderToXML
}
i = -1;
foreach (var apiname in apinames)
foreach (var api in APIs.Values)
{
i++;
var apiname = api.Attribute("name").Value;
var cmd_version = version.Length > i ? version[i] : version[0];
var api = APIs[apiname];
// Mark all deprecated functions as such
foreach (var command in feature.Elements("remove").Elements("command"))

View file

@ -147,6 +147,7 @@ namespace CHeaderToXML
output.Add(
new XElement("add",
new XAttribute("name", api.Attribute("name").Value),
api.Attribute("version") != null ? new XAttribute("version", api.Attribute("version").Value) : null,
api.Elements()
.OrderBy(s => s.Name.LocalName)
.ThenBy(s => (string)s.Attribute("value") ?? String.Empty)
@ -190,19 +191,21 @@ namespace CHeaderToXML
private static Dictionary<string, XElement> MergeDuplicates(IEnumerable<IEnumerable<XElement>> sigs)
{
var entries = new Dictionary<string, XElement>();
foreach (var e in sigs.SelectMany(s => s))//.Where(s => s.Name.LocalName == "enum"))
foreach (var e in sigs.SelectMany(s => s))
{
var name = (string)e.Attribute("name") ?? "";
if (entries.ContainsKey(name))// && e.Name.LocalName == "enum")
var version = (string)e.Attribute("version") ?? "";
var key = name + version;
if (entries.ContainsKey(key))
{
var p = entries[name];
var p = entries[key];
var curTokens = p.Nodes().ToList();
p.RemoveNodes();
p.Add(curTokens.Concat(e.Nodes()).Distinct(new EnumTokenComparer()));
}
else
{
entries.Add(name, e);
entries.Add(key, e);
}
}
return entries;