Take api version into account

XmlSpecReader will now respect version attributes and will avoid
inserting foreign tokens into the generated bindings.
This commit is contained in:
Stefanos A 2013-11-03 20:32:10 +01:00
parent 08823f5d5b
commit 922fb935a1

View file

@ -56,7 +56,7 @@ namespace Bind
#region ISpecReader Members
public void ReadDelegates(string file, DelegateCollection delegates, string apiname, string apiversion)
public void ReadDelegates(string file, DelegateCollection delegates, string apiname, string apiversions)
{
var specs = new XPathDocument(file);
@ -71,6 +71,8 @@ namespace Bind
apiname = null;
}
foreach (var apiversion in apiversions.Split('|'))
{
string xpath_add, xpath_delete;
GetSignaturePaths(apiname, apiversion, out xpath_add, out xpath_delete);
@ -84,8 +86,9 @@ namespace Bind
Utilities.Merge(delegates, ReadDelegates(nav, apiversion));
}
}
}
public void ReadEnums(string file, EnumCollection enums, string apiname, string apiversion)
public void ReadEnums(string file, EnumCollection enums, string apiname, string apiversions)
{
var specs = new XPathDocument(file);
@ -100,6 +103,8 @@ namespace Bind
apiname = null;
}
foreach (var apiversion in apiversions.Split('|'))
{
string xpath_add, xpath_delete;
GetSignaturePaths(apiname, apiversion, out xpath_add, out xpath_delete);
@ -115,6 +120,7 @@ namespace Bind
Utilities.Merge(enums, ReadEnums(nav));
}
}
}
public Dictionary<string, string> ReadTypeMap(string file)
{
@ -217,10 +223,21 @@ namespace Bind
xpath_add = "/signatures/add";
xpath_delete = "/signatures/delete";
if (!String.IsNullOrEmpty(apiname))
if (!String.IsNullOrEmpty(apiname) && !String.IsNullOrEmpty(apiversion))
{
xpath_add += String.Format("[contains(concat('|', @name, '|'), '|{0}|')]", apiname);
xpath_delete += String.Format("[contains(concat('|', @name, '|'), '|{0}|')]", apiname);
var match = String.Format(
"[contains(concat('|', @name, '|'), '|{0}|') and " +
"(contains(concat('|', @version, '|'), '|{1}|') or not(boolean(@version)))]",
apiname,
apiversion);
xpath_add += match;
xpath_delete += match;
}
else if (!String.IsNullOrEmpty(apiname))
{
var match = String.Format("[contains(concat('|', @name, '|'), '|{0}|')]", apiname);
xpath_add += match;
xpath_delete += match;
}
}