Corrected Parameter.IsEnum property

This commit is contained in:
thefiddler 2013-11-11 10:00:54 +01:00
parent dde7c645c4
commit af16be42d5

View file

@ -227,12 +227,12 @@ namespace Bind
}
else if (Generator.GLTypes.TryGetValue(type.CurrentType, out s))
{
type.IsEnum = true;
// Check if the parameter is a generic GLenum. If it is, search for a better match,
// otherwise fallback to Settings.CompleteEnumName (named 'All' by default).
if (s.Contains("GLenum") /*&& !String.IsNullOrEmpty(category)*/)
{
type.IsEnum = true;
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) != Settings.Legacy.None)
{
type.QualifiedType = "int";
@ -256,6 +256,8 @@ namespace Bind
}
else
{
type.IsEnum = false;
// Todo: what is the point of this here? It is overwritten below.
// A few translations for consistency
switch (type.CurrentType.ToLower())
@ -610,6 +612,28 @@ namespace Bind
{
wrappers.AddRange(CreateNormalWrappers(d, enums));
}
if ((Settings.Compatibility & Settings.Legacy.KeepUntypedEnums) != 0)
{
// Generate an "All" overload for every function that takes strongly-typed enums
var overloads = new List<Function>();
foreach (var list in wrappers.Values)
{
overloads.AddRange(list.Where(f => f.Parameters.Any(p => p.IsEnum)).Select(f =>
{
var fnew = new Function(f);
foreach (var p in fnew.Parameters)
{
if (p.IsEnum)
{
p.CurrentType = Settings.CompleteEnumName;
}
}
return fnew;
}));
}
wrappers.AddRange(overloads);
}
return wrappers;
}