genbindings/exceptions: move header imports to exceptions.go

This commit is contained in:
mappu 2024-08-18 19:02:14 +12:00
parent 3ef53b4224
commit cf2585416f
2 changed files with 27 additions and 6 deletions

View File

@ -420,12 +420,7 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
`)
for _, ref := range getReferencedTypes(src) {
if ref[0] != 'Q' {
continue
}
if strings.HasPrefix(ref, "QPlatform") {
// e.g. QPlatformPixmap, QPlatformWindow, QPlatformScreen
// These classes don't have a <> version to include
if !ImportHeaderForClass(ref) {
continue
}

View File

@ -1,5 +1,9 @@
package main
import (
"strings"
)
func AllowDelete(c CppClass) bool {
switch c.ClassName {
case "QClipboard":
@ -8,6 +12,28 @@ func AllowDelete(c CppClass) bool {
return true
}
func ImportHeaderForClass(className string) bool {
if className[0] != 'Q' {
return false
}
// TODO this could be implict by checking if files exist in known header paths
if strings.HasPrefix(className, "QPlatform") {
// e.g. QPlatformPixmap, QPlatformWindow, QPlatformScreen
// These classes don't have a <> version to include
return false
}
switch className {
case "QGraphicsEffectSource", // e.g. qgraphicseffect.h
"QText": // e.g. qtextcursor.h
return false
}
return true
}
func CheckComplexity(p CppParameter) error {
if p.QMapOf() {