Work around marshalling for bools

Apparently C# marshalls bools as 4 byte integers
This commit is contained in:
Simon Lübeß
2026-09-19 23:16:02 +02:00
parent e27237360f
commit da349465fd
@@ -204,6 +204,18 @@ public class ScriptGlueGenerator : IIncrementalGenerator
ReturnValueConversion = null 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 beefTypeToMappedType.Add("uint8*", new MappedType
{ {
BeefTypeName = "uint8*", BeefTypeName = "uint8*",