genbindings/const: fixes for disambiguating calls to const methods

This commit is contained in:
mappu 2024-08-29 17:14:44 +12:00
parent 8da51d61f5
commit 7b5db7c7ea

View File

@ -601,13 +601,7 @@ extern "C" {
}
} else if m.ReturnType.QtClassType() && !m.ReturnType.Pointer {
// Still need const/nonconst in order to properly call function overloads that are only disambiguated by const-ness
// e.g. QCborArray::begin() can return an Iterator or a ConstIterator
if m.IsConst {
shouldReturn = "const " + m.ReturnType.ParameterType + " ret = "
} else {
shouldReturn = m.ReturnType.ParameterType + " ret = "
}
shouldReturn = m.ReturnType.ParameterType + " ret = "
afterCall = "\t// Copy-construct value returned type into heap-allocated copy\n"
afterCall += "\treturn static_cast<" + m.ReturnType.ParameterType + "*>(new " + m.ReturnType.ParameterType + "(ret));\n"
@ -631,6 +625,9 @@ extern "C" {
callTarget := "self->"
if m.IsStatic {
callTarget = c.ClassName + "::"
} else if m.IsConst {
callTarget = "const_cast<const " + c.ClassName + "*>(self)->"
}
ret.WriteString(fmt.Sprintf(