From e629117e54cd9088bc3598787b0c88471de75e28 Mon Sep 17 00:00:00 2001 From: mappu Date: Thu, 22 Aug 2024 19:20:29 +1200 Subject: [PATCH] genbindings/ints: qint64 handling applies to pointer types too --- cmd/genbindings/emitcabi.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/genbindings/emitcabi.go b/cmd/genbindings/emitcabi.go index 90f47a6..9843ccd 100644 --- a/cmd/genbindings/emitcabi.go +++ b/cmd/genbindings/emitcabi.go @@ -225,15 +225,18 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f if p.ByRef { // e.g. QDataStream::operator>>() overloads castSrc = "*" + castSrc castType += "&" // believe it or not, this is legal - - if p.ParameterType == "qint64" || p.ParameterType == "quint64" { - // QDataStream::operator>>() - // CABI has these as int64_t* (long int) which fails a static_cast to qint64& (long long int&) - // Hack a hard C-style cast - castSrc = "(" + castType + ")(" + castSrc + ")" - } } - tmp = append(tmp, "static_cast<"+castType+">("+castSrc+")") + + if p.ParameterType == "qint64" || p.ParameterType == "quint64" { + // QDataStream::operator>>() by reference + // QLockFile::getLockInfo() by pointer + // CABI has these as int64_t* (long int) which fails a static_cast to qint64& (long long int&) + // Hack a hard C-style cast + tmp = append(tmp, "("+castType+")("+castSrc+")") + } else { + // Use static_cast<> safely + tmp = append(tmp, "static_cast<"+castType+">("+castSrc+")") + } } else if p.ByRef { // We changed RenderTypeCabi() to render this as a pointer