From da349465fd420c114bd844e93b362967e72e76e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 19 Sep 2026 23:16:02 +0200 Subject: [PATCH] Work around marshalling for bools Apparently C# marshalls bools as 4 byte integers --- ScriptCoreGenerator/ScriptGlueGenerator.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ScriptCoreGenerator/ScriptGlueGenerator.cs b/ScriptCoreGenerator/ScriptGlueGenerator.cs index 1dd87e7..e38260a 100644 --- a/ScriptCoreGenerator/ScriptGlueGenerator.cs +++ b/ScriptCoreGenerator/ScriptGlueGenerator.cs @@ -204,6 +204,18 @@ public class ScriptGlueGenerator : IIncrementalGenerator ReturnValueConversion = null }); + // A bool in an unmanaged function pointer is marshalled as a 4-byte Win32 BOOL. + // Beef bools are 1 byte (only al is written), so we pass them as byte and convert manually. + beefTypeToMappedType.Add("bool", new MappedType + { + BeefTypeName = "bool", + CSharpTypeName = "byte", + CSharpWrapperType = "bool", + ReturnValueConversion = "return returnValue != 0;", + WrapperConvertInput = "byte {0} = (byte)({1} ? 1 : 0);", + WrapperOutConversion = "{1} = {0} != 0;" + }); + beefTypeToMappedType.Add("uint8*", new MappedType { BeefTypeName = "uint8*",