mirror of
https://github.com/amerkoleci/Vortice.Win32.git
synced 2026-01-14 16:16:04 +08:00
Generator: Improve struct return types in other cases (ID2D1Bitmap::GetPixelSize)
This commit is contained in:
@@ -1985,8 +1985,9 @@ public static class Program
|
||||
if (returnType != "void" &&
|
||||
method.ReturnType.TargetKind != "Com" &&
|
||||
method.ReturnType.Kind == "ApiRef" &&
|
||||
!IsPrimitive(method.ReturnType) &&
|
||||
!IsEnum(method.ReturnType))
|
||||
!IsEnum(method.ReturnType) &&
|
||||
IsStructAsReturnMarshal(method.ReturnType)
|
||||
)
|
||||
{
|
||||
useReturnAsParameter = true;
|
||||
}
|
||||
@@ -2699,6 +2700,59 @@ public static class Program
|
||||
return IsPrimitive(typeName);
|
||||
}
|
||||
|
||||
private static bool IsStructAsReturnMarshal(ApiDataType dataType)
|
||||
{
|
||||
if (dataType.Kind != "ApiRef")
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
string apiRefType = GetTypeName($"{dataType.Api}.{dataType.Name}");
|
||||
if (apiRefType.EndsWith("*"))
|
||||
{
|
||||
apiRefType = apiRefType.Substring(0, apiRefType.Length - 1);
|
||||
}
|
||||
|
||||
switch (apiRefType)
|
||||
{
|
||||
case "void":
|
||||
case "bool":
|
||||
case "byte":
|
||||
case "sbyte":
|
||||
case "int":
|
||||
case "uint":
|
||||
case "short":
|
||||
case "ushort":
|
||||
case "long":
|
||||
case "ulong":
|
||||
case "float":
|
||||
case "double":
|
||||
return false;
|
||||
|
||||
case "nint":
|
||||
case "nuint":
|
||||
case "IntPtr":
|
||||
case "UIntPtr":
|
||||
case "Guid":
|
||||
return false;
|
||||
|
||||
case "Bool32":
|
||||
case "HResult":
|
||||
return false;
|
||||
|
||||
case "LargeInteger":
|
||||
case "ULargeInteger":
|
||||
return true;
|
||||
|
||||
case "Luid":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool IsEnum(ApiDataType dataType)
|
||||
{
|
||||
if (dataType.Kind == "ApiRef")
|
||||
|
||||
Reference in New Issue
Block a user