From bcfdb4ea152138efdbe9d9c348c914ff1b911f97 Mon Sep 17 00:00:00 2001 From: mappu Date: Fri, 11 Oct 2024 18:37:38 +1300 Subject: [PATCH] genbindings/integers: properly treat char as signed int8, not byte --- cmd/genbindings/emitgo.go | 11 +++++++---- cmd/genbindings/intermediate.go | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index 6d488ac..37d982f 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -45,11 +45,14 @@ func (p CppParameter) RenderTypeGo() string { } switch p.ParameterType { - case "char", "qint8", "signed char", "unsigned char", "uchar", "quint8": - ret += "byte" // Strictly speaking, Go byte is unsigned and char may be signed - case "short", "qint16": + case "unsigned char", "uchar", "quint8": + // Go byte is unsigned + ret += "byte" + case "char", "qint8", "signed char": + ret += "int8" // Signed + case "short", "qint16", "int16_t": ret += "int16" - case "ushort", "quint16", "unsigned short": + case "ushort", "quint16", "unsigned short", "uint16_t": ret += "uint16" case "long": // Windows ILP32 - 32-bits diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index f7a2435..1a3328b 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -151,10 +151,10 @@ func (p CppParameter) IntType() bool { switch p.ParameterType { case "int", "unsigned int", "uint", - "short", "unsigned short", "ushort", "qint16", "quint16", + "short", "unsigned short", "ushort", "qint16", "quint16", "uint16_t", "int16_t", "qint8", "quint8", "unsigned char", "signed char", "uchar", - "long", "unsigned long", "ulong", "qint32", "quint32", + "long", "unsigned long", "ulong", "qint32", "quint32", "int32_t", "uint32_t", "longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long", "qintptr", "quintptr", "uintptr_t", "intptr_t", "qsizetype", "size_t",