genbindings: add QtClassType() helper

This commit is contained in:
mappu 2024-08-08 19:06:14 +12:00
parent d5e6a21ae4
commit 2dc9d1bab7
3 changed files with 6 additions and 2 deletions

View File

@ -26,7 +26,7 @@ func emitParametersCpp(params []CppParameter, selfType string) string {
// Declare that we take two parameters
tmp = append(tmp, "const char* "+p.ParameterName+", size_t "+p.ParameterName+"_Strlen")
} else if (p.ByRef || p.Pointer) && p.ParameterType[0] == 'Q' {
} else if (p.ByRef || p.Pointer) && p.QtClassType() {
// Pointer to Qt type
// Replace with taking our PQ typedef by value
tmp = append(tmp, "P"+p.ParameterType+" "+p.ParameterName)

View File

@ -48,7 +48,7 @@ func emitParametersGo2CABIForwarding(params []CppParameter) (preamble string, fo
preamble += "defer C.free(" + p.ParameterName + "_Cstring)\n"
tmp = append(tmp, p.ParameterName+"_Cstring")
} else if (p.Pointer || p.ByRef) && p.ParameterType[0] == 'Q' {
} else if (p.Pointer || p.ByRef) && p.QtClassType() {
// The C++ type is a pointer to Qt class
// We want our functions to accept the Go wrapper type, and forward as cPointer()
tmp = append(tmp, p.ParameterName+".cPointer()")

View File

@ -13,6 +13,10 @@ type CppParameter struct {
Optional bool
}
func (p CppParameter) QtClassType() bool {
return p.ParameterType[0] == 'Q'
}
type CppProperty struct {
PropertyName string
PropertyType string