diff --git a/Source/Libs/GLibSharp/HookList.cs b/Source/Libs/GLibSharp/HookList.cs index 07d2a4c0c..3498454f5 100644 --- a/Source/Libs/GLibSharp/HookList.cs +++ b/Source/Libs/GLibSharp/HookList.cs @@ -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 diff --git a/Source/Tools/GapiCodegen/GenerationInfo.cs b/Source/Tools/GapiCodegen/GenerationInfo.cs index b7ee41549..6ced13550 100644 --- a/Source/Tools/GapiCodegen/GenerationInfo.cs +++ b/Source/Tools/GapiCodegen/GenerationInfo.cs @@ -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 + ">()"; } }