mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-25 22:01:08 +00:00
[Bind] Add int overloads to buffer size (IntPtr) parameters
As a convenience, int overloads are provided for IntPtr size parameters (corresponding to BufferSize or size_t). In the vast majority of cases, a 32bit int is sufficient for buffer sizes, so these overloads avoid the necessity of annoying (IntPtr) casts. If more than 2^31-1 elements are required, the IntPtr overloads remain available. (As always, this requires a 64bit runtime environment.)
This commit is contained in:
parent
074a4ff807
commit
cbe0684d7f
|
@ -324,19 +324,18 @@ namespace Bind
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Todo: what is the point of this here? It is overwritten below.
|
|
||||||
// A few translations for consistency
|
|
||||||
switch (type.CurrentType.ToLower())
|
|
||||||
{
|
|
||||||
case "string":
|
|
||||||
type.QualifiedType = "String";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
type.QualifiedType = s;
|
type.QualifiedType = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((type.Array == 0 && type.Pointer == 0 && !type.Reference) &&
|
||||||
|
(type.QualifiedType.ToLower().Contains("buffersize") ||
|
||||||
|
type.QualifiedType.ToLower().Contains("sizeiptr") ||
|
||||||
|
type.QualifiedType.Contains("size_t")))
|
||||||
|
{
|
||||||
|
type.WrapperType |= WrapperTypes.SizeParameter;
|
||||||
|
}
|
||||||
|
|
||||||
type.CurrentType =
|
type.CurrentType =
|
||||||
Generator.CSTypes.ContainsKey(type.CurrentType) ?
|
Generator.CSTypes.ContainsKey(type.CurrentType) ?
|
||||||
Generator.CSTypes[type.CurrentType] : type.CurrentType;
|
Generator.CSTypes[type.CurrentType] : type.CurrentType;
|
||||||
|
@ -960,6 +959,27 @@ namespace Bind
|
||||||
convenience_wrappers.Add(f);
|
convenience_wrappers.Add(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for IntPtr parameters that correspond to size_t (e.g. GLsizei)
|
||||||
|
// and add Int32 overloads for convenience.
|
||||||
|
{
|
||||||
|
Function f = null;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var p in d.Parameters)
|
||||||
|
{
|
||||||
|
if ((p.WrapperType & WrapperTypes.SizeParameter) != 0)
|
||||||
|
{
|
||||||
|
f = f ?? new Function(d);
|
||||||
|
f.Parameters[i].QualifiedType = "Int32";
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f != null)
|
||||||
|
{
|
||||||
|
convenience_wrappers.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convenience_wrappers;
|
return convenience_wrappers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,11 @@ namespace Bind
|
||||||
/// Function takes a String[] parameter
|
/// Function takes a String[] parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
StringArrayParameter = 1 << 13,
|
StringArrayParameter = 1 << 13,
|
||||||
|
/// <summary>
|
||||||
|
/// Functions takes an IntPtr that corresponds to a size_t.
|
||||||
|
/// Add an int32 overload for convenience.
|
||||||
|
/// </summary>
|
||||||
|
SizeParameter = 1 << 14,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue