mirror of
https://github.com/mappu/miqt.git
synced 2025-01-22 06:30:38 +00:00
genbindings: add explicit int casts when calling, to select overload
This commit is contained in:
parent
89f4024951
commit
3dcdfbd594
@ -106,6 +106,15 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f
|
|||||||
preamble += "\t}\n"
|
preamble += "\t}\n"
|
||||||
tmp = append(tmp, p.ParameterName+"_QList")
|
tmp = append(tmp, p.ParameterName+"_QList")
|
||||||
|
|
||||||
|
} else if p.IntType() {
|
||||||
|
// Use the raw ParameterType to select an explicit integer overload
|
||||||
|
// Don't use RenderTypeCpp() since it canonicalizes some int types for CABI
|
||||||
|
castType := p.ParameterType
|
||||||
|
if p.Pointer {
|
||||||
|
castType += "*"
|
||||||
|
}
|
||||||
|
tmp = append(tmp, "static_cast<"+castType+">("+p.ParameterName+")")
|
||||||
|
|
||||||
} else if p.ByRef {
|
} else if p.ByRef {
|
||||||
// We changed RenderTypeCpp() to render this as a pointer
|
// We changed RenderTypeCpp() to render this as a pointer
|
||||||
// Need to dereference so we can pass as reference to the actual Qt C++ function
|
// Need to dereference so we can pass as reference to the actual Qt C++ function
|
||||||
|
@ -25,6 +25,20 @@ func (p CppParameter) QListOf() (CppParameter, bool) {
|
|||||||
return CppParameter{}, false
|
return CppParameter{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p CppParameter) IntType() bool {
|
||||||
|
switch p.ParameterType {
|
||||||
|
case "int", "uint",
|
||||||
|
"short", "ushort",
|
||||||
|
// "char", "uchar", // Don't count char or char* as integer types that need cast assertions
|
||||||
|
"long", "ulong",
|
||||||
|
"longlong", "ulonglong", "qlonglong", "qulonglong", "int64_t", "uint64_t",
|
||||||
|
"double", "float", "qreal":
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type CppProperty struct {
|
type CppProperty struct {
|
||||||
PropertyName string
|
PropertyName string
|
||||||
PropertyType string
|
PropertyType string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user