genbindings: fix QClipboard private dtor

This commit is contained in:
mappu 2024-08-18 17:47:19 +12:00
parent e57459c5e7
commit 441d96398f
3 changed files with 26 additions and 12 deletions

View File

@ -343,7 +343,9 @@ extern "C" {
}
// delete
ret.WriteString(fmt.Sprintf("void %s_Delete(%s* self);\n", c.ClassName, c.ClassName))
if AllowDelete(c) {
ret.WriteString(fmt.Sprintf("void %s_Delete(%s* self);\n", c.ClassName, c.ClassName))
}
ret.WriteString("\n")
}
@ -495,13 +497,15 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
}
// Delete
ret.WriteString(fmt.Sprintf(
"void %s_Delete(%s* self) {\n"+
"\tdelete self;\n"+
"}\n"+
"\n",
c.ClassName, c.ClassName,
))
if AllowDelete(c) {
ret.WriteString(fmt.Sprintf(
"void %s_Delete(%s* self) {\n"+
"\tdelete self;\n"+
"}\n"+
"\n",
c.ClassName, c.ClassName,
))
}
}
return ret.String(), nil

View File

@ -376,11 +376,13 @@ import "C"
`)
}
ret.WriteString(`
func (this *` + c.ClassName + `) Delete() {
C.` + c.ClassName + `_Delete(this.h)
if AllowDelete(c) {
ret.WriteString(`
func (this *` + c.ClassName + `) Delete() {
C.` + c.ClassName + `_Delete(this.h)
}
`)
}
`)
}

View File

@ -1,5 +1,13 @@
package main
func AllowDelete(c CppClass) bool {
switch c.ClassName {
case "QClipboard":
return false // The destructor is marked private. TODO grab this from the AST
}
return true
}
func CheckComplexity(p CppParameter) error {
if p.QMapOf() {