mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 11:35:39 +00:00
Use untyped int for enums in unmanaged callsites
By using untyped integers instead of typed integers in the unmanaged callsites, we allow monolinker to keep the exact set of enums that are used by the user. Without this, we’d have to keep every single enum in place to avoid missing type exceptions. This does not affect the public signatures or the generated code in any way.
This commit is contained in:
parent
6f535ec095
commit
2290e06cbd
|
@ -1,4 +1,4 @@
|
|||
#region License
|
||||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
|
@ -405,7 +405,7 @@ namespace Bind
|
|||
|
||||
sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]",
|
||||
f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.EntryPoint);
|
||||
sw.WriteLine("public static extern {0};", GetDeclarationString(f));
|
||||
sw.WriteLine("public static extern {0};", GetDeclarationString(f, Settings.Compatibility));
|
||||
}
|
||||
|
||||
DocProcessor processor_;
|
||||
|
@ -675,11 +675,11 @@ namespace Bind
|
|||
sb.Append(d.Unsafe ? "unsafe " : "");
|
||||
if (is_delegate)
|
||||
sb.Append("delegate ");
|
||||
sb.Append(GetDeclarationString(d.ReturnType));
|
||||
sb.Append(GetDeclarationString(d.ReturnType, Settings.Legacy.ConstIntEnums));
|
||||
sb.Append(" ");
|
||||
sb.Append(Settings.FunctionPrefix);
|
||||
sb.Append(d.Name);
|
||||
sb.Append(GetDeclarationString(d.Parameters));
|
||||
sb.Append(GetDeclarationString(d.Parameters, Settings.Legacy.ConstIntEnums));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -717,12 +717,12 @@ namespace Bind
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
string GetDeclarationString(Function f)
|
||||
string GetDeclarationString(Function f, Settings.Legacy settings)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append(f.Unsafe ? "unsafe " : "");
|
||||
sb.Append(GetDeclarationString(f.ReturnType));
|
||||
sb.Append(GetDeclarationString(f.ReturnType, settings));
|
||||
sb.Append(" ");
|
||||
if ((Settings.Compatibility & Settings.Legacy.NoTrimFunctionEnding) != Settings.Legacy.None)
|
||||
{
|
||||
|
@ -745,7 +745,7 @@ namespace Bind
|
|||
sb.Append(">");
|
||||
}
|
||||
|
||||
sb.Append(GetDeclarationString(f.Parameters));
|
||||
sb.Append(GetDeclarationString(f.Parameters, settings));
|
||||
|
||||
if (f.Parameters.HasGenericParameters)
|
||||
{
|
||||
|
@ -760,7 +760,7 @@ namespace Bind
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
string GetDeclarationString(Parameter p, bool override_unsafe_setting)
|
||||
string GetDeclarationString(Parameter p, bool override_unsafe_setting, Settings.Legacy settings)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
@ -785,12 +785,12 @@ namespace Bind
|
|||
}
|
||||
else
|
||||
{
|
||||
sb.Append(GetDeclarationString(p as Type));
|
||||
sb.Append(GetDeclarationString(p as Type, settings));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(GetDeclarationString(p as Type));
|
||||
sb.Append(GetDeclarationString(p as Type, settings));
|
||||
}
|
||||
if (!String.IsNullOrEmpty(p.Name))
|
||||
{
|
||||
|
@ -801,7 +801,7 @@ namespace Bind
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
string GetDeclarationString(ParameterCollection parameters)
|
||||
string GetDeclarationString(ParameterCollection parameters, Settings.Legacy settings)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
@ -810,7 +810,7 @@ namespace Bind
|
|||
{
|
||||
foreach (Parameter p in parameters)
|
||||
{
|
||||
sb.Append(GetDeclarationString(p, false));
|
||||
sb.Append(GetDeclarationString(p, false, settings));
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||
|
@ -823,10 +823,19 @@ namespace Bind
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
string GetDeclarationString(Type type)
|
||||
string GetDeclarationString(Type type, Settings.Legacy settings)
|
||||
{
|
||||
var t = type.QualifiedType;
|
||||
if ((settings & Settings.Legacy.ConstIntEnums) != 0)
|
||||
{
|
||||
if (type.IsEnum)
|
||||
{
|
||||
t = "System.Int32";
|
||||
}
|
||||
}
|
||||
|
||||
return String.Format("{0}{1}{2}",
|
||||
type.QualifiedType,
|
||||
t,
|
||||
pointer_levels[type.Pointer],
|
||||
array_levels[type.Array]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue