mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
genbindings: change simple operator== to use infix syntax
This commit is contained in:
parent
33c5bbaafb
commit
2a502f24ff
@ -1026,6 +1026,14 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
|
||||
|
||||
callTarget += m.CppCallTarget() + "(" + forwarding + ")"
|
||||
|
||||
// Qt 6.8 moved many operator== implementations from class methods
|
||||
// into global operators.
|
||||
// By using infix syntax, either can be called
|
||||
if m.IsReadonlyOperator() && len(m.Parameters) == 1 {
|
||||
operator := m.CppCallTarget()[8:]
|
||||
callTarget = "(*self " + operator + " " + forwarding + ")"
|
||||
}
|
||||
|
||||
if m.LinuxOnly {
|
||||
ret.WriteString(fmt.Sprintf(
|
||||
"%s %s_%s(%s) {\n"+
|
||||
|
@ -348,6 +348,16 @@ func (nm CppMethod) SafeMethodName() string {
|
||||
return tmp
|
||||
}
|
||||
|
||||
func (nm CppMethod) IsReadonlyOperator() bool {
|
||||
targ := nm.CppCallTarget()
|
||||
switch targ {
|
||||
case "operator==", "operator!=",
|
||||
"operator<", "operator<=", "operator>", "operator>=":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type CppEnumEntry struct {
|
||||
EntryName string
|
||||
EntryValue string
|
||||
|
Loading…
Reference in New Issue
Block a user