mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-21 15:08:37 +00:00
Avoid singletons; Move logic to FuncProcessor
This is part of a long-due cleanup patch series. All translation logic is now part of the FuncProcessor. Language-specific code generation is now part of the ISpecWriter, not the delegate class. Implemented the IEquatable interface.
This commit is contained in:
parent
f83443d221
commit
9c5d43b72b
|
@ -19,7 +19,7 @@ namespace Bind.Structures
|
||||||
/// Represents an opengl function.
|
/// Represents an opengl function.
|
||||||
/// The return value, function name, function parameters and opengl version can be retrieved or set.
|
/// The return value, function name, function parameters and opengl version can be retrieved or set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class Delegate : IComparable<Delegate>
|
class Delegate : IComparable<Delegate>, IEquatable<Delegate>
|
||||||
{
|
{
|
||||||
//internal static DelegateCollection Delegates;
|
//internal static DelegateCollection Delegates;
|
||||||
|
|
||||||
|
@ -240,43 +240,9 @@ namespace Bind.Structures
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
// This method should only be used for debugging purposes, not for code generation!
|
||||||
/// Returns a string that represents an invocation of this delegate.
|
// Returns a string representing the full delegate declaration without decorations.
|
||||||
/// </summary>
|
// (ie "(unsafe) void delegate glXxxYyy(int a, float b, IntPtr c)"
|
||||||
public string CallString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.Append(Settings.DelegatesClass);
|
|
||||||
sb.Append(Settings.NamespaceSeparator);
|
|
||||||
sb.Append(Settings.FunctionPrefix);
|
|
||||||
sb.Append(Name);
|
|
||||||
sb.Append(Parameters.CallString());
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a string representing the full non-delegate declaration without decorations.
|
|
||||||
/// (ie "(unsafe) void glXxxYyy(int a, float b, IntPtr c)"
|
|
||||||
/// </summary>
|
|
||||||
public string DeclarationString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.Append(Unsafe ? "unsafe " : "");
|
|
||||||
sb.Append(ReturnType);
|
|
||||||
sb.Append(" ");
|
|
||||||
sb.Append(Name);
|
|
||||||
sb.Append(Parameters.ToString(true));
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a string representing the full delegate declaration without decorations.
|
|
||||||
/// (ie "(unsafe) void delegate glXxxYyy(int a, float b, IntPtr c)"
|
|
||||||
/// </summary>
|
|
||||||
override public string ToString()
|
override public string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -286,25 +252,11 @@ namespace Bind.Structures
|
||||||
sb.Append(ReturnType);
|
sb.Append(ReturnType);
|
||||||
sb.Append(" ");
|
sb.Append(" ");
|
||||||
sb.Append(Name);
|
sb.Append(Name);
|
||||||
sb.Append(Parameters.ToString(true));
|
sb.Append(Parameters.ToString());
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Delegate GetCLSCompliantDelegate()
|
|
||||||
{
|
|
||||||
Delegate f = new Delegate(this);
|
|
||||||
|
|
||||||
for (int i = 0; i < f.Parameters.Count; i++)
|
|
||||||
{
|
|
||||||
f.Parameters[i].CurrentType = f.Parameters[i].GetCLSCompliantType();
|
|
||||||
}
|
|
||||||
|
|
||||||
f.ReturnType.CurrentType = f.ReturnType.GetCLSCompliantType();
|
|
||||||
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IComparable<Delegate> Members
|
#region IComparable<Delegate> Members
|
||||||
|
|
||||||
public int CompareTo(Delegate other)
|
public int CompareTo(Delegate other)
|
||||||
|
@ -313,6 +265,15 @@ namespace Bind.Structures
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IEquatable<Delegate> Members
|
||||||
|
|
||||||
|
public bool Equals(Delegate other)
|
||||||
|
{
|
||||||
|
return CompareTo(other) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#region class DelegateCollection : SortedDictionary<string, Delegate>
|
#region class DelegateCollection : SortedDictionary<string, Delegate>
|
||||||
|
|
Loading…
Reference in a new issue