Address PR feedback

This commit is contained in:
Andrii Kurdiumov 2021-07-21 00:38:34 +06:00
parent 2c54a7824c
commit 1b73bc8042
2 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@ namespace GLib {
),
new GLib.AbiField("is_setup"
, -1
, (uint) sizeof (bool) // is_setup
, (uint) sizeof(uint) // is_setup
, "hook_size"
, "hooks"
, 1

View File

@ -237,6 +237,7 @@ namespace GtkSharp.Generation {
internal static string GetSizeOfExpression(string cstype)
{
// See https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types
bool isBlittable = cstype == "IntPtr"
|| cstype == "UIntPtr"
|| cstype == "ulong"
@ -247,11 +248,15 @@ namespace GtkSharp.Generation {
|| cstype == "short"
|| cstype == "byte"
|| cstype == "sbyte"
|| cstype == "char"
|| cstype == "byte";
|| cstype == "float"
|| cstype == "double";
if (isBlittable)
return "sizeof( " + cstype + " )";
// This is optimization based on https://github.com/GtkSharp/GtkSharp/pull/261#discussion_r673381869
if (cstype == "bool")
return "sizeof( uint )";
return "Marshal.SizeOf<" + cstype + ">()";
}
}