genbindings: add Delete() functions

This commit is contained in:
mappu 2024-08-10 10:32:57 +12:00
parent 8c572259c4
commit 76f4323676
2 changed files with 19 additions and 0 deletions

View File

@ -147,6 +147,9 @@ extern "C" {
ret.WriteString(fmt.Sprintf("%s %s_%s(%s);\n", emitReturnTypeCabi(m.ReturnType), c.ClassName, m.SafeMethodName(), emitParametersCabi(m, "P"+c.ClassName)))
}
// delete
ret.WriteString(fmt.Sprintf("void %s_Delete(P%s self);\n", c.ClassName, c.ClassName))
ret.WriteString("\n")
}
@ -217,6 +220,16 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
afterCall,
))
}
// Delete
ret.WriteString(fmt.Sprintf(
"void %s_Delete(P%s self) {\n"+
"\tdelete static_cast<%s*>(self);\n"+
"}\n"+
"\n",
c.ClassName, c.ClassName,
c.ClassName,
))
}
return ret.String(), nil

View File

@ -147,6 +147,12 @@ import "C"
`)
}
ret.WriteString(`
func (this *` + c.ClassName + `) Delete() {
C.` + c.ClassName + `_Delete(this.h)
}
`)
}
goSrc := ret.String()