Add feature to Bind to generate legacy array overloads

This commit is contained in:
Fraser Waters 2017-10-05 12:33:19 +01:00
parent 6bd1f0e603
commit ffa26fb204
2 changed files with 31 additions and 0 deletions

View file

@ -648,6 +648,22 @@ namespace Bind
{
d.Parameters[i].WrapperType |= WrapperTypes.UncheckedParameter;
}
if (function_override != null)
{
XPathNavigator param_override = function_override.SelectSingleNode(String.Format(
"param[@name='{0}' or @index='{1}']",
d.Parameters[i].RawName,
i));
if (param_override != null)
{
var legacyArrayParameter = param_override.GetAttribute("legacyArrayParameter", String.Empty);
if (!String.IsNullOrEmpty(legacyArrayParameter))
{
d.Parameters[i].WrapperType |= WrapperTypes.LegacyArrayParameter;
}
}
}
}
}
@ -1097,6 +1113,17 @@ namespace Bind
// Generics are handled in a second pass.
if ((parameter.WrapperType & WrapperTypes.GenericParameter) == 0)
{
if ((parameter.WrapperType & WrapperTypes.LegacyArrayParameter) != 0)
{
foreach (var wrapper in GetWrapper(wrappers, WrapperTypes.LegacyArrayParameter, func))
{
wrapper.Obsolete = "Use out overload instead";
var p = wrapper.Parameters[i];
p.Array++;
p.Pointer--;
}
}
if ((parameter.WrapperType & WrapperTypes.ArrayParameter) != 0)
{
foreach (var wrapper in GetWrapper(wrappers, WrapperTypes.ArrayParameter, func))

View file

@ -94,6 +94,10 @@ namespace Bind
/// Add an int32 overload for convenience.
/// </summary>
SizeParameter = 1 << 14,
/// <summary>
/// Function takes a ref but we emit a legacy array overload to maintain backwards compatability.
/// </summary>
LegacyArrayParameter = 1 << 15,
}
internal static class Utilities