diff --git a/README.md b/README.md index 403c452e..81484399 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,12 @@ MIQT is a clean-room binding that does not use any code from other Qt bindings. Most functions are implemented 1:1. [The Qt documentation](https://doc.qt.io/qt-5/classes.html) should be used. -The `QByteArray`, `QString`, `QList`, and `QVector` types are projected as plain Go `[]byte`, `string`, and `[]T`. Therefore, you can't call any of QByteArray/QString/QList/QVector's helper methods, you must use some Go equivalent method instead. +The `QByteArray`, `QString`, `QList`, `QVector`, `QMap`, `QHash` types are projected as plain Go `[]byte`, `string`, `[]T`, and `map[K]V`. Therefore, you can't call any of the Qt type's methods, you must use some Go equivalent method instead. - Go strings are internally converted to QString using `QString::fromUtf8`. Therefore, the Go string must be UTF-8 to avoid [mojibake](https://en.wikipedia.org/wiki/Mojibake). If the Go string contains binary data, the conversion would corrupt such bytes into U+FFFD (�). On return to Go space, this becomes `\xEF\xBF\xBD`. +- The iteration order of a Qt QMap/QHash will differ from the Go map iteration order. QMap is iterated by key order, but Go maps and QHash iterate in an undefined internal order. + Where Qt returns a C++ object by value (e.g. `QSize`), the binding may have moved it to the heap, and in Go this may be represented as a pointer type. In such cases, a Go finalizer is added to automatically delete the heap object. This means code using MIQT can look basically similar to the Qt C++ equivalent code. The `connect(sourceObject, sourceSignal, targetObject, targetSlot)` is projected as `targetObject.onSourceSignal(func()...)`. @@ -189,7 +191,7 @@ pacman -S mingw-w64-ucrt-x86_64-qt6-base # For Qt 6 go build -ldflags "-s -w -H windowsgui" ``` -- Note: the MSYS2 `qt5-base` package [links against `libicu`](https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-qt5-base/PKGBUILD#L241), whereas the Fsu0413 Qt packages do not. When using MSYS2, your distribution size including `.dll` files will be larger. +- Note: the MSYS2 `qt5-base` package [is built to use `libicu`](https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-qt5-base/PKGBUILD#L241), whereas the Fsu0413 Qt packages are not. [ICU is included by default with Windows 10 1703 and later](https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255). If you are targeting older versions of Windows, then when using MSYS2, your distribution size including `.dll` files will be larger. For static linking: @@ -254,7 +256,7 @@ See FAQ Q3 for advice about docker performance. *Tested with Raymii Qt 5.15 / Android SDK 31 / Android NDK 22* -Miqt supports compiling for Android. Some extra steps are required to bridge the Java, C++, Go worlds. +MIQT supports compiling for Android. Some extra steps are required to bridge the Java, C++, Go worlds. ![](doc/android-architecture.png) diff --git a/cmd/genbindings/config-allowlist.go b/cmd/genbindings/config-allowlist.go index 4807eeeb..9253f1de 100644 --- a/cmd/genbindings/config-allowlist.go +++ b/cmd/genbindings/config-allowlist.go @@ -82,6 +82,8 @@ func AllowHeader(fullpath string) bool { "qbytearray.h", // QByteArray does not exist in this binding "qlist.h", // QList does not exist in this binding "qvector.h", // QVector does not exist in this binding + "qhash.h", // QHash does not exist in this binding + "qmap.h", // QMap does not exist in this binding "qtcoreexports.h", // Nothing bindable here and has Q_CORE_EXPORT definition issues "q20algorithm.h", // Qt 6 unstable header "q20functional.h", // Qt 6 unstable header @@ -216,9 +218,6 @@ func AllowMethod(className string, mm CppMethod) error { // Any type not permitted by AllowClass is also not permitted by this method. func AllowType(p CppParameter, isReturnType bool) error { - if p.QMapOf() { - return ErrTooComplex // Example??? - } if p.QPairOf() { return ErrTooComplex // e.g. QGradientStop } @@ -238,6 +237,15 @@ func AllowType(p CppParameter, isReturnType bool) error { return ErrTooComplex } } + if kType, vType, ok := p.QMapOf(); ok { + if err := AllowType(kType, isReturnType); err != nil { + return err + } + if err := AllowType(vType, isReturnType); err != nil { + return err + } + } + if !AllowClass(p.ParameterType) { return ErrTooComplex // This whole class type has been blocked, not only as a parameter/return type } @@ -294,6 +302,12 @@ func AllowType(p CppParameter, isReturnType bool) error { if strings.Contains(p.ParameterType, `Iterator::value_type`) { return ErrTooComplex // e.g. qcbormap } + if strings.Contains(p.ParameterType, `>::iterator`) || + strings.Contains(p.ParameterType, `>::const_iterator`) { + // qresultstore.h tries to create a + // NewQtPrivate__ResultIteratorBase2(_mapIterator QMap__const_iterator) + return ErrTooComplex + } if strings.Contains(p.ParameterType, `::QPrivate`) { return ErrTooComplex // e.g. QAbstractItemModel::QPrivateSignal } diff --git a/cmd/genbindings/emitcabi.go b/cmd/genbindings/emitcabi.go index 3020f423..781393f8 100644 --- a/cmd/genbindings/emitcabi.go +++ b/cmd/genbindings/emitcabi.go @@ -15,10 +15,13 @@ func (p CppParameter) RenderTypeCabi() string { return "struct miqt_string" } else if _, ok := p.QListOf(); ok { - return "struct miqt_array*" + return "struct miqt_array" } else if _, ok := p.QSetOf(); ok { - return "struct miqt_array*" + return "struct miqt_array" + + } else if _, _, ok := p.QMapOf(); ok { + return "struct miqt_map" } else if (p.Pointer || p.ByRef) && p.QtClassType() { return cabiClassName(p.ParameterType) + "*" @@ -155,10 +158,10 @@ func emitParametersCabi(m CppMethod, selfType string) string { tmp = append(tmp, "struct miqt_string "+p.ParameterName) } else if t, ok := p.QListOf(); ok { - tmp = append(tmp, "struct miqt_array* /* of "+t.RenderTypeCabi()+" */ "+p.ParameterName) + tmp = append(tmp, "struct miqt_array /* of "+t.RenderTypeCabi()+" */ "+p.ParameterName) } else if t, ok := p.QSetOf(); ok { - tmp = append(tmp, "struct miqt_array* /* Set of "+t.RenderTypeCabi()+" */ "+p.ParameterName) + tmp = append(tmp, "struct miqt_array /* Set of "+t.RenderTypeCabi()+" */ "+p.ParameterName) } else if p.QtClassType() { if p.ByRef || p.Pointer { @@ -218,10 +221,10 @@ func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, for } else if listType, ok := p.QListOf(); ok { preamble += indent + p.GetQtCppType().ParameterType + " " + nameprefix + "_QList;\n" - preamble += indent + nameprefix + "_QList.reserve(" + p.ParameterName + "->len);\n" + preamble += indent + nameprefix + "_QList.reserve(" + p.ParameterName + ".len);\n" - preamble += indent + listType.RenderTypeCabi() + "* " + nameprefix + "_arr = static_cast<" + listType.RenderTypeCabi() + "*>(" + p.ParameterName + "->data);\n" - preamble += indent + "for(size_t i = 0; i < " + p.ParameterName + "->len; ++i) {\n" + preamble += indent + listType.RenderTypeCabi() + "* " + nameprefix + "_arr = static_cast<" + listType.RenderTypeCabi() + "*>(" + p.ParameterName + ".data);\n" + preamble += indent + "for(size_t i = 0; i < " + p.ParameterName + ".len; ++i) {\n" listType.ParameterName = nameprefix + "_arr[i]" addPre, addFwd := emitCABI2CppForwarding(listType, indent+"\t") @@ -231,6 +234,32 @@ func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, for preamble += indent + "}\n" return preamble, nameprefix + "_QList" + } else if kType, vType, ok := p.QMapOf(); ok { + preamble += indent + p.GetQtCppType().ParameterType + " " + nameprefix + "_QMap;\n" + + // This container may be a QMap or a QHash + // QHash supports .reserve(), but QMap doesn't + if strings.HasPrefix(p.ParameterType, "QHash<") { + preamble += indent + nameprefix + "_QMap.reserve(" + p.ParameterName + ".len);\n" + } + + preamble += indent + kType.RenderTypeCabi() + "* " + nameprefix + "_karr = static_cast<" + kType.RenderTypeCabi() + "*>(" + p.ParameterName + ".keys);\n" + preamble += indent + vType.RenderTypeCabi() + "* " + nameprefix + "_varr = static_cast<" + vType.RenderTypeCabi() + "*>(" + p.ParameterName + ".values);\n" + preamble += indent + "for(size_t i = 0; i < " + p.ParameterName + ".len; ++i) {\n" + + kType.ParameterName = nameprefix + "_karr[i]" + addPreK, addFwdK := emitCABI2CppForwarding(kType, indent+"\t") + preamble += addPreK + + vType.ParameterName = nameprefix + "_varr[i]" + addPreV, addFwdV := emitCABI2CppForwarding(vType, indent+"\t") + preamble += addPreV + + preamble += indent + "\t" + nameprefix + "_QMap[" + addFwdK + "] = " + addFwdV + ";\n" + + preamble += indent + "}\n" + return preamble, nameprefix + "_QMap" + } else if p.IsFlagType() || p.IntType() || p.IsKnownEnum() { castSrc := p.ParameterName castType := p.RenderTypeQtCpp() @@ -362,9 +391,9 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string) afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_arr[i] = ", t, namePrefix+"_ret[i]") afterCall += indent + "}\n" - afterCall += indent + "struct miqt_array* " + namePrefix + "_out = static_cast(malloc(sizeof(struct miqt_array)));\n" - afterCall += indent + "" + namePrefix + "_out->len = " + namePrefix + "_ret.length();\n" - afterCall += indent + "" + namePrefix + "_out->data = static_cast(" + namePrefix + "_arr);\n" + afterCall += indent + "struct miqt_array " + namePrefix + "_out;\n" + afterCall += indent + "" + namePrefix + "_out.len = " + namePrefix + "_ret.length();\n" + afterCall += indent + "" + namePrefix + "_out.data = static_cast(" + namePrefix + "_arr);\n" afterCall += indent + assignExpression + "" + namePrefix + "_out;\n" @@ -380,9 +409,33 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string) afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_arr["+namePrefix+"_ctr++] = ", t, namePrefix+"_itr.next()") afterCall += indent + "}\n" - afterCall += indent + "struct miqt_array* " + namePrefix + "_out = static_cast(malloc(sizeof(struct miqt_array)));\n" - afterCall += indent + "" + namePrefix + "_out->len = " + namePrefix + "_ret.size();\n" - afterCall += indent + "" + namePrefix + "_out->data = static_cast(" + namePrefix + "_arr);\n" + afterCall += indent + "struct miqt_array " + namePrefix + "_out;\n" + afterCall += indent + "" + namePrefix + "_out.len = " + namePrefix + "_ret.size();\n" + afterCall += indent + "" + namePrefix + "_out.data = static_cast(" + namePrefix + "_arr);\n" + + afterCall += indent + assignExpression + "" + namePrefix + "_out;\n" + + } else if kType, vType, ok := p.QMapOf(); ok { + // QMap + + shouldReturn = p.RenderTypeQtCpp() + " " + namePrefix + "_ret = " + + afterCall += indent + "// Convert QMap<> from C++ memory to manually-managed C memory\n" + afterCall += indent + "" + kType.RenderTypeCabi() + "* " + namePrefix + "_karr = static_cast<" + kType.RenderTypeCabi() + "*>(malloc(sizeof(" + kType.RenderTypeCabi() + ") * " + namePrefix + "_ret.size()));\n" + afterCall += indent + "" + vType.RenderTypeCabi() + "* " + namePrefix + "_varr = static_cast<" + vType.RenderTypeCabi() + "*>(malloc(sizeof(" + vType.RenderTypeCabi() + ") * " + namePrefix + "_ret.size()));\n" + + afterCall += indent + "int " + namePrefix + "_ctr = 0;\n" + afterCall += indent + "for (auto " + namePrefix + "_itr = " + namePrefix + "_ret.keyValueBegin(); " + namePrefix + "_itr != " + namePrefix + "_ret.keyValueEnd(); ++" + namePrefix + "_itr) {\n" + afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_karr["+namePrefix+"_ctr] = ", kType, namePrefix+"_itr->first") + afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_varr["+namePrefix+"_ctr] = ", vType, namePrefix+"_itr->second") + afterCall += indent + "\t" + namePrefix + "_ctr++;\n" + + afterCall += indent + "}\n" + + afterCall += indent + "struct miqt_map " + namePrefix + "_out;\n" + afterCall += indent + "" + namePrefix + "_out.len = " + namePrefix + "_ret.size();\n" + afterCall += indent + "" + namePrefix + "_out.keys = static_cast(" + namePrefix + "_karr);\n" + afterCall += indent + "" + namePrefix + "_out.values = static_cast(" + namePrefix + "_varr);\n" afterCall += indent + assignExpression + "" + namePrefix + "_out;\n" @@ -428,44 +481,42 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string) func getReferencedTypes(src *CppParsedHeader) []string { foundTypes := map[string]struct{}{} + + maybeAddType := func(p CppParameter) { + if p.QtClassType() { + foundTypes[p.ParameterType] = struct{}{} + } + if t, ok := p.QListOf(); ok { + foundTypes["QList"] = struct{}{} // FIXME or QVector? + if t.QtClassType() { + foundTypes[t.ParameterType] = struct{}{} + } + } + if kType, vType, ok := p.QMapOf(); ok { + foundTypes["QMap"] = struct{}{} // FIXME or QHash? + if kType.QtClassType() { + foundTypes[kType.ParameterType] = struct{}{} + } + if vType.QtClassType() { + foundTypes[vType.ParameterType] = struct{}{} + } + } + } + for _, c := range src.Classes { foundTypes[c.ClassName] = struct{}{} for _, ctor := range c.Ctors { for _, p := range ctor.Parameters { - if p.QtClassType() { - foundTypes[p.ParameterType] = struct{}{} - } - if t, ok := p.QListOf(); ok { - foundTypes["QList"] = struct{}{} // FIXME or QVector? - if t.QtClassType() { - foundTypes[t.ParameterType] = struct{}{} - } - } + maybeAddType(p) } } for _, m := range c.Methods { for _, p := range m.Parameters { - if p.QtClassType() { - foundTypes[p.ParameterType] = struct{}{} - } - if t, ok := p.QListOf(); ok { - foundTypes["QList"] = struct{}{} // FIXME or QVector? - if t.QtClassType() { - foundTypes[t.ParameterType] = struct{}{} - } - } - } - if m.ReturnType.QtClassType() { - foundTypes[m.ReturnType.ParameterType] = struct{}{} - } - if t, ok := m.ReturnType.QListOf(); ok { - foundTypes["QList"] = struct{}{} // FIXME or QVector? - if t.QtClassType() { - foundTypes[t.ParameterType] = struct{}{} - } + maybeAddType(p) } + maybeAddType(m.ReturnType) } } @@ -477,10 +528,7 @@ func getReferencedTypes(src *CppParsedHeader) []string { // Convert to sorted list foundTypesList := make([]string, 0, len(foundTypes)) for ft := range foundTypes { - if strings.HasPrefix(ft, "QList<") || strings.HasPrefix(ft, "QVector<") { // TODO properly exclude via the QListOf() check above - continue - } - if strings.HasSuffix(ft, "Private") { // qbrush.h finds QGradientPrivate + if !AllowClass(ft) { continue } @@ -504,6 +552,15 @@ func cabiClassName(className string) string { return strings.Replace(className, `::`, `__`, -1) } +func cabiPreventStructDeclaration(className string) bool { + switch className { + case "QList", "QString", "QSet", "QMap", "QHash": + return true // These types are reprojected + default: + return false + } +} + func emitBindingHeader(src *CppParsedHeader, filename string, packageName string) (string, error) { ret := strings.Builder{} @@ -537,7 +594,7 @@ extern "C" { ret.WriteString("#ifdef __cplusplus\n") for _, ft := range foundTypesList { - if ft == "QList" || ft == "QString" { // These types are reprojected + if cabiPreventStructDeclaration(ft) { continue } @@ -559,7 +616,7 @@ extern "C" { ret.WriteString("#else\n") for _, ft := range foundTypesList { - if ft == "QList" || ft == "QString" { // These types are reprojected + if cabiPreventStructDeclaration(ft) { continue } ret.WriteString(`typedef struct ` + cabiClassName(ft) + " " + cabiClassName(ft) + ";\n") diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index 17ada269..7cc8c8cc 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -39,6 +39,10 @@ func (p CppParameter) RenderTypeGo(gfs *goFileState) string { return "map[" + t.RenderTypeGo(gfs) + "]struct{}" } + if t1, t2, ok := p.QMapOf(); ok { + return "map[" + t1.RenderTypeGo(gfs) + "]" + t2.RenderTypeGo(gfs) + } + if p.ParameterType == "void" && p.Pointer { return "unsafe.Pointer" } @@ -154,11 +158,15 @@ func (p CppParameter) parameterTypeCgo() string { } if _, ok := p.QListOf(); ok { - return "*C.struct_miqt_array" + return "C.struct_miqt_array" } if _, ok := p.QSetOf(); ok { - return "*C.struct_miqt_array" + return "C.struct_miqt_array" + } + + if _, _, ok := p.QMapOf(); ok { + return "C.struct_miqt_map" } tmp := strings.Replace(p.RenderTypeCabi(), `*`, "", -1) @@ -182,6 +190,15 @@ func (p CppParameter) parameterTypeCgo() string { } } +func (p CppParameter) mallocSizeCgoExpression() string { + if p.ParameterType == "QString" || p.ParameterType == "QByteArray" { + return "int(unsafe.Sizeof(C.struct_miqt_string{}))" + } + + // Default (sizeof pointer) + return "8" +} + func (gfs *goFileState) emitParametersGo(params []CppParameter) string { tmp := make([]string, 0, len(params)) @@ -289,18 +306,9 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble // Go: convert T[] -> t* and len // CABI: create a real QList<> - gfs.imports["runtime"] = struct{}{} gfs.imports["unsafe"] = struct{}{} - var mallocSize string - if listType.ParameterType == "QString" || listType.ParameterType == "QByteArray" { - preamble += "// For the C ABI, malloc a C array of structs\n" - mallocSize = "int(unsafe.Sizeof(C.struct_miqt_string{}))" - - } else { - preamble += "// For the C ABI, malloc a C array of raw pointers\n" - mallocSize = "8" - } + mallocSize := listType.mallocSizeCgoExpression() preamble += nameprefix + "_CArray := (*[0xffff]" + listType.parameterTypeCgo() + ")(C.malloc(C.size_t(" + mallocSize + " * len(" + p.ParameterName + "))))\n" preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_CArray))\n" @@ -313,14 +321,46 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble preamble += nameprefix + "_CArray[i] = " + innerRvalue + "\n" preamble += "}\n" - preamble += p.ParameterName + "_ma := &C.struct_miqt_array{len: C.size_t(len(" + p.ParameterName + ")), data: unsafe.Pointer(" + nameprefix + "_CArray)}\n" - preamble += "defer runtime.KeepAlive(unsafe.Pointer(" + nameprefix + "_ma))\n" + preamble += p.ParameterName + "_ma := C.struct_miqt_array{len: C.size_t(len(" + p.ParameterName + ")), data: unsafe.Pointer(" + nameprefix + "_CArray)}\n" rvalue = p.ParameterName + "_ma" } else if _, ok := p.QSetOf(); ok { panic("QSet<> arguments are not yet implemented") // n.b. doesn't seem to exist in QtCore/QtGui/QtWidgets at all + } else if kType, vType, ok := p.QMapOf(); ok { + // QMap + + gfs.imports["unsafe"] = struct{}{} + + preamble += nameprefix + "_Keys_CArray := (*[0xffff]" + kType.parameterTypeCgo() + ")(C.malloc(C.size_t(" + kType.mallocSizeCgoExpression() + " * len(" + p.ParameterName + "))))\n" + preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_Keys_CArray))\n" + + preamble += nameprefix + "_Values_CArray := (*[0xffff]" + vType.parameterTypeCgo() + ")(C.malloc(C.size_t(" + vType.mallocSizeCgoExpression() + " * len(" + p.ParameterName + "))))\n" + preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_Values_CArray))\n" + + preamble += nameprefix + "_ctr := 0\n" + + preamble += "for " + nameprefix + "_k, " + nameprefix + "_v := range " + p.ParameterName + "{\n" + + kType.ParameterName = nameprefix + "_k" + addPreamble, innerRvalue := gfs.emitParameterGo2CABIForwarding(kType) + preamble += addPreamble + preamble += nameprefix + "_Keys_CArray[" + nameprefix + "_ctr] = " + innerRvalue + "\n" + + vType.ParameterName = nameprefix + "_v" + addPreamble, innerRvalue = gfs.emitParameterGo2CABIForwarding(vType) + preamble += addPreamble + preamble += nameprefix + "_Values_CArray[" + nameprefix + "_ctr] = " + innerRvalue + "\n" + + preamble += nameprefix + "_ctr++\n" + + preamble += "}\n" + + preamble += p.ParameterName + "_mm := C.struct_miqt_map{\nlen: C.size_t(len(" + p.ParameterName + ")),\nkeys: unsafe.Pointer(" + nameprefix + "_Keys_CArray),\nvalues: unsafe.Pointer(" + nameprefix + "_Values_CArray),\n}\n" + + rvalue = p.ParameterName + "_mm" + } else if p.Pointer && p.ParameterType == "char" { // Single char* argument gfs.imports["unsafe"] = struct{}{} @@ -412,7 +452,7 @@ func (gfs *goFileState) emitCabiToGo(assignExpr string, rt CppParameter, rvalue } else if t, ok := rt.QListOf(); ok { gfs.imports["unsafe"] = struct{}{} - shouldReturn = "var " + namePrefix + "_ma *C.struct_miqt_array = " + shouldReturn = "var " + namePrefix + "_ma C.struct_miqt_array = " afterword += namePrefix + "_ret := make([]" + t.RenderTypeGo(gfs) + ", int(" + namePrefix + "_ma.len))\n" afterword += namePrefix + "_outCast := (*[0xffff]" + t.parameterTypeCgo() + ")(unsafe.Pointer(" + namePrefix + "_ma.data)) // hey ya\n" @@ -421,7 +461,7 @@ func (gfs *goFileState) emitCabiToGo(assignExpr string, rt CppParameter, rvalue afterword += gfs.emitCabiToGo(namePrefix+"_ret[i] = ", t, namePrefix+"_outCast[i]") afterword += "}\n" - afterword += "C.free(unsafe.Pointer(" + namePrefix + "_ma))\n" + afterword += assignExpr + " " + namePrefix + "_ret\n" return shouldReturn + " " + rvalue + "\n" + afterword @@ -429,7 +469,7 @@ func (gfs *goFileState) emitCabiToGo(assignExpr string, rt CppParameter, rvalue gfs.imports["unsafe"] = struct{}{} - shouldReturn = "var " + namePrefix + "_ma *C.struct_miqt_array = " + shouldReturn = "var " + namePrefix + "_ma C.struct_miqt_array = " afterword += namePrefix + "_ret := make(map[" + t.RenderTypeGo(gfs) + "]struct{}, int(" + namePrefix + "_ma.len))\n" afterword += namePrefix + "_outCast := (*[0xffff]" + t.parameterTypeCgo() + ")(unsafe.Pointer(" + namePrefix + "_ma.data)) // hey ya\n" @@ -439,7 +479,24 @@ func (gfs *goFileState) emitCabiToGo(assignExpr string, rt CppParameter, rvalue afterword += namePrefix + "_ret[" + namePrefix + "_element] = struct{}{}\n" afterword += "}\n" - afterword += "C.free(unsafe.Pointer(" + namePrefix + "_ma))\n" + afterword += assignExpr + " " + namePrefix + "_ret\n" + return shouldReturn + " " + rvalue + "\n" + afterword + + } else if kType, vType, ok := rt.QMapOf(); ok { + gfs.imports["unsafe"] = struct{}{} + + shouldReturn = "var " + namePrefix + "_mm C.struct_miqt_map = " + + afterword += namePrefix + "_ret := make(map[" + kType.RenderTypeGo(gfs) + "]" + vType.RenderTypeGo(gfs) + ", int(" + namePrefix + "_mm.len))\n" + afterword += namePrefix + "_Keys := (*[0xffff]" + kType.parameterTypeCgo() + ")(unsafe.Pointer(" + namePrefix + "_mm.keys))\n" + afterword += namePrefix + "_Values := (*[0xffff]" + vType.parameterTypeCgo() + ")(unsafe.Pointer(" + namePrefix + "_mm.values))\n" + afterword += "for i := 0; i < int(" + namePrefix + "_mm.len); i++ {\n" + + afterword += gfs.emitCabiToGo(namePrefix+"_entry_Key := ", kType, namePrefix+"_Keys[i]") + "\n" + afterword += gfs.emitCabiToGo(namePrefix+"_entry_Value := ", vType, namePrefix+"_Values[i]") + "\n" + afterword += namePrefix + "_ret[" + namePrefix + "_entry_Key] = " + namePrefix + "_entry_Value\n" + + afterword += "}\n" afterword += assignExpr + " " + namePrefix + "_ret\n" return shouldReturn + " " + rvalue + "\n" + afterword diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index 62ddc725..9b65782e 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -105,6 +105,9 @@ func (p CppParameter) IsFlagType() bool { func (p CppParameter) QtClassType() bool { + // QtClassType returns false for our customized container types (QList, + // QMap, QSet, etc) + // Maybe if it's an inner class if _, ok := KnownClassnames[p.ParameterType]; ok { return true @@ -142,9 +145,36 @@ func (p CppParameter) QListOf() (CppParameter, bool) { return CppParameter{}, false } -func (p CppParameter) QMapOf() bool { - return strings.HasPrefix(p.ParameterType, `QMap<`) || - strings.HasPrefix(p.ParameterType, `QHash<`) // TODO support this +func (p CppParameter) QMapOf() (CppParameter, CppParameter, bool) { + // n.b. Need to block QMap::const_terator + + if strings.HasPrefix(p.ParameterType, `QMap<`) && strings.HasSuffix(p.ParameterType, `>`) { + interior := tokenizeMultipleParameters(p.ParameterType[5 : len(p.ParameterType)-1]) + if len(interior) != 2 { + panic("QMap<> has unexpected number of template arguments") + } + + first := parseSingleTypeString(interior[0]) + first.ParameterName = p.ParameterName + "_mapkey" + second := parseSingleTypeString(interior[1]) + second.ParameterName = p.ParameterName + "_mapval" + return first, second, true + } + + if strings.HasPrefix(p.ParameterType, `QHash<`) && strings.HasSuffix(p.ParameterType, `>`) { + interior := tokenizeMultipleParameters(p.ParameterType[6 : len(p.ParameterType)-1]) + if len(interior) != 2 { + panic("QHash<> has unexpected number of template arguments") + } + + first := parseSingleTypeString(interior[0]) + first.ParameterName = p.ParameterName + "_hashkey" + second := parseSingleTypeString(interior[1]) + second.ParameterName = p.ParameterName + "_hashval" + return first, second, true + } + + return CppParameter{}, CppParameter{}, false } func (p CppParameter) QPairOf() bool { diff --git a/examples/marshalling/marshalling_test.go b/examples/marshalling/marshalling_test.go index bc105433..15d5d8d0 100644 --- a/examples/marshalling/marshalling_test.go +++ b/examples/marshalling/marshalling_test.go @@ -3,6 +3,7 @@ package main import ( "os" "reflect" + "strings" "testing" "github.com/mappu/miqt/qt" @@ -91,9 +92,9 @@ func testMarshalling(t *testing.T) { t.Errorf("QList: expected %#v, got %#v", expect, got) } } - }) + // QByteArray t.Run("QByteArray", func(t *testing.T) { input := "foo bar baz" @@ -103,8 +104,36 @@ func testMarshalling(t *testing.T) { if input != got { t.Fatalf("QByteArray: expected %q, got %q", input, got) } - }) + + // QMap + t.Run("QMap", func(t *testing.T) { + input := make(map[string]qt.QVariant) + input["foo"] = *qt.NewQVariant14("FOO") + input["bar"] = *qt.NewQVariant14("BAR") + input["baz"] = *qt.NewQVariant14("BAZ") + + qtobj := qt.QJsonObject_FromVariantMap(input) + got := qtobj.ToVariantMap() + + if len(got) != len(input) { + t.Fatalf("QMap: expected len %d, got len %d", len(input), len(got)) + } + + for src_key, _ := range input { + qvalue, ok := got[src_key] + if !ok { + t.Fatalf("QMap: missing entry %q", src_key) + } + + gotValue := qvalue.ToString() + expectValue := strings.ToUpper(src_key) + if gotValue != expectValue { + t.Fatalf("QMap: single value expected %q, got %q", expectValue, gotValue) + } + } + }) + } func TestMarshalling(t *testing.T) { diff --git a/libmiqt/libmiqt.h b/libmiqt/libmiqt.h index 4ffc6528..8b6ddbc1 100644 --- a/libmiqt/libmiqt.h +++ b/libmiqt/libmiqt.h @@ -18,6 +18,12 @@ struct miqt_array { void* data; }; +struct miqt_map { + size_t len; + void* keys; + void* values; +}; + struct miqt_string* miqt_strdup(const char* src, size_t len); typedef const char const_char; diff --git a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.cpp b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.cpp index 34e27ef6..1b844ab6 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.cpp +++ b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.cpp @@ -41,18 +41,18 @@ QsciLexer* QsciAbstractAPIs_Lexer(const QsciAbstractAPIs* self) { return self->lexer(); } -void QsciAbstractAPIs_UpdateAutoCompletionList(QsciAbstractAPIs* self, struct miqt_array* /* of struct miqt_string */ context, struct miqt_array* /* of struct miqt_string */ list) { +void QsciAbstractAPIs_UpdateAutoCompletionList(QsciAbstractAPIs* self, struct miqt_array /* of struct miqt_string */ context, struct miqt_array /* of struct miqt_string */ list) { QStringList context_QList; - context_QList.reserve(context->len); - struct miqt_string* context_arr = static_cast(context->data); - for(size_t i = 0; i < context->len; ++i) { + context_QList.reserve(context.len); + struct miqt_string* context_arr = static_cast(context.data); + for(size_t i = 0; i < context.len; ++i) { QString context_arr_i_QString = QString::fromUtf8(context_arr[i].data, context_arr[i].len); context_QList.push_back(context_arr_i_QString); } QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } @@ -64,18 +64,18 @@ void QsciAbstractAPIs_AutoCompletionSelected(QsciAbstractAPIs* self, struct miqt self->autoCompletionSelected(selection_QString); } -struct miqt_array* QsciAbstractAPIs_CallTips(QsciAbstractAPIs* self, struct miqt_array* /* of struct miqt_string */ context, int commas, int style, struct miqt_array* /* of int */ shifts) { +struct miqt_array QsciAbstractAPIs_CallTips(QsciAbstractAPIs* self, struct miqt_array /* of struct miqt_string */ context, int commas, int style, struct miqt_array /* of int */ shifts) { QStringList context_QList; - context_QList.reserve(context->len); - struct miqt_string* context_arr = static_cast(context->data); - for(size_t i = 0; i < context->len; ++i) { + context_QList.reserve(context.len); + struct miqt_string* context_arr = static_cast(context.data); + for(size_t i = 0; i < context.len; ++i) { QString context_arr_i_QString = QString::fromUtf8(context_arr[i].data, context_arr[i].len); context_QList.push_back(context_arr_i_QString); } QList shifts_QList; - shifts_QList.reserve(shifts->len); - int* shifts_arr = static_cast(shifts->data); - for(size_t i = 0; i < shifts->len; ++i) { + shifts_QList.reserve(shifts.len); + int* shifts_arr = static_cast(shifts.data); + for(size_t i = 0; i < shifts.len; ++i) { shifts_QList.push_back(static_cast(shifts_arr[i])); } QStringList _ret = self->callTips(context_QList, static_cast(commas), static_cast(style), shifts_QList); @@ -91,9 +91,9 @@ struct miqt_array* QsciAbstractAPIs_CallTips(QsciAbstractAPIs* self, struct miqt memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.go b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.go index c47db279..f2ad3e88 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.go +++ b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.go @@ -77,7 +77,6 @@ func (this *QsciAbstractAPIs) Lexer() *QsciLexer { } func (this *QsciAbstractAPIs) UpdateAutoCompletionList(context []string, list []string) { - // For the C ABI, malloc a C array of structs context_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(context)))) defer C.free(unsafe.Pointer(context_CArray)) for i := range context { @@ -87,9 +86,7 @@ func (this *QsciAbstractAPIs) UpdateAutoCompletionList(context []string, list [] defer C.free(unsafe.Pointer(context_i_ms.data)) context_CArray[i] = context_i_ms } - context_ma := &C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(context_ma)) - // For the C ABI, malloc a C array of structs + context_ma := C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -99,8 +96,7 @@ func (this *QsciAbstractAPIs) UpdateAutoCompletionList(context []string, list [] defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QsciAbstractAPIs_UpdateAutoCompletionList(this.h, context_ma, list_ma) } @@ -113,7 +109,6 @@ func (this *QsciAbstractAPIs) AutoCompletionSelected(selection string) { } func (this *QsciAbstractAPIs) CallTips(context []string, commas int, style QsciScintilla__CallTipsStyle, shifts []int) []string { - // For the C ABI, malloc a C array of structs context_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(context)))) defer C.free(unsafe.Pointer(context_CArray)) for i := range context { @@ -123,17 +118,14 @@ func (this *QsciAbstractAPIs) CallTips(context []string, commas int, style QsciS defer C.free(unsafe.Pointer(context_i_ms.data)) context_CArray[i] = context_i_ms } - context_ma := &C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(context_ma)) - // For the C ABI, malloc a C array of raw pointers + context_ma := C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} shifts_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(shifts)))) defer C.free(unsafe.Pointer(shifts_CArray)) for i := range shifts { shifts_CArray[i] = (C.int)(shifts[i]) } - shifts_ma := &C.struct_miqt_array{len: C.size_t(len(shifts)), data: unsafe.Pointer(shifts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(shifts_ma)) - var _ma *C.struct_miqt_array = C.QsciAbstractAPIs_CallTips(this.h, context_ma, (C.int)(commas), (C.int)(style), shifts_ma) + shifts_ma := C.struct_miqt_array{len: C.size_t(len(shifts)), data: unsafe.Pointer(shifts_CArray)} + var _ma C.struct_miqt_array = C.QsciAbstractAPIs_CallTips(this.h, context_ma, (C.int)(commas), (C.int)(style), shifts_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -142,7 +134,6 @@ func (this *QsciAbstractAPIs) CallTips(context []string, commas int, style QsciS C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.h b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.h index 5974111f..a63e587d 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciabstractapis.h +++ b/qt-restricted-extras/qscintilla/gen_qsciabstractapis.h @@ -28,9 +28,9 @@ void* QsciAbstractAPIs_Metacast(QsciAbstractAPIs* self, const char* param1); struct miqt_string QsciAbstractAPIs_Tr(const char* s); struct miqt_string QsciAbstractAPIs_TrUtf8(const char* s); QsciLexer* QsciAbstractAPIs_Lexer(const QsciAbstractAPIs* self); -void QsciAbstractAPIs_UpdateAutoCompletionList(QsciAbstractAPIs* self, struct miqt_array* /* of struct miqt_string */ context, struct miqt_array* /* of struct miqt_string */ list); +void QsciAbstractAPIs_UpdateAutoCompletionList(QsciAbstractAPIs* self, struct miqt_array /* of struct miqt_string */ context, struct miqt_array /* of struct miqt_string */ list); void QsciAbstractAPIs_AutoCompletionSelected(QsciAbstractAPIs* self, struct miqt_string selection); -struct miqt_array* QsciAbstractAPIs_CallTips(QsciAbstractAPIs* self, struct miqt_array* /* of struct miqt_string */ context, int commas, int style, struct miqt_array* /* of int */ shifts); +struct miqt_array QsciAbstractAPIs_CallTips(QsciAbstractAPIs* self, struct miqt_array /* of struct miqt_string */ context, int commas, int style, struct miqt_array /* of int */ shifts); struct miqt_string QsciAbstractAPIs_Tr2(const char* s, const char* c); struct miqt_string QsciAbstractAPIs_Tr3(const char* s, const char* c, int n); struct miqt_string QsciAbstractAPIs_TrUtf82(const char* s, const char* c); diff --git a/qt-restricted-extras/qscintilla/gen_qsciapis.cpp b/qt-restricted-extras/qscintilla/gen_qsciapis.cpp index 06e66693..e26108e6 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciapis.cpp +++ b/qt-restricted-extras/qscintilla/gen_qsciapis.cpp @@ -92,18 +92,18 @@ bool QsciAPIs_SavePrepared(const QsciAPIs* self) { return self->savePrepared(); } -void QsciAPIs_UpdateAutoCompletionList(QsciAPIs* self, struct miqt_array* /* of struct miqt_string */ context, struct miqt_array* /* of struct miqt_string */ list) { +void QsciAPIs_UpdateAutoCompletionList(QsciAPIs* self, struct miqt_array /* of struct miqt_string */ context, struct miqt_array /* of struct miqt_string */ list) { QStringList context_QList; - context_QList.reserve(context->len); - struct miqt_string* context_arr = static_cast(context->data); - for(size_t i = 0; i < context->len; ++i) { + context_QList.reserve(context.len); + struct miqt_string* context_arr = static_cast(context.data); + for(size_t i = 0; i < context.len; ++i) { QString context_arr_i_QString = QString::fromUtf8(context_arr[i].data, context_arr[i].len); context_QList.push_back(context_arr_i_QString); } QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } @@ -115,18 +115,18 @@ void QsciAPIs_AutoCompletionSelected(QsciAPIs* self, struct miqt_string sel) { self->autoCompletionSelected(sel_QString); } -struct miqt_array* QsciAPIs_CallTips(QsciAPIs* self, struct miqt_array* /* of struct miqt_string */ context, int commas, int style, struct miqt_array* /* of int */ shifts) { +struct miqt_array QsciAPIs_CallTips(QsciAPIs* self, struct miqt_array /* of struct miqt_string */ context, int commas, int style, struct miqt_array /* of int */ shifts) { QStringList context_QList; - context_QList.reserve(context->len); - struct miqt_string* context_arr = static_cast(context->data); - for(size_t i = 0; i < context->len; ++i) { + context_QList.reserve(context.len); + struct miqt_string* context_arr = static_cast(context.data); + for(size_t i = 0; i < context.len; ++i) { QString context_arr_i_QString = QString::fromUtf8(context_arr[i].data, context_arr[i].len); context_QList.push_back(context_arr_i_QString); } QList shifts_QList; - shifts_QList.reserve(shifts->len); - int* shifts_arr = static_cast(shifts->data); - for(size_t i = 0; i < shifts->len; ++i) { + shifts_QList.reserve(shifts.len); + int* shifts_arr = static_cast(shifts.data); + for(size_t i = 0; i < shifts.len; ++i) { shifts_QList.push_back(static_cast(shifts_arr[i])); } QStringList _ret = self->callTips(context_QList, static_cast(commas), static_cast(style), shifts_QList); @@ -142,9 +142,9 @@ struct miqt_array* QsciAPIs_CallTips(QsciAPIs* self, struct miqt_array* /* of st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -152,7 +152,7 @@ bool QsciAPIs_Event(QsciAPIs* self, QEvent* e) { return self->event(e); } -struct miqt_array* QsciAPIs_InstalledAPIFiles(const QsciAPIs* self) { +struct miqt_array QsciAPIs_InstalledAPIFiles(const QsciAPIs* self) { QStringList _ret = self->installedAPIFiles(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -166,9 +166,9 @@ struct miqt_array* QsciAPIs_InstalledAPIFiles(const QsciAPIs* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qsciapis.go b/qt-restricted-extras/qscintilla/gen_qsciapis.go index 5019e893..d8c4eb98 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciapis.go +++ b/qt-restricted-extras/qscintilla/gen_qsciapis.go @@ -135,7 +135,6 @@ func (this *QsciAPIs) SavePrepared() bool { } func (this *QsciAPIs) UpdateAutoCompletionList(context []string, list []string) { - // For the C ABI, malloc a C array of structs context_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(context)))) defer C.free(unsafe.Pointer(context_CArray)) for i := range context { @@ -145,9 +144,7 @@ func (this *QsciAPIs) UpdateAutoCompletionList(context []string, list []string) defer C.free(unsafe.Pointer(context_i_ms.data)) context_CArray[i] = context_i_ms } - context_ma := &C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(context_ma)) - // For the C ABI, malloc a C array of structs + context_ma := C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -157,8 +154,7 @@ func (this *QsciAPIs) UpdateAutoCompletionList(context []string, list []string) defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QsciAPIs_UpdateAutoCompletionList(this.h, context_ma, list_ma) } @@ -171,7 +167,6 @@ func (this *QsciAPIs) AutoCompletionSelected(sel string) { } func (this *QsciAPIs) CallTips(context []string, commas int, style QsciScintilla__CallTipsStyle, shifts []int) []string { - // For the C ABI, malloc a C array of structs context_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(context)))) defer C.free(unsafe.Pointer(context_CArray)) for i := range context { @@ -181,17 +176,14 @@ func (this *QsciAPIs) CallTips(context []string, commas int, style QsciScintilla defer C.free(unsafe.Pointer(context_i_ms.data)) context_CArray[i] = context_i_ms } - context_ma := &C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(context_ma)) - // For the C ABI, malloc a C array of raw pointers + context_ma := C.struct_miqt_array{len: C.size_t(len(context)), data: unsafe.Pointer(context_CArray)} shifts_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(shifts)))) defer C.free(unsafe.Pointer(shifts_CArray)) for i := range shifts { shifts_CArray[i] = (C.int)(shifts[i]) } - shifts_ma := &C.struct_miqt_array{len: C.size_t(len(shifts)), data: unsafe.Pointer(shifts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(shifts_ma)) - var _ma *C.struct_miqt_array = C.QsciAPIs_CallTips(this.h, context_ma, (C.int)(commas), (C.int)(style), shifts_ma) + shifts_ma := C.struct_miqt_array{len: C.size_t(len(shifts)), data: unsafe.Pointer(shifts_CArray)} + var _ma C.struct_miqt_array = C.QsciAPIs_CallTips(this.h, context_ma, (C.int)(commas), (C.int)(style), shifts_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -200,7 +192,6 @@ func (this *QsciAPIs) CallTips(context []string, commas int, style QsciScintilla C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -209,7 +200,7 @@ func (this *QsciAPIs) Event(e *qt.QEvent) bool { } func (this *QsciAPIs) InstalledAPIFiles() []string { - var _ma *C.struct_miqt_array = C.QsciAPIs_InstalledAPIFiles(this.h) + var _ma C.struct_miqt_array = C.QsciAPIs_InstalledAPIFiles(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -218,7 +209,6 @@ func (this *QsciAPIs) InstalledAPIFiles() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qsciapis.h b/qt-restricted-extras/qscintilla/gen_qsciapis.h index 58b048ce..298896f9 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciapis.h +++ b/qt-restricted-extras/qscintilla/gen_qsciapis.h @@ -40,11 +40,11 @@ struct miqt_string QsciAPIs_DefaultPreparedName(const QsciAPIs* self); bool QsciAPIs_IsPrepared(const QsciAPIs* self); bool QsciAPIs_LoadPrepared(QsciAPIs* self); bool QsciAPIs_SavePrepared(const QsciAPIs* self); -void QsciAPIs_UpdateAutoCompletionList(QsciAPIs* self, struct miqt_array* /* of struct miqt_string */ context, struct miqt_array* /* of struct miqt_string */ list); +void QsciAPIs_UpdateAutoCompletionList(QsciAPIs* self, struct miqt_array /* of struct miqt_string */ context, struct miqt_array /* of struct miqt_string */ list); void QsciAPIs_AutoCompletionSelected(QsciAPIs* self, struct miqt_string sel); -struct miqt_array* QsciAPIs_CallTips(QsciAPIs* self, struct miqt_array* /* of struct miqt_string */ context, int commas, int style, struct miqt_array* /* of int */ shifts); +struct miqt_array QsciAPIs_CallTips(QsciAPIs* self, struct miqt_array /* of struct miqt_string */ context, int commas, int style, struct miqt_array /* of int */ shifts); bool QsciAPIs_Event(QsciAPIs* self, QEvent* e); -struct miqt_array* QsciAPIs_InstalledAPIFiles(const QsciAPIs* self); +struct miqt_array QsciAPIs_InstalledAPIFiles(const QsciAPIs* self); void QsciAPIs_ApiPreparationCancelled(QsciAPIs* self); void QsciAPIs_connect_ApiPreparationCancelled(QsciAPIs* self, intptr_t slot); void QsciAPIs_ApiPreparationStarted(QsciAPIs* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscicommandset.cpp b/qt-restricted-extras/qscintilla/gen_qscicommandset.cpp index 6a0821ee..31d4dd00 100644 --- a/qt-restricted-extras/qscintilla/gen_qscicommandset.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscicommandset.cpp @@ -12,16 +12,16 @@ bool QsciCommandSet_WriteSettings(QsciCommandSet* self, QSettings* qs) { return self->writeSettings(*qs); } -struct miqt_array* QsciCommandSet_Commands(QsciCommandSet* self) { +struct miqt_array QsciCommandSet_Commands(QsciCommandSet* self) { QList& _ret = self->commands(); // Convert QList<> from C++ memory to manually-managed C memory QsciCommand** _arr = static_cast(malloc(sizeof(QsciCommand*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscicommandset.go b/qt-restricted-extras/qscintilla/gen_qscicommandset.go index f295db55..3b5d6154 100644 --- a/qt-restricted-extras/qscintilla/gen_qscicommandset.go +++ b/qt-restricted-extras/qscintilla/gen_qscicommandset.go @@ -51,13 +51,12 @@ func (this *QsciCommandSet) WriteSettings(qs *qt.QSettings) bool { } func (this *QsciCommandSet) Commands() []*QsciCommand { - var _ma *C.struct_miqt_array = C.QsciCommandSet_Commands(this.h) + var _ma C.struct_miqt_array = C.QsciCommandSet_Commands(this.h) _ret := make([]*QsciCommand, int(_ma.len)) _outCast := (*[0xffff]*C.QsciCommand)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQsciCommand(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscicommandset.h b/qt-restricted-extras/qscintilla/gen_qscicommandset.h index 44047215..a6b1751f 100644 --- a/qt-restricted-extras/qscintilla/gen_qscicommandset.h +++ b/qt-restricted-extras/qscintilla/gen_qscicommandset.h @@ -25,7 +25,7 @@ typedef struct QsciCommandSet QsciCommandSet; bool QsciCommandSet_ReadSettings(QsciCommandSet* self, QSettings* qs); bool QsciCommandSet_WriteSettings(QsciCommandSet* self, QSettings* qs); -struct miqt_array* QsciCommandSet_Commands(QsciCommandSet* self); +struct miqt_array QsciCommandSet_Commands(QsciCommandSet* self); void QsciCommandSet_ClearKeys(QsciCommandSet* self); void QsciCommandSet_ClearAlternateKeys(QsciCommandSet* self); QsciCommand* QsciCommandSet_BoundTo(const QsciCommandSet* self, int key); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexer.cpp b/qt-restricted-extras/qscintilla/gen_qscilexer.cpp index 1566aed1..f0c24b40 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexer.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexer.cpp @@ -60,7 +60,7 @@ const char* QsciLexer_AutoCompletionFillups(const QsciLexer* self) { return (const char*) self->autoCompletionFillups(); } -struct miqt_array* QsciLexer_AutoCompletionWordSeparators(const QsciLexer* self) { +struct miqt_array QsciLexer_AutoCompletionWordSeparators(const QsciLexer* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -74,9 +74,9 @@ struct miqt_array* QsciLexer_AutoCompletionWordSeparators(const QsciLexer* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexer.go b/qt-restricted-extras/qscintilla/gen_qscilexer.go index 97ec6079..131d6524 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexer.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexer.go @@ -97,7 +97,7 @@ func (this *QsciLexer) AutoCompletionFillups() string { } func (this *QsciLexer) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexer_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexer_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -106,7 +106,6 @@ func (this *QsciLexer) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexer.h b/qt-restricted-extras/qscintilla/gen_qscilexer.h index ef8c3861..d8ab0098 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexer.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexer.h @@ -40,7 +40,7 @@ const char* QsciLexer_Lexer(const QsciLexer* self); int QsciLexer_LexerId(const QsciLexer* self); QsciAbstractAPIs* QsciLexer_Apis(const QsciLexer* self); const char* QsciLexer_AutoCompletionFillups(const QsciLexer* self); -struct miqt_array* QsciLexer_AutoCompletionWordSeparators(const QsciLexer* self); +struct miqt_array QsciLexer_AutoCompletionWordSeparators(const QsciLexer* self); int QsciLexer_AutoIndentStyle(QsciLexer* self); const char* QsciLexer_BlockEnd(const QsciLexer* self); int QsciLexer_BlockLookback(const QsciLexer* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.cpp b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.cpp index b13bd19b..663624f2 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.cpp @@ -56,7 +56,7 @@ const char* QsciLexerCoffeeScript_Lexer(const QsciLexerCoffeeScript* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerCoffeeScript_AutoCompletionWordSeparators(const QsciLexerCoffeeScript* self) { +struct miqt_array QsciLexerCoffeeScript_AutoCompletionWordSeparators(const QsciLexerCoffeeScript* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerCoffeeScript_AutoCompletionWordSeparators(const Qsci memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.go b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.go index 722b5eec..a9997d06 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.go @@ -124,7 +124,7 @@ func (this *QsciLexerCoffeeScript) Lexer() string { } func (this *QsciLexerCoffeeScript) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerCoffeeScript_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerCoffeeScript_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -133,7 +133,6 @@ func (this *QsciLexerCoffeeScript) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.h b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.h index 275b026c..d50603e8 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexercoffeescript.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerCoffeeScript_Tr(const char* s); struct miqt_string QsciLexerCoffeeScript_TrUtf8(const char* s); const char* QsciLexerCoffeeScript_Language(const QsciLexerCoffeeScript* self); const char* QsciLexerCoffeeScript_Lexer(const QsciLexerCoffeeScript* self); -struct miqt_array* QsciLexerCoffeeScript_AutoCompletionWordSeparators(const QsciLexerCoffeeScript* self); +struct miqt_array QsciLexerCoffeeScript_AutoCompletionWordSeparators(const QsciLexerCoffeeScript* self); const char* QsciLexerCoffeeScript_BlockEnd(const QsciLexerCoffeeScript* self); const char* QsciLexerCoffeeScript_BlockStart(const QsciLexerCoffeeScript* self); const char* QsciLexerCoffeeScript_BlockStartKeyword(const QsciLexerCoffeeScript* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercpp.cpp b/qt-restricted-extras/qscintilla/gen_qscilexercpp.cpp index f6b3c8d6..992a972d 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercpp.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexercpp.cpp @@ -60,7 +60,7 @@ const char* QsciLexerCPP_Lexer(const QsciLexerCPP* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerCPP_AutoCompletionWordSeparators(const QsciLexerCPP* self) { +struct miqt_array QsciLexerCPP_AutoCompletionWordSeparators(const QsciLexerCPP* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -74,9 +74,9 @@ struct miqt_array* QsciLexerCPP_AutoCompletionWordSeparators(const QsciLexerCPP* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercpp.go b/qt-restricted-extras/qscintilla/gen_qscilexercpp.go index 8fc8d3ff..52f8c973 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercpp.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexercpp.go @@ -162,7 +162,7 @@ func (this *QsciLexerCPP) Lexer() string { } func (this *QsciLexerCPP) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerCPP_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerCPP_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -171,7 +171,6 @@ func (this *QsciLexerCPP) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexercpp.h b/qt-restricted-extras/qscintilla/gen_qscilexercpp.h index 54cbd3ea..5af72560 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexercpp.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexercpp.h @@ -36,7 +36,7 @@ struct miqt_string QsciLexerCPP_Tr(const char* s); struct miqt_string QsciLexerCPP_TrUtf8(const char* s); const char* QsciLexerCPP_Language(const QsciLexerCPP* self); const char* QsciLexerCPP_Lexer(const QsciLexerCPP* self); -struct miqt_array* QsciLexerCPP_AutoCompletionWordSeparators(const QsciLexerCPP* self); +struct miqt_array QsciLexerCPP_AutoCompletionWordSeparators(const QsciLexerCPP* self); const char* QsciLexerCPP_BlockEnd(const QsciLexerCPP* self); const char* QsciLexerCPP_BlockStart(const QsciLexerCPP* self); const char* QsciLexerCPP_BlockStartKeyword(const QsciLexerCPP* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerd.cpp b/qt-restricted-extras/qscintilla/gen_qscilexerd.cpp index 918929bd..c6732b9f 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerd.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexerd.cpp @@ -56,7 +56,7 @@ const char* QsciLexerD_Lexer(const QsciLexerD* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerD_AutoCompletionWordSeparators(const QsciLexerD* self) { +struct miqt_array QsciLexerD_AutoCompletionWordSeparators(const QsciLexerD* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerD_AutoCompletionWordSeparators(const QsciLexerD* sel memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerd.go b/qt-restricted-extras/qscintilla/gen_qscilexerd.go index 98366f91..085bfc8d 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerd.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexerd.go @@ -123,7 +123,7 @@ func (this *QsciLexerD) Lexer() string { } func (this *QsciLexerD) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerD_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerD_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -132,7 +132,6 @@ func (this *QsciLexerD) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerd.h b/qt-restricted-extras/qscintilla/gen_qscilexerd.h index b7fb3117..2e94d0dd 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerd.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexerd.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerD_Tr(const char* s); struct miqt_string QsciLexerD_TrUtf8(const char* s); const char* QsciLexerD_Language(const QsciLexerD* self); const char* QsciLexerD_Lexer(const QsciLexerD* self); -struct miqt_array* QsciLexerD_AutoCompletionWordSeparators(const QsciLexerD* self); +struct miqt_array QsciLexerD_AutoCompletionWordSeparators(const QsciLexerD* self); const char* QsciLexerD_BlockEnd(const QsciLexerD* self); const char* QsciLexerD_BlockStart(const QsciLexerD* self); const char* QsciLexerD_BlockStartKeyword(const QsciLexerD* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerlua.cpp b/qt-restricted-extras/qscintilla/gen_qscilexerlua.cpp index abd12202..8255e21f 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerlua.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexerlua.cpp @@ -56,7 +56,7 @@ const char* QsciLexerLua_Lexer(const QsciLexerLua* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerLua_AutoCompletionWordSeparators(const QsciLexerLua* self) { +struct miqt_array QsciLexerLua_AutoCompletionWordSeparators(const QsciLexerLua* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerLua_AutoCompletionWordSeparators(const QsciLexerLua* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerlua.go b/qt-restricted-extras/qscintilla/gen_qscilexerlua.go index e7c4e79c..936eb392 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerlua.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexerlua.go @@ -120,7 +120,7 @@ func (this *QsciLexerLua) Lexer() string { } func (this *QsciLexerLua) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerLua_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerLua_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -129,7 +129,6 @@ func (this *QsciLexerLua) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerlua.h b/qt-restricted-extras/qscintilla/gen_qscilexerlua.h index 333eae28..1e6a3b17 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerlua.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexerlua.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerLua_Tr(const char* s); struct miqt_string QsciLexerLua_TrUtf8(const char* s); const char* QsciLexerLua_Language(const QsciLexerLua* self); const char* QsciLexerLua_Lexer(const QsciLexerLua* self); -struct miqt_array* QsciLexerLua_AutoCompletionWordSeparators(const QsciLexerLua* self); +struct miqt_array QsciLexerLua_AutoCompletionWordSeparators(const QsciLexerLua* self); const char* QsciLexerLua_BlockStart(const QsciLexerLua* self); int QsciLexerLua_BraceStyle(const QsciLexerLua* self); QColor* QsciLexerLua_DefaultColor(const QsciLexerLua* self, int style); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.cpp b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.cpp index 809584c8..79e42031 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.cpp @@ -56,7 +56,7 @@ const char* QsciLexerPascal_Lexer(const QsciLexerPascal* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerPascal_AutoCompletionWordSeparators(const QsciLexerPascal* self) { +struct miqt_array QsciLexerPascal_AutoCompletionWordSeparators(const QsciLexerPascal* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerPascal_AutoCompletionWordSeparators(const QsciLexerP memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.go b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.go index 220464e8..9ca72b9e 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.go @@ -115,7 +115,7 @@ func (this *QsciLexerPascal) Lexer() string { } func (this *QsciLexerPascal) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerPascal_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerPascal_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -124,7 +124,6 @@ func (this *QsciLexerPascal) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.h b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.h index 73664757..7fdea44a 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpascal.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpascal.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerPascal_Tr(const char* s); struct miqt_string QsciLexerPascal_TrUtf8(const char* s); const char* QsciLexerPascal_Language(const QsciLexerPascal* self); const char* QsciLexerPascal_Lexer(const QsciLexerPascal* self); -struct miqt_array* QsciLexerPascal_AutoCompletionWordSeparators(const QsciLexerPascal* self); +struct miqt_array QsciLexerPascal_AutoCompletionWordSeparators(const QsciLexerPascal* self); const char* QsciLexerPascal_BlockEnd(const QsciLexerPascal* self); const char* QsciLexerPascal_BlockStart(const QsciLexerPascal* self); const char* QsciLexerPascal_BlockStartKeyword(const QsciLexerPascal* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerperl.cpp b/qt-restricted-extras/qscintilla/gen_qscilexerperl.cpp index b245c980..98665d74 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerperl.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexerperl.cpp @@ -56,7 +56,7 @@ const char* QsciLexerPerl_Lexer(const QsciLexerPerl* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerPerl_AutoCompletionWordSeparators(const QsciLexerPerl* self) { +struct miqt_array QsciLexerPerl_AutoCompletionWordSeparators(const QsciLexerPerl* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerPerl_AutoCompletionWordSeparators(const QsciLexerPer memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerperl.go b/qt-restricted-extras/qscintilla/gen_qscilexerperl.go index e83a0fd2..ba7f8113 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerperl.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexerperl.go @@ -141,7 +141,7 @@ func (this *QsciLexerPerl) Lexer() string { } func (this *QsciLexerPerl) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerPerl_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerPerl_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -150,7 +150,6 @@ func (this *QsciLexerPerl) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerperl.h b/qt-restricted-extras/qscintilla/gen_qscilexerperl.h index 58205cb0..66139c80 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerperl.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexerperl.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerPerl_Tr(const char* s); struct miqt_string QsciLexerPerl_TrUtf8(const char* s); const char* QsciLexerPerl_Language(const QsciLexerPerl* self); const char* QsciLexerPerl_Lexer(const QsciLexerPerl* self); -struct miqt_array* QsciLexerPerl_AutoCompletionWordSeparators(const QsciLexerPerl* self); +struct miqt_array QsciLexerPerl_AutoCompletionWordSeparators(const QsciLexerPerl* self); const char* QsciLexerPerl_BlockEnd(const QsciLexerPerl* self); const char* QsciLexerPerl_BlockStart(const QsciLexerPerl* self); int QsciLexerPerl_BraceStyle(const QsciLexerPerl* self); diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpython.cpp b/qt-restricted-extras/qscintilla/gen_qscilexerpython.cpp index 3a9efa9f..14b29a45 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpython.cpp +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpython.cpp @@ -56,7 +56,7 @@ const char* QsciLexerPython_Lexer(const QsciLexerPython* self) { return (const char*) self->lexer(); } -struct miqt_array* QsciLexerPython_AutoCompletionWordSeparators(const QsciLexerPython* self) { +struct miqt_array QsciLexerPython_AutoCompletionWordSeparators(const QsciLexerPython* self) { QStringList _ret = self->autoCompletionWordSeparators(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,9 +70,9 @@ struct miqt_array* QsciLexerPython_AutoCompletionWordSeparators(const QsciLexerP memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpython.go b/qt-restricted-extras/qscintilla/gen_qscilexerpython.go index 7360a274..6c4b88d0 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpython.go +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpython.go @@ -130,7 +130,7 @@ func (this *QsciLexerPython) Lexer() string { } func (this *QsciLexerPython) AutoCompletionWordSeparators() []string { - var _ma *C.struct_miqt_array = C.QsciLexerPython_AutoCompletionWordSeparators(this.h) + var _ma C.struct_miqt_array = C.QsciLexerPython_AutoCompletionWordSeparators(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -139,7 +139,6 @@ func (this *QsciLexerPython) AutoCompletionWordSeparators() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt-restricted-extras/qscintilla/gen_qscilexerpython.h b/qt-restricted-extras/qscintilla/gen_qscilexerpython.h index e83af3a5..71fd135d 100644 --- a/qt-restricted-extras/qscintilla/gen_qscilexerpython.h +++ b/qt-restricted-extras/qscintilla/gen_qscilexerpython.h @@ -35,7 +35,7 @@ struct miqt_string QsciLexerPython_Tr(const char* s); struct miqt_string QsciLexerPython_TrUtf8(const char* s); const char* QsciLexerPython_Language(const QsciLexerPython* self); const char* QsciLexerPython_Lexer(const QsciLexerPython* self); -struct miqt_array* QsciLexerPython_AutoCompletionWordSeparators(const QsciLexerPython* self); +struct miqt_array QsciLexerPython_AutoCompletionWordSeparators(const QsciLexerPython* self); int QsciLexerPython_BlockLookback(const QsciLexerPython* self); const char* QsciLexerPython_BlockStart(const QsciLexerPython* self); int QsciLexerPython_BraceStyle(const QsciLexerPython* self); diff --git a/qt-restricted-extras/qscintilla/gen_qsciscintilla.cpp b/qt-restricted-extras/qscintilla/gen_qsciscintilla.cpp index 69b94f0c..592afea9 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciscintilla.cpp +++ b/qt-restricted-extras/qscintilla/gen_qsciscintilla.cpp @@ -54,7 +54,7 @@ struct miqt_string QsciScintilla_TrUtf8(const char* s) { return _ms; } -struct miqt_array* QsciScintilla_ApiContext(QsciScintilla* self, int pos, int* context_start, int* last_word_start) { +struct miqt_array QsciScintilla_ApiContext(QsciScintilla* self, int pos, int* context_start, int* last_word_start) { QStringList _ret = self->apiContext(static_cast(pos), static_cast(*context_start), static_cast(*last_word_start)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -68,9 +68,9 @@ struct miqt_array* QsciScintilla_ApiContext(QsciScintilla* self, int pos, int* c memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -206,16 +206,16 @@ QColor* QsciScintilla_Color(const QsciScintilla* self) { return new QColor(self->color()); } -struct miqt_array* QsciScintilla_ContractedFolds(const QsciScintilla* self) { +struct miqt_array QsciScintilla_ContractedFolds(const QsciScintilla* self) { QList _ret = self->contractedFolds(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -542,11 +542,11 @@ void QsciScintilla_SetAutoCompletionFillups(QsciScintilla* self, const char* fil self->setAutoCompletionFillups(fillups); } -void QsciScintilla_SetAutoCompletionWordSeparators(QsciScintilla* self, struct miqt_array* /* of struct miqt_string */ separators) { +void QsciScintilla_SetAutoCompletionWordSeparators(QsciScintilla* self, struct miqt_array /* of struct miqt_string */ separators) { QStringList separators_QList; - separators_QList.reserve(separators->len); - struct miqt_string* separators_arr = static_cast(separators->data); - for(size_t i = 0; i < separators->len; ++i) { + separators_QList.reserve(separators.len); + struct miqt_string* separators_arr = static_cast(separators.data); + for(size_t i = 0; i < separators.len; ++i) { QString separators_arr_i_QString = QString::fromUtf8(separators_arr[i].data, separators_arr[i].len); separators_QList.push_back(separators_arr_i_QString); } @@ -577,11 +577,11 @@ void QsciScintilla_SetCallTipsVisible(QsciScintilla* self, int nr) { self->setCallTipsVisible(static_cast(nr)); } -void QsciScintilla_SetContractedFolds(QsciScintilla* self, struct miqt_array* /* of int */ folds) { +void QsciScintilla_SetContractedFolds(QsciScintilla* self, struct miqt_array /* of int */ folds) { QList folds_QList; - folds_QList.reserve(folds->len); - int* folds_arr = static_cast(folds->data); - for(size_t i = 0; i < folds->len; ++i) { + folds_QList.reserve(folds.len); + int* folds_arr = static_cast(folds.data); + for(size_t i = 0; i < folds.len; ++i) { folds_QList.push_back(static_cast(folds_arr[i])); } self->setContractedFolds(folds_QList); @@ -788,11 +788,11 @@ void QsciScintilla_SetWrapIndentMode(QsciScintilla* self, int mode) { self->setWrapIndentMode(static_cast(mode)); } -void QsciScintilla_ShowUserList(QsciScintilla* self, int id, struct miqt_array* /* of struct miqt_string */ list) { +void QsciScintilla_ShowUserList(QsciScintilla* self, int id, struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } diff --git a/qt-restricted-extras/qscintilla/gen_qsciscintilla.go b/qt-restricted-extras/qscintilla/gen_qsciscintilla.go index ec20e678..73c9b3c7 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciscintilla.go +++ b/qt-restricted-extras/qscintilla/gen_qsciscintilla.go @@ -290,7 +290,7 @@ func QsciScintilla_TrUtf8(s string) string { } func (this *QsciScintilla) ApiContext(pos int, context_start *int, last_word_start *int) []string { - var _ma *C.struct_miqt_array = C.QsciScintilla_ApiContext(this.h, (C.int)(pos), (*C.int)(unsafe.Pointer(context_start)), (*C.int)(unsafe.Pointer(last_word_start))) + var _ma C.struct_miqt_array = C.QsciScintilla_ApiContext(this.h, (C.int)(pos), (*C.int)(unsafe.Pointer(context_start)), (*C.int)(unsafe.Pointer(last_word_start))) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -299,7 +299,6 @@ func (this *QsciScintilla) ApiContext(pos int, context_start *int, last_word_sta C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -433,13 +432,12 @@ func (this *QsciScintilla) Color() *qt.QColor { } func (this *QsciScintilla) ContractedFolds() []int { - var _ma *C.struct_miqt_array = C.QsciScintilla_ContractedFolds(this.h) + var _ma C.struct_miqt_array = C.QsciScintilla_ContractedFolds(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -786,7 +784,6 @@ func (this *QsciScintilla) SetAutoCompletionFillups(fillups string) { } func (this *QsciScintilla) SetAutoCompletionWordSeparators(separators []string) { - // For the C ABI, malloc a C array of structs separators_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(separators)))) defer C.free(unsafe.Pointer(separators_CArray)) for i := range separators { @@ -796,8 +793,7 @@ func (this *QsciScintilla) SetAutoCompletionWordSeparators(separators []string) defer C.free(unsafe.Pointer(separators_i_ms.data)) separators_CArray[i] = separators_i_ms } - separators_ma := &C.struct_miqt_array{len: C.size_t(len(separators)), data: unsafe.Pointer(separators_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(separators_ma)) + separators_ma := C.struct_miqt_array{len: C.size_t(len(separators)), data: unsafe.Pointer(separators_CArray)} C.QsciScintilla_SetAutoCompletionWordSeparators(this.h, separators_ma) } @@ -826,14 +822,12 @@ func (this *QsciScintilla) SetCallTipsVisible(nr int) { } func (this *QsciScintilla) SetContractedFolds(folds []int) { - // For the C ABI, malloc a C array of raw pointers folds_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(folds)))) defer C.free(unsafe.Pointer(folds_CArray)) for i := range folds { folds_CArray[i] = (C.int)(folds[i]) } - folds_ma := &C.struct_miqt_array{len: C.size_t(len(folds)), data: unsafe.Pointer(folds_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(folds_ma)) + folds_ma := C.struct_miqt_array{len: C.size_t(len(folds)), data: unsafe.Pointer(folds_CArray)} C.QsciScintilla_SetContractedFolds(this.h, folds_ma) } @@ -1041,7 +1035,6 @@ func (this *QsciScintilla) SetWrapIndentMode(mode QsciScintilla__WrapIndentMode) } func (this *QsciScintilla) ShowUserList(id int, list []string) { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -1051,8 +1044,7 @@ func (this *QsciScintilla) ShowUserList(id int, list []string) { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QsciScintilla_ShowUserList(this.h, (C.int)(id), list_ma) } diff --git a/qt-restricted-extras/qscintilla/gen_qsciscintilla.h b/qt-restricted-extras/qscintilla/gen_qsciscintilla.h index 91c81add..124e2932 100644 --- a/qt-restricted-extras/qscintilla/gen_qsciscintilla.h +++ b/qt-restricted-extras/qscintilla/gen_qsciscintilla.h @@ -55,7 +55,7 @@ QMetaObject* QsciScintilla_MetaObject(const QsciScintilla* self); void* QsciScintilla_Metacast(QsciScintilla* self, const char* param1); struct miqt_string QsciScintilla_Tr(const char* s); struct miqt_string QsciScintilla_TrUtf8(const char* s); -struct miqt_array* QsciScintilla_ApiContext(QsciScintilla* self, int pos, int* context_start, int* last_word_start); +struct miqt_array QsciScintilla_ApiContext(QsciScintilla* self, int pos, int* context_start, int* last_word_start); void QsciScintilla_Annotate(QsciScintilla* self, int line, struct miqt_string text, int style); void QsciScintilla_Annotate2(QsciScintilla* self, int line, struct miqt_string text, QsciStyle* style); void QsciScintilla_Annotate3(QsciScintilla* self, int line, QsciStyledText* text); @@ -84,7 +84,7 @@ void QsciScintilla_ClearFolds(QsciScintilla* self); void QsciScintilla_ClearIndicatorRange(QsciScintilla* self, int lineFrom, int indexFrom, int lineTo, int indexTo, int indicatorNumber); void QsciScintilla_ClearRegisteredImages(QsciScintilla* self); QColor* QsciScintilla_Color(const QsciScintilla* self); -struct miqt_array* QsciScintilla_ContractedFolds(const QsciScintilla* self); +struct miqt_array QsciScintilla_ContractedFolds(const QsciScintilla* self); void QsciScintilla_ConvertEols(QsciScintilla* self, int mode); QMenu* QsciScintilla_CreateStandardContextMenu(QsciScintilla* self); QsciDocument* QsciScintilla_Document(const QsciScintilla* self); @@ -164,14 +164,14 @@ void QsciScintilla_SetFoldMarginColors(QsciScintilla* self, QColor* fore, QColor void QsciScintilla_SetAnnotationDisplay(QsciScintilla* self, int display); void QsciScintilla_SetAutoCompletionFillupsEnabled(QsciScintilla* self, bool enabled); void QsciScintilla_SetAutoCompletionFillups(QsciScintilla* self, const char* fillups); -void QsciScintilla_SetAutoCompletionWordSeparators(QsciScintilla* self, struct miqt_array* /* of struct miqt_string */ separators); +void QsciScintilla_SetAutoCompletionWordSeparators(QsciScintilla* self, struct miqt_array /* of struct miqt_string */ separators); void QsciScintilla_SetCallTipsBackgroundColor(QsciScintilla* self, QColor* col); void QsciScintilla_SetCallTipsForegroundColor(QsciScintilla* self, QColor* col); void QsciScintilla_SetCallTipsHighlightColor(QsciScintilla* self, QColor* col); void QsciScintilla_SetCallTipsPosition(QsciScintilla* self, int position); void QsciScintilla_SetCallTipsStyle(QsciScintilla* self, int style); void QsciScintilla_SetCallTipsVisible(QsciScintilla* self, int nr); -void QsciScintilla_SetContractedFolds(QsciScintilla* self, struct miqt_array* /* of int */ folds); +void QsciScintilla_SetContractedFolds(QsciScintilla* self, struct miqt_array /* of int */ folds); void QsciScintilla_SetDocument(QsciScintilla* self, QsciDocument* document); void QsciScintilla_AddEdgeColumn(QsciScintilla* self, int colnr, QColor* col); void QsciScintilla_ClearEdgeColumns(QsciScintilla* self); @@ -220,7 +220,7 @@ void QsciScintilla_SetWhitespaceBackgroundColor(QsciScintilla* self, QColor* col void QsciScintilla_SetWhitespaceForegroundColor(QsciScintilla* self, QColor* col); void QsciScintilla_SetWhitespaceSize(QsciScintilla* self, int size); void QsciScintilla_SetWrapIndentMode(QsciScintilla* self, int mode); -void QsciScintilla_ShowUserList(QsciScintilla* self, int id, struct miqt_array* /* of struct miqt_string */ list); +void QsciScintilla_ShowUserList(QsciScintilla* self, int id, struct miqt_array /* of struct miqt_string */ list); QsciCommandSet* QsciScintilla_StandardCommands(const QsciScintilla* self); int QsciScintilla_TabDrawMode(const QsciScintilla* self); bool QsciScintilla_TabIndents(const QsciScintilla* self); diff --git a/qt/gen_qabstracteventdispatcher.cpp b/qt/gen_qabstracteventdispatcher.cpp index d7f7d46d..796e16f1 100644 --- a/qt/gen_qabstracteventdispatcher.cpp +++ b/qt/gen_qabstracteventdispatcher.cpp @@ -80,16 +80,16 @@ bool QAbstractEventDispatcher_UnregisterTimers(QAbstractEventDispatcher* self, Q return self->unregisterTimers(object); } -struct miqt_array* QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object) { +struct miqt_array QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object) { QList _ret = self->registeredTimers(object); // Convert QList<> from C++ memory to manually-managed C memory QAbstractEventDispatcher__TimerInfo** _arr = static_cast(malloc(sizeof(QAbstractEventDispatcher__TimerInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QAbstractEventDispatcher::TimerInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qabstracteventdispatcher.go b/qt/gen_qabstracteventdispatcher.go index 6b4758cc..86e7c983 100644 --- a/qt/gen_qabstracteventdispatcher.go +++ b/qt/gen_qabstracteventdispatcher.go @@ -109,7 +109,7 @@ func (this *QAbstractEventDispatcher) UnregisterTimers(object *QObject) bool { } func (this *QAbstractEventDispatcher) RegisteredTimers(object *QObject) []QAbstractEventDispatcher__TimerInfo { - var _ma *C.struct_miqt_array = C.QAbstractEventDispatcher_RegisteredTimers(this.h, object.cPointer()) + var _ma C.struct_miqt_array = C.QAbstractEventDispatcher_RegisteredTimers(this.h, object.cPointer()) _ret := make([]QAbstractEventDispatcher__TimerInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractEventDispatcher__TimerInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -118,7 +118,6 @@ func (this *QAbstractEventDispatcher) RegisteredTimers(object *QObject) []QAbstr _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qabstracteventdispatcher.h b/qt/gen_qabstracteventdispatcher.h index d942d584..b4447864 100644 --- a/qt/gen_qabstracteventdispatcher.h +++ b/qt/gen_qabstracteventdispatcher.h @@ -50,7 +50,7 @@ int QAbstractEventDispatcher_RegisterTimer(QAbstractEventDispatcher* self, int i void QAbstractEventDispatcher_RegisterTimer2(QAbstractEventDispatcher* self, int timerId, int interval, int timerType, QObject* object); bool QAbstractEventDispatcher_UnregisterTimer(QAbstractEventDispatcher* self, int timerId); bool QAbstractEventDispatcher_UnregisterTimers(QAbstractEventDispatcher* self, QObject* object); -struct miqt_array* QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object); +struct miqt_array QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object); int QAbstractEventDispatcher_RemainingTime(QAbstractEventDispatcher* self, int timerId); void QAbstractEventDispatcher_WakeUp(QAbstractEventDispatcher* self); void QAbstractEventDispatcher_Interrupt(QAbstractEventDispatcher* self); diff --git a/qt/gen_qabstractitemdelegate.cpp b/qt/gen_qabstractitemdelegate.cpp index 390b5810..d055349a 100644 --- a/qt/gen_qabstractitemdelegate.cpp +++ b/qt/gen_qabstractitemdelegate.cpp @@ -96,16 +96,16 @@ bool QAbstractItemDelegate_HelpEvent(QAbstractItemDelegate* self, QHelpEvent* ev return self->helpEvent(event, view, *option, *index); } -struct miqt_array* QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self) { +struct miqt_array QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self) { QVector _ret = self->paintingRoles(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qabstractitemdelegate.go b/qt/gen_qabstractitemdelegate.go index 155d81a7..e2249f80 100644 --- a/qt/gen_qabstractitemdelegate.go +++ b/qt/gen_qabstractitemdelegate.go @@ -133,13 +133,12 @@ func (this *QAbstractItemDelegate) HelpEvent(event *QHelpEvent, view *QAbstractI } func (this *QAbstractItemDelegate) PaintingRoles() []int { - var _ma *C.struct_miqt_array = C.QAbstractItemDelegate_PaintingRoles(this.h) + var _ma C.struct_miqt_array = C.QAbstractItemDelegate_PaintingRoles(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qabstractitemdelegate.h b/qt/gen_qabstractitemdelegate.h index e1d8118a..355377fb 100644 --- a/qt/gen_qabstractitemdelegate.h +++ b/qt/gen_qabstractitemdelegate.h @@ -55,7 +55,7 @@ void QAbstractItemDelegate_UpdateEditorGeometry(const QAbstractItemDelegate* sel bool QAbstractItemDelegate_EditorEvent(QAbstractItemDelegate* self, QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem* option, QModelIndex* index); struct miqt_string QAbstractItemDelegate_ElidedText(QFontMetrics* fontMetrics, int width, int mode, struct miqt_string text); bool QAbstractItemDelegate_HelpEvent(QAbstractItemDelegate* self, QHelpEvent* event, QAbstractItemView* view, QStyleOptionViewItem* option, QModelIndex* index); -struct miqt_array* QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self); +struct miqt_array QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self); void QAbstractItemDelegate_CommitData(QAbstractItemDelegate* self, QWidget* editor); void QAbstractItemDelegate_connect_CommitData(QAbstractItemDelegate* self, intptr_t slot); void QAbstractItemDelegate_CloseEditor(QAbstractItemDelegate* self, QWidget* editor); diff --git a/qt/gen_qabstractitemmodel.cpp b/qt/gen_qabstractitemmodel.cpp index 21ebc1f6..8d367b5c 100644 --- a/qt/gen_qabstractitemmodel.cpp +++ b/qt/gen_qabstractitemmodel.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -269,7 +271,35 @@ bool QAbstractItemModel_SetHeaderData(QAbstractItemModel* self, int section, int return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } -struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) { +struct miqt_map QAbstractItemModel_ItemData(const QAbstractItemModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QAbstractItemModel_SetItemData(QAbstractItemModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + +struct miqt_array QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -283,17 +313,17 @@ struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -386,16 +416,16 @@ QModelIndex* QAbstractItemModel_Buddy(const QAbstractItemModel* self, QModelInde return new QModelIndex(self->buddy(*index)); } -struct miqt_array* QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -403,6 +433,29 @@ QSize* QAbstractItemModel_Span(const QAbstractItemModel* self, QModelIndex* inde return new QSize(self->span(*index)); } +struct miqt_map QAbstractItemModel_RoleNames(const QAbstractItemModel* self) { + QHash _ret = self->roleNames(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + struct miqt_string* _varr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + QByteArray _hashval_qb = _itr->second; + struct miqt_string _hashval_ms; + _hashval_ms.len = _hashval_qb.length(); + _hashval_ms.data = static_cast(malloc(_hashval_ms.len)); + memcpy(_hashval_ms.data, _hashval_qb.data(), _hashval_ms.len); + _varr[_ctr] = _hashval_ms; + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + bool QAbstractItemModel_CheckIndex(const QAbstractItemModel* self, QModelIndex* index) { return self->checkIndex(*index); } @@ -581,29 +634,29 @@ void QAbstractItemModel_Sort2(QAbstractItemModel* self, int column, int order) { self->sort(static_cast(column), static_cast(order)); } -struct miqt_array* QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -611,11 +664,11 @@ bool QAbstractItemModel_CheckIndex2(const QAbstractItemModel* self, QModelIndex* return self->checkIndex(*index, static_cast(options)); } -void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles) { +void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles) { QVector roles_QList; - roles_QList.reserve(roles->len); - int* roles_arr = static_cast(roles->data); - for(size_t i = 0; i < roles->len; ++i) { + roles_QList.reserve(roles.len); + int* roles_arr = static_cast(roles.data); + for(size_t i = 0; i < roles.len; ++i) { roles_QList.push_back(static_cast(roles_arr[i])); } self->dataChanged(*topLeft, *bottomRight, roles_QList); @@ -635,19 +688,19 @@ void QAbstractItemModel_connect_DataChanged3(QAbstractItemModel* self, intptr_t for (size_t i = 0, e = roles_ret.length(); i < e; ++i) { roles_arr[i] = roles_ret[i]; } - struct miqt_array* roles_out = static_cast(malloc(sizeof(struct miqt_array))); - roles_out->len = roles_ret.length(); - roles_out->data = static_cast(roles_arr); - struct miqt_array* sigval3 = roles_out; + struct miqt_array roles_out; + roles_out.len = roles_ret.length(); + roles_out.data = static_cast(roles_arr); + struct miqt_array sigval3 = roles_out; miqt_exec_callback_QAbstractItemModel_DataChanged3(slot, sigval1, sigval2, sigval3); }); } -void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents) { +void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutChanged(parents_QList); @@ -661,19 +714,19 @@ void QAbstractItemModel_connect_LayoutChanged1(QAbstractItemModel* self, intptr_ for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; miqt_exec_callback_QAbstractItemModel_LayoutChanged1(slot, sigval1); }); } -void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint) { +void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutChanged(parents_QList, static_cast(hint)); @@ -687,21 +740,21 @@ void QAbstractItemModel_connect_LayoutChanged2(QAbstractItemModel* self, intptr_ for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; QAbstractItemModel::LayoutChangeHint hint_ret = hint; int sigval2 = static_cast(hint_ret); miqt_exec_callback_QAbstractItemModel_LayoutChanged2(slot, sigval1, sigval2); }); } -void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents) { +void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutAboutToBeChanged(parents_QList); @@ -715,19 +768,19 @@ void QAbstractItemModel_connect_LayoutAboutToBeChanged1(QAbstractItemModel* self for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(slot, sigval1); }); } -void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint) { +void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutAboutToBeChanged(parents_QList, static_cast(hint)); @@ -741,10 +794,10 @@ void QAbstractItemModel_connect_LayoutAboutToBeChanged2(QAbstractItemModel* self for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; QAbstractItemModel::LayoutChangeHint hint_ret = hint; int sigval2 = static_cast(hint_ret); miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(slot, sigval1, sigval2); diff --git a/qt/gen_qabstractitemmodel.go b/qt/gen_qabstractitemmodel.go index 8114f47e..ccb60824 100644 --- a/qt/gen_qabstractitemmodel.go +++ b/qt/gen_qabstractitemmodel.go @@ -448,8 +448,45 @@ func (this *QAbstractItemModel) SetHeaderData(section int, orientation Orientati return (bool)(C.QAbstractItemModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } +func (this *QAbstractItemModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QAbstractItemModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QAbstractItemModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QAbstractItemModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QAbstractItemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QAbstractItemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -458,19 +495,16 @@ func (this *QAbstractItemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAbstractItemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QAbstractItemModel_MimeData(this.h, indexes_ma))) } @@ -562,7 +596,7 @@ func (this *QAbstractItemModel) Buddy(index *QModelIndex) *QModelIndex { } func (this *QAbstractItemModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -571,7 +605,6 @@ func (this *QAbstractItemModel) Match(start *QModelIndex, role int, value *QVari _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -582,6 +615,23 @@ func (this *QAbstractItemModel) Span(index *QModelIndex) *QSize { return _goptr } +func (this *QAbstractItemModel) RoleNames() map[int][]byte { + var _mm C.struct_miqt_map = C.QAbstractItemModel_RoleNames(this.h) + _ret := make(map[int][]byte, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + var _hashval_bytearray C.struct_miqt_string = _Values[i] + _hashval_ret := C.GoBytes(unsafe.Pointer(_hashval_bytearray.data), C.int(int64(_hashval_bytearray.len))) + C.free(unsafe.Pointer(_hashval_bytearray.data)) + _entry_Value := _hashval_ret + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QAbstractItemModel) CheckIndex(index *QModelIndex) bool { return (bool)(C.QAbstractItemModel_CheckIndex(this.h, index.cPointer())) } @@ -799,7 +849,7 @@ func (this *QAbstractItemModel) Sort2(column int, order SortOrder) { } func (this *QAbstractItemModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -808,12 +858,11 @@ func (this *QAbstractItemModel) Match4(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAbstractItemModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -822,7 +871,6 @@ func (this *QAbstractItemModel) Match5(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -831,14 +879,12 @@ func (this *QAbstractItemModel) CheckIndex2(index *QModelIndex, options QAbstrac } func (this *QAbstractItemModel) DataChanged3(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int) { - // For the C ABI, malloc a C array of raw pointers roles_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) defer C.free(unsafe.Pointer(roles_CArray)) for i := range roles { roles_CArray[i] = (C.int)(roles[i]) } - roles_ma := &C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(roles_ma)) + roles_ma := C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} C.QAbstractItemModel_DataChanged3(this.h, topLeft.cPointer(), bottomRight.cPointer(), roles_ma) } func (this *QAbstractItemModel) OnDataChanged3(slot func(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int)) { @@ -846,7 +892,7 @@ func (this *QAbstractItemModel) OnDataChanged3(slot func(topLeft *QModelIndex, b } //export miqt_exec_callback_QAbstractItemModel_DataChanged3 -func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft *C.QModelIndex, bottomRight *C.QModelIndex, roles *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft *C.QModelIndex, bottomRight *C.QModelIndex, roles C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") @@ -855,27 +901,24 @@ func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft * // Convert all CABI parameters to Go parameters slotval1 := UnsafeNewQModelIndex(unsafe.Pointer(topLeft)) slotval2 := UnsafeNewQModelIndex(unsafe.Pointer(bottomRight)) - var roles_ma *C.struct_miqt_array = roles + var roles_ma C.struct_miqt_array = roles roles_ret := make([]int, int(roles_ma.len)) roles_outCast := (*[0xffff]C.int)(unsafe.Pointer(roles_ma.data)) // hey ya for i := 0; i < int(roles_ma.len); i++ { roles_ret[i] = (int)(roles_outCast[i]) } - C.free(unsafe.Pointer(roles_ma)) slotval3 := roles_ret gofunc(slotval1, slotval2, slotval3) } func (this *QAbstractItemModel) LayoutChanged1(parents []QPersistentModelIndex) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutChanged1(this.h, parents_ma) } func (this *QAbstractItemModel) OnLayoutChanged1(slot func(parents []QPersistentModelIndex)) { @@ -883,14 +926,14 @@ func (this *QAbstractItemModel) OnLayoutChanged1(slot func(parents []QPersistent } //export miqt_exec_callback_QAbstractItemModel_LayoutChanged1 -func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -899,21 +942,18 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret gofunc(slotval1) } func (this *QAbstractItemModel) LayoutChanged2(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutChanged2(this.h, parents_ma, (C.int)(hint)) } func (this *QAbstractItemModel) OnLayoutChanged2(slot func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) { @@ -921,14 +961,14 @@ func (this *QAbstractItemModel) OnLayoutChanged2(slot func(parents []QPersistent } //export miqt_exec_callback_QAbstractItemModel_LayoutChanged2 -func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents *C.struct_miqt_array, hint C.int) { +func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents C.struct_miqt_array, hint C.int) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -937,7 +977,6 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret slotval2 := (QAbstractItemModel__LayoutChangeHint)(hint) @@ -946,14 +985,12 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents } func (this *QAbstractItemModel) LayoutAboutToBeChanged1(parents []QPersistentModelIndex) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutAboutToBeChanged1(this.h, parents_ma) } func (this *QAbstractItemModel) OnLayoutAboutToBeChanged1(slot func(parents []QPersistentModelIndex)) { @@ -961,14 +998,14 @@ func (this *QAbstractItemModel) OnLayoutAboutToBeChanged1(slot func(parents []QP } //export miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1 -func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t, parents *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t, parents C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -977,21 +1014,18 @@ func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret gofunc(slotval1) } func (this *QAbstractItemModel) LayoutAboutToBeChanged2(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutAboutToBeChanged2(this.h, parents_ma, (C.int)(hint)) } func (this *QAbstractItemModel) OnLayoutAboutToBeChanged2(slot func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) { @@ -999,14 +1033,14 @@ func (this *QAbstractItemModel) OnLayoutAboutToBeChanged2(slot func(parents []QP } //export miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2 -func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t, parents *C.struct_miqt_array, hint C.int) { +func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t, parents C.struct_miqt_array, hint C.int) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -1015,7 +1049,6 @@ func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret slotval2 := (QAbstractItemModel__LayoutChangeHint)(hint) diff --git a/qt/gen_qabstractitemmodel.h b/qt/gen_qabstractitemmodel.h index b8922f80..95b41f47 100644 --- a/qt/gen_qabstractitemmodel.h +++ b/qt/gen_qabstractitemmodel.h @@ -17,6 +17,7 @@ extern "C" { class QAbstractItemModel; class QAbstractListModel; class QAbstractTableModel; +class QByteArray; class QMetaObject; class QMimeData; class QModelIndex; @@ -27,6 +28,7 @@ class QVariant; typedef struct QAbstractItemModel QAbstractItemModel; typedef struct QAbstractListModel QAbstractListModel; typedef struct QAbstractTableModel QAbstractTableModel; +typedef struct QByteArray QByteArray; typedef struct QMetaObject QMetaObject; typedef struct QMimeData QMimeData; typedef struct QModelIndex QModelIndex; @@ -96,8 +98,10 @@ QVariant* QAbstractItemModel_Data(const QAbstractItemModel* self, QModelIndex* i bool QAbstractItemModel_SetData(QAbstractItemModel* self, QModelIndex* index, QVariant* value); QVariant* QAbstractItemModel_HeaderData(const QAbstractItemModel* self, int section, int orientation); bool QAbstractItemModel_SetHeaderData(QAbstractItemModel* self, int section, int orientation, QVariant* value); -struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self); -QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_map QAbstractItemModel_ItemData(const QAbstractItemModel* self, QModelIndex* index); +bool QAbstractItemModel_SetItemData(QAbstractItemModel* self, QModelIndex* index, struct miqt_map roles); +struct miqt_array QAbstractItemModel_MimeTypes(const QAbstractItemModel* self); +QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QAbstractItemModel_CanDropMimeData(const QAbstractItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QAbstractItemModel_DropMimeData(QAbstractItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); int QAbstractItemModel_SupportedDropActions(const QAbstractItemModel* self); @@ -119,8 +123,9 @@ bool QAbstractItemModel_CanFetchMore(const QAbstractItemModel* self, QModelIndex int QAbstractItemModel_Flags(const QAbstractItemModel* self, QModelIndex* index); void QAbstractItemModel_Sort(QAbstractItemModel* self, int column); QModelIndex* QAbstractItemModel_Buddy(const QAbstractItemModel* self, QModelIndex* index); -struct miqt_array* QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value); QSize* QAbstractItemModel_Span(const QAbstractItemModel* self, QModelIndex* index); +struct miqt_map QAbstractItemModel_RoleNames(const QAbstractItemModel* self); bool QAbstractItemModel_CheckIndex(const QAbstractItemModel* self, QModelIndex* index); void QAbstractItemModel_DataChanged(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight); void QAbstractItemModel_connect_DataChanged(QAbstractItemModel* self, intptr_t slot); @@ -154,18 +159,18 @@ bool QAbstractItemModel_InsertColumn2(QAbstractItemModel* self, int column, QMod bool QAbstractItemModel_RemoveRow2(QAbstractItemModel* self, int row, QModelIndex* parent); bool QAbstractItemModel_RemoveColumn2(QAbstractItemModel* self, int column, QModelIndex* parent); void QAbstractItemModel_Sort2(QAbstractItemModel* self, int column, int order); -struct miqt_array* QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); bool QAbstractItemModel_CheckIndex2(const QAbstractItemModel* self, QModelIndex* index, int options); -void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles); +void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles); void QAbstractItemModel_connect_DataChanged3(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents); +void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents); void QAbstractItemModel_connect_LayoutChanged1(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint); +void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint); void QAbstractItemModel_connect_LayoutChanged2(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents); +void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents); void QAbstractItemModel_connect_LayoutAboutToBeChanged1(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint); +void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint); void QAbstractItemModel_connect_LayoutAboutToBeChanged2(QAbstractItemModel* self, intptr_t slot); void QAbstractItemModel_Delete(QAbstractItemModel* self); diff --git a/qt/gen_qabstractproxymodel.cpp b/qt/gen_qabstractproxymodel.cpp index 700be6a2..245d410f 100644 --- a/qt/gen_qabstractproxymodel.cpp +++ b/qt/gen_qabstractproxymodel.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,24 @@ QVariant* QAbstractProxyModel_HeaderData(const QAbstractProxyModel* self, int se return new QVariant(self->headerData(static_cast(section), static_cast(orientation))); } +struct miqt_map QAbstractProxyModel_ItemData(const QAbstractProxyModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + int QAbstractProxyModel_Flags(const QAbstractProxyModel* self, QModelIndex* index) { Qt::ItemFlags _ret = self->flags(*index); return static_cast(_ret); @@ -84,6 +103,16 @@ bool QAbstractProxyModel_SetData(QAbstractProxyModel* self, QModelIndex* index, return self->setData(*index, *value); } +bool QAbstractProxyModel_SetItemData(QAbstractProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + bool QAbstractProxyModel_SetHeaderData(QAbstractProxyModel* self, int section, int orientation, QVariant* value) { return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } @@ -116,11 +145,11 @@ QModelIndex* QAbstractProxyModel_Sibling(const QAbstractProxyModel* self, int ro return new QModelIndex(self->sibling(static_cast(row), static_cast(column), *idx)); } -QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -134,7 +163,7 @@ bool QAbstractProxyModel_DropMimeData(QAbstractProxyModel* self, QMimeData* data return self->dropMimeData(data, static_cast(action), static_cast(row), static_cast(column), *parent); } -struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self) { +struct miqt_array QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -148,9 +177,9 @@ struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qabstractproxymodel.go b/qt/gen_qabstractproxymodel.go index 5e057a03..e0821bb5 100644 --- a/qt/gen_qabstractproxymodel.go +++ b/qt/gen_qabstractproxymodel.go @@ -115,6 +115,24 @@ func (this *QAbstractProxyModel) HeaderData(section int, orientation Orientation return _goptr } +func (this *QAbstractProxyModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QAbstractProxyModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QAbstractProxyModel) Flags(index *QModelIndex) ItemFlag { return (ItemFlag)(C.QAbstractProxyModel_Flags(this.h, index.cPointer())) } @@ -123,6 +141,25 @@ func (this *QAbstractProxyModel) SetData(index *QModelIndex, value *QVariant) bo return (bool)(C.QAbstractProxyModel_SetData(this.h, index.cPointer(), value.cPointer())) } +func (this *QAbstractProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QAbstractProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QAbstractProxyModel) SetHeaderData(section int, orientation Orientation, value *QVariant) bool { return (bool)(C.QAbstractProxyModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } @@ -165,14 +202,12 @@ func (this *QAbstractProxyModel) Sibling(row int, column int, idx *QModelIndex) } func (this *QAbstractProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QAbstractProxyModel_MimeData(this.h, indexes_ma))) } @@ -185,7 +220,7 @@ func (this *QAbstractProxyModel) DropMimeData(data *QMimeData, action DropAction } func (this *QAbstractProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QAbstractProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QAbstractProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -194,7 +229,6 @@ func (this *QAbstractProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qabstractproxymodel.h b/qt/gen_qabstractproxymodel.h index 44cae6bd..2b041b5e 100644 --- a/qt/gen_qabstractproxymodel.h +++ b/qt/gen_qabstractproxymodel.h @@ -43,8 +43,10 @@ bool QAbstractProxyModel_Submit(QAbstractProxyModel* self); void QAbstractProxyModel_Revert(QAbstractProxyModel* self); QVariant* QAbstractProxyModel_Data(const QAbstractProxyModel* self, QModelIndex* proxyIndex); QVariant* QAbstractProxyModel_HeaderData(const QAbstractProxyModel* self, int section, int orientation); +struct miqt_map QAbstractProxyModel_ItemData(const QAbstractProxyModel* self, QModelIndex* index); int QAbstractProxyModel_Flags(const QAbstractProxyModel* self, QModelIndex* index); bool QAbstractProxyModel_SetData(QAbstractProxyModel* self, QModelIndex* index, QVariant* value); +bool QAbstractProxyModel_SetItemData(QAbstractProxyModel* self, QModelIndex* index, struct miqt_map roles); bool QAbstractProxyModel_SetHeaderData(QAbstractProxyModel* self, int section, int orientation, QVariant* value); QModelIndex* QAbstractProxyModel_Buddy(const QAbstractProxyModel* self, QModelIndex* index); bool QAbstractProxyModel_CanFetchMore(const QAbstractProxyModel* self, QModelIndex* parent); @@ -53,10 +55,10 @@ void QAbstractProxyModel_Sort(QAbstractProxyModel* self, int column); QSize* QAbstractProxyModel_Span(const QAbstractProxyModel* self, QModelIndex* index); bool QAbstractProxyModel_HasChildren(const QAbstractProxyModel* self); QModelIndex* QAbstractProxyModel_Sibling(const QAbstractProxyModel* self, int row, int column, QModelIndex* idx); -QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QAbstractProxyModel_CanDropMimeData(const QAbstractProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QAbstractProxyModel_DropMimeData(QAbstractProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); -struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self); +struct miqt_array QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self); int QAbstractProxyModel_SupportedDragActions(const QAbstractProxyModel* self); int QAbstractProxyModel_SupportedDropActions(const QAbstractProxyModel* self); struct miqt_string QAbstractProxyModel_Tr2(const char* s, const char* c); diff --git a/qt/gen_qabstractscrollarea.cpp b/qt/gen_qabstractscrollarea.cpp index 9e922741..c8550d38 100644 --- a/qt/gen_qabstractscrollarea.cpp +++ b/qt/gen_qabstractscrollarea.cpp @@ -95,16 +95,16 @@ void QAbstractScrollArea_AddScrollBarWidget(QAbstractScrollArea* self, QWidget* self->addScrollBarWidget(widget, static_cast(alignment)); } -struct miqt_array* QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment) { +struct miqt_array QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment) { QWidgetList _ret = self->scrollBarWidgets(static_cast(alignment)); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qabstractscrollarea.go b/qt/gen_qabstractscrollarea.go index fa664f4f..ce3af480 100644 --- a/qt/gen_qabstractscrollarea.go +++ b/qt/gen_qabstractscrollarea.go @@ -136,13 +136,12 @@ func (this *QAbstractScrollArea) AddScrollBarWidget(widget *QWidget, alignment A } func (this *QAbstractScrollArea) ScrollBarWidgets(alignment AlignmentFlag) []*QWidget { - var _ma *C.struct_miqt_array = C.QAbstractScrollArea_ScrollBarWidgets(this.h, (C.int)(alignment)) + var _ma C.struct_miqt_array = C.QAbstractScrollArea_ScrollBarWidgets(this.h, (C.int)(alignment)) _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qabstractscrollarea.h b/qt/gen_qabstractscrollarea.h index 2b0ed1be..887d8dac 100644 --- a/qt/gen_qabstractscrollarea.h +++ b/qt/gen_qabstractscrollarea.h @@ -44,7 +44,7 @@ void QAbstractScrollArea_SetHorizontalScrollBar(QAbstractScrollArea* self, QScro QWidget* QAbstractScrollArea_CornerWidget(const QAbstractScrollArea* self); void QAbstractScrollArea_SetCornerWidget(QAbstractScrollArea* self, QWidget* widget); void QAbstractScrollArea_AddScrollBarWidget(QAbstractScrollArea* self, QWidget* widget, int alignment); -struct miqt_array* QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment); +struct miqt_array QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment); QWidget* QAbstractScrollArea_Viewport(const QAbstractScrollArea* self); void QAbstractScrollArea_SetViewport(QAbstractScrollArea* self, QWidget* widget); QSize* QAbstractScrollArea_MaximumViewportSize(const QAbstractScrollArea* self); diff --git a/qt/gen_qabstracttransition.cpp b/qt/gen_qabstracttransition.cpp index f1df9bc8..7c6d6ee3 100644 --- a/qt/gen_qabstracttransition.cpp +++ b/qt/gen_qabstracttransition.cpp @@ -54,24 +54,24 @@ void QAbstractTransition_SetTargetState(QAbstractTransition* self, QAbstractStat self->setTargetState(target); } -struct miqt_array* QAbstractTransition_TargetStates(const QAbstractTransition* self) { +struct miqt_array QAbstractTransition_TargetStates(const QAbstractTransition* self) { QList _ret = self->targetStates(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractState** _arr = static_cast(malloc(sizeof(QAbstractState*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QAbstractTransition_SetTargetStates(QAbstractTransition* self, struct miqt_array* /* of QAbstractState* */ targets) { +void QAbstractTransition_SetTargetStates(QAbstractTransition* self, struct miqt_array /* of QAbstractState* */ targets) { QList targets_QList; - targets_QList.reserve(targets->len); - QAbstractState** targets_arr = static_cast(targets->data); - for(size_t i = 0; i < targets->len; ++i) { + targets_QList.reserve(targets.len); + QAbstractState** targets_arr = static_cast(targets.data); + for(size_t i = 0; i < targets.len; ++i) { targets_QList.push_back(targets_arr[i]); } self->setTargetStates(targets_QList); @@ -98,16 +98,16 @@ void QAbstractTransition_RemoveAnimation(QAbstractTransition* self, QAbstractAni self->removeAnimation(animation); } -struct miqt_array* QAbstractTransition_Animations(const QAbstractTransition* self) { +struct miqt_array QAbstractTransition_Animations(const QAbstractTransition* self) { QList _ret = self->animations(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractAnimation** _arr = static_cast(malloc(sizeof(QAbstractAnimation*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qabstracttransition.go b/qt/gen_qabstracttransition.go index b5e95694..823a70a3 100644 --- a/qt/gen_qabstracttransition.go +++ b/qt/gen_qabstracttransition.go @@ -91,25 +91,22 @@ func (this *QAbstractTransition) SetTargetState(target *QAbstractState) { } func (this *QAbstractTransition) TargetStates() []*QAbstractState { - var _ma *C.struct_miqt_array = C.QAbstractTransition_TargetStates(this.h) + var _ma C.struct_miqt_array = C.QAbstractTransition_TargetStates(this.h) _ret := make([]*QAbstractState, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractState)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractState(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAbstractTransition) SetTargetStates(targets []*QAbstractState) { - // For the C ABI, malloc a C array of raw pointers targets_CArray := (*[0xffff]*C.QAbstractState)(C.malloc(C.size_t(8 * len(targets)))) defer C.free(unsafe.Pointer(targets_CArray)) for i := range targets { targets_CArray[i] = targets[i].cPointer() } - targets_ma := &C.struct_miqt_array{len: C.size_t(len(targets)), data: unsafe.Pointer(targets_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(targets_ma)) + targets_ma := C.struct_miqt_array{len: C.size_t(len(targets)), data: unsafe.Pointer(targets_CArray)} C.QAbstractTransition_SetTargetStates(this.h, targets_ma) } @@ -134,13 +131,12 @@ func (this *QAbstractTransition) RemoveAnimation(animation *QAbstractAnimation) } func (this *QAbstractTransition) Animations() []*QAbstractAnimation { - var _ma *C.struct_miqt_array = C.QAbstractTransition_Animations(this.h) + var _ma C.struct_miqt_array = C.QAbstractTransition_Animations(this.h) _ret := make([]*QAbstractAnimation, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractAnimation)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractAnimation(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qabstracttransition.h b/qt/gen_qabstracttransition.h index 1c2c0010..23d76b83 100644 --- a/qt/gen_qabstracttransition.h +++ b/qt/gen_qabstracttransition.h @@ -36,14 +36,14 @@ struct miqt_string QAbstractTransition_TrUtf8(const char* s); QState* QAbstractTransition_SourceState(const QAbstractTransition* self); QAbstractState* QAbstractTransition_TargetState(const QAbstractTransition* self); void QAbstractTransition_SetTargetState(QAbstractTransition* self, QAbstractState* target); -struct miqt_array* QAbstractTransition_TargetStates(const QAbstractTransition* self); -void QAbstractTransition_SetTargetStates(QAbstractTransition* self, struct miqt_array* /* of QAbstractState* */ targets); +struct miqt_array QAbstractTransition_TargetStates(const QAbstractTransition* self); +void QAbstractTransition_SetTargetStates(QAbstractTransition* self, struct miqt_array /* of QAbstractState* */ targets); int QAbstractTransition_TransitionType(const QAbstractTransition* self); void QAbstractTransition_SetTransitionType(QAbstractTransition* self, int typeVal); QStateMachine* QAbstractTransition_Machine(const QAbstractTransition* self); void QAbstractTransition_AddAnimation(QAbstractTransition* self, QAbstractAnimation* animation); void QAbstractTransition_RemoveAnimation(QAbstractTransition* self, QAbstractAnimation* animation); -struct miqt_array* QAbstractTransition_Animations(const QAbstractTransition* self); +struct miqt_array QAbstractTransition_Animations(const QAbstractTransition* self); struct miqt_string QAbstractTransition_Tr2(const char* s, const char* c); struct miqt_string QAbstractTransition_Tr3(const char* s, const char* c, int n); struct miqt_string QAbstractTransition_TrUtf82(const char* s, const char* c); diff --git a/qt/gen_qaccessible.cpp b/qt/gen_qaccessible.cpp index 3bb7b666..7ba08c4d 100644 --- a/qt/gen_qaccessible.cpp +++ b/qt/gen_qaccessible.cpp @@ -357,29 +357,29 @@ bool QAccessibleTableCellInterface_IsSelected(const QAccessibleTableCellInterfac return self->isSelected(); } -struct miqt_array* QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self) { +struct miqt_array QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self) { QList _ret = self->columnHeaderCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self) { +struct miqt_array QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self) { QList _ret = self->rowHeaderCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -427,16 +427,16 @@ int QAccessibleTableInterface_SelectedCellCount(const QAccessibleTableInterface* return self->selectedCellCount(); } -struct miqt_array* QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self) { QList _ret = self->selectedCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -478,29 +478,29 @@ int QAccessibleTableInterface_RowCount(const QAccessibleTableInterface* self) { return self->rowCount(); } -struct miqt_array* QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self) { QList _ret = self->selectedColumns(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self) { QList _ret = self->selectedRows(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -558,7 +558,7 @@ struct miqt_string QAccessibleActionInterface_TrUtf8(const char* sourceText) { return _ms; } -struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self) { +struct miqt_array QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self) { QStringList _ret = self->actionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -572,9 +572,9 @@ struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -607,7 +607,7 @@ void QAccessibleActionInterface_DoAction(QAccessibleActionInterface* self, struc self->doAction(actionName_QString); } -struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName) { +struct miqt_array QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName) { QString actionName_QString = QString::fromUtf8(actionName.data, actionName.len); QStringList _ret = self->keyBindingsForAction(actionName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -622,9 +622,9 @@ struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccess memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qaccessible.go b/qt/gen_qaccessible.go index 900f6ef0..bb9207cc 100644 --- a/qt/gen_qaccessible.go +++ b/qt/gen_qaccessible.go @@ -773,24 +773,22 @@ func (this *QAccessibleTableCellInterface) IsSelected() bool { } func (this *QAccessibleTableCellInterface) ColumnHeaderCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableCellInterface_ColumnHeaderCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableCellInterface_ColumnHeaderCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAccessibleTableCellInterface) RowHeaderCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableCellInterface_RowHeaderCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableCellInterface_RowHeaderCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -878,13 +876,12 @@ func (this *QAccessibleTableInterface) SelectedCellCount() int { } func (this *QAccessibleTableInterface) SelectedCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -919,24 +916,22 @@ func (this *QAccessibleTableInterface) RowCount() int { } func (this *QAccessibleTableInterface) SelectedColumns() []int { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedColumns(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedColumns(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAccessibleTableInterface) SelectedRows() []int { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedRows(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedRows(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1030,7 +1025,7 @@ func QAccessibleActionInterface_TrUtf8(sourceText string) string { } func (this *QAccessibleActionInterface) ActionNames() []string { - var _ma *C.struct_miqt_array = C.QAccessibleActionInterface_ActionNames(this.h) + var _ma C.struct_miqt_array = C.QAccessibleActionInterface_ActionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1039,7 +1034,6 @@ func (this *QAccessibleActionInterface) ActionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1078,7 +1072,7 @@ func (this *QAccessibleActionInterface) KeyBindingsForAction(actionName string) actionName_ms.data = C.CString(actionName) actionName_ms.len = C.size_t(len(actionName)) defer C.free(unsafe.Pointer(actionName_ms.data)) - var _ma *C.struct_miqt_array = C.QAccessibleActionInterface_KeyBindingsForAction(this.h, actionName_ms) + var _ma C.struct_miqt_array = C.QAccessibleActionInterface_KeyBindingsForAction(this.h, actionName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1087,7 +1081,6 @@ func (this *QAccessibleActionInterface) KeyBindingsForAction(actionName string) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qaccessible.h b/qt/gen_qaccessible.h index d6b93181..c29acaef 100644 --- a/qt/gen_qaccessible.h +++ b/qt/gen_qaccessible.h @@ -153,8 +153,8 @@ void QAccessibleValueInterface_OperatorAssign(QAccessibleValueInterface* self, Q void QAccessibleValueInterface_Delete(QAccessibleValueInterface* self); bool QAccessibleTableCellInterface_IsSelected(const QAccessibleTableCellInterface* self); -struct miqt_array* QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self); -struct miqt_array* QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self); +struct miqt_array QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self); +struct miqt_array QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_ColumnIndex(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_RowIndex(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_ColumnExtent(const QAccessibleTableCellInterface* self); @@ -167,15 +167,15 @@ QAccessibleInterface* QAccessibleTableInterface_Caption(const QAccessibleTableIn QAccessibleInterface* QAccessibleTableInterface_Summary(const QAccessibleTableInterface* self); QAccessibleInterface* QAccessibleTableInterface_CellAt(const QAccessibleTableInterface* self, int row, int column); int QAccessibleTableInterface_SelectedCellCount(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self); struct miqt_string QAccessibleTableInterface_ColumnDescription(const QAccessibleTableInterface* self, int column); struct miqt_string QAccessibleTableInterface_RowDescription(const QAccessibleTableInterface* self, int row); int QAccessibleTableInterface_SelectedColumnCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_SelectedRowCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_ColumnCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_RowCount(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self); bool QAccessibleTableInterface_IsColumnSelected(const QAccessibleTableInterface* self, int column); bool QAccessibleTableInterface_IsRowSelected(const QAccessibleTableInterface* self, int row); bool QAccessibleTableInterface_SelectRow(QAccessibleTableInterface* self, int row); @@ -187,11 +187,11 @@ void QAccessibleTableInterface_Delete(QAccessibleTableInterface* self); struct miqt_string QAccessibleActionInterface_Tr(const char* sourceText); struct miqt_string QAccessibleActionInterface_TrUtf8(const char* sourceText); -struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self); +struct miqt_array QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self); struct miqt_string QAccessibleActionInterface_LocalizedActionName(const QAccessibleActionInterface* self, struct miqt_string name); struct miqt_string QAccessibleActionInterface_LocalizedActionDescription(const QAccessibleActionInterface* self, struct miqt_string name); void QAccessibleActionInterface_DoAction(QAccessibleActionInterface* self, struct miqt_string actionName); -struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName); +struct miqt_array QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName); struct miqt_string QAccessibleActionInterface_PressAction(); struct miqt_string QAccessibleActionInterface_IncreaseAction(); struct miqt_string QAccessibleActionInterface_DecreaseAction(); diff --git a/qt/gen_qaccessiblewidget.cpp b/qt/gen_qaccessiblewidget.cpp index 6f24396b..3714d335 100644 --- a/qt/gen_qaccessiblewidget.cpp +++ b/qt/gen_qaccessiblewidget.cpp @@ -90,7 +90,7 @@ void* QAccessibleWidget_InterfaceCast(QAccessibleWidget* self, int t) { return self->interface_cast(static_cast(t)); } -struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self) { +struct miqt_array QAccessibleWidget_ActionNames(const QAccessibleWidget* self) { QStringList _ret = self->actionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -104,9 +104,9 @@ struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -115,7 +115,7 @@ void QAccessibleWidget_DoAction(QAccessibleWidget* self, struct miqt_string acti self->doAction(actionName_QString); } -struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName) { +struct miqt_array QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName) { QString actionName_QString = QString::fromUtf8(actionName.data, actionName.len); QStringList _ret = self->keyBindingsForAction(actionName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -130,9 +130,9 @@ struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidge memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qaccessiblewidget.go b/qt/gen_qaccessiblewidget.go index 138e1301..4c334d20 100644 --- a/qt/gen_qaccessiblewidget.go +++ b/qt/gen_qaccessiblewidget.go @@ -137,7 +137,7 @@ func (this *QAccessibleWidget) InterfaceCast(t QAccessible__InterfaceType) unsaf } func (this *QAccessibleWidget) ActionNames() []string { - var _ma *C.struct_miqt_array = C.QAccessibleWidget_ActionNames(this.h) + var _ma C.struct_miqt_array = C.QAccessibleWidget_ActionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -146,7 +146,6 @@ func (this *QAccessibleWidget) ActionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -163,7 +162,7 @@ func (this *QAccessibleWidget) KeyBindingsForAction(actionName string) []string actionName_ms.data = C.CString(actionName) actionName_ms.len = C.size_t(len(actionName)) defer C.free(unsafe.Pointer(actionName_ms.data)) - var _ma *C.struct_miqt_array = C.QAccessibleWidget_KeyBindingsForAction(this.h, actionName_ms) + var _ma C.struct_miqt_array = C.QAccessibleWidget_KeyBindingsForAction(this.h, actionName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,6 +171,5 @@ func (this *QAccessibleWidget) KeyBindingsForAction(actionName string) []string C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qaccessiblewidget.h b/qt/gen_qaccessiblewidget.h index bb1fbc73..f6b7b643 100644 --- a/qt/gen_qaccessiblewidget.h +++ b/qt/gen_qaccessiblewidget.h @@ -52,9 +52,9 @@ QAccessible__State* QAccessibleWidget_State(const QAccessibleWidget* self); QColor* QAccessibleWidget_ForegroundColor(const QAccessibleWidget* self); QColor* QAccessibleWidget_BackgroundColor(const QAccessibleWidget* self); void* QAccessibleWidget_InterfaceCast(QAccessibleWidget* self, int t); -struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self); +struct miqt_array QAccessibleWidget_ActionNames(const QAccessibleWidget* self); void QAccessibleWidget_DoAction(QAccessibleWidget* self, struct miqt_string actionName); -struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName); +struct miqt_array QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName); #ifdef __cplusplus } /* extern C */ diff --git a/qt/gen_qaction.cpp b/qt/gen_qaction.cpp index 1675d8c2..f6f9573b 100644 --- a/qt/gen_qaction.cpp +++ b/qt/gen_qaction.cpp @@ -204,11 +204,11 @@ QKeySequence* QAction_Shortcut(const QAction* self) { return new QKeySequence(self->shortcut()); } -void QAction_SetShortcuts(QAction* self, struct miqt_array* /* of QKeySequence* */ shortcuts) { +void QAction_SetShortcuts(QAction* self, struct miqt_array /* of QKeySequence* */ shortcuts) { QList shortcuts_QList; - shortcuts_QList.reserve(shortcuts->len); - QKeySequence** shortcuts_arr = static_cast(shortcuts->data); - for(size_t i = 0; i < shortcuts->len; ++i) { + shortcuts_QList.reserve(shortcuts.len); + QKeySequence** shortcuts_arr = static_cast(shortcuts.data); + for(size_t i = 0; i < shortcuts.len; ++i) { shortcuts_QList.push_back(*(shortcuts_arr[i])); } self->setShortcuts(shortcuts_QList); @@ -218,16 +218,16 @@ void QAction_SetShortcutsWithShortcuts(QAction* self, int shortcuts) { self->setShortcuts(static_cast(shortcuts)); } -struct miqt_array* QAction_Shortcuts(const QAction* self) { +struct miqt_array QAction_Shortcuts(const QAction* self) { QList _ret = self->shortcuts(); // Convert QList<> from C++ memory to manually-managed C memory QKeySequence** _arr = static_cast(malloc(sizeof(QKeySequence*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -321,29 +321,29 @@ QWidget* QAction_ParentWidget(const QAction* self) { return self->parentWidget(); } -struct miqt_array* QAction_AssociatedWidgets(const QAction* self) { +struct miqt_array QAction_AssociatedWidgets(const QAction* self) { QList _ret = self->associatedWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAction_AssociatedGraphicsWidgets(const QAction* self) { +struct miqt_array QAction_AssociatedGraphicsWidgets(const QAction* self) { QList _ret = self->associatedGraphicsWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsWidget** _arr = static_cast(malloc(sizeof(QGraphicsWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qaction.go b/qt/gen_qaction.go index 9bc430d5..57dcad41 100644 --- a/qt/gen_qaction.go +++ b/qt/gen_qaction.go @@ -281,14 +281,12 @@ func (this *QAction) Shortcut() *QKeySequence { } func (this *QAction) SetShortcuts(shortcuts []QKeySequence) { - // For the C ABI, malloc a C array of raw pointers shortcuts_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(shortcuts)))) defer C.free(unsafe.Pointer(shortcuts_CArray)) for i := range shortcuts { shortcuts_CArray[i] = shortcuts[i].cPointer() } - shortcuts_ma := &C.struct_miqt_array{len: C.size_t(len(shortcuts)), data: unsafe.Pointer(shortcuts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(shortcuts_ma)) + shortcuts_ma := C.struct_miqt_array{len: C.size_t(len(shortcuts)), data: unsafe.Pointer(shortcuts_CArray)} C.QAction_SetShortcuts(this.h, shortcuts_ma) } @@ -297,7 +295,7 @@ func (this *QAction) SetShortcutsWithShortcuts(shortcuts QKeySequence__StandardK } func (this *QAction) Shortcuts() []QKeySequence { - var _ma *C.struct_miqt_array = C.QAction_Shortcuts(this.h) + var _ma C.struct_miqt_array = C.QAction_Shortcuts(this.h) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -306,7 +304,6 @@ func (this *QAction) Shortcuts() []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -405,24 +402,22 @@ func (this *QAction) ParentWidget() *QWidget { } func (this *QAction) AssociatedWidgets() []*QWidget { - var _ma *C.struct_miqt_array = C.QAction_AssociatedWidgets(this.h) + var _ma C.struct_miqt_array = C.QAction_AssociatedWidgets(this.h) _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAction) AssociatedGraphicsWidgets() []*QGraphicsWidget { - var _ma *C.struct_miqt_array = C.QAction_AssociatedGraphicsWidgets(this.h) + var _ma C.struct_miqt_array = C.QAction_AssociatedGraphicsWidgets(this.h) _ret := make([]*QGraphicsWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qaction.h b/qt/gen_qaction.h index cc451e35..c5d8b8c1 100644 --- a/qt/gen_qaction.h +++ b/qt/gen_qaction.h @@ -71,9 +71,9 @@ void QAction_SetSeparator(QAction* self, bool b); bool QAction_IsSeparator(const QAction* self); void QAction_SetShortcut(QAction* self, QKeySequence* shortcut); QKeySequence* QAction_Shortcut(const QAction* self); -void QAction_SetShortcuts(QAction* self, struct miqt_array* /* of QKeySequence* */ shortcuts); +void QAction_SetShortcuts(QAction* self, struct miqt_array /* of QKeySequence* */ shortcuts); void QAction_SetShortcutsWithShortcuts(QAction* self, int shortcuts); -struct miqt_array* QAction_Shortcuts(const QAction* self); +struct miqt_array QAction_Shortcuts(const QAction* self); void QAction_SetShortcutContext(QAction* self, int context); int QAction_ShortcutContext(const QAction* self); void QAction_SetAutoRepeat(QAction* self, bool autoRepeat); @@ -96,8 +96,8 @@ bool QAction_IsIconVisibleInMenu(const QAction* self); void QAction_SetShortcutVisibleInContextMenu(QAction* self, bool show); bool QAction_IsShortcutVisibleInContextMenu(const QAction* self); QWidget* QAction_ParentWidget(const QAction* self); -struct miqt_array* QAction_AssociatedWidgets(const QAction* self); -struct miqt_array* QAction_AssociatedGraphicsWidgets(const QAction* self); +struct miqt_array QAction_AssociatedWidgets(const QAction* self); +struct miqt_array QAction_AssociatedGraphicsWidgets(const QAction* self); void QAction_Trigger(QAction* self); void QAction_Hover(QAction* self); void QAction_SetChecked(QAction* self, bool checked); diff --git a/qt/gen_qactiongroup.cpp b/qt/gen_qactiongroup.cpp index abcd5485..c01cb599 100644 --- a/qt/gen_qactiongroup.cpp +++ b/qt/gen_qactiongroup.cpp @@ -63,16 +63,16 @@ void QActionGroup_RemoveAction(QActionGroup* self, QAction* a) { self->removeAction(a); } -struct miqt_array* QActionGroup_Actions(const QActionGroup* self) { +struct miqt_array QActionGroup_Actions(const QActionGroup* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qactiongroup.go b/qt/gen_qactiongroup.go index 3321aa54..96f28d22 100644 --- a/qt/gen_qactiongroup.go +++ b/qt/gen_qactiongroup.go @@ -111,13 +111,12 @@ func (this *QActionGroup) RemoveAction(a *QAction) { } func (this *QActionGroup) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QActionGroup_Actions(this.h) + var _ma C.struct_miqt_array = C.QActionGroup_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qactiongroup.h b/qt/gen_qactiongroup.h index 12740220..5aaaa3d3 100644 --- a/qt/gen_qactiongroup.h +++ b/qt/gen_qactiongroup.h @@ -36,7 +36,7 @@ QAction* QActionGroup_AddAction(QActionGroup* self, QAction* a); QAction* QActionGroup_AddActionWithText(QActionGroup* self, struct miqt_string text); QAction* QActionGroup_AddAction2(QActionGroup* self, QIcon* icon, struct miqt_string text); void QActionGroup_RemoveAction(QActionGroup* self, QAction* a); -struct miqt_array* QActionGroup_Actions(const QActionGroup* self); +struct miqt_array QActionGroup_Actions(const QActionGroup* self); QAction* QActionGroup_CheckedAction(const QActionGroup* self); bool QActionGroup_IsExclusive(const QActionGroup* self); bool QActionGroup_IsEnabled(const QActionGroup* self); diff --git a/qt/gen_qapplication.cpp b/qt/gen_qapplication.cpp index 2fdf2f62..fb22923f 100644 --- a/qt/gen_qapplication.cpp +++ b/qt/gen_qapplication.cpp @@ -118,29 +118,29 @@ QIcon* QApplication_WindowIcon() { return new QIcon(QApplication::windowIcon()); } -struct miqt_array* QApplication_AllWidgets() { +struct miqt_array QApplication_AllWidgets() { QWidgetList _ret = QApplication::allWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QApplication_TopLevelWidgets() { +struct miqt_array QApplication_TopLevelWidgets() { QWidgetList _ret = QApplication::topLevelWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qapplication.go b/qt/gen_qapplication.go index d3db4ff9..7b10b2fd 100644 --- a/qt/gen_qapplication.go +++ b/qt/gen_qapplication.go @@ -196,24 +196,22 @@ func QApplication_WindowIcon() *QIcon { } func QApplication_AllWidgets() []*QWidget { - var _ma *C.struct_miqt_array = C.QApplication_AllWidgets() + var _ma C.struct_miqt_array = C.QApplication_AllWidgets() _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QApplication_TopLevelWidgets() []*QWidget { - var _ma *C.struct_miqt_array = C.QApplication_TopLevelWidgets() + var _ma C.struct_miqt_array = C.QApplication_TopLevelWidgets() _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qapplication.h b/qt/gen_qapplication.h index b9bf2827..d089db34 100644 --- a/qt/gen_qapplication.h +++ b/qt/gen_qapplication.h @@ -64,8 +64,8 @@ void QApplication_SetFont(QFont* param1); QFontMetrics* QApplication_FontMetrics(); void QApplication_SetWindowIcon(QIcon* icon); QIcon* QApplication_WindowIcon(); -struct miqt_array* QApplication_AllWidgets(); -struct miqt_array* QApplication_TopLevelWidgets(); +struct miqt_array QApplication_AllWidgets(); +struct miqt_array QApplication_TopLevelWidgets(); QDesktopWidget* QApplication_Desktop(); QWidget* QApplication_ActivePopupWidget(); QWidget* QApplication_ActiveModalWidget(); diff --git a/qt/gen_qbuttongroup.cpp b/qt/gen_qbuttongroup.cpp index d38997e0..99f07520 100644 --- a/qt/gen_qbuttongroup.cpp +++ b/qt/gen_qbuttongroup.cpp @@ -64,16 +64,16 @@ void QButtonGroup_RemoveButton(QButtonGroup* self, QAbstractButton* param1) { self->removeButton(param1); } -struct miqt_array* QButtonGroup_Buttons(const QButtonGroup* self) { +struct miqt_array QButtonGroup_Buttons(const QButtonGroup* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qbuttongroup.go b/qt/gen_qbuttongroup.go index 1ac95b77..ed175119 100644 --- a/qt/gen_qbuttongroup.go +++ b/qt/gen_qbuttongroup.go @@ -101,13 +101,12 @@ func (this *QButtonGroup) RemoveButton(param1 *QAbstractButton) { } func (this *QButtonGroup) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QButtonGroup_Buttons(this.h) + var _ma C.struct_miqt_array = C.QButtonGroup_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qbuttongroup.h b/qt/gen_qbuttongroup.h index 1e2fde9a..b4a27c95 100644 --- a/qt/gen_qbuttongroup.h +++ b/qt/gen_qbuttongroup.h @@ -35,7 +35,7 @@ void QButtonGroup_SetExclusive(QButtonGroup* self, bool exclusive); bool QButtonGroup_Exclusive(const QButtonGroup* self); void QButtonGroup_AddButton(QButtonGroup* self, QAbstractButton* param1); void QButtonGroup_RemoveButton(QButtonGroup* self, QAbstractButton* param1); -struct miqt_array* QButtonGroup_Buttons(const QButtonGroup* self); +struct miqt_array QButtonGroup_Buttons(const QButtonGroup* self); QAbstractButton* QButtonGroup_CheckedButton(const QButtonGroup* self); QAbstractButton* QButtonGroup_Button(const QButtonGroup* self, int id); void QButtonGroup_SetId(QButtonGroup* self, QAbstractButton* button, int id); diff --git a/qt/gen_qcalendar.cpp b/qt/gen_qcalendar.cpp index c662a6f2..38a5828d 100644 --- a/qt/gen_qcalendar.cpp +++ b/qt/gen_qcalendar.cpp @@ -149,7 +149,7 @@ struct miqt_string QCalendar_StandaloneWeekDayName(const QCalendar* self, QLocal return _ms; } -struct miqt_array* QCalendar_AvailableCalendars() { +struct miqt_array QCalendar_AvailableCalendars() { QStringList _ret = QCalendar::availableCalendars(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -163,9 +163,9 @@ struct miqt_array* QCalendar_AvailableCalendars() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcalendar.go b/qt/gen_qcalendar.go index 05810be5..6f06c112 100644 --- a/qt/gen_qcalendar.go +++ b/qt/gen_qcalendar.go @@ -193,7 +193,7 @@ func (this *QCalendar) StandaloneWeekDayName(locale *QLocale, day int) string { } func QCalendar_AvailableCalendars() []string { - var _ma *C.struct_miqt_array = C.QCalendar_AvailableCalendars() + var _ma C.struct_miqt_array = C.QCalendar_AvailableCalendars() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -202,7 +202,6 @@ func QCalendar_AvailableCalendars() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcalendar.h b/qt/gen_qcalendar.h index 98ab313f..d57fa991 100644 --- a/qt/gen_qcalendar.h +++ b/qt/gen_qcalendar.h @@ -55,7 +55,7 @@ struct miqt_string QCalendar_MonthName(const QCalendar* self, QLocale* locale, i struct miqt_string QCalendar_StandaloneMonthName(const QCalendar* self, QLocale* locale, int month); struct miqt_string QCalendar_WeekDayName(const QCalendar* self, QLocale* locale, int day); struct miqt_string QCalendar_StandaloneWeekDayName(const QCalendar* self, QLocale* locale, int day); -struct miqt_array* QCalendar_AvailableCalendars(); +struct miqt_array QCalendar_AvailableCalendars(); int QCalendar_DaysInMonth2(const QCalendar* self, int month, int year); struct miqt_string QCalendar_MonthName3(const QCalendar* self, QLocale* locale, int month, int year); struct miqt_string QCalendar_MonthName4(const QCalendar* self, QLocale* locale, int month, int year, int format); diff --git a/qt/gen_qcalendarwidget.cpp b/qt/gen_qcalendarwidget.cpp index 9062ae63..0a901a64 100644 --- a/qt/gen_qcalendarwidget.cpp +++ b/qt/gen_qcalendarwidget.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,24 @@ void QCalendarWidget_SetWeekdayTextFormat(QCalendarWidget* self, int dayOfWeek, self->setWeekdayTextFormat(static_cast(dayOfWeek), *format); } +struct miqt_map QCalendarWidget_DateTextFormat(const QCalendarWidget* self) { + QMap _ret = self->dateTextFormat(); + // Convert QMap<> from C++ memory to manually-managed C memory + QDate** _karr = static_cast(malloc(sizeof(QDate*) * _ret.size())); + QTextCharFormat** _varr = static_cast(malloc(sizeof(QTextCharFormat*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = new QDate(_itr->first); + _varr[_ctr] = new QTextCharFormat(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QTextCharFormat* QCalendarWidget_DateTextFormatWithDate(const QCalendarWidget* self, QDate* date) { return new QTextCharFormat(self->dateTextFormat(*date)); } diff --git a/qt/gen_qcalendarwidget.go b/qt/gen_qcalendarwidget.go index 92679a08..e359da01 100644 --- a/qt/gen_qcalendarwidget.go +++ b/qt/gen_qcalendarwidget.go @@ -231,6 +231,27 @@ func (this *QCalendarWidget) SetWeekdayTextFormat(dayOfWeek DayOfWeek, format *Q C.QCalendarWidget_SetWeekdayTextFormat(this.h, (C.int)(dayOfWeek), format.cPointer()) } +func (this *QCalendarWidget) DateTextFormat() map[QDate]QTextCharFormat { + var _mm C.struct_miqt_map = C.QCalendarWidget_DateTextFormat(this.h) + _ret := make(map[QDate]QTextCharFormat, int(_mm.len)) + _Keys := (*[0xffff]*C.QDate)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QTextCharFormat)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _mapkey_ret := _Keys[i] + _mapkey_goptr := newQDate(_mapkey_ret) + _mapkey_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Key := *_mapkey_goptr + + _mapval_ret := _Values[i] + _mapval_goptr := newQTextCharFormat(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QCalendarWidget) DateTextFormatWithDate(date *QDate) *QTextCharFormat { _ret := C.QCalendarWidget_DateTextFormatWithDate(this.h, date.cPointer()) _goptr := newQTextCharFormat(_ret) diff --git a/qt/gen_qcalendarwidget.h b/qt/gen_qcalendarwidget.h index 1d1d2047..7b2f4d8d 100644 --- a/qt/gen_qcalendarwidget.h +++ b/qt/gen_qcalendarwidget.h @@ -62,6 +62,7 @@ QTextCharFormat* QCalendarWidget_HeaderTextFormat(const QCalendarWidget* self); void QCalendarWidget_SetHeaderTextFormat(QCalendarWidget* self, QTextCharFormat* format); QTextCharFormat* QCalendarWidget_WeekdayTextFormat(const QCalendarWidget* self, int dayOfWeek); void QCalendarWidget_SetWeekdayTextFormat(QCalendarWidget* self, int dayOfWeek, QTextCharFormat* format); +struct miqt_map QCalendarWidget_DateTextFormat(const QCalendarWidget* self); QTextCharFormat* QCalendarWidget_DateTextFormatWithDate(const QCalendarWidget* self, QDate* date); void QCalendarWidget_SetDateTextFormat(QCalendarWidget* self, QDate* date, QTextCharFormat* format); bool QCalendarWidget_IsDateEditEnabled(const QCalendarWidget* self); diff --git a/qt/gen_qcborarray.cpp b/qt/gen_qcborarray.cpp index bd859857..36e37a97 100644 --- a/qt/gen_qcborarray.cpp +++ b/qt/gen_qcborarray.cpp @@ -221,11 +221,11 @@ QCborArray* QCborArray_OperatorShiftLeft(QCborArray* self, QCborValue* v) { return &_ret; } -QCborArray* QCborArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list) { +QCborArray* QCborArray_FromStringList(struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } diff --git a/qt/gen_qcborarray.go b/qt/gen_qcborarray.go index 01654287..9caa531b 100644 --- a/qt/gen_qcborarray.go +++ b/qt/gen_qcborarray.go @@ -329,7 +329,6 @@ func (this *QCborArray) OperatorShiftLeft(v *QCborValue) *QCborArray { } func QCborArray_FromStringList(list []string) *QCborArray { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -339,8 +338,7 @@ func QCborArray_FromStringList(list []string) *QCborArray { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} _ret := C.QCborArray_FromStringList(list_ma) _goptr := newQCborArray(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt/gen_qcborarray.h b/qt/gen_qcborarray.h index 8307b0a6..f0b017ec 100644 --- a/qt/gen_qcborarray.h +++ b/qt/gen_qcborarray.h @@ -88,7 +88,7 @@ bool QCborArray_Empty(const QCborArray* self); QCborArray* QCborArray_OperatorPlus(const QCborArray* self, QCborValue* v); QCborArray* QCborArray_OperatorPlusAssign(QCborArray* self, QCborValue* v); QCborArray* QCborArray_OperatorShiftLeft(QCborArray* self, QCborValue* v); -QCborArray* QCborArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list); +QCborArray* QCborArray_FromStringList(struct miqt_array /* of struct miqt_string */ list); QCborArray* QCborArray_FromJsonArray(QJsonArray* array); QJsonArray* QCborArray_ToJsonArray(const QCborArray* self); void QCborArray_Delete(QCborArray* self); diff --git a/qt/gen_qcbormap.cpp b/qt/gen_qcbormap.cpp index b278e9e6..01c071c7 100644 --- a/qt/gen_qcbormap.cpp +++ b/qt/gen_qcbormap.cpp @@ -5,9 +5,11 @@ #include #include #include +#include #include #include #include +#include #include #include "gen_qcbormap.h" #include "_cgo_export.h" @@ -45,16 +47,16 @@ void QCborMap_Clear(QCborMap* self) { self->clear(); } -struct miqt_array* QCborMap_Keys(const QCborMap* self) { +struct miqt_array QCborMap_Keys(const QCborMap* self) { QVector _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory QCborValue** _arr = static_cast(malloc(sizeof(QCborValue*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QCborValue(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -256,10 +258,83 @@ QCborMap__Iterator* QCborMap_Insert4(QCborMap* self, QCborValue* key, QCborValue return new QCborMap::Iterator(self->insert(*key, *value_)); } +QCborMap* QCborMap_FromVariantMap(struct miqt_map mapVal) { + QVariantMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QCborMap(QCborMap::fromVariantMap(mapVal_QMap)); +} + +QCborMap* QCborMap_FromVariantHash(struct miqt_map hash) { + QVariantHash hash_QMap; + hash_QMap.reserve(hash.len); + struct miqt_string* hash_karr = static_cast(hash.keys); + QVariant** hash_varr = static_cast(hash.values); + for(size_t i = 0; i < hash.len; ++i) { + QString hash_karr_i_QString = QString::fromUtf8(hash_karr[i].data, hash_karr[i].len); + hash_QMap[hash_karr_i_QString] = *(hash_varr[i]); + } + return new QCborMap(QCborMap::fromVariantHash(hash_QMap)); +} + QCborMap* QCborMap_FromJsonObject(QJsonObject* o) { return new QCborMap(QCborMap::fromJsonObject(*o)); } +struct miqt_map QCborMap_ToVariantMap(const QCborMap* self) { + QVariantMap _ret = self->toVariantMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_map QCborMap_ToVariantHash(const QCborMap* self) { + QVariantHash _ret = self->toVariantHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QJsonObject* QCborMap_ToJsonObject(const QCborMap* self) { return new QJsonObject(self->toJsonObject()); } diff --git a/qt/gen_qcbormap.go b/qt/gen_qcbormap.go index aa80227e..7348b390 100644 --- a/qt/gen_qcbormap.go +++ b/qt/gen_qcbormap.go @@ -82,7 +82,7 @@ func (this *QCborMap) Clear() { } func (this *QCborMap) Keys() []QCborValue { - var _ma *C.struct_miqt_array = C.QCborMap_Keys(this.h) + var _ma C.struct_miqt_array = C.QCborMap_Keys(this.h) _ret := make([]QCborValue, int(_ma.len)) _outCast := (*[0xffff]*C.QCborValue)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -91,7 +91,6 @@ func (this *QCborMap) Keys() []QCborValue { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -431,6 +430,58 @@ func (this *QCborMap) Insert4(key *QCborValue, value_ *QCborValue) *QCborMap__It return _goptr } +func QCborMap_FromVariantMap(mapVal map[string]QVariant) *QCborMap { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QCborMap_FromVariantMap(mapVal_mm) + _goptr := newQCborMap(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func QCborMap_FromVariantHash(hash map[string]QVariant) *QCborMap { + hash_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(hash)))) + defer C.free(unsafe.Pointer(hash_Keys_CArray)) + hash_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(hash)))) + defer C.free(unsafe.Pointer(hash_Values_CArray)) + hash_ctr := 0 + for hash_k, hash_v := range hash { + hash_k_ms := C.struct_miqt_string{} + hash_k_ms.data = C.CString(hash_k) + hash_k_ms.len = C.size_t(len(hash_k)) + defer C.free(unsafe.Pointer(hash_k_ms.data)) + hash_Keys_CArray[hash_ctr] = hash_k_ms + hash_Values_CArray[hash_ctr] = hash_v.cPointer() + hash_ctr++ + } + hash_mm := C.struct_miqt_map{ + len: C.size_t(len(hash)), + keys: unsafe.Pointer(hash_Keys_CArray), + values: unsafe.Pointer(hash_Values_CArray), + } + _ret := C.QCborMap_FromVariantHash(hash_mm) + _goptr := newQCborMap(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + func QCborMap_FromJsonObject(o *QJsonObject) *QCborMap { _ret := C.QCborMap_FromJsonObject(o.cPointer()) _goptr := newQCborMap(_ret) @@ -438,6 +489,46 @@ func QCborMap_FromJsonObject(o *QJsonObject) *QCborMap { return _goptr } +func (this *QCborMap) ToVariantMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QCborMap_ToVariantMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QCborMap) ToVariantHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QCborMap_ToVariantHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QCborMap) ToJsonObject() *QJsonObject { _ret := C.QCborMap_ToJsonObject(this.h) _goptr := newQJsonObject(_ret) diff --git a/qt/gen_qcbormap.h b/qt/gen_qcbormap.h index 88a84d67..ceb3db7a 100644 --- a/qt/gen_qcbormap.h +++ b/qt/gen_qcbormap.h @@ -28,6 +28,7 @@ class QCborMap__Iterator; class QCborValue; class QCborValueRef; class QJsonObject; +class QVariant; #else typedef struct QCborMap QCborMap; typedef struct QCborMap__ConstIterator QCborMap__ConstIterator; @@ -35,6 +36,7 @@ typedef struct QCborMap__Iterator QCborMap__Iterator; typedef struct QCborValue QCborValue; typedef struct QCborValueRef QCborValueRef; typedef struct QJsonObject QJsonObject; +typedef struct QVariant QVariant; #endif QCborMap* QCborMap_new(); @@ -45,7 +47,7 @@ QCborValue* QCborMap_ToCborValue(const QCborMap* self); ptrdiff_t QCborMap_Size(const QCborMap* self); bool QCborMap_IsEmpty(const QCborMap* self); void QCborMap_Clear(QCborMap* self); -struct miqt_array* QCborMap_Keys(const QCborMap* self); +struct miqt_array QCborMap_Keys(const QCborMap* self); QCborValue* QCborMap_Value(const QCborMap* self, long long key); QCborValue* QCborMap_Value2(const QCborMap* self, struct miqt_string key); QCborValue* QCborMap_Value3(const QCborMap* self, QCborValue* key); @@ -93,7 +95,11 @@ QCborMap__ConstIterator* QCborMap_Find7(const QCborMap* self, QCborValue* key); QCborMap__Iterator* QCborMap_Insert(QCborMap* self, long long key, QCborValue* value_); QCborMap__Iterator* QCborMap_Insert3(QCborMap* self, struct miqt_string key, QCborValue* value_); QCborMap__Iterator* QCborMap_Insert4(QCborMap* self, QCborValue* key, QCborValue* value_); +QCborMap* QCborMap_FromVariantMap(struct miqt_map mapVal); +QCborMap* QCborMap_FromVariantHash(struct miqt_map hash); QCborMap* QCborMap_FromJsonObject(QJsonObject* o); +struct miqt_map QCborMap_ToVariantMap(const QCborMap* self); +struct miqt_map QCborMap_ToVariantHash(const QCborMap* self); QJsonObject* QCborMap_ToJsonObject(const QCborMap* self); void QCborMap_Delete(QCborMap* self); diff --git a/qt/gen_qcolor.cpp b/qt/gen_qcolor.cpp index f2183f5f..59730269 100644 --- a/qt/gen_qcolor.cpp +++ b/qt/gen_qcolor.cpp @@ -96,7 +96,7 @@ void QColor_SetNamedColor(QColor* self, struct miqt_string name) { self->setNamedColor(name_QString); } -struct miqt_array* QColor_ColorNames() { +struct miqt_array QColor_ColorNames() { QStringList _ret = QColor::colorNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -110,9 +110,9 @@ struct miqt_array* QColor_ColorNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcolor.go b/qt/gen_qcolor.go index 24e5166b..c1df8b33 100644 --- a/qt/gen_qcolor.go +++ b/qt/gen_qcolor.go @@ -173,7 +173,7 @@ func (this *QColor) SetNamedColor(name string) { } func QColor_ColorNames() []string { - var _ma *C.struct_miqt_array = C.QColor_ColorNames() + var _ma C.struct_miqt_array = C.QColor_ColorNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -182,7 +182,6 @@ func QColor_ColorNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcolor.h b/qt/gen_qcolor.h index 23973ce9..ef70bea4 100644 --- a/qt/gen_qcolor.h +++ b/qt/gen_qcolor.h @@ -39,7 +39,7 @@ bool QColor_IsValid(const QColor* self); struct miqt_string QColor_Name(const QColor* self); struct miqt_string QColor_NameWithFormat(const QColor* self, int format); void QColor_SetNamedColor(QColor* self, struct miqt_string name); -struct miqt_array* QColor_ColorNames(); +struct miqt_array QColor_ColorNames(); int QColor_Spec(const QColor* self); int QColor_Alpha(const QColor* self); void QColor_SetAlpha(QColor* self, int alpha); diff --git a/qt/gen_qcolormap.cpp b/qt/gen_qcolormap.cpp index ba436556..cd0435c0 100644 --- a/qt/gen_qcolormap.cpp +++ b/qt/gen_qcolormap.cpp @@ -47,16 +47,16 @@ QColor* QColormap_ColorAt(const QColormap* self, unsigned int pixel) { return new QColor(self->colorAt(static_cast(pixel))); } -struct miqt_array* QColormap_Colormap(const QColormap* self) { +struct miqt_array QColormap_Colormap(const QColormap* self) { const QVector _ret = self->colormap(); // Convert QList<> from C++ memory to manually-managed C memory QColor** _arr = static_cast(malloc(sizeof(QColor*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QColor(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcolormap.go b/qt/gen_qcolormap.go index ee62f7eb..2e77525a 100644 --- a/qt/gen_qcolormap.go +++ b/qt/gen_qcolormap.go @@ -99,7 +99,7 @@ func (this *QColormap) ColorAt(pixel uint) *QColor { } func (this *QColormap) Colormap() []QColor { - var _ma *C.struct_miqt_array = C.QColormap_Colormap(this.h) + var _ma C.struct_miqt_array = C.QColormap_Colormap(this.h) _ret := make([]QColor, int(_ma.len)) _outCast := (*[0xffff]*C.QColor)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -108,7 +108,6 @@ func (this *QColormap) Colormap() []QColor { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcolormap.h b/qt/gen_qcolormap.h index f04e5257..980e81d9 100644 --- a/qt/gen_qcolormap.h +++ b/qt/gen_qcolormap.h @@ -31,7 +31,7 @@ int QColormap_Depth(const QColormap* self); int QColormap_Size(const QColormap* self); unsigned int QColormap_Pixel(const QColormap* self, QColor* color); QColor* QColormap_ColorAt(const QColormap* self, unsigned int pixel); -struct miqt_array* QColormap_Colormap(const QColormap* self); +struct miqt_array QColormap_Colormap(const QColormap* self); QColormap* QColormap_Instance1(int screen); void QColormap_Delete(QColormap* self); diff --git a/qt/gen_qcolumnview.cpp b/qt/gen_qcolumnview.cpp index 03d99e18..925a829f 100644 --- a/qt/gen_qcolumnview.cpp +++ b/qt/gen_qcolumnview.cpp @@ -114,26 +114,26 @@ void QColumnView_SetPreviewWidget(QColumnView* self, QWidget* widget) { self->setPreviewWidget(widget); } -void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array* /* of int */ list) { +void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array /* of int */ list) { QList list_QList; - list_QList.reserve(list->len); - int* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + int* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(static_cast(list_arr[i])); } self->setColumnWidths(list_QList); } -struct miqt_array* QColumnView_ColumnWidths(const QColumnView* self) { +struct miqt_array QColumnView_ColumnWidths(const QColumnView* self) { QList _ret = self->columnWidths(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcolumnview.go b/qt/gen_qcolumnview.go index 90bc7ff9..10555647 100644 --- a/qt/gen_qcolumnview.go +++ b/qt/gen_qcolumnview.go @@ -162,25 +162,22 @@ func (this *QColumnView) SetPreviewWidget(widget *QWidget) { } func (this *QColumnView) SetColumnWidths(list []int) { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = (C.int)(list[i]) } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QColumnView_SetColumnWidths(this.h, list_ma) } func (this *QColumnView) ColumnWidths() []int { - var _ma *C.struct_miqt_array = C.QColumnView_ColumnWidths(this.h) + var _ma C.struct_miqt_array = C.QColumnView_ColumnWidths(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcolumnview.h b/qt/gen_qcolumnview.h index 03f94d8d..08aa0f22 100644 --- a/qt/gen_qcolumnview.h +++ b/qt/gen_qcolumnview.h @@ -55,8 +55,8 @@ void QColumnView_SetResizeGripsVisible(QColumnView* self, bool visible); bool QColumnView_ResizeGripsVisible(const QColumnView* self); QWidget* QColumnView_PreviewWidget(const QColumnView* self); void QColumnView_SetPreviewWidget(QColumnView* self, QWidget* widget); -void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array* /* of int */ list); -struct miqt_array* QColumnView_ColumnWidths(const QColumnView* self); +void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array /* of int */ list); +struct miqt_array QColumnView_ColumnWidths(const QColumnView* self); struct miqt_string QColumnView_Tr2(const char* s, const char* c); struct miqt_string QColumnView_Tr3(const char* s, const char* c, int n); struct miqt_string QColumnView_TrUtf82(const char* s, const char* c); diff --git a/qt/gen_qcombobox.cpp b/qt/gen_qcombobox.cpp index d1a52ce5..6417ca58 100644 --- a/qt/gen_qcombobox.cpp +++ b/qt/gen_qcombobox.cpp @@ -282,11 +282,11 @@ void QComboBox_AddItem2(QComboBox* self, QIcon* icon, struct miqt_string text) { self->addItem(*icon, text_QString); } -void QComboBox_AddItems(QComboBox* self, struct miqt_array* /* of struct miqt_string */ texts) { +void QComboBox_AddItems(QComboBox* self, struct miqt_array /* of struct miqt_string */ texts) { QStringList texts_QList; - texts_QList.reserve(texts->len); - struct miqt_string* texts_arr = static_cast(texts->data); - for(size_t i = 0; i < texts->len; ++i) { + texts_QList.reserve(texts.len); + struct miqt_string* texts_arr = static_cast(texts.data); + for(size_t i = 0; i < texts.len; ++i) { QString texts_arr_i_QString = QString::fromUtf8(texts_arr[i].data, texts_arr[i].len); texts_QList.push_back(texts_arr_i_QString); } @@ -303,11 +303,11 @@ void QComboBox_InsertItem2(QComboBox* self, int index, QIcon* icon, struct miqt_ self->insertItem(static_cast(index), *icon, text_QString); } -void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array* /* of struct miqt_string */ texts) { +void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array /* of struct miqt_string */ texts) { QStringList texts_QList; - texts_QList.reserve(texts->len); - struct miqt_string* texts_arr = static_cast(texts->data); - for(size_t i = 0; i < texts->len; ++i) { + texts_QList.reserve(texts.len); + struct miqt_string* texts_arr = static_cast(texts.data); + for(size_t i = 0; i < texts.len; ++i) { QString texts_arr_i_QString = QString::fromUtf8(texts_arr[i].data, texts_arr[i].len); texts_QList.push_back(texts_arr_i_QString); } diff --git a/qt/gen_qcombobox.go b/qt/gen_qcombobox.go index da901e96..0a449079 100644 --- a/qt/gen_qcombobox.go +++ b/qt/gen_qcombobox.go @@ -342,7 +342,6 @@ func (this *QComboBox) AddItem2(icon *QIcon, text string) { } func (this *QComboBox) AddItems(texts []string) { - // For the C ABI, malloc a C array of structs texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts)))) defer C.free(unsafe.Pointer(texts_CArray)) for i := range texts { @@ -352,8 +351,7 @@ func (this *QComboBox) AddItems(texts []string) { defer C.free(unsafe.Pointer(texts_i_ms.data)) texts_CArray[i] = texts_i_ms } - texts_ma := &C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(texts_ma)) + texts_ma := C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} C.QComboBox_AddItems(this.h, texts_ma) } @@ -374,7 +372,6 @@ func (this *QComboBox) InsertItem2(index int, icon *QIcon, text string) { } func (this *QComboBox) InsertItems(index int, texts []string) { - // For the C ABI, malloc a C array of structs texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts)))) defer C.free(unsafe.Pointer(texts_CArray)) for i := range texts { @@ -384,8 +381,7 @@ func (this *QComboBox) InsertItems(index int, texts []string) { defer C.free(unsafe.Pointer(texts_i_ms.data)) texts_CArray[i] = texts_i_ms } - texts_ma := &C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(texts_ma)) + texts_ma := C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} C.QComboBox_InsertItems(this.h, (C.int)(index), texts_ma) } diff --git a/qt/gen_qcombobox.h b/qt/gen_qcombobox.h index 7defe6ec..e682f042 100644 --- a/qt/gen_qcombobox.h +++ b/qt/gen_qcombobox.h @@ -100,10 +100,10 @@ QIcon* QComboBox_ItemIcon(const QComboBox* self, int index); QVariant* QComboBox_ItemData(const QComboBox* self, int index); void QComboBox_AddItem(QComboBox* self, struct miqt_string text); void QComboBox_AddItem2(QComboBox* self, QIcon* icon, struct miqt_string text); -void QComboBox_AddItems(QComboBox* self, struct miqt_array* /* of struct miqt_string */ texts); +void QComboBox_AddItems(QComboBox* self, struct miqt_array /* of struct miqt_string */ texts); void QComboBox_InsertItem(QComboBox* self, int index, struct miqt_string text); void QComboBox_InsertItem2(QComboBox* self, int index, QIcon* icon, struct miqt_string text); -void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array* /* of struct miqt_string */ texts); +void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array /* of struct miqt_string */ texts); void QComboBox_InsertSeparator(QComboBox* self, int index); void QComboBox_RemoveItem(QComboBox* self, int index); void QComboBox_SetItemText(QComboBox* self, int index, struct miqt_string text); diff --git a/qt/gen_qcommandlineoption.cpp b/qt/gen_qcommandlineoption.cpp index 5f03d558..9043b011 100644 --- a/qt/gen_qcommandlineoption.cpp +++ b/qt/gen_qcommandlineoption.cpp @@ -12,11 +12,11 @@ QCommandLineOption* QCommandLineOption_new(struct miqt_string name) { return new QCommandLineOption(name_QString); } -QCommandLineOption* QCommandLineOption_new2(struct miqt_array* /* of struct miqt_string */ names) { +QCommandLineOption* QCommandLineOption_new2(struct miqt_array /* of struct miqt_string */ names) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -29,11 +29,11 @@ QCommandLineOption* QCommandLineOption_new3(struct miqt_string name, struct miqt return new QCommandLineOption(name_QString, description_QString); } -QCommandLineOption* QCommandLineOption_new4(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description) { +QCommandLineOption* QCommandLineOption_new4(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -60,11 +60,11 @@ QCommandLineOption* QCommandLineOption_new7(struct miqt_string name, struct miqt return new QCommandLineOption(name_QString, description_QString, valueName_QString, defaultValue_QString); } -QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName) { +QCommandLineOption* QCommandLineOption_new8(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -73,11 +73,11 @@ QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt return new QCommandLineOption(names_QList, description_QString, valueName_QString); } -QCommandLineOption* QCommandLineOption_new9(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue) { +QCommandLineOption* QCommandLineOption_new9(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -95,7 +95,7 @@ void QCommandLineOption_Swap(QCommandLineOption* self, QCommandLineOption* other self->swap(*other); } -struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self) { +struct miqt_array QCommandLineOption_Names(const QCommandLineOption* self) { QStringList _ret = self->names(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -109,9 +109,9 @@ struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -152,18 +152,18 @@ void QCommandLineOption_SetDefaultValue(QCommandLineOption* self, struct miqt_st self->setDefaultValue(defaultValue_QString); } -void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array* /* of struct miqt_string */ defaultValues) { +void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array /* of struct miqt_string */ defaultValues) { QStringList defaultValues_QList; - defaultValues_QList.reserve(defaultValues->len); - struct miqt_string* defaultValues_arr = static_cast(defaultValues->data); - for(size_t i = 0; i < defaultValues->len; ++i) { + defaultValues_QList.reserve(defaultValues.len); + struct miqt_string* defaultValues_arr = static_cast(defaultValues.data); + for(size_t i = 0; i < defaultValues.len; ++i) { QString defaultValues_arr_i_QString = QString::fromUtf8(defaultValues_arr[i].data, defaultValues_arr[i].len); defaultValues_QList.push_back(defaultValues_arr_i_QString); } self->setDefaultValues(defaultValues_QList); } -struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* self) { +struct miqt_array QCommandLineOption_DefaultValues(const QCommandLineOption* self) { QStringList _ret = self->defaultValues(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -177,9 +177,9 @@ struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* se memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcommandlineoption.go b/qt/gen_qcommandlineoption.go index 0120734b..58bc4783 100644 --- a/qt/gen_qcommandlineoption.go +++ b/qt/gen_qcommandlineoption.go @@ -61,7 +61,6 @@ func NewQCommandLineOption(name string) *QCommandLineOption { // NewQCommandLineOption2 constructs a new QCommandLineOption object. func NewQCommandLineOption2(names []string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -71,8 +70,7 @@ func NewQCommandLineOption2(names []string) *QCommandLineOption { defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} ret := C.QCommandLineOption_new2(names_ma) return newQCommandLineOption(ret) } @@ -93,7 +91,6 @@ func NewQCommandLineOption3(name string, description string) *QCommandLineOption // NewQCommandLineOption4 constructs a new QCommandLineOption object. func NewQCommandLineOption4(names []string, description string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -103,8 +100,7 @@ func NewQCommandLineOption4(names []string, description string) *QCommandLineOpt defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -161,7 +157,6 @@ func NewQCommandLineOption7(name string, description string, valueName string, d // NewQCommandLineOption8 constructs a new QCommandLineOption object. func NewQCommandLineOption8(names []string, description string, valueName string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -171,8 +166,7 @@ func NewQCommandLineOption8(names []string, description string, valueName string defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -187,7 +181,6 @@ func NewQCommandLineOption8(names []string, description string, valueName string // NewQCommandLineOption9 constructs a new QCommandLineOption object. func NewQCommandLineOption9(names []string, description string, valueName string, defaultValue string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -197,8 +190,7 @@ func NewQCommandLineOption9(names []string, description string, valueName string defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -224,7 +216,7 @@ func (this *QCommandLineOption) Swap(other *QCommandLineOption) { } func (this *QCommandLineOption) Names() []string { - var _ma *C.struct_miqt_array = C.QCommandLineOption_Names(this.h) + var _ma C.struct_miqt_array = C.QCommandLineOption_Names(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -233,7 +225,6 @@ func (this *QCommandLineOption) Names() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -276,7 +267,6 @@ func (this *QCommandLineOption) SetDefaultValue(defaultValue string) { } func (this *QCommandLineOption) SetDefaultValues(defaultValues []string) { - // For the C ABI, malloc a C array of structs defaultValues_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(defaultValues)))) defer C.free(unsafe.Pointer(defaultValues_CArray)) for i := range defaultValues { @@ -286,13 +276,12 @@ func (this *QCommandLineOption) SetDefaultValues(defaultValues []string) { defer C.free(unsafe.Pointer(defaultValues_i_ms.data)) defaultValues_CArray[i] = defaultValues_i_ms } - defaultValues_ma := &C.struct_miqt_array{len: C.size_t(len(defaultValues)), data: unsafe.Pointer(defaultValues_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(defaultValues_ma)) + defaultValues_ma := C.struct_miqt_array{len: C.size_t(len(defaultValues)), data: unsafe.Pointer(defaultValues_CArray)} C.QCommandLineOption_SetDefaultValues(this.h, defaultValues_ma) } func (this *QCommandLineOption) DefaultValues() []string { - var _ma *C.struct_miqt_array = C.QCommandLineOption_DefaultValues(this.h) + var _ma C.struct_miqt_array = C.QCommandLineOption_DefaultValues(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -301,7 +290,6 @@ func (this *QCommandLineOption) DefaultValues() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcommandlineoption.h b/qt/gen_qcommandlineoption.h index 30729765..f4f5047d 100644 --- a/qt/gen_qcommandlineoption.h +++ b/qt/gen_qcommandlineoption.h @@ -20,24 +20,24 @@ typedef struct QCommandLineOption QCommandLineOption; #endif QCommandLineOption* QCommandLineOption_new(struct miqt_string name); -QCommandLineOption* QCommandLineOption_new2(struct miqt_array* /* of struct miqt_string */ names); +QCommandLineOption* QCommandLineOption_new2(struct miqt_array /* of struct miqt_string */ names); QCommandLineOption* QCommandLineOption_new3(struct miqt_string name, struct miqt_string description); -QCommandLineOption* QCommandLineOption_new4(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description); +QCommandLineOption* QCommandLineOption_new4(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description); QCommandLineOption* QCommandLineOption_new5(QCommandLineOption* other); QCommandLineOption* QCommandLineOption_new6(struct miqt_string name, struct miqt_string description, struct miqt_string valueName); QCommandLineOption* QCommandLineOption_new7(struct miqt_string name, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); -QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName); -QCommandLineOption* QCommandLineOption_new9(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); +QCommandLineOption* QCommandLineOption_new8(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName); +QCommandLineOption* QCommandLineOption_new9(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); void QCommandLineOption_OperatorAssign(QCommandLineOption* self, QCommandLineOption* other); void QCommandLineOption_Swap(QCommandLineOption* self, QCommandLineOption* other); -struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self); +struct miqt_array QCommandLineOption_Names(const QCommandLineOption* self); void QCommandLineOption_SetValueName(QCommandLineOption* self, struct miqt_string name); struct miqt_string QCommandLineOption_ValueName(const QCommandLineOption* self); void QCommandLineOption_SetDescription(QCommandLineOption* self, struct miqt_string description); struct miqt_string QCommandLineOption_Description(const QCommandLineOption* self); void QCommandLineOption_SetDefaultValue(QCommandLineOption* self, struct miqt_string defaultValue); -void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array* /* of struct miqt_string */ defaultValues); -struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* self); +void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array /* of struct miqt_string */ defaultValues); +struct miqt_array QCommandLineOption_DefaultValues(const QCommandLineOption* self); int QCommandLineOption_Flags(const QCommandLineOption* self); void QCommandLineOption_SetFlags(QCommandLineOption* self, int aflags); void QCommandLineOption_SetHidden(QCommandLineOption* self, bool hidden); diff --git a/qt/gen_qcommandlineparser.cpp b/qt/gen_qcommandlineparser.cpp index 294fbdd8..1d204c39 100644 --- a/qt/gen_qcommandlineparser.cpp +++ b/qt/gen_qcommandlineparser.cpp @@ -47,11 +47,11 @@ bool QCommandLineParser_AddOption(QCommandLineParser* self, QCommandLineOption* return self->addOption(*commandLineOption); } -bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array* /* of QCommandLineOption* */ options) { +bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array /* of QCommandLineOption* */ options) { QList options_QList; - options_QList.reserve(options->len); - QCommandLineOption** options_arr = static_cast(options->data); - for(size_t i = 0; i < options->len; ++i) { + options_QList.reserve(options.len); + QCommandLineOption** options_arr = static_cast(options.data); + for(size_t i = 0; i < options.len; ++i) { options_QList.push_back(*(options_arr[i])); } return self->addOptions(options_QList); @@ -91,11 +91,11 @@ void QCommandLineParser_ClearPositionalArguments(QCommandLineParser* self) { self->clearPositionalArguments(); } -void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments) { +void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -106,11 +106,11 @@ void QCommandLineParser_ProcessWithApp(QCommandLineParser* self, QCoreApplicatio self->process(*app); } -bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments) { +bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -145,7 +145,7 @@ struct miqt_string QCommandLineParser_Value(const QCommandLineParser* self, stru return _ms; } -struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name) { +struct miqt_array QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name) { QString name_QString = QString::fromUtf8(name.data, name.len); QStringList _ret = self->values(name_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -160,9 +160,9 @@ struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, str memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -181,7 +181,7 @@ struct miqt_string QCommandLineParser_ValueWithOption(const QCommandLineParser* return _ms; } -struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option) { +struct miqt_array QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option) { QStringList _ret = self->values(*option); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -195,13 +195,13 @@ struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_PositionalArguments(const QCommandLineParser* self) { QStringList _ret = self->positionalArguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -215,13 +215,13 @@ struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLinePars memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_OptionNames(const QCommandLineParser* self) { QStringList _ret = self->optionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -235,13 +235,13 @@ struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self) { QStringList _ret = self->unknownOptionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -255,9 +255,9 @@ struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParse memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcommandlineparser.go b/qt/gen_qcommandlineparser.go index 2a9047af..49d4a02b 100644 --- a/qt/gen_qcommandlineparser.go +++ b/qt/gen_qcommandlineparser.go @@ -93,14 +93,12 @@ func (this *QCommandLineParser) AddOption(commandLineOption *QCommandLineOption) } func (this *QCommandLineParser) AddOptions(options []QCommandLineOption) bool { - // For the C ABI, malloc a C array of raw pointers options_CArray := (*[0xffff]*C.QCommandLineOption)(C.malloc(C.size_t(8 * len(options)))) defer C.free(unsafe.Pointer(options_CArray)) for i := range options { options_CArray[i] = options[i].cPointer() } - options_ma := &C.struct_miqt_array{len: C.size_t(len(options)), data: unsafe.Pointer(options_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(options_ma)) + options_ma := C.struct_miqt_array{len: C.size_t(len(options)), data: unsafe.Pointer(options_CArray)} return (bool)(C.QCommandLineParser_AddOptions(this.h, options_ma)) } @@ -150,7 +148,6 @@ func (this *QCommandLineParser) ClearPositionalArguments() { } func (this *QCommandLineParser) Process(arguments []string) { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -160,8 +157,7 @@ func (this *QCommandLineParser) Process(arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QCommandLineParser_Process(this.h, arguments_ma) } @@ -170,7 +166,6 @@ func (this *QCommandLineParser) ProcessWithApp(app *QCoreApplication) { } func (this *QCommandLineParser) Parse(arguments []string) bool { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -180,8 +175,7 @@ func (this *QCommandLineParser) Parse(arguments []string) bool { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (bool)(C.QCommandLineParser_Parse(this.h, arguments_ma)) } @@ -216,7 +210,7 @@ func (this *QCommandLineParser) Values(name string) []string { name_ms.data = C.CString(name) name_ms.len = C.size_t(len(name)) defer C.free(unsafe.Pointer(name_ms.data)) - var _ma *C.struct_miqt_array = C.QCommandLineParser_Values(this.h, name_ms) + var _ma C.struct_miqt_array = C.QCommandLineParser_Values(this.h, name_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -225,7 +219,6 @@ func (this *QCommandLineParser) Values(name string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -241,7 +234,7 @@ func (this *QCommandLineParser) ValueWithOption(option *QCommandLineOption) stri } func (this *QCommandLineParser) ValuesWithOption(option *QCommandLineOption) []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_ValuesWithOption(this.h, option.cPointer()) + var _ma C.struct_miqt_array = C.QCommandLineParser_ValuesWithOption(this.h, option.cPointer()) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -250,12 +243,11 @@ func (this *QCommandLineParser) ValuesWithOption(option *QCommandLineOption) []s C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) PositionalArguments() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_PositionalArguments(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_PositionalArguments(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -264,12 +256,11 @@ func (this *QCommandLineParser) PositionalArguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) OptionNames() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_OptionNames(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_OptionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -278,12 +269,11 @@ func (this *QCommandLineParser) OptionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) UnknownOptionNames() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_UnknownOptionNames(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_UnknownOptionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -292,7 +282,6 @@ func (this *QCommandLineParser) UnknownOptionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcommandlineparser.h b/qt/gen_qcommandlineparser.h index 96b786e8..0f86e3d7 100644 --- a/qt/gen_qcommandlineparser.h +++ b/qt/gen_qcommandlineparser.h @@ -29,26 +29,26 @@ struct miqt_string QCommandLineParser_TrUtf8(const char* sourceText); void QCommandLineParser_SetSingleDashWordOptionMode(QCommandLineParser* self, int parsingMode); void QCommandLineParser_SetOptionsAfterPositionalArgumentsMode(QCommandLineParser* self, int mode); bool QCommandLineParser_AddOption(QCommandLineParser* self, QCommandLineOption* commandLineOption); -bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array* /* of QCommandLineOption* */ options); +bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array /* of QCommandLineOption* */ options); QCommandLineOption* QCommandLineParser_AddVersionOption(QCommandLineParser* self); QCommandLineOption* QCommandLineParser_AddHelpOption(QCommandLineParser* self); void QCommandLineParser_SetApplicationDescription(QCommandLineParser* self, struct miqt_string description); struct miqt_string QCommandLineParser_ApplicationDescription(const QCommandLineParser* self); void QCommandLineParser_AddPositionalArgument(QCommandLineParser* self, struct miqt_string name, struct miqt_string description); void QCommandLineParser_ClearPositionalArguments(QCommandLineParser* self); -void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments); +void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments); void QCommandLineParser_ProcessWithApp(QCommandLineParser* self, QCoreApplication* app); -bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments); +bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments); struct miqt_string QCommandLineParser_ErrorText(const QCommandLineParser* self); bool QCommandLineParser_IsSet(const QCommandLineParser* self, struct miqt_string name); struct miqt_string QCommandLineParser_Value(const QCommandLineParser* self, struct miqt_string name); -struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name); +struct miqt_array QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name); bool QCommandLineParser_IsSetWithOption(const QCommandLineParser* self, QCommandLineOption* option); struct miqt_string QCommandLineParser_ValueWithOption(const QCommandLineParser* self, QCommandLineOption* option); -struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option); -struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLineParser* self); -struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self); -struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option); +struct miqt_array QCommandLineParser_PositionalArguments(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_OptionNames(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self); struct miqt_string QCommandLineParser_HelpText(const QCommandLineParser* self); struct miqt_string QCommandLineParser_Tr2(const char* sourceText, const char* disambiguation); struct miqt_string QCommandLineParser_Tr3(const char* sourceText, const char* disambiguation, int n); diff --git a/qt/gen_qcompleter.cpp b/qt/gen_qcompleter.cpp index 7aa70132..eb11aa20 100644 --- a/qt/gen_qcompleter.cpp +++ b/qt/gen_qcompleter.cpp @@ -22,11 +22,11 @@ QCompleter* QCompleter_new2(QAbstractItemModel* model) { return new QCompleter(model); } -QCompleter* QCompleter_new3(struct miqt_array* /* of struct miqt_string */ completions) { +QCompleter* QCompleter_new3(struct miqt_array /* of struct miqt_string */ completions) { QStringList completions_QList; - completions_QList.reserve(completions->len); - struct miqt_string* completions_arr = static_cast(completions->data); - for(size_t i = 0; i < completions->len; ++i) { + completions_QList.reserve(completions.len); + struct miqt_string* completions_arr = static_cast(completions.data); + for(size_t i = 0; i < completions.len; ++i) { QString completions_arr_i_QString = QString::fromUtf8(completions_arr[i].data, completions_arr[i].len); completions_QList.push_back(completions_arr_i_QString); } @@ -41,11 +41,11 @@ QCompleter* QCompleter_new5(QAbstractItemModel* model, QObject* parent) { return new QCompleter(model, parent); } -QCompleter* QCompleter_new6(struct miqt_array* /* of struct miqt_string */ completions, QObject* parent) { +QCompleter* QCompleter_new6(struct miqt_array /* of struct miqt_string */ completions, QObject* parent) { QStringList completions_QList; - completions_QList.reserve(completions->len); - struct miqt_string* completions_arr = static_cast(completions->data); - for(size_t i = 0; i < completions->len; ++i) { + completions_QList.reserve(completions.len); + struct miqt_string* completions_arr = static_cast(completions.data); + for(size_t i = 0; i < completions.len; ++i) { QString completions_arr_i_QString = QString::fromUtf8(completions_arr[i].data, completions_arr[i].len); completions_QList.push_back(completions_arr_i_QString); } @@ -236,7 +236,7 @@ struct miqt_string QCompleter_PathFromIndex(const QCompleter* self, QModelIndex* return _ms; } -struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_string path) { +struct miqt_array QCompleter_SplitPath(const QCompleter* self, struct miqt_string path) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList _ret = self->splitPath(path_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -251,9 +251,9 @@ struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_stri memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcompleter.go b/qt/gen_qcompleter.go index d61884f5..46bb2641 100644 --- a/qt/gen_qcompleter.go +++ b/qt/gen_qcompleter.go @@ -74,7 +74,6 @@ func NewQCompleter2(model *QAbstractItemModel) *QCompleter { // NewQCompleter3 constructs a new QCompleter object. func NewQCompleter3(completions []string) *QCompleter { - // For the C ABI, malloc a C array of structs completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions)))) defer C.free(unsafe.Pointer(completions_CArray)) for i := range completions { @@ -84,8 +83,7 @@ func NewQCompleter3(completions []string) *QCompleter { defer C.free(unsafe.Pointer(completions_i_ms.data)) completions_CArray[i] = completions_i_ms } - completions_ma := &C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(completions_ma)) + completions_ma := C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} ret := C.QCompleter_new3(completions_ma) return newQCompleter(ret) } @@ -104,7 +102,6 @@ func NewQCompleter5(model *QAbstractItemModel, parent *QObject) *QCompleter { // NewQCompleter6 constructs a new QCompleter object. func NewQCompleter6(completions []string, parent *QObject) *QCompleter { - // For the C ABI, malloc a C array of structs completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions)))) defer C.free(unsafe.Pointer(completions_CArray)) for i := range completions { @@ -114,8 +111,7 @@ func NewQCompleter6(completions []string, parent *QObject) *QCompleter { defer C.free(unsafe.Pointer(completions_i_ms.data)) completions_CArray[i] = completions_i_ms } - completions_ma := &C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(completions_ma)) + completions_ma := C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} ret := C.QCompleter_new6(completions_ma, parent.cPointer()) return newQCompleter(ret) } @@ -297,7 +293,7 @@ func (this *QCompleter) SplitPath(path string) []string { path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - var _ma *C.struct_miqt_array = C.QCompleter_SplitPath(this.h, path_ms) + var _ma C.struct_miqt_array = C.QCompleter_SplitPath(this.h, path_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -306,7 +302,6 @@ func (this *QCompleter) SplitPath(path string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcompleter.h b/qt/gen_qcompleter.h index a63167d1..1f5a4846 100644 --- a/qt/gen_qcompleter.h +++ b/qt/gen_qcompleter.h @@ -35,10 +35,10 @@ typedef struct QWidget QWidget; QCompleter* QCompleter_new(); QCompleter* QCompleter_new2(QAbstractItemModel* model); -QCompleter* QCompleter_new3(struct miqt_array* /* of struct miqt_string */ completions); +QCompleter* QCompleter_new3(struct miqt_array /* of struct miqt_string */ completions); QCompleter* QCompleter_new4(QObject* parent); QCompleter* QCompleter_new5(QAbstractItemModel* model, QObject* parent); -QCompleter* QCompleter_new6(struct miqt_array* /* of struct miqt_string */ completions, QObject* parent); +QCompleter* QCompleter_new6(struct miqt_array /* of struct miqt_string */ completions, QObject* parent); QMetaObject* QCompleter_MetaObject(const QCompleter* self); void* QCompleter_Metacast(QCompleter* self, const char* param1); struct miqt_string QCompleter_Tr(const char* s); @@ -75,7 +75,7 @@ void QCompleter_SetCompletionPrefix(QCompleter* self, struct miqt_string prefix) void QCompleter_Complete(QCompleter* self); void QCompleter_SetWrapAround(QCompleter* self, bool wrap); struct miqt_string QCompleter_PathFromIndex(const QCompleter* self, QModelIndex* index); -struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_string path); +struct miqt_array QCompleter_SplitPath(const QCompleter* self, struct miqt_string path); void QCompleter_Activated(QCompleter* self, struct miqt_string text); void QCompleter_connect_Activated(QCompleter* self, intptr_t slot); void QCompleter_ActivatedWithIndex(QCompleter* self, QModelIndex* index); diff --git a/qt/gen_qconcatenatetablesproxymodel.cpp b/qt/gen_qconcatenatetablesproxymodel.cpp index 0b790683..c7d01401 100644 --- a/qt/gen_qconcatenatetablesproxymodel.cpp +++ b/qt/gen_qconcatenatetablesproxymodel.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -52,16 +53,16 @@ struct miqt_string QConcatenateTablesProxyModel_TrUtf8(const char* s) { return _ms; } -struct miqt_array* QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self) { +struct miqt_array QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self) { QList _ret = self->sourceModels(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractItemModel** _arr = static_cast(malloc(sizeof(QAbstractItemModel*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -89,6 +90,34 @@ bool QConcatenateTablesProxyModel_SetData(QConcatenateTablesProxyModel* self, QM return self->setData(*index, *value); } +struct miqt_map QConcatenateTablesProxyModel_ItemData(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex) { + QMap _ret = self->itemData(*proxyIndex); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QConcatenateTablesProxyModel_SetItemData(QConcatenateTablesProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + int QConcatenateTablesProxyModel_Flags(const QConcatenateTablesProxyModel* self, QModelIndex* index) { Qt::ItemFlags _ret = self->flags(*index); return static_cast(_ret); @@ -114,7 +143,7 @@ int QConcatenateTablesProxyModel_ColumnCount(const QConcatenateTablesProxyModel* return self->columnCount(); } -struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self) { +struct miqt_array QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -128,17 +157,17 @@ struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTabl memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); diff --git a/qt/gen_qconcatenatetablesproxymodel.go b/qt/gen_qconcatenatetablesproxymodel.go index 8b1f4151..b7afd500 100644 --- a/qt/gen_qconcatenatetablesproxymodel.go +++ b/qt/gen_qconcatenatetablesproxymodel.go @@ -84,13 +84,12 @@ func QConcatenateTablesProxyModel_TrUtf8(s string) string { } func (this *QConcatenateTablesProxyModel) SourceModels() []*QAbstractItemModel { - var _ma *C.struct_miqt_array = C.QConcatenateTablesProxyModel_SourceModels(this.h) + var _ma C.struct_miqt_array = C.QConcatenateTablesProxyModel_SourceModels(this.h) _ret := make([]*QAbstractItemModel, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractItemModel)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractItemModel(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -127,6 +126,43 @@ func (this *QConcatenateTablesProxyModel) SetData(index *QModelIndex, value *QVa return (bool)(C.QConcatenateTablesProxyModel_SetData(this.h, index.cPointer(), value.cPointer())) } +func (this *QConcatenateTablesProxyModel) ItemData(proxyIndex *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QConcatenateTablesProxyModel_ItemData(this.h, proxyIndex.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QConcatenateTablesProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QConcatenateTablesProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QConcatenateTablesProxyModel) Flags(index *QModelIndex) ItemFlag { return (ItemFlag)(C.QConcatenateTablesProxyModel_Flags(this.h, index.cPointer())) } @@ -161,7 +197,7 @@ func (this *QConcatenateTablesProxyModel) ColumnCount() int { } func (this *QConcatenateTablesProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QConcatenateTablesProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QConcatenateTablesProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -170,19 +206,16 @@ func (this *QConcatenateTablesProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QConcatenateTablesProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QConcatenateTablesProxyModel_MimeData(this.h, indexes_ma))) } diff --git a/qt/gen_qconcatenatetablesproxymodel.h b/qt/gen_qconcatenatetablesproxymodel.h index f0ee6883..b23e87cf 100644 --- a/qt/gen_qconcatenatetablesproxymodel.h +++ b/qt/gen_qconcatenatetablesproxymodel.h @@ -39,21 +39,23 @@ QMetaObject* QConcatenateTablesProxyModel_MetaObject(const QConcatenateTablesPro void* QConcatenateTablesProxyModel_Metacast(QConcatenateTablesProxyModel* self, const char* param1); struct miqt_string QConcatenateTablesProxyModel_Tr(const char* s); struct miqt_string QConcatenateTablesProxyModel_TrUtf8(const char* s); -struct miqt_array* QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self); +struct miqt_array QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self); void QConcatenateTablesProxyModel_AddSourceModel(QConcatenateTablesProxyModel* self, QAbstractItemModel* sourceModel); void QConcatenateTablesProxyModel_RemoveSourceModel(QConcatenateTablesProxyModel* self, QAbstractItemModel* sourceModel); QModelIndex* QConcatenateTablesProxyModel_MapFromSource(const QConcatenateTablesProxyModel* self, QModelIndex* sourceIndex); QModelIndex* QConcatenateTablesProxyModel_MapToSource(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex); QVariant* QConcatenateTablesProxyModel_Data(const QConcatenateTablesProxyModel* self, QModelIndex* index); bool QConcatenateTablesProxyModel_SetData(QConcatenateTablesProxyModel* self, QModelIndex* index, QVariant* value); +struct miqt_map QConcatenateTablesProxyModel_ItemData(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex); +bool QConcatenateTablesProxyModel_SetItemData(QConcatenateTablesProxyModel* self, QModelIndex* index, struct miqt_map roles); int QConcatenateTablesProxyModel_Flags(const QConcatenateTablesProxyModel* self, QModelIndex* index); QModelIndex* QConcatenateTablesProxyModel_Index(const QConcatenateTablesProxyModel* self, int row, int column); QModelIndex* QConcatenateTablesProxyModel_Parent(const QConcatenateTablesProxyModel* self, QModelIndex* index); int QConcatenateTablesProxyModel_RowCount(const QConcatenateTablesProxyModel* self); QVariant* QConcatenateTablesProxyModel_HeaderData(const QConcatenateTablesProxyModel* self, int section, int orientation); int QConcatenateTablesProxyModel_ColumnCount(const QConcatenateTablesProxyModel* self); -struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self); -QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self); +QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QConcatenateTablesProxyModel_CanDropMimeData(const QConcatenateTablesProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QConcatenateTablesProxyModel_DropMimeData(QConcatenateTablesProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); QSize* QConcatenateTablesProxyModel_Span(const QConcatenateTablesProxyModel* self, QModelIndex* index); diff --git a/qt/gen_qcoreapplication.cpp b/qt/gen_qcoreapplication.cpp index b1640a25..ec25170b 100644 --- a/qt/gen_qcoreapplication.cpp +++ b/qt/gen_qcoreapplication.cpp @@ -51,7 +51,7 @@ struct miqt_string QCoreApplication_TrUtf8(const char* s) { return _ms; } -struct miqt_array* QCoreApplication_Arguments() { +struct miqt_array QCoreApplication_Arguments() { QStringList _ret = QCoreApplication::arguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -65,9 +65,9 @@ struct miqt_array* QCoreApplication_Arguments() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -238,18 +238,18 @@ long long QCoreApplication_ApplicationPid() { return static_cast(_ret); } -void QCoreApplication_SetLibraryPaths(struct miqt_array* /* of struct miqt_string */ libraryPaths) { +void QCoreApplication_SetLibraryPaths(struct miqt_array /* of struct miqt_string */ libraryPaths) { QStringList libraryPaths_QList; - libraryPaths_QList.reserve(libraryPaths->len); - struct miqt_string* libraryPaths_arr = static_cast(libraryPaths->data); - for(size_t i = 0; i < libraryPaths->len; ++i) { + libraryPaths_QList.reserve(libraryPaths.len); + struct miqt_string* libraryPaths_arr = static_cast(libraryPaths.data); + for(size_t i = 0; i < libraryPaths.len; ++i) { QString libraryPaths_arr_i_QString = QString::fromUtf8(libraryPaths_arr[i].data, libraryPaths_arr[i].len); libraryPaths_QList.push_back(libraryPaths_arr_i_QString); } QCoreApplication::setLibraryPaths(libraryPaths_QList); } -struct miqt_array* QCoreApplication_LibraryPaths() { +struct miqt_array QCoreApplication_LibraryPaths() { QStringList _ret = QCoreApplication::libraryPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -263,9 +263,9 @@ struct miqt_array* QCoreApplication_LibraryPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qcoreapplication.go b/qt/gen_qcoreapplication.go index 5df3c2e5..79323e74 100644 --- a/qt/gen_qcoreapplication.go +++ b/qt/gen_qcoreapplication.go @@ -105,7 +105,7 @@ func QCoreApplication_TrUtf8(s string) string { } func QCoreApplication_Arguments() []string { - var _ma *C.struct_miqt_array = C.QCoreApplication_Arguments() + var _ma C.struct_miqt_array = C.QCoreApplication_Arguments() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -114,7 +114,6 @@ func QCoreApplication_Arguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -273,7 +272,6 @@ func QCoreApplication_ApplicationPid() int64 { } func QCoreApplication_SetLibraryPaths(libraryPaths []string) { - // For the C ABI, malloc a C array of structs libraryPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(libraryPaths)))) defer C.free(unsafe.Pointer(libraryPaths_CArray)) for i := range libraryPaths { @@ -283,13 +281,12 @@ func QCoreApplication_SetLibraryPaths(libraryPaths []string) { defer C.free(unsafe.Pointer(libraryPaths_i_ms.data)) libraryPaths_CArray[i] = libraryPaths_i_ms } - libraryPaths_ma := &C.struct_miqt_array{len: C.size_t(len(libraryPaths)), data: unsafe.Pointer(libraryPaths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(libraryPaths_ma)) + libraryPaths_ma := C.struct_miqt_array{len: C.size_t(len(libraryPaths)), data: unsafe.Pointer(libraryPaths_CArray)} C.QCoreApplication_SetLibraryPaths(libraryPaths_ma) } func QCoreApplication_LibraryPaths() []string { - var _ma *C.struct_miqt_array = C.QCoreApplication_LibraryPaths() + var _ma C.struct_miqt_array = C.QCoreApplication_LibraryPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -298,7 +295,6 @@ func QCoreApplication_LibraryPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qcoreapplication.h b/qt/gen_qcoreapplication.h index 0bfbd7e4..1cbd8b4c 100644 --- a/qt/gen_qcoreapplication.h +++ b/qt/gen_qcoreapplication.h @@ -37,7 +37,7 @@ QMetaObject* QCoreApplication_MetaObject(const QCoreApplication* self); void* QCoreApplication_Metacast(QCoreApplication* self, const char* param1); struct miqt_string QCoreApplication_Tr(const char* s); struct miqt_string QCoreApplication_TrUtf8(const char* s); -struct miqt_array* QCoreApplication_Arguments(); +struct miqt_array QCoreApplication_Arguments(); void QCoreApplication_SetAttribute(int attribute); bool QCoreApplication_TestAttribute(int attribute); void QCoreApplication_SetOrganizationDomain(struct miqt_string orgDomain); @@ -68,8 +68,8 @@ bool QCoreApplication_ClosingDown(); struct miqt_string QCoreApplication_ApplicationDirPath(); struct miqt_string QCoreApplication_ApplicationFilePath(); long long QCoreApplication_ApplicationPid(); -void QCoreApplication_SetLibraryPaths(struct miqt_array* /* of struct miqt_string */ libraryPaths); -struct miqt_array* QCoreApplication_LibraryPaths(); +void QCoreApplication_SetLibraryPaths(struct miqt_array /* of struct miqt_string */ libraryPaths); +struct miqt_array QCoreApplication_LibraryPaths(); void QCoreApplication_AddLibraryPath(struct miqt_string param1); void QCoreApplication_RemoveLibraryPath(struct miqt_string param1); bool QCoreApplication_InstallTranslator(QTranslator* messageFile); diff --git a/qt/gen_qdialogbuttonbox.cpp b/qt/gen_qdialogbuttonbox.cpp index 03cf5594..35498144 100644 --- a/qt/gen_qdialogbuttonbox.cpp +++ b/qt/gen_qdialogbuttonbox.cpp @@ -103,16 +103,16 @@ void QDialogButtonBox_Clear(QDialogButtonBox* self) { self->clear(); } -struct miqt_array* QDialogButtonBox_Buttons(const QDialogButtonBox* self) { +struct miqt_array QDialogButtonBox_Buttons(const QDialogButtonBox* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qdialogbuttonbox.go b/qt/gen_qdialogbuttonbox.go index a7f474e2..fa55e1fa 100644 --- a/qt/gen_qdialogbuttonbox.go +++ b/qt/gen_qdialogbuttonbox.go @@ -205,13 +205,12 @@ func (this *QDialogButtonBox) Clear() { } func (this *QDialogButtonBox) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QDialogButtonBox_Buttons(this.h) + var _ma C.struct_miqt_array = C.QDialogButtonBox_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qdialogbuttonbox.h b/qt/gen_qdialogbuttonbox.h index 0fea6c99..c7e486de 100644 --- a/qt/gen_qdialogbuttonbox.h +++ b/qt/gen_qdialogbuttonbox.h @@ -46,7 +46,7 @@ QPushButton* QDialogButtonBox_AddButton2(QDialogButtonBox* self, struct miqt_str QPushButton* QDialogButtonBox_AddButtonWithButton(QDialogButtonBox* self, int button); void QDialogButtonBox_RemoveButton(QDialogButtonBox* self, QAbstractButton* button); void QDialogButtonBox_Clear(QDialogButtonBox* self); -struct miqt_array* QDialogButtonBox_Buttons(const QDialogButtonBox* self); +struct miqt_array QDialogButtonBox_Buttons(const QDialogButtonBox* self); int QDialogButtonBox_ButtonRole(const QDialogButtonBox* self, QAbstractButton* button); void QDialogButtonBox_SetStandardButtons(QDialogButtonBox* self, int buttons); int QDialogButtonBox_StandardButtons(const QDialogButtonBox* self); diff --git a/qt/gen_qdir.cpp b/qt/gen_qdir.cpp index ff68f543..a1ae8ed5 100644 --- a/qt/gen_qdir.cpp +++ b/qt/gen_qdir.cpp @@ -96,12 +96,12 @@ void QDir_AddResourceSearchPath(struct miqt_string path) { QDir::addResourceSearchPath(path_QString); } -void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array* /* of struct miqt_string */ searchPaths) { +void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array /* of struct miqt_string */ searchPaths) { QString prefix_QString = QString::fromUtf8(prefix.data, prefix.len); QStringList searchPaths_QList; - searchPaths_QList.reserve(searchPaths->len); - struct miqt_string* searchPaths_arr = static_cast(searchPaths->data); - for(size_t i = 0; i < searchPaths->len; ++i) { + searchPaths_QList.reserve(searchPaths.len); + struct miqt_string* searchPaths_arr = static_cast(searchPaths.data); + for(size_t i = 0; i < searchPaths.len; ++i) { QString searchPaths_arr_i_QString = QString::fromUtf8(searchPaths_arr[i].data, searchPaths_arr[i].len); searchPaths_QList.push_back(searchPaths_arr_i_QString); } @@ -114,7 +114,7 @@ void QDir_AddSearchPath(struct miqt_string prefix, struct miqt_string path) { QDir::addSearchPath(prefix_QString, path_QString); } -struct miqt_array* QDir_SearchPaths(struct miqt_string prefix) { +struct miqt_array QDir_SearchPaths(struct miqt_string prefix) { QString prefix_QString = QString::fromUtf8(prefix.data, prefix.len); QStringList _ret = QDir::searchPaths(prefix_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -129,9 +129,9 @@ struct miqt_array* QDir_SearchPaths(struct miqt_string prefix) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -215,7 +215,7 @@ bool QDir_CdUp(QDir* self) { return self->cdUp(); } -struct miqt_array* QDir_NameFilters(const QDir* self) { +struct miqt_array QDir_NameFilters(const QDir* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -229,17 +229,17 @@ struct miqt_array* QDir_NameFilters(const QDir* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QDir_SetNameFilters(QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +void QDir_SetNameFilters(QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -284,7 +284,7 @@ struct miqt_string QDir_OperatorSubscript(const QDir* self, int param1) { return _ms; } -struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter) { +struct miqt_array QDir_NameFiltersFromString(struct miqt_string nameFilter) { QString nameFilter_QString = QString::fromUtf8(nameFilter.data, nameFilter.len); QStringList _ret = QDir::nameFiltersFromString(nameFilter_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -299,13 +299,13 @@ struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList(const QDir* self) { +struct miqt_array QDir_EntryList(const QDir* self) { QStringList _ret = self->entryList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -319,17 +319,17 @@ struct miqt_array* QDir_EntryList(const QDir* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +struct miqt_array QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -346,30 +346,30 @@ struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_a memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList(const QDir* self) { +struct miqt_array QDir_EntryInfoList(const QDir* self) { QFileInfoList _ret = self->entryInfoList(); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +struct miqt_array QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -379,9 +379,9 @@ struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct mi for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -467,16 +467,16 @@ bool QDir_ExistsWithName(const QDir* self, struct miqt_string name) { return self->exists(name_QString); } -struct miqt_array* QDir_Drives() { +struct miqt_array QDir_Drives() { QFileInfoList _ret = QDir::drives(); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -553,11 +553,11 @@ struct miqt_string QDir_TempPath() { return _ms; } -bool QDir_Match(struct miqt_array* /* of struct miqt_string */ filters, struct miqt_string fileName) { +bool QDir_Match(struct miqt_array /* of struct miqt_string */ filters, struct miqt_string fileName) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } @@ -591,7 +591,7 @@ bool QDir_IsEmpty1(const QDir* self, int filters) { return self->isEmpty(static_cast(filters)); } -struct miqt_array* QDir_EntryList1(const QDir* self, int filters) { +struct miqt_array QDir_EntryList1(const QDir* self, int filters) { QStringList _ret = self->entryList(static_cast(filters)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -605,13 +605,13 @@ struct miqt_array* QDir_EntryList1(const QDir* self, int filters) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort) { +struct miqt_array QDir_EntryList2(const QDir* self, int filters, int sort) { QStringList _ret = self->entryList(static_cast(filters), static_cast(sort)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -625,17 +625,17 @@ struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +struct miqt_array QDir_EntryList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -652,17 +652,17 @@ struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of s memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort) { +struct miqt_array QDir_EntryList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -679,43 +679,43 @@ struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList1(const QDir* self, int filters) { +struct miqt_array QDir_EntryInfoList1(const QDir* self, int filters) { QFileInfoList _ret = self->entryInfoList(static_cast(filters)); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList2(const QDir* self, int filters, int sort) { +struct miqt_array QDir_EntryInfoList2(const QDir* self, int filters, int sort) { QFileInfoList _ret = self->entryInfoList(static_cast(filters), static_cast(sort)); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +struct miqt_array QDir_EntryInfoList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -725,17 +725,17 @@ struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort) { +struct miqt_array QDir_EntryInfoList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -745,9 +745,9 @@ struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* o for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qdir.go b/qt/gen_qdir.go index a121e13a..f7aeb237 100644 --- a/qt/gen_qdir.go +++ b/qt/gen_qdir.go @@ -206,7 +206,6 @@ func QDir_SetSearchPaths(prefix string, searchPaths []string) { prefix_ms.data = C.CString(prefix) prefix_ms.len = C.size_t(len(prefix)) defer C.free(unsafe.Pointer(prefix_ms.data)) - // For the C ABI, malloc a C array of structs searchPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(searchPaths)))) defer C.free(unsafe.Pointer(searchPaths_CArray)) for i := range searchPaths { @@ -216,8 +215,7 @@ func QDir_SetSearchPaths(prefix string, searchPaths []string) { defer C.free(unsafe.Pointer(searchPaths_i_ms.data)) searchPaths_CArray[i] = searchPaths_i_ms } - searchPaths_ma := &C.struct_miqt_array{len: C.size_t(len(searchPaths)), data: unsafe.Pointer(searchPaths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(searchPaths_ma)) + searchPaths_ma := C.struct_miqt_array{len: C.size_t(len(searchPaths)), data: unsafe.Pointer(searchPaths_CArray)} C.QDir_SetSearchPaths(prefix_ms, searchPaths_ma) } @@ -238,7 +236,7 @@ func QDir_SearchPaths(prefix string) []string { prefix_ms.data = C.CString(prefix) prefix_ms.len = C.size_t(len(prefix)) defer C.free(unsafe.Pointer(prefix_ms.data)) - var _ma *C.struct_miqt_array = C.QDir_SearchPaths(prefix_ms) + var _ma C.struct_miqt_array = C.QDir_SearchPaths(prefix_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -247,7 +245,6 @@ func QDir_SearchPaths(prefix string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -326,7 +323,7 @@ func (this *QDir) CdUp() bool { } func (this *QDir) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QDir_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QDir_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -335,12 +332,10 @@ func (this *QDir) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) SetNameFilters(nameFilters []string) { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -350,8 +345,7 @@ func (this *QDir) SetNameFilters(nameFilters []string) { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} C.QDir_SetNameFilters(this.h, nameFilters_ma) } @@ -391,7 +385,7 @@ func QDir_NameFiltersFromString(nameFilter string) []string { nameFilter_ms.data = C.CString(nameFilter) nameFilter_ms.len = C.size_t(len(nameFilter)) defer C.free(unsafe.Pointer(nameFilter_ms.data)) - var _ma *C.struct_miqt_array = C.QDir_NameFiltersFromString(nameFilter_ms) + var _ma C.struct_miqt_array = C.QDir_NameFiltersFromString(nameFilter_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -400,12 +394,11 @@ func QDir_NameFiltersFromString(nameFilter string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList() []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList(this.h) + var _ma C.struct_miqt_array = C.QDir_EntryList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -414,12 +407,10 @@ func (this *QDir) EntryList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -429,9 +420,8 @@ func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryListWithNameFilters(this.h, nameFilters_ma) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryListWithNameFilters(this.h, nameFilters_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -440,12 +430,11 @@ func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList() []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList(this.h) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList(this.h) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -454,12 +443,10 @@ func (this *QDir) EntryInfoList() []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -469,9 +456,8 @@ func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoListWithNameFilters(this.h, nameFilters_ma) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoListWithNameFilters(this.h, nameFilters_ma) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -480,7 +466,6 @@ func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -597,7 +582,7 @@ func (this *QDir) ExistsWithName(name string) bool { } func QDir_Drives() []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_Drives() + var _ma C.struct_miqt_array = C.QDir_Drives() _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -606,7 +591,6 @@ func QDir_Drives() []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -689,7 +673,6 @@ func QDir_TempPath() string { } func QDir_Match(filters []string, fileName string) bool { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -699,8 +682,7 @@ func QDir_Match(filters []string, fileName string) bool { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} fileName_ms := C.struct_miqt_string{} fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) @@ -740,7 +722,7 @@ func (this *QDir) IsEmpty1(filters QDir__Filter) bool { } func (this *QDir) EntryList1(filters QDir__Filter) []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList1(this.h, (C.int)(filters)) + var _ma C.struct_miqt_array = C.QDir_EntryList1(this.h, (C.int)(filters)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -749,12 +731,11 @@ func (this *QDir) EntryList1(filters QDir__Filter) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList2(filters QDir__Filter, sort QDir__SortFlag) []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList2(this.h, (C.int)(filters), (C.int)(sort)) + var _ma C.struct_miqt_array = C.QDir_EntryList2(this.h, (C.int)(filters), (C.int)(sort)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -763,12 +744,10 @@ func (this *QDir) EntryList2(filters QDir__Filter, sort QDir__SortFlag) []string C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -778,9 +757,8 @@ func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []stri defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryList22(this.h, nameFilters_ma, (C.int)(filters)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryList22(this.h, nameFilters_ma, (C.int)(filters)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -789,12 +767,10 @@ func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []stri C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -804,9 +780,8 @@ func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QD defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -815,12 +790,11 @@ func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QD C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList1(filters QDir__Filter) []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList1(this.h, (C.int)(filters)) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList1(this.h, (C.int)(filters)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -829,12 +803,11 @@ func (this *QDir) EntryInfoList1(filters QDir__Filter) []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList2(filters QDir__Filter, sort QDir__SortFlag) []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList2(this.h, (C.int)(filters), (C.int)(sort)) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList2(this.h, (C.int)(filters), (C.int)(sort)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -843,12 +816,10 @@ func (this *QDir) EntryInfoList2(filters QDir__Filter, sort QDir__SortFlag) []QF _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -858,9 +829,8 @@ func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) [] defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList22(this.h, nameFilters_ma, (C.int)(filters)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoList22(this.h, nameFilters_ma, (C.int)(filters)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -869,12 +839,10 @@ func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) [] _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -884,9 +852,8 @@ func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sor defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -895,7 +862,6 @@ func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sor _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qdir.h b/qt/gen_qdir.h index 9779c3ad..6265204d 100644 --- a/qt/gen_qdir.h +++ b/qt/gen_qdir.h @@ -37,9 +37,9 @@ struct miqt_string QDir_Path(const QDir* self); struct miqt_string QDir_AbsolutePath(const QDir* self); struct miqt_string QDir_CanonicalPath(const QDir* self); void QDir_AddResourceSearchPath(struct miqt_string path); -void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array* /* of struct miqt_string */ searchPaths); +void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array /* of struct miqt_string */ searchPaths); void QDir_AddSearchPath(struct miqt_string prefix, struct miqt_string path); -struct miqt_array* QDir_SearchPaths(struct miqt_string prefix); +struct miqt_array QDir_SearchPaths(struct miqt_string prefix); struct miqt_string QDir_DirName(const QDir* self); struct miqt_string QDir_FilePath(const QDir* self, struct miqt_string fileName); struct miqt_string QDir_AbsoluteFilePath(const QDir* self, struct miqt_string fileName); @@ -48,8 +48,8 @@ struct miqt_string QDir_ToNativeSeparators(struct miqt_string pathName); struct miqt_string QDir_FromNativeSeparators(struct miqt_string pathName); bool QDir_Cd(QDir* self, struct miqt_string dirName); bool QDir_CdUp(QDir* self); -struct miqt_array* QDir_NameFilters(const QDir* self); -void QDir_SetNameFilters(QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_NameFilters(const QDir* self); +void QDir_SetNameFilters(QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); int QDir_Filter(const QDir* self); void QDir_SetFilter(QDir* self, int filter); int QDir_Sorting(const QDir* self); @@ -57,11 +57,11 @@ void QDir_SetSorting(QDir* self, int sort); unsigned int QDir_Count(const QDir* self); bool QDir_IsEmpty(const QDir* self); struct miqt_string QDir_OperatorSubscript(const QDir* self, int param1); -struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter); -struct miqt_array* QDir_EntryList(const QDir* self); -struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); -struct miqt_array* QDir_EntryInfoList(const QDir* self); -struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_NameFiltersFromString(struct miqt_string nameFilter); +struct miqt_array QDir_EntryList(const QDir* self); +struct miqt_array QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_EntryInfoList(const QDir* self); +struct miqt_array QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); bool QDir_Mkdir(const QDir* self, struct miqt_string dirName); bool QDir_Rmdir(const QDir* self, struct miqt_string dirName); bool QDir_Mkpath(const QDir* self, struct miqt_string dirPath); @@ -80,7 +80,7 @@ bool QDir_OperatorNotEqual(const QDir* self, QDir* dir); bool QDir_Remove(QDir* self, struct miqt_string fileName); bool QDir_Rename(QDir* self, struct miqt_string oldName, struct miqt_string newName); bool QDir_ExistsWithName(const QDir* self, struct miqt_string name); -struct miqt_array* QDir_Drives(); +struct miqt_array QDir_Drives(); QChar* QDir_ListSeparator(); QChar* QDir_Separator(); bool QDir_SetCurrent(struct miqt_string path); @@ -92,19 +92,19 @@ QDir* QDir_Root(); struct miqt_string QDir_RootPath(); QDir* QDir_Temp(); struct miqt_string QDir_TempPath(); -bool QDir_Match(struct miqt_array* /* of struct miqt_string */ filters, struct miqt_string fileName); +bool QDir_Match(struct miqt_array /* of struct miqt_string */ filters, struct miqt_string fileName); bool QDir_Match2(struct miqt_string filter, struct miqt_string fileName); struct miqt_string QDir_CleanPath(struct miqt_string path); void QDir_Refresh(const QDir* self); bool QDir_IsEmpty1(const QDir* self, int filters); -struct miqt_array* QDir_EntryList1(const QDir* self, int filters); -struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort); -struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort); -struct miqt_array* QDir_EntryInfoList1(const QDir* self, int filters); -struct miqt_array* QDir_EntryInfoList2(const QDir* self, int filters, int sort); -struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort); +struct miqt_array QDir_EntryList1(const QDir* self, int filters); +struct miqt_array QDir_EntryList2(const QDir* self, int filters, int sort); +struct miqt_array QDir_EntryList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +struct miqt_array QDir_EntryList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort); +struct miqt_array QDir_EntryInfoList1(const QDir* self, int filters); +struct miqt_array QDir_EntryInfoList2(const QDir* self, int filters, int sort); +struct miqt_array QDir_EntryInfoList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +struct miqt_array QDir_EntryInfoList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort); void QDir_Delete(QDir* self); #ifdef __cplusplus diff --git a/qt/gen_qdiriterator.cpp b/qt/gen_qdiriterator.cpp index 5389c0d5..b4f5043d 100644 --- a/qt/gen_qdiriterator.cpp +++ b/qt/gen_qdiriterator.cpp @@ -23,12 +23,12 @@ QDirIterator* QDirIterator_new3(struct miqt_string path, int filter) { return new QDirIterator(path_QString, static_cast(filter)); } -QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters) { +QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -49,24 +49,24 @@ QDirIterator* QDirIterator_new7(struct miqt_string path, int filter, int flags) return new QDirIterator(path_QString, static_cast(filter), static_cast(flags)); } -QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } return new QDirIterator(path_QString, nameFilters_QList, static_cast(filters)); } -QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int flags) { +QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int flags) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } diff --git a/qt/gen_qdiriterator.go b/qt/gen_qdiriterator.go index fabb3bbe..5499fba5 100644 --- a/qt/gen_qdiriterator.go +++ b/qt/gen_qdiriterator.go @@ -82,7 +82,6 @@ func NewQDirIterator4(path string, nameFilters []string) *QDirIterator { path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -92,8 +91,7 @@ func NewQDirIterator4(path string, nameFilters []string) *QDirIterator { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new4(path_ms, nameFilters_ma) return newQDirIterator(ret) } @@ -130,7 +128,6 @@ func NewQDirIterator8(path string, nameFilters []string, filters QDir__Filter) * path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -140,8 +137,7 @@ func NewQDirIterator8(path string, nameFilters []string, filters QDir__Filter) * defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new8(path_ms, nameFilters_ma, (C.int)(filters)) return newQDirIterator(ret) } @@ -152,7 +148,6 @@ func NewQDirIterator9(path string, nameFilters []string, filters QDir__Filter, f path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -162,8 +157,7 @@ func NewQDirIterator9(path string, nameFilters []string, filters QDir__Filter, f defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new9(path_ms, nameFilters_ma, (C.int)(filters), (C.int)(flags)) return newQDirIterator(ret) } diff --git a/qt/gen_qdiriterator.h b/qt/gen_qdiriterator.h index 2578f6a5..8179e25b 100644 --- a/qt/gen_qdiriterator.h +++ b/qt/gen_qdiriterator.h @@ -26,12 +26,12 @@ typedef struct QFileInfo QFileInfo; QDirIterator* QDirIterator_new(QDir* dir); QDirIterator* QDirIterator_new2(struct miqt_string path); QDirIterator* QDirIterator_new3(struct miqt_string path, int filter); -QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters); +QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters); QDirIterator* QDirIterator_new5(QDir* dir, int flags); QDirIterator* QDirIterator_new6(struct miqt_string path, int flags); QDirIterator* QDirIterator_new7(struct miqt_string path, int filter, int flags); -QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int flags); +QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int flags); struct miqt_string QDirIterator_Next(QDirIterator* self); bool QDirIterator_HasNext(const QDirIterator* self); struct miqt_string QDirIterator_FileName(const QDirIterator* self); diff --git a/qt/gen_qdirmodel.cpp b/qt/gen_qdirmodel.cpp index ff771d81..f8cabc80 100644 --- a/qt/gen_qdirmodel.cpp +++ b/qt/gen_qdirmodel.cpp @@ -15,11 +15,11 @@ #include "gen_qdirmodel.h" #include "_cgo_export.h" -QDirModel* QDirModel_new(struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort) { +QDirModel* QDirModel_new(struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -30,11 +30,11 @@ QDirModel* QDirModel_new2() { return new QDirModel(); } -QDirModel* QDirModel_new3(struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort, QObject* parent) { +QDirModel* QDirModel_new3(struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort, QObject* parent) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -116,7 +116,7 @@ void QDirModel_Sort(QDirModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QDirModel_MimeTypes(const QDirModel* self) { +struct miqt_array QDirModel_MimeTypes(const QDirModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -130,17 +130,17 @@ struct miqt_array* QDirModel_MimeTypes(const QDirModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QDirModel_MimeData(const QDirModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QDirModel_MimeData(const QDirModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -163,18 +163,18 @@ QFileIconProvider* QDirModel_IconProvider(const QDirModel* self) { return self->iconProvider(); } -void QDirModel_SetNameFilters(QDirModel* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QDirModel_SetNameFilters(QDirModel* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setNameFilters(filters_QList); } -struct miqt_array* QDirModel_NameFilters(const QDirModel* self) { +struct miqt_array QDirModel_NameFilters(const QDirModel* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -188,9 +188,9 @@ struct miqt_array* QDirModel_NameFilters(const QDirModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qdirmodel.go b/qt/gen_qdirmodel.go index 03d575aa..824ac9b2 100644 --- a/qt/gen_qdirmodel.go +++ b/qt/gen_qdirmodel.go @@ -53,7 +53,6 @@ func UnsafeNewQDirModel(h unsafe.Pointer) *QDirModel { // NewQDirModel constructs a new QDirModel object. func NewQDirModel(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) *QDirModel { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -63,8 +62,7 @@ func NewQDirModel(nameFilters []string, filters QDir__Filter, sort QDir__SortFla defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirModel_new(nameFilters_ma, (C.int)(filters), (C.int)(sort)) return newQDirModel(ret) } @@ -77,7 +75,6 @@ func NewQDirModel2() *QDirModel { // NewQDirModel3 constructs a new QDirModel object. func NewQDirModel3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag, parent *QObject) *QDirModel { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -87,8 +84,7 @@ func NewQDirModel3(nameFilters []string, filters QDir__Filter, sort QDir__SortFl defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirModel_new3(nameFilters_ma, (C.int)(filters), (C.int)(sort), parent.cPointer()) return newQDirModel(ret) } @@ -180,7 +176,7 @@ func (this *QDirModel) Sort(column int) { } func (this *QDirModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QDirModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QDirModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -189,19 +185,16 @@ func (this *QDirModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDirModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QDirModel_MimeData(this.h, indexes_ma))) } @@ -222,7 +215,6 @@ func (this *QDirModel) IconProvider() *QFileIconProvider { } func (this *QDirModel) SetNameFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -232,13 +224,12 @@ func (this *QDirModel) SetNameFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QDirModel_SetNameFilters(this.h, filters_ma) } func (this *QDirModel) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QDirModel_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QDirModel_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -247,7 +238,6 @@ func (this *QDirModel) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qdirmodel.h b/qt/gen_qdirmodel.h index 8ab27b8c..bf1ef571 100644 --- a/qt/gen_qdirmodel.h +++ b/qt/gen_qdirmodel.h @@ -35,9 +35,9 @@ typedef struct QObject QObject; typedef struct QVariant QVariant; #endif -QDirModel* QDirModel_new(struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort); +QDirModel* QDirModel_new(struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort); QDirModel* QDirModel_new2(); -QDirModel* QDirModel_new3(struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort, QObject* parent); +QDirModel* QDirModel_new3(struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort, QObject* parent); QDirModel* QDirModel_new4(QObject* parent); QMetaObject* QDirModel_MetaObject(const QDirModel* self); void* QDirModel_Metacast(QDirModel* self, const char* param1); @@ -53,14 +53,14 @@ QVariant* QDirModel_HeaderData(const QDirModel* self, int section, int orientati bool QDirModel_HasChildren(const QDirModel* self); int QDirModel_Flags(const QDirModel* self, QModelIndex* index); void QDirModel_Sort(QDirModel* self, int column); -struct miqt_array* QDirModel_MimeTypes(const QDirModel* self); -QMimeData* QDirModel_MimeData(const QDirModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QDirModel_MimeTypes(const QDirModel* self); +QMimeData* QDirModel_MimeData(const QDirModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QDirModel_DropMimeData(QDirModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); int QDirModel_SupportedDropActions(const QDirModel* self); void QDirModel_SetIconProvider(QDirModel* self, QFileIconProvider* provider); QFileIconProvider* QDirModel_IconProvider(const QDirModel* self); -void QDirModel_SetNameFilters(QDirModel* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QDirModel_NameFilters(const QDirModel* self); +void QDirModel_SetNameFilters(QDirModel* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QDirModel_NameFilters(const QDirModel* self); void QDirModel_SetFilter(QDirModel* self, int filters); int QDirModel_Filter(const QDirModel* self); void QDirModel_SetSorting(QDirModel* self, int sort); diff --git a/qt/gen_qeasingcurve.cpp b/qt/gen_qeasingcurve.cpp index 76a227a2..5ae0d963 100644 --- a/qt/gen_qeasingcurve.cpp +++ b/qt/gen_qeasingcurve.cpp @@ -68,16 +68,16 @@ void QEasingCurve_AddTCBSegment(QEasingCurve* self, QPointF* nextPoint, double t self->addTCBSegment(*nextPoint, static_cast(t), static_cast(c), static_cast(b)); } -struct miqt_array* QEasingCurve_ToCubicSpline(const QEasingCurve* self) { +struct miqt_array QEasingCurve_ToCubicSpline(const QEasingCurve* self) { QVector _ret = self->toCubicSpline(); // Convert QList<> from C++ memory to manually-managed C memory QPointF** _arr = static_cast(malloc(sizeof(QPointF*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qeasingcurve.go b/qt/gen_qeasingcurve.go index 0cd61dea..253a4000 100644 --- a/qt/gen_qeasingcurve.go +++ b/qt/gen_qeasingcurve.go @@ -163,7 +163,7 @@ func (this *QEasingCurve) AddTCBSegment(nextPoint *QPointF, t float64, c float64 } func (this *QEasingCurve) ToCubicSpline() []QPointF { - var _ma *C.struct_miqt_array = C.QEasingCurve_ToCubicSpline(this.h) + var _ma C.struct_miqt_array = C.QEasingCurve_ToCubicSpline(this.h) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,7 +172,6 @@ func (this *QEasingCurve) ToCubicSpline() []QPointF { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qeasingcurve.h b/qt/gen_qeasingcurve.h index 72694465..b70f923a 100644 --- a/qt/gen_qeasingcurve.h +++ b/qt/gen_qeasingcurve.h @@ -36,7 +36,7 @@ double QEasingCurve_Overshoot(const QEasingCurve* self); void QEasingCurve_SetOvershoot(QEasingCurve* self, double overshoot); void QEasingCurve_AddCubicBezierSegment(QEasingCurve* self, QPointF* c1, QPointF* c2, QPointF* endPoint); void QEasingCurve_AddTCBSegment(QEasingCurve* self, QPointF* nextPoint, double t, double c, double b); -struct miqt_array* QEasingCurve_ToCubicSpline(const QEasingCurve* self); +struct miqt_array QEasingCurve_ToCubicSpline(const QEasingCurve* self); int QEasingCurve_Type(const QEasingCurve* self); void QEasingCurve_SetType(QEasingCurve* self, int typeVal); double QEasingCurve_ValueForProgress(const QEasingCurve* self, double progress); diff --git a/qt/gen_qevent.cpp b/qt/gen_qevent.cpp index 13dd1872..7c972334 100644 --- a/qt/gen_qevent.cpp +++ b/qt/gen_qevent.cpp @@ -935,12 +935,12 @@ QInputMethodEvent* QInputMethodEvent_new() { return new QInputMethodEvent(); } -QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array* /* of QInputMethodEvent__Attribute* */ attributes) { +QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array /* of QInputMethodEvent__Attribute* */ attributes) { QString preeditText_QString = QString::fromUtf8(preeditText.data, preeditText.len); QList attributes_QList; - attributes_QList.reserve(attributes->len); - QInputMethodEvent__Attribute** attributes_arr = static_cast(attributes->data); - for(size_t i = 0; i < attributes->len; ++i) { + attributes_QList.reserve(attributes.len); + QInputMethodEvent__Attribute** attributes_arr = static_cast(attributes.data); + for(size_t i = 0; i < attributes.len; ++i) { attributes_QList.push_back(*(attributes_arr[i])); } return new QInputMethodEvent(preeditText_QString, attributes_QList); @@ -955,16 +955,16 @@ void QInputMethodEvent_SetCommitString(QInputMethodEvent* self, struct miqt_stri self->setCommitString(commitString_QString); } -struct miqt_array* QInputMethodEvent_Attributes(const QInputMethodEvent* self) { +struct miqt_array QInputMethodEvent_Attributes(const QInputMethodEvent* self) { const QList& _ret = self->attributes(); // Convert QList<> from C++ memory to manually-managed C memory QInputMethodEvent__Attribute** _arr = static_cast(malloc(sizeof(QInputMethodEvent__Attribute*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QInputMethodEvent::Attribute(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1440,11 +1440,11 @@ QTouchEvent* QTouchEvent_new5(int eventType, QTouchDevice* device, int modifiers return new QTouchEvent(static_cast(eventType), device, static_cast(modifiers), static_cast(touchPointStates)); } -QTouchEvent* QTouchEvent_new6(int eventType, QTouchDevice* device, int modifiers, int touchPointStates, struct miqt_array* /* of QTouchEvent__TouchPoint* */ touchPoints) { +QTouchEvent* QTouchEvent_new6(int eventType, QTouchDevice* device, int modifiers, int touchPointStates, struct miqt_array /* of QTouchEvent__TouchPoint* */ touchPoints) { QList touchPoints_QList; - touchPoints_QList.reserve(touchPoints->len); - QTouchEvent__TouchPoint** touchPoints_arr = static_cast(touchPoints->data); - for(size_t i = 0; i < touchPoints->len; ++i) { + touchPoints_QList.reserve(touchPoints.len); + QTouchEvent__TouchPoint** touchPoints_arr = static_cast(touchPoints.data); + for(size_t i = 0; i < touchPoints.len; ++i) { touchPoints_QList.push_back(*(touchPoints_arr[i])); } return new QTouchEvent(static_cast(eventType), device, static_cast(modifiers), static_cast(touchPointStates), touchPoints_QList); @@ -1463,16 +1463,16 @@ int QTouchEvent_TouchPointStates(const QTouchEvent* self) { return static_cast(_ret); } -struct miqt_array* QTouchEvent_TouchPoints(const QTouchEvent* self) { +struct miqt_array QTouchEvent_TouchPoints(const QTouchEvent* self) { const QList& _ret = self->touchPoints(); // Convert QList<> from C++ memory to manually-managed C memory QTouchEvent__TouchPoint** _arr = static_cast(malloc(sizeof(QTouchEvent__TouchPoint*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTouchEvent::TouchPoint(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1492,11 +1492,11 @@ void QTouchEvent_SetTouchPointStates(QTouchEvent* self, int aTouchPointStates) { self->setTouchPointStates(static_cast(aTouchPointStates)); } -void QTouchEvent_SetTouchPoints(QTouchEvent* self, struct miqt_array* /* of QTouchEvent__TouchPoint* */ atouchPoints) { +void QTouchEvent_SetTouchPoints(QTouchEvent* self, struct miqt_array /* of QTouchEvent__TouchPoint* */ atouchPoints) { QList atouchPoints_QList; - atouchPoints_QList.reserve(atouchPoints->len); - QTouchEvent__TouchPoint** atouchPoints_arr = static_cast(atouchPoints->data); - for(size_t i = 0; i < atouchPoints->len; ++i) { + atouchPoints_QList.reserve(atouchPoints.len); + QTouchEvent__TouchPoint** atouchPoints_arr = static_cast(atouchPoints.data); + for(size_t i = 0; i < atouchPoints.len; ++i) { atouchPoints_QList.push_back(*(atouchPoints_arr[i])); } self->setTouchPoints(atouchPoints_QList); @@ -1761,16 +1761,16 @@ int QTouchEvent__TouchPoint_Flags(const QTouchEvent__TouchPoint* self) { return static_cast(_ret); } -struct miqt_array* QTouchEvent__TouchPoint_RawScreenPositions(const QTouchEvent__TouchPoint* self) { +struct miqt_array QTouchEvent__TouchPoint_RawScreenPositions(const QTouchEvent__TouchPoint* self) { QVector _ret = self->rawScreenPositions(); // Convert QList<> from C++ memory to manually-managed C memory QPointF** _arr = static_cast(malloc(sizeof(QPointF*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1854,11 +1854,11 @@ void QTouchEvent__TouchPoint_SetFlags(QTouchEvent__TouchPoint* self, int flags) self->setFlags(static_cast(flags)); } -void QTouchEvent__TouchPoint_SetRawScreenPositions(QTouchEvent__TouchPoint* self, struct miqt_array* /* of QPointF* */ positions) { +void QTouchEvent__TouchPoint_SetRawScreenPositions(QTouchEvent__TouchPoint* self, struct miqt_array /* of QPointF* */ positions) { QVector positions_QList; - positions_QList.reserve(positions->len); - QPointF** positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + QPointF** positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(*(positions_arr[i])); } self->setRawScreenPositions(positions_QList); diff --git a/qt/gen_qevent.go b/qt/gen_qevent.go index 70f42076..5b866364 100644 --- a/qt/gen_qevent.go +++ b/qt/gen_qevent.go @@ -1863,14 +1863,12 @@ func NewQInputMethodEvent2(preeditText string, attributes []QInputMethodEvent__A preeditText_ms.data = C.CString(preeditText) preeditText_ms.len = C.size_t(len(preeditText)) defer C.free(unsafe.Pointer(preeditText_ms.data)) - // For the C ABI, malloc a C array of raw pointers attributes_CArray := (*[0xffff]*C.QInputMethodEvent__Attribute)(C.malloc(C.size_t(8 * len(attributes)))) defer C.free(unsafe.Pointer(attributes_CArray)) for i := range attributes { attributes_CArray[i] = attributes[i].cPointer() } - attributes_ma := &C.struct_miqt_array{len: C.size_t(len(attributes)), data: unsafe.Pointer(attributes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(attributes_ma)) + attributes_ma := C.struct_miqt_array{len: C.size_t(len(attributes)), data: unsafe.Pointer(attributes_CArray)} ret := C.QInputMethodEvent_new2(preeditText_ms, attributes_ma) return newQInputMethodEvent(ret) } @@ -1890,7 +1888,7 @@ func (this *QInputMethodEvent) SetCommitString(commitString string) { } func (this *QInputMethodEvent) Attributes() []QInputMethodEvent__Attribute { - var _ma *C.struct_miqt_array = C.QInputMethodEvent_Attributes(this.h) + var _ma C.struct_miqt_array = C.QInputMethodEvent_Attributes(this.h) _ret := make([]QInputMethodEvent__Attribute, int(_ma.len)) _outCast := (*[0xffff]*C.QInputMethodEvent__Attribute)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1899,7 +1897,6 @@ func (this *QInputMethodEvent) Attributes() []QInputMethodEvent__Attribute { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -3048,14 +3045,12 @@ func NewQTouchEvent5(eventType QEvent__Type, device *QTouchDevice, modifiers Key // NewQTouchEvent6 constructs a new QTouchEvent object. func NewQTouchEvent6(eventType QEvent__Type, device *QTouchDevice, modifiers KeyboardModifier, touchPointStates TouchPointState, touchPoints []QTouchEvent__TouchPoint) *QTouchEvent { - // For the C ABI, malloc a C array of raw pointers touchPoints_CArray := (*[0xffff]*C.QTouchEvent__TouchPoint)(C.malloc(C.size_t(8 * len(touchPoints)))) defer C.free(unsafe.Pointer(touchPoints_CArray)) for i := range touchPoints { touchPoints_CArray[i] = touchPoints[i].cPointer() } - touchPoints_ma := &C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(touchPoints_ma)) + touchPoints_ma := C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} ret := C.QTouchEvent_new6((C.int)(eventType), device.cPointer(), (C.int)(modifiers), (C.int)(touchPointStates), touchPoints_ma) return newQTouchEvent(ret) } @@ -3073,7 +3068,7 @@ func (this *QTouchEvent) TouchPointStates() TouchPointState { } func (this *QTouchEvent) TouchPoints() []QTouchEvent__TouchPoint { - var _ma *C.struct_miqt_array = C.QTouchEvent_TouchPoints(this.h) + var _ma C.struct_miqt_array = C.QTouchEvent_TouchPoints(this.h) _ret := make([]QTouchEvent__TouchPoint, int(_ma.len)) _outCast := (*[0xffff]*C.QTouchEvent__TouchPoint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -3082,7 +3077,6 @@ func (this *QTouchEvent) TouchPoints() []QTouchEvent__TouchPoint { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -3103,14 +3097,12 @@ func (this *QTouchEvent) SetTouchPointStates(aTouchPointStates TouchPointState) } func (this *QTouchEvent) SetTouchPoints(atouchPoints []QTouchEvent__TouchPoint) { - // For the C ABI, malloc a C array of raw pointers atouchPoints_CArray := (*[0xffff]*C.QTouchEvent__TouchPoint)(C.malloc(C.size_t(8 * len(atouchPoints)))) defer C.free(unsafe.Pointer(atouchPoints_CArray)) for i := range atouchPoints { atouchPoints_CArray[i] = atouchPoints[i].cPointer() } - atouchPoints_ma := &C.struct_miqt_array{len: C.size_t(len(atouchPoints)), data: unsafe.Pointer(atouchPoints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(atouchPoints_ma)) + atouchPoints_ma := C.struct_miqt_array{len: C.size_t(len(atouchPoints)), data: unsafe.Pointer(atouchPoints_CArray)} C.QTouchEvent_SetTouchPoints(this.h, atouchPoints_ma) } @@ -3705,7 +3697,7 @@ func (this *QTouchEvent__TouchPoint) Flags() QTouchEvent__TouchPoint__InfoFlag { } func (this *QTouchEvent__TouchPoint) RawScreenPositions() []QPointF { - var _ma *C.struct_miqt_array = C.QTouchEvent__TouchPoint_RawScreenPositions(this.h) + var _ma C.struct_miqt_array = C.QTouchEvent__TouchPoint_RawScreenPositions(this.h) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -3714,7 +3706,6 @@ func (this *QTouchEvent__TouchPoint) RawScreenPositions() []QPointF { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -3799,14 +3790,12 @@ func (this *QTouchEvent__TouchPoint) SetFlags(flags QTouchEvent__TouchPoint__Inf } func (this *QTouchEvent__TouchPoint) SetRawScreenPositions(positions []QPointF) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]*C.QPointF)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = positions[i].cPointer() } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QTouchEvent__TouchPoint_SetRawScreenPositions(this.h, positions_ma) } diff --git a/qt/gen_qevent.h b/qt/gen_qevent.h index fd9a9490..eb43e595 100644 --- a/qt/gen_qevent.h +++ b/qt/gen_qevent.h @@ -357,10 +357,10 @@ int QContextMenuEvent_Reason(const QContextMenuEvent* self); void QContextMenuEvent_Delete(QContextMenuEvent* self); QInputMethodEvent* QInputMethodEvent_new(); -QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array* /* of QInputMethodEvent__Attribute* */ attributes); +QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array /* of QInputMethodEvent__Attribute* */ attributes); QInputMethodEvent* QInputMethodEvent_new3(QInputMethodEvent* other); void QInputMethodEvent_SetCommitString(QInputMethodEvent* self, struct miqt_string commitString); -struct miqt_array* QInputMethodEvent_Attributes(const QInputMethodEvent* self); +struct miqt_array QInputMethodEvent_Attributes(const QInputMethodEvent* self); struct miqt_string QInputMethodEvent_PreeditString(const QInputMethodEvent* self); struct miqt_string QInputMethodEvent_CommitString(const QInputMethodEvent* self); int QInputMethodEvent_ReplacementStart(const QInputMethodEvent* self); @@ -480,16 +480,16 @@ QTouchEvent* QTouchEvent_new2(QTouchEvent* param1); QTouchEvent* QTouchEvent_new3(int eventType, QTouchDevice* device); QTouchEvent* QTouchEvent_new4(int eventType, QTouchDevice* device, int modifiers); QTouchEvent* QTouchEvent_new5(int eventType, QTouchDevice* device, int modifiers, int touchPointStates); -QTouchEvent* QTouchEvent_new6(int eventType, QTouchDevice* device, int modifiers, int touchPointStates, struct miqt_array* /* of QTouchEvent__TouchPoint* */ touchPoints); +QTouchEvent* QTouchEvent_new6(int eventType, QTouchDevice* device, int modifiers, int touchPointStates, struct miqt_array /* of QTouchEvent__TouchPoint* */ touchPoints); QWindow* QTouchEvent_Window(const QTouchEvent* self); QObject* QTouchEvent_Target(const QTouchEvent* self); int QTouchEvent_TouchPointStates(const QTouchEvent* self); -struct miqt_array* QTouchEvent_TouchPoints(const QTouchEvent* self); +struct miqt_array QTouchEvent_TouchPoints(const QTouchEvent* self); QTouchDevice* QTouchEvent_Device(const QTouchEvent* self); void QTouchEvent_SetWindow(QTouchEvent* self, QWindow* awindow); void QTouchEvent_SetTarget(QTouchEvent* self, QObject* atarget); void QTouchEvent_SetTouchPointStates(QTouchEvent* self, int aTouchPointStates); -void QTouchEvent_SetTouchPoints(QTouchEvent* self, struct miqt_array* /* of QTouchEvent__TouchPoint* */ atouchPoints); +void QTouchEvent_SetTouchPoints(QTouchEvent* self, struct miqt_array /* of QTouchEvent__TouchPoint* */ atouchPoints); void QTouchEvent_SetDevice(QTouchEvent* self, QTouchDevice* adevice); void QTouchEvent_Delete(QTouchEvent* self); @@ -559,7 +559,7 @@ double QTouchEvent__TouchPoint_Rotation(const QTouchEvent__TouchPoint* self); QSizeF* QTouchEvent__TouchPoint_EllipseDiameters(const QTouchEvent__TouchPoint* self); QVector2D* QTouchEvent__TouchPoint_Velocity(const QTouchEvent__TouchPoint* self); int QTouchEvent__TouchPoint_Flags(const QTouchEvent__TouchPoint* self); -struct miqt_array* QTouchEvent__TouchPoint_RawScreenPositions(const QTouchEvent__TouchPoint* self); +struct miqt_array QTouchEvent__TouchPoint_RawScreenPositions(const QTouchEvent__TouchPoint* self); void QTouchEvent__TouchPoint_SetId(QTouchEvent__TouchPoint* self, int id); void QTouchEvent__TouchPoint_SetUniqueId(QTouchEvent__TouchPoint* self, long long uid); void QTouchEvent__TouchPoint_SetState(QTouchEvent__TouchPoint* self, int state); @@ -580,7 +580,7 @@ void QTouchEvent__TouchPoint_SetRotation(QTouchEvent__TouchPoint* self, double a void QTouchEvent__TouchPoint_SetEllipseDiameters(QTouchEvent__TouchPoint* self, QSizeF* dia); void QTouchEvent__TouchPoint_SetVelocity(QTouchEvent__TouchPoint* self, QVector2D* v); void QTouchEvent__TouchPoint_SetFlags(QTouchEvent__TouchPoint* self, int flags); -void QTouchEvent__TouchPoint_SetRawScreenPositions(QTouchEvent__TouchPoint* self, struct miqt_array* /* of QPointF* */ positions); +void QTouchEvent__TouchPoint_SetRawScreenPositions(QTouchEvent__TouchPoint* self, struct miqt_array /* of QPointF* */ positions); void QTouchEvent__TouchPoint_Delete(QTouchEvent__TouchPoint* self); #ifdef __cplusplus diff --git a/qt/gen_qfactoryinterface.cpp b/qt/gen_qfactoryinterface.cpp index 7c3eafaa..dec46a8f 100644 --- a/qt/gen_qfactoryinterface.cpp +++ b/qt/gen_qfactoryinterface.cpp @@ -7,7 +7,7 @@ #include "gen_qfactoryinterface.h" #include "_cgo_export.h" -struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self) { +struct miqt_array QFactoryInterface_Keys(const QFactoryInterface* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -21,9 +21,9 @@ struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfactoryinterface.go b/qt/gen_qfactoryinterface.go index 63356c43..60ca7ac9 100644 --- a/qt/gen_qfactoryinterface.go +++ b/qt/gen_qfactoryinterface.go @@ -43,7 +43,7 @@ func UnsafeNewQFactoryInterface(h unsafe.Pointer) *QFactoryInterface { } func (this *QFactoryInterface) Keys() []string { - var _ma *C.struct_miqt_array = C.QFactoryInterface_Keys(this.h) + var _ma C.struct_miqt_array = C.QFactoryInterface_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func (this *QFactoryInterface) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfactoryinterface.h b/qt/gen_qfactoryinterface.h index ae93f479..e9f4546f 100644 --- a/qt/gen_qfactoryinterface.h +++ b/qt/gen_qfactoryinterface.h @@ -19,7 +19,7 @@ class QFactoryInterface; typedef struct QFactoryInterface QFactoryInterface; #endif -struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self); +struct miqt_array QFactoryInterface_Keys(const QFactoryInterface* self); void QFactoryInterface_Delete(QFactoryInterface* self); #ifdef __cplusplus diff --git a/qt/gen_qfiledialog.cpp b/qt/gen_qfiledialog.cpp index 9f424c24..2f6ee920 100644 --- a/qt/gen_qfiledialog.cpp +++ b/qt/gen_qfiledialog.cpp @@ -101,7 +101,7 @@ void QFileDialog_SelectFile(QFileDialog* self, struct miqt_string filename) { self->selectFile(filename_QString); } -struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self) { +struct miqt_array QFileDialog_SelectedFiles(const QFileDialog* self) { QStringList _ret = self->selectedFiles(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -115,9 +115,9 @@ struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -125,16 +125,16 @@ void QFileDialog_SelectUrl(QFileDialog* self, QUrl* url) { self->selectUrl(*url); } -struct miqt_array* QFileDialog_SelectedUrls(const QFileDialog* self) { +struct miqt_array QFileDialog_SelectedUrls(const QFileDialog* self) { QList _ret = self->selectedUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -151,18 +151,18 @@ void QFileDialog_SetNameFilter(QFileDialog* self, struct miqt_string filter) { self->setNameFilter(filter_QString); } -void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setNameFilters(filters_QList); } -struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self) { +struct miqt_array QFileDialog_NameFilters(const QFileDialog* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -176,9 +176,9 @@ struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -209,18 +209,18 @@ struct miqt_string QFileDialog_SelectedNameFilter(const QFileDialog* self) { return _ms; } -void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setMimeTypeFilters(filters_QList); } -struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self) { +struct miqt_array QFileDialog_MimeTypeFilters(const QFileDialog* self) { QStringList _ret = self->mimeTypeFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -234,9 +234,9 @@ struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -297,26 +297,26 @@ bool QFileDialog_ResolveSymlinks(const QFileDialog* self) { return self->resolveSymlinks(); } -void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls) { +void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->setSidebarUrls(urls_QList); } -struct miqt_array* QFileDialog_SidebarUrls(const QFileDialog* self) { +struct miqt_array QFileDialog_SidebarUrls(const QFileDialog* self) { QList _ret = self->sidebarUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -358,18 +358,18 @@ struct miqt_string QFileDialog_DefaultSuffix(const QFileDialog* self) { return _ms; } -void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ paths) { +void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } self->setHistory(paths_QList); } -struct miqt_array* QFileDialog_History(const QFileDialog* self) { +struct miqt_array QFileDialog_History(const QFileDialog* self) { QStringList _ret = self->history(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -383,9 +383,9 @@ struct miqt_array* QFileDialog_History(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -421,18 +421,18 @@ struct miqt_string QFileDialog_LabelText(const QFileDialog* self, int label) { return _ms; } -void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ schemes) { +void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array /* of struct miqt_string */ schemes) { QStringList schemes_QList; - schemes_QList.reserve(schemes->len); - struct miqt_string* schemes_arr = static_cast(schemes->data); - for(size_t i = 0; i < schemes->len; ++i) { + schemes_QList.reserve(schemes.len); + struct miqt_string* schemes_arr = static_cast(schemes.data); + for(size_t i = 0; i < schemes.len; ++i) { QString schemes_arr_i_QString = QString::fromUtf8(schemes_arr[i].data, schemes_arr[i].len); schemes_QList.push_back(schemes_arr_i_QString); } self->setSupportedSchemes(schemes_QList); } -struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self) { +struct miqt_array QFileDialog_SupportedSchemes(const QFileDialog* self) { QStringList _ret = self->supportedSchemes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -446,9 +446,9 @@ struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -500,11 +500,11 @@ void QFileDialog_connect_FileSelected(QFileDialog* self, intptr_t slot) { }); } -void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ files) { +void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -526,10 +526,10 @@ void QFileDialog_connect_FilesSelected(QFileDialog* self, intptr_t slot) { memcpy(files_lv_ms.data, files_lv_b.data(), files_lv_ms.len); files_arr[i] = files_lv_ms; } - struct miqt_array* files_out = static_cast(malloc(sizeof(struct miqt_array))); - files_out->len = files_ret.length(); - files_out->data = static_cast(files_arr); - struct miqt_array* sigval1 = files_out; + struct miqt_array files_out; + files_out.len = files_ret.length(); + files_out.data = static_cast(files_arr); + struct miqt_array sigval1 = files_out; miqt_exec_callback_QFileDialog_FilesSelected(slot, sigval1); }); } @@ -585,11 +585,11 @@ void QFileDialog_connect_UrlSelected(QFileDialog* self, intptr_t slot) { }); } -void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls) { +void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->urlsSelected(urls_QList); @@ -603,10 +603,10 @@ void QFileDialog_connect_UrlsSelected(QFileDialog* self, intptr_t slot) { for (size_t i = 0, e = urls_ret.length(); i < e; ++i) { urls_arr[i] = new QUrl(urls_ret[i]); } - struct miqt_array* urls_out = static_cast(malloc(sizeof(struct miqt_array))); - urls_out->len = urls_ret.length(); - urls_out->data = static_cast(urls_arr); - struct miqt_array* sigval1 = urls_out; + struct miqt_array urls_out; + urls_out.len = urls_ret.length(); + urls_out.data = static_cast(urls_arr); + struct miqt_array sigval1 = urls_out; miqt_exec_callback_QFileDialog_UrlsSelected(slot, sigval1); }); } @@ -701,7 +701,7 @@ QUrl* QFileDialog_GetExistingDirectoryUrl() { return new QUrl(QFileDialog::getExistingDirectoryUrl()); } -struct miqt_array* QFileDialog_GetOpenFileNames() { +struct miqt_array QFileDialog_GetOpenFileNames() { QStringList _ret = QFileDialog::getOpenFileNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -715,22 +715,22 @@ struct miqt_array* QFileDialog_GetOpenFileNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls() { +struct miqt_array QFileDialog_GetOpenFileUrls() { QList _ret = QFileDialog::getOpenFileUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -996,19 +996,19 @@ QUrl* QFileDialog_GetExistingDirectoryUrl4(QWidget* parent, struct miqt_string c return new QUrl(QFileDialog::getExistingDirectoryUrl(parent, caption_QString, *dir, static_cast(options))); } -QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array* /* of struct miqt_string */ supportedSchemes) { +QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array /* of struct miqt_string */ supportedSchemes) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QStringList supportedSchemes_QList; - supportedSchemes_QList.reserve(supportedSchemes->len); - struct miqt_string* supportedSchemes_arr = static_cast(supportedSchemes->data); - for(size_t i = 0; i < supportedSchemes->len; ++i) { + supportedSchemes_QList.reserve(supportedSchemes.len); + struct miqt_string* supportedSchemes_arr = static_cast(supportedSchemes.data); + for(size_t i = 0; i < supportedSchemes.len; ++i) { QString supportedSchemes_arr_i_QString = QString::fromUtf8(supportedSchemes_arr[i].data, supportedSchemes_arr[i].len); supportedSchemes_QList.push_back(supportedSchemes_arr_i_QString); } return new QUrl(QFileDialog::getExistingDirectoryUrl(parent, caption_QString, *dir, static_cast(options), supportedSchemes_QList)); } -struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent) { +struct miqt_array QFileDialog_GetOpenFileNames1(QWidget* parent) { QStringList _ret = QFileDialog::getOpenFileNames(parent); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -1022,13 +1022,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption) { +struct miqt_array QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QStringList _ret = QFileDialog::getOpenFileNames(parent, caption_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -1043,13 +1043,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir) { +struct miqt_array QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString dir_QString = QString::fromUtf8(dir.data, dir.len); QStringList _ret = QFileDialog::getOpenFileNames(parent, caption_QString, dir_QString); @@ -1065,13 +1065,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter) { +struct miqt_array QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString dir_QString = QString::fromUtf8(dir.data, dir.len); QString filter_QString = QString::fromUtf8(filter.data, filter.len); @@ -1088,26 +1088,26 @@ struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls1(QWidget* parent) { +struct miqt_array QFileDialog_GetOpenFileUrls1(QWidget* parent) { QList _ret = QFileDialog::getOpenFileUrls(parent); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption) { +struct miqt_array QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -1115,13 +1115,13 @@ struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir) { +struct miqt_array QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString, *dir); // Convert QList<> from C++ memory to manually-managed C memory @@ -1129,13 +1129,13 @@ struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter) { +struct miqt_array QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString filter_QString = QString::fromUtf8(filter.data, filter.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString, *dir, filter_QString); @@ -1144,9 +1144,9 @@ struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfiledialog.go b/qt/gen_qfiledialog.go index 9221270b..e145a595 100644 --- a/qt/gen_qfiledialog.go +++ b/qt/gen_qfiledialog.go @@ -218,7 +218,7 @@ func (this *QFileDialog) SelectFile(filename string) { } func (this *QFileDialog) SelectedFiles() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_SelectedFiles(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SelectedFiles(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -227,7 +227,6 @@ func (this *QFileDialog) SelectedFiles() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -236,7 +235,7 @@ func (this *QFileDialog) SelectUrl(url *QUrl) { } func (this *QFileDialog) SelectedUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_SelectedUrls(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SelectedUrls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -245,7 +244,6 @@ func (this *QFileDialog) SelectedUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -266,7 +264,6 @@ func (this *QFileDialog) SetNameFilter(filter string) { } func (this *QFileDialog) SetNameFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -276,13 +273,12 @@ func (this *QFileDialog) SetNameFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileDialog_SetNameFilters(this.h, filters_ma) } func (this *QFileDialog) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -291,7 +287,6 @@ func (this *QFileDialog) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -318,7 +313,6 @@ func (this *QFileDialog) SelectedNameFilter() string { } func (this *QFileDialog) SetMimeTypeFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -328,13 +322,12 @@ func (this *QFileDialog) SetMimeTypeFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileDialog_SetMimeTypeFilters(this.h, filters_ma) } func (this *QFileDialog) MimeTypeFilters() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_MimeTypeFilters(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_MimeTypeFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -343,7 +336,6 @@ func (this *QFileDialog) MimeTypeFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -404,19 +396,17 @@ func (this *QFileDialog) ResolveSymlinks() bool { } func (this *QFileDialog) SetSidebarUrls(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QFileDialog_SetSidebarUrls(this.h, urls_ma) } func (this *QFileDialog) SidebarUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_SidebarUrls(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SidebarUrls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -425,7 +415,6 @@ func (this *QFileDialog) SidebarUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -467,7 +456,6 @@ func (this *QFileDialog) DefaultSuffix() string { } func (this *QFileDialog) SetHistory(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -477,13 +465,12 @@ func (this *QFileDialog) SetHistory(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QFileDialog_SetHistory(this.h, paths_ma) } func (this *QFileDialog) History() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_History(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_History(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -492,7 +479,6 @@ func (this *QFileDialog) History() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -528,7 +514,6 @@ func (this *QFileDialog) LabelText(label QFileDialog__DialogLabel) string { } func (this *QFileDialog) SetSupportedSchemes(schemes []string) { - // For the C ABI, malloc a C array of structs schemes_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(schemes)))) defer C.free(unsafe.Pointer(schemes_CArray)) for i := range schemes { @@ -538,13 +523,12 @@ func (this *QFileDialog) SetSupportedSchemes(schemes []string) { defer C.free(unsafe.Pointer(schemes_i_ms.data)) schemes_CArray[i] = schemes_i_ms } - schemes_ma := &C.struct_miqt_array{len: C.size_t(len(schemes)), data: unsafe.Pointer(schemes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(schemes_ma)) + schemes_ma := C.struct_miqt_array{len: C.size_t(len(schemes)), data: unsafe.Pointer(schemes_CArray)} C.QFileDialog_SetSupportedSchemes(this.h, schemes_ma) } func (this *QFileDialog) SupportedSchemes() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_SupportedSchemes(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SupportedSchemes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -553,7 +537,6 @@ func (this *QFileDialog) SupportedSchemes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -613,7 +596,6 @@ func miqt_exec_callback_QFileDialog_FileSelected(cb C.intptr_t, file C.struct_mi } func (this *QFileDialog) FilesSelected(files []string) { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -623,8 +605,7 @@ func (this *QFileDialog) FilesSelected(files []string) { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} C.QFileDialog_FilesSelected(this.h, files_ma) } func (this *QFileDialog) OnFilesSelected(slot func(files []string)) { @@ -632,14 +613,14 @@ func (this *QFileDialog) OnFilesSelected(slot func(files []string)) { } //export miqt_exec_callback_QFileDialog_FilesSelected -func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files *C.struct_miqt_array) { +func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(files []string)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var files_ma *C.struct_miqt_array = files + var files_ma C.struct_miqt_array = files files_ret := make([]string, int(files_ma.len)) files_outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(files_ma.data)) // hey ya for i := 0; i < int(files_ma.len); i++ { @@ -648,7 +629,6 @@ func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files *C.struct C.free(unsafe.Pointer(files_lv_ms.data)) files_ret[i] = files_lv_ret } - C.free(unsafe.Pointer(files_ma)) slotval1 := files_ret gofunc(slotval1) @@ -729,14 +709,12 @@ func miqt_exec_callback_QFileDialog_UrlSelected(cb C.intptr_t, url *C.QUrl) { } func (this *QFileDialog) UrlsSelected(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QFileDialog_UrlsSelected(this.h, urls_ma) } func (this *QFileDialog) OnUrlsSelected(slot func(urls []QUrl)) { @@ -744,14 +722,14 @@ func (this *QFileDialog) OnUrlsSelected(slot func(urls []QUrl)) { } //export miqt_exec_callback_QFileDialog_UrlsSelected -func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls *C.struct_miqt_array) { +func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(urls []QUrl)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var urls_ma *C.struct_miqt_array = urls + var urls_ma C.struct_miqt_array = urls urls_ret := make([]QUrl, int(urls_ma.len)) urls_outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(urls_ma.data)) // hey ya for i := 0; i < int(urls_ma.len); i++ { @@ -760,7 +738,6 @@ func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls *C.struct_m urls_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer urls_ret[i] = *urls_lv_goptr } - C.free(unsafe.Pointer(urls_ma)) slotval1 := urls_ret gofunc(slotval1) @@ -876,7 +853,7 @@ func QFileDialog_GetExistingDirectoryUrl() *QUrl { } func QFileDialog_GetOpenFileNames() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames() + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -885,12 +862,11 @@ func QFileDialog_GetOpenFileNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFileDialog_GetOpenFileUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls() + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls() _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -899,7 +875,6 @@ func QFileDialog_GetOpenFileUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1247,7 +1222,6 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - // For the C ABI, malloc a C array of structs supportedSchemes_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(supportedSchemes)))) defer C.free(unsafe.Pointer(supportedSchemes_CArray)) for i := range supportedSchemes { @@ -1257,8 +1231,7 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * defer C.free(unsafe.Pointer(supportedSchemes_i_ms.data)) supportedSchemes_CArray[i] = supportedSchemes_i_ms } - supportedSchemes_ma := &C.struct_miqt_array{len: C.size_t(len(supportedSchemes)), data: unsafe.Pointer(supportedSchemes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(supportedSchemes_ma)) + supportedSchemes_ma := C.struct_miqt_array{len: C.size_t(len(supportedSchemes)), data: unsafe.Pointer(supportedSchemes_CArray)} _ret := C.QFileDialog_GetExistingDirectoryUrl5(parent.cPointer(), caption_ms, dir.cPointer(), (C.int)(options), supportedSchemes_ma) _goptr := newQUrl(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer @@ -1266,7 +1239,7 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * } func QFileDialog_GetOpenFileNames1(parent *QWidget) []string { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames1(parent.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames1(parent.cPointer()) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1275,7 +1248,6 @@ func QFileDialog_GetOpenFileNames1(parent *QWidget) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1284,7 +1256,7 @@ func QFileDialog_GetOpenFileNames2(parent *QWidget, caption string) []string { caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames2(parent.cPointer(), caption_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames2(parent.cPointer(), caption_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1293,7 +1265,6 @@ func QFileDialog_GetOpenFileNames2(parent *QWidget, caption string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1306,7 +1277,7 @@ func QFileDialog_GetOpenFileNames3(parent *QWidget, caption string, dir string) dir_ms.data = C.CString(dir) dir_ms.len = C.size_t(len(dir)) defer C.free(unsafe.Pointer(dir_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames3(parent.cPointer(), caption_ms, dir_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames3(parent.cPointer(), caption_ms, dir_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1315,7 +1286,6 @@ func QFileDialog_GetOpenFileNames3(parent *QWidget, caption string, dir string) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1332,7 +1302,7 @@ func QFileDialog_GetOpenFileNames4(parent *QWidget, caption string, dir string, filter_ms.data = C.CString(filter) filter_ms.len = C.size_t(len(filter)) defer C.free(unsafe.Pointer(filter_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames4(parent.cPointer(), caption_ms, dir_ms, filter_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames4(parent.cPointer(), caption_ms, dir_ms, filter_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1341,12 +1311,11 @@ func QFileDialog_GetOpenFileNames4(parent *QWidget, caption string, dir string, C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFileDialog_GetOpenFileUrls1(parent *QWidget) []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls1(parent.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls1(parent.cPointer()) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1355,7 +1324,6 @@ func QFileDialog_GetOpenFileUrls1(parent *QWidget) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1364,7 +1332,7 @@ func QFileDialog_GetOpenFileUrls2(parent *QWidget, caption string) []QUrl { caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls2(parent.cPointer(), caption_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls2(parent.cPointer(), caption_ms) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1373,7 +1341,6 @@ func QFileDialog_GetOpenFileUrls2(parent *QWidget, caption string) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1382,7 +1349,7 @@ func QFileDialog_GetOpenFileUrls3(parent *QWidget, caption string, dir *QUrl) [] caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls3(parent.cPointer(), caption_ms, dir.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls3(parent.cPointer(), caption_ms, dir.cPointer()) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1391,7 +1358,6 @@ func QFileDialog_GetOpenFileUrls3(parent *QWidget, caption string, dir *QUrl) [] _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1404,7 +1370,7 @@ func QFileDialog_GetOpenFileUrls4(parent *QWidget, caption string, dir *QUrl, fi filter_ms.data = C.CString(filter) filter_ms.len = C.size_t(len(filter)) defer C.free(unsafe.Pointer(filter_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls4(parent.cPointer(), caption_ms, dir.cPointer(), filter_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls4(parent.cPointer(), caption_ms, dir.cPointer(), filter_ms) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1413,7 +1379,6 @@ func QFileDialog_GetOpenFileUrls4(parent *QWidget, caption string, dir *QUrl, fi _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfiledialog.h b/qt/gen_qfiledialog.h index 8cd7bc13..abe997bb 100644 --- a/qt/gen_qfiledialog.h +++ b/qt/gen_qfiledialog.h @@ -51,19 +51,19 @@ QDir* QFileDialog_Directory(const QFileDialog* self); void QFileDialog_SetDirectoryUrl(QFileDialog* self, QUrl* directory); QUrl* QFileDialog_DirectoryUrl(const QFileDialog* self); void QFileDialog_SelectFile(QFileDialog* self, struct miqt_string filename); -struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self); +struct miqt_array QFileDialog_SelectedFiles(const QFileDialog* self); void QFileDialog_SelectUrl(QFileDialog* self, QUrl* url); -struct miqt_array* QFileDialog_SelectedUrls(const QFileDialog* self); +struct miqt_array QFileDialog_SelectedUrls(const QFileDialog* self); void QFileDialog_SetNameFilterDetailsVisible(QFileDialog* self, bool enabled); bool QFileDialog_IsNameFilterDetailsVisible(const QFileDialog* self); void QFileDialog_SetNameFilter(QFileDialog* self, struct miqt_string filter); -void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self); +void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileDialog_NameFilters(const QFileDialog* self); void QFileDialog_SelectNameFilter(QFileDialog* self, struct miqt_string filter); struct miqt_string QFileDialog_SelectedMimeTypeFilter(const QFileDialog* self); struct miqt_string QFileDialog_SelectedNameFilter(const QFileDialog* self); -void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self); +void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileDialog_MimeTypeFilters(const QFileDialog* self); void QFileDialog_SelectMimeTypeFilter(QFileDialog* self, struct miqt_string filter); int QFileDialog_Filter(const QFileDialog* self); void QFileDialog_SetFilter(QFileDialog* self, int filters); @@ -77,24 +77,24 @@ void QFileDialog_SetReadOnly(QFileDialog* self, bool enabled); bool QFileDialog_IsReadOnly(const QFileDialog* self); void QFileDialog_SetResolveSymlinks(QFileDialog* self, bool enabled); bool QFileDialog_ResolveSymlinks(const QFileDialog* self); -void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls); -struct miqt_array* QFileDialog_SidebarUrls(const QFileDialog* self); +void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array /* of QUrl* */ urls); +struct miqt_array QFileDialog_SidebarUrls(const QFileDialog* self); struct miqt_string QFileDialog_SaveState(const QFileDialog* self); bool QFileDialog_RestoreState(QFileDialog* self, struct miqt_string state); void QFileDialog_SetConfirmOverwrite(QFileDialog* self, bool enabled); bool QFileDialog_ConfirmOverwrite(const QFileDialog* self); void QFileDialog_SetDefaultSuffix(QFileDialog* self, struct miqt_string suffix); struct miqt_string QFileDialog_DefaultSuffix(const QFileDialog* self); -void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ paths); -struct miqt_array* QFileDialog_History(const QFileDialog* self); +void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array /* of struct miqt_string */ paths); +struct miqt_array QFileDialog_History(const QFileDialog* self); void QFileDialog_SetItemDelegate(QFileDialog* self, QAbstractItemDelegate* delegate); QAbstractItemDelegate* QFileDialog_ItemDelegate(const QFileDialog* self); void QFileDialog_SetIconProvider(QFileDialog* self, QFileIconProvider* provider); QFileIconProvider* QFileDialog_IconProvider(const QFileDialog* self); void QFileDialog_SetLabelText(QFileDialog* self, int label, struct miqt_string text); struct miqt_string QFileDialog_LabelText(const QFileDialog* self, int label); -void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ schemes); -struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self); +void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array /* of struct miqt_string */ schemes); +struct miqt_array QFileDialog_SupportedSchemes(const QFileDialog* self); void QFileDialog_SetProxyModel(QFileDialog* self, QAbstractProxyModel* model); QAbstractProxyModel* QFileDialog_ProxyModel(const QFileDialog* self); void QFileDialog_SetOption(QFileDialog* self, int option); @@ -104,7 +104,7 @@ int QFileDialog_Options(const QFileDialog* self); void QFileDialog_SetVisible(QFileDialog* self, bool visible); void QFileDialog_FileSelected(QFileDialog* self, struct miqt_string file); void QFileDialog_connect_FileSelected(QFileDialog* self, intptr_t slot); -void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ files); +void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array /* of struct miqt_string */ files); void QFileDialog_connect_FilesSelected(QFileDialog* self, intptr_t slot); void QFileDialog_CurrentChanged(QFileDialog* self, struct miqt_string path); void QFileDialog_connect_CurrentChanged(QFileDialog* self, intptr_t slot); @@ -112,7 +112,7 @@ void QFileDialog_DirectoryEntered(QFileDialog* self, struct miqt_string director void QFileDialog_connect_DirectoryEntered(QFileDialog* self, intptr_t slot); void QFileDialog_UrlSelected(QFileDialog* self, QUrl* url); void QFileDialog_connect_UrlSelected(QFileDialog* self, intptr_t slot); -void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls); +void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array /* of QUrl* */ urls); void QFileDialog_connect_UrlsSelected(QFileDialog* self, intptr_t slot); void QFileDialog_CurrentUrlChanged(QFileDialog* self, QUrl* url); void QFileDialog_connect_CurrentUrlChanged(QFileDialog* self, intptr_t slot); @@ -126,8 +126,8 @@ struct miqt_string QFileDialog_GetSaveFileName(); QUrl* QFileDialog_GetSaveFileUrl(); struct miqt_string QFileDialog_GetExistingDirectory(); QUrl* QFileDialog_GetExistingDirectoryUrl(); -struct miqt_array* QFileDialog_GetOpenFileNames(); -struct miqt_array* QFileDialog_GetOpenFileUrls(); +struct miqt_array QFileDialog_GetOpenFileNames(); +struct miqt_array QFileDialog_GetOpenFileUrls(); void QFileDialog_SaveFileContent(struct miqt_string fileContent, struct miqt_string fileNameHint); struct miqt_string QFileDialog_Tr2(const char* s, const char* c); struct miqt_string QFileDialog_Tr3(const char* s, const char* c, int n); @@ -158,15 +158,15 @@ QUrl* QFileDialog_GetExistingDirectoryUrl1(QWidget* parent); QUrl* QFileDialog_GetExistingDirectoryUrl2(QWidget* parent, struct miqt_string caption); QUrl* QFileDialog_GetExistingDirectoryUrl3(QWidget* parent, struct miqt_string caption, QUrl* dir); QUrl* QFileDialog_GetExistingDirectoryUrl4(QWidget* parent, struct miqt_string caption, QUrl* dir, int options); -QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array* /* of struct miqt_string */ supportedSchemes); -struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent); -struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption); -struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir); -struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter); -struct miqt_array* QFileDialog_GetOpenFileUrls1(QWidget* parent); -struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption); -struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir); -struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter); +QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array /* of struct miqt_string */ supportedSchemes); +struct miqt_array QFileDialog_GetOpenFileNames1(QWidget* parent); +struct miqt_array QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption); +struct miqt_array QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir); +struct miqt_array QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter); +struct miqt_array QFileDialog_GetOpenFileUrls1(QWidget* parent); +struct miqt_array QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption); +struct miqt_array QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir); +struct miqt_array QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter); void QFileDialog_Delete(QFileDialog* self); #ifdef __cplusplus diff --git a/qt/gen_qfileselector.cpp b/qt/gen_qfileselector.cpp index 145ecbd3..f9ef81e8 100644 --- a/qt/gen_qfileselector.cpp +++ b/qt/gen_qfileselector.cpp @@ -64,7 +64,7 @@ QUrl* QFileSelector_SelectWithFilePath(const QFileSelector* self, QUrl* filePath return new QUrl(self->select(*filePath)); } -struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self) { +struct miqt_array QFileSelector_ExtraSelectors(const QFileSelector* self) { QStringList _ret = self->extraSelectors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -78,24 +78,24 @@ struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array* /* of struct miqt_string */ list) { +void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } self->setExtraSelectors(list_QList); } -struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self) { +struct miqt_array QFileSelector_AllSelectors(const QFileSelector* self) { QStringList _ret = self->allSelectors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -109,9 +109,9 @@ struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfileselector.go b/qt/gen_qfileselector.go index 913f8367..17ce8a98 100644 --- a/qt/gen_qfileselector.go +++ b/qt/gen_qfileselector.go @@ -102,7 +102,7 @@ func (this *QFileSelector) SelectWithFilePath(filePath *QUrl) *QUrl { } func (this *QFileSelector) ExtraSelectors() []string { - var _ma *C.struct_miqt_array = C.QFileSelector_ExtraSelectors(this.h) + var _ma C.struct_miqt_array = C.QFileSelector_ExtraSelectors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -111,12 +111,10 @@ func (this *QFileSelector) ExtraSelectors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSelector) SetExtraSelectors(list []string) { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -126,13 +124,12 @@ func (this *QFileSelector) SetExtraSelectors(list []string) { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QFileSelector_SetExtraSelectors(this.h, list_ma) } func (this *QFileSelector) AllSelectors() []string { - var _ma *C.struct_miqt_array = C.QFileSelector_AllSelectors(this.h) + var _ma C.struct_miqt_array = C.QFileSelector_AllSelectors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -141,7 +138,6 @@ func (this *QFileSelector) AllSelectors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfileselector.h b/qt/gen_qfileselector.h index 7ec676a2..666a9818 100644 --- a/qt/gen_qfileselector.h +++ b/qt/gen_qfileselector.h @@ -33,9 +33,9 @@ struct miqt_string QFileSelector_Tr(const char* s); struct miqt_string QFileSelector_TrUtf8(const char* s); struct miqt_string QFileSelector_Select(const QFileSelector* self, struct miqt_string filePath); QUrl* QFileSelector_SelectWithFilePath(const QFileSelector* self, QUrl* filePath); -struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self); -void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array* /* of struct miqt_string */ list); -struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self); +struct miqt_array QFileSelector_ExtraSelectors(const QFileSelector* self); +void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array /* of struct miqt_string */ list); +struct miqt_array QFileSelector_AllSelectors(const QFileSelector* self); struct miqt_string QFileSelector_Tr2(const char* s, const char* c); struct miqt_string QFileSelector_Tr3(const char* s, const char* c, int n); struct miqt_string QFileSelector_TrUtf82(const char* s, const char* c); diff --git a/qt/gen_qfilesystemmodel.cpp b/qt/gen_qfilesystemmodel.cpp index cb265dd2..a7b09ea0 100644 --- a/qt/gen_qfilesystemmodel.cpp +++ b/qt/gen_qfilesystemmodel.cpp @@ -192,7 +192,7 @@ void QFileSystemModel_Sort(QFileSystemModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self) { +struct miqt_array QFileSystemModel_MimeTypes(const QFileSystemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -206,17 +206,17 @@ struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -292,18 +292,18 @@ bool QFileSystemModel_NameFilterDisables(const QFileSystemModel* self) { return self->nameFilterDisables(); } -void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setNameFilters(filters_QList); } -struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self) { +struct miqt_array QFileSystemModel_NameFilters(const QFileSystemModel* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -317,9 +317,9 @@ struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfilesystemmodel.go b/qt/gen_qfilesystemmodel.go index 6c52c7fb..f26b4ffe 100644 --- a/qt/gen_qfilesystemmodel.go +++ b/qt/gen_qfilesystemmodel.go @@ -284,7 +284,7 @@ func (this *QFileSystemModel) Sort(column int) { } func (this *QFileSystemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QFileSystemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QFileSystemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -293,19 +293,16 @@ func (this *QFileSystemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QFileSystemModel_MimeData(this.h, indexes_ma))) } @@ -383,7 +380,6 @@ func (this *QFileSystemModel) NameFilterDisables() bool { } func (this *QFileSystemModel) SetNameFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -393,13 +389,12 @@ func (this *QFileSystemModel) SetNameFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileSystemModel_SetNameFilters(this.h, filters_ma) } func (this *QFileSystemModel) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QFileSystemModel_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QFileSystemModel_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -408,7 +403,6 @@ func (this *QFileSystemModel) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfilesystemmodel.h b/qt/gen_qfilesystemmodel.h index a75617b2..92bce3ef 100644 --- a/qt/gen_qfilesystemmodel.h +++ b/qt/gen_qfilesystemmodel.h @@ -66,8 +66,8 @@ bool QFileSystemModel_SetData(QFileSystemModel* self, QModelIndex* index, QVaria QVariant* QFileSystemModel_HeaderData(const QFileSystemModel* self, int section, int orientation); int QFileSystemModel_Flags(const QFileSystemModel* self, QModelIndex* index); void QFileSystemModel_Sort(QFileSystemModel* self, int column); -struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self); -QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QFileSystemModel_MimeTypes(const QFileSystemModel* self); +QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QFileSystemModel_DropMimeData(QFileSystemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); int QFileSystemModel_SupportedDropActions(const QFileSystemModel* self); QModelIndex* QFileSystemModel_SetRootPath(QFileSystemModel* self, struct miqt_string path); @@ -83,8 +83,8 @@ void QFileSystemModel_SetReadOnly(QFileSystemModel* self, bool enable); bool QFileSystemModel_IsReadOnly(const QFileSystemModel* self); void QFileSystemModel_SetNameFilterDisables(QFileSystemModel* self, bool enable); bool QFileSystemModel_NameFilterDisables(const QFileSystemModel* self); -void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self); +void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileSystemModel_NameFilters(const QFileSystemModel* self); void QFileSystemModel_SetOption(QFileSystemModel* self, int option); bool QFileSystemModel_TestOption(const QFileSystemModel* self, int option); void QFileSystemModel_SetOptions(QFileSystemModel* self, int options); diff --git a/qt/gen_qfilesystemwatcher.cpp b/qt/gen_qfilesystemwatcher.cpp index 5c455e33..c851edb6 100644 --- a/qt/gen_qfilesystemwatcher.cpp +++ b/qt/gen_qfilesystemwatcher.cpp @@ -13,11 +13,11 @@ QFileSystemWatcher* QFileSystemWatcher_new() { return new QFileSystemWatcher(); } -QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array* /* of struct miqt_string */ paths) { +QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -28,11 +28,11 @@ QFileSystemWatcher* QFileSystemWatcher_new3(QObject* parent) { return new QFileSystemWatcher(parent); } -QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array* /* of struct miqt_string */ paths, QObject* parent) { +QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array /* of struct miqt_string */ paths, QObject* parent) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -74,11 +74,11 @@ bool QFileSystemWatcher_AddPath(QFileSystemWatcher* self, struct miqt_string fil return self->addPath(file_QString); } -struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files) { +struct miqt_array QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -95,9 +95,9 @@ struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -106,11 +106,11 @@ bool QFileSystemWatcher_RemovePath(QFileSystemWatcher* self, struct miqt_string return self->removePath(file_QString); } -struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files) { +struct miqt_array QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -127,13 +127,13 @@ struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, stru memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self) { +struct miqt_array QFileSystemWatcher_Files(const QFileSystemWatcher* self) { QStringList _ret = self->files(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -147,13 +147,13 @@ struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self) { +struct miqt_array QFileSystemWatcher_Directories(const QFileSystemWatcher* self) { QStringList _ret = self->directories(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -167,9 +167,9 @@ struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfilesystemwatcher.go b/qt/gen_qfilesystemwatcher.go index 008492e8..303b98e5 100644 --- a/qt/gen_qfilesystemwatcher.go +++ b/qt/gen_qfilesystemwatcher.go @@ -51,7 +51,6 @@ func NewQFileSystemWatcher() *QFileSystemWatcher { // NewQFileSystemWatcher2 constructs a new QFileSystemWatcher object. func NewQFileSystemWatcher2(paths []string) *QFileSystemWatcher { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -61,8 +60,7 @@ func NewQFileSystemWatcher2(paths []string) *QFileSystemWatcher { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} ret := C.QFileSystemWatcher_new2(paths_ma) return newQFileSystemWatcher(ret) } @@ -75,7 +73,6 @@ func NewQFileSystemWatcher3(parent *QObject) *QFileSystemWatcher { // NewQFileSystemWatcher4 constructs a new QFileSystemWatcher object. func NewQFileSystemWatcher4(paths []string, parent *QObject) *QFileSystemWatcher { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -85,8 +82,7 @@ func NewQFileSystemWatcher4(paths []string, parent *QObject) *QFileSystemWatcher defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} ret := C.QFileSystemWatcher_new4(paths_ma, parent.cPointer()) return newQFileSystemWatcher(ret) } @@ -128,7 +124,6 @@ func (this *QFileSystemWatcher) AddPath(file string) bool { } func (this *QFileSystemWatcher) AddPaths(files []string) []string { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -138,9 +133,8 @@ func (this *QFileSystemWatcher) AddPaths(files []string) []string { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_AddPaths(this.h, files_ma) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} + var _ma C.struct_miqt_array = C.QFileSystemWatcher_AddPaths(this.h, files_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -149,7 +143,6 @@ func (this *QFileSystemWatcher) AddPaths(files []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -162,7 +155,6 @@ func (this *QFileSystemWatcher) RemovePath(file string) bool { } func (this *QFileSystemWatcher) RemovePaths(files []string) []string { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -172,9 +164,8 @@ func (this *QFileSystemWatcher) RemovePaths(files []string) []string { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_RemovePaths(this.h, files_ma) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} + var _ma C.struct_miqt_array = C.QFileSystemWatcher_RemovePaths(this.h, files_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -183,12 +174,11 @@ func (this *QFileSystemWatcher) RemovePaths(files []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemWatcher) Files() []string { - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_Files(this.h) + var _ma C.struct_miqt_array = C.QFileSystemWatcher_Files(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -197,12 +187,11 @@ func (this *QFileSystemWatcher) Files() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemWatcher) Directories() []string { - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_Directories(this.h) + var _ma C.struct_miqt_array = C.QFileSystemWatcher_Directories(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -211,7 +200,6 @@ func (this *QFileSystemWatcher) Directories() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfilesystemwatcher.h b/qt/gen_qfilesystemwatcher.h index f435e322..bd582afa 100644 --- a/qt/gen_qfilesystemwatcher.h +++ b/qt/gen_qfilesystemwatcher.h @@ -24,19 +24,19 @@ typedef struct QObject QObject; #endif QFileSystemWatcher* QFileSystemWatcher_new(); -QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array* /* of struct miqt_string */ paths); +QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array /* of struct miqt_string */ paths); QFileSystemWatcher* QFileSystemWatcher_new3(QObject* parent); -QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array* /* of struct miqt_string */ paths, QObject* parent); +QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array /* of struct miqt_string */ paths, QObject* parent); QMetaObject* QFileSystemWatcher_MetaObject(const QFileSystemWatcher* self); void* QFileSystemWatcher_Metacast(QFileSystemWatcher* self, const char* param1); struct miqt_string QFileSystemWatcher_Tr(const char* s); struct miqt_string QFileSystemWatcher_TrUtf8(const char* s); bool QFileSystemWatcher_AddPath(QFileSystemWatcher* self, struct miqt_string file); -struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files); +struct miqt_array QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files); bool QFileSystemWatcher_RemovePath(QFileSystemWatcher* self, struct miqt_string file); -struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files); -struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self); -struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self); +struct miqt_array QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files); +struct miqt_array QFileSystemWatcher_Files(const QFileSystemWatcher* self); +struct miqt_array QFileSystemWatcher_Directories(const QFileSystemWatcher* self); struct miqt_string QFileSystemWatcher_Tr2(const char* s, const char* c); struct miqt_string QFileSystemWatcher_Tr3(const char* s, const char* c, int n); struct miqt_string QFileSystemWatcher_TrUtf82(const char* s, const char* c); diff --git a/qt/gen_qfont.cpp b/qt/gen_qfont.cpp index b411df63..c24c6b12 100644 --- a/qt/gen_qfont.cpp +++ b/qt/gen_qfont.cpp @@ -64,7 +64,7 @@ void QFont_SetFamily(QFont* self, struct miqt_string family) { self->setFamily(family_QString); } -struct miqt_array* QFont_Families(const QFont* self) { +struct miqt_array QFont_Families(const QFont* self) { QStringList _ret = self->families(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -78,17 +78,17 @@ struct miqt_array* QFont_Families(const QFont* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QFont_SetFamilies(QFont* self, struct miqt_array* /* of struct miqt_string */ families) { +void QFont_SetFamilies(QFont* self, struct miqt_array /* of struct miqt_string */ families) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -363,7 +363,7 @@ struct miqt_string QFont_Substitute(struct miqt_string param1) { return _ms; } -struct miqt_array* QFont_Substitutes(struct miqt_string param1) { +struct miqt_array QFont_Substitutes(struct miqt_string param1) { QString param1_QString = QString::fromUtf8(param1.data, param1.len); QStringList _ret = QFont::substitutes(param1_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -378,13 +378,13 @@ struct miqt_array* QFont_Substitutes(struct miqt_string param1) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFont_Substitutions() { +struct miqt_array QFont_Substitutions() { QStringList _ret = QFont::substitutions(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -398,9 +398,9 @@ struct miqt_array* QFont_Substitutions() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -410,12 +410,12 @@ void QFont_InsertSubstitution(struct miqt_string param1, struct miqt_string para QFont::insertSubstitution(param1_QString, param2_QString); } -void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array* /* of struct miqt_string */ param2) { +void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array /* of struct miqt_string */ param2) { QString param1_QString = QString::fromUtf8(param1.data, param1.len); QStringList param2_QList; - param2_QList.reserve(param2->len); - struct miqt_string* param2_arr = static_cast(param2->data); - for(size_t i = 0; i < param2->len; ++i) { + param2_QList.reserve(param2.len); + struct miqt_string* param2_arr = static_cast(param2.data); + for(size_t i = 0; i < param2.len; ++i) { QString param2_arr_i_QString = QString::fromUtf8(param2_arr[i].data, param2_arr[i].len); param2_QList.push_back(param2_arr_i_QString); } diff --git a/qt/gen_qfont.go b/qt/gen_qfont.go index 82bc3ff3..ce585a4e 100644 --- a/qt/gen_qfont.go +++ b/qt/gen_qfont.go @@ -251,7 +251,7 @@ func (this *QFont) SetFamily(family string) { } func (this *QFont) Families() []string { - var _ma *C.struct_miqt_array = C.QFont_Families(this.h) + var _ma C.struct_miqt_array = C.QFont_Families(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -260,12 +260,10 @@ func (this *QFont) Families() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFont) SetFamilies(families []string) { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -275,8 +273,7 @@ func (this *QFont) SetFamilies(families []string) { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} C.QFont_SetFamilies(this.h, families_ma) } @@ -536,7 +533,7 @@ func QFont_Substitutes(param1 string) []string { param1_ms.data = C.CString(param1) param1_ms.len = C.size_t(len(param1)) defer C.free(unsafe.Pointer(param1_ms.data)) - var _ma *C.struct_miqt_array = C.QFont_Substitutes(param1_ms) + var _ma C.struct_miqt_array = C.QFont_Substitutes(param1_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -545,12 +542,11 @@ func QFont_Substitutes(param1 string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFont_Substitutions() []string { - var _ma *C.struct_miqt_array = C.QFont_Substitutions() + var _ma C.struct_miqt_array = C.QFont_Substitutions() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -559,7 +555,6 @@ func QFont_Substitutions() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -580,7 +575,6 @@ func QFont_InsertSubstitutions(param1 string, param2 []string) { param1_ms.data = C.CString(param1) param1_ms.len = C.size_t(len(param1)) defer C.free(unsafe.Pointer(param1_ms.data)) - // For the C ABI, malloc a C array of structs param2_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(param2)))) defer C.free(unsafe.Pointer(param2_CArray)) for i := range param2 { @@ -590,8 +584,7 @@ func QFont_InsertSubstitutions(param1 string, param2 []string) { defer C.free(unsafe.Pointer(param2_i_ms.data)) param2_CArray[i] = param2_i_ms } - param2_ma := &C.struct_miqt_array{len: C.size_t(len(param2)), data: unsafe.Pointer(param2_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(param2_ma)) + param2_ma := C.struct_miqt_array{len: C.size_t(len(param2)), data: unsafe.Pointer(param2_CArray)} C.QFont_InsertSubstitutions(param1_ms, param2_ma) } diff --git a/qt/gen_qfont.h b/qt/gen_qfont.h index 8f92f31d..24df58c2 100644 --- a/qt/gen_qfont.h +++ b/qt/gen_qfont.h @@ -32,8 +32,8 @@ QFont* QFont_new8(struct miqt_string family, int pointSize, int weight, bool ita void QFont_Swap(QFont* self, QFont* other); struct miqt_string QFont_Family(const QFont* self); void QFont_SetFamily(QFont* self, struct miqt_string family); -struct miqt_array* QFont_Families(const QFont* self); -void QFont_SetFamilies(QFont* self, struct miqt_array* /* of struct miqt_string */ families); +struct miqt_array QFont_Families(const QFont* self); +void QFont_SetFamilies(QFont* self, struct miqt_array /* of struct miqt_string */ families); struct miqt_string QFont_StyleName(const QFont* self); void QFont_SetStyleName(QFont* self, struct miqt_string styleName); int QFont_PointSize(const QFont* self); @@ -89,10 +89,10 @@ struct miqt_string QFont_Key(const QFont* self); struct miqt_string QFont_ToString(const QFont* self); bool QFont_FromString(QFont* self, struct miqt_string param1); struct miqt_string QFont_Substitute(struct miqt_string param1); -struct miqt_array* QFont_Substitutes(struct miqt_string param1); -struct miqt_array* QFont_Substitutions(); +struct miqt_array QFont_Substitutes(struct miqt_string param1); +struct miqt_array QFont_Substitutions(); void QFont_InsertSubstitution(struct miqt_string param1, struct miqt_string param2); -void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array* /* of struct miqt_string */ param2); +void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array /* of struct miqt_string */ param2); void QFont_RemoveSubstitutions(struct miqt_string param1); void QFont_Initialize(); void QFont_Cleanup(); diff --git a/qt/gen_qfontdatabase.cpp b/qt/gen_qfontdatabase.cpp index 7acb2175..f108dff7 100644 --- a/qt/gen_qfontdatabase.cpp +++ b/qt/gen_qfontdatabase.cpp @@ -14,20 +14,20 @@ QFontDatabase* QFontDatabase_new() { return new QFontDatabase(); } -struct miqt_array* QFontDatabase_StandardSizes() { +struct miqt_array QFontDatabase_StandardSizes() { QList _ret = QFontDatabase::standardSizes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_WritingSystems(const QFontDatabase* self) { +struct miqt_array QFontDatabase_WritingSystems(const QFontDatabase* self) { QList _ret = self->writingSystems(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -35,13 +35,13 @@ struct miqt_array* QFontDatabase_WritingSystems(const QFontDatabase* self) { QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_WritingSystemsWithFamily(const QFontDatabase* self, struct miqt_string family) { +struct miqt_array QFontDatabase_WritingSystemsWithFamily(const QFontDatabase* self, struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QList _ret = self->writingSystems(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -50,13 +50,13 @@ struct miqt_array* QFontDatabase_WritingSystemsWithFamily(const QFontDatabase* s QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_Families(const QFontDatabase* self) { +struct miqt_array QFontDatabase_Families(const QFontDatabase* self) { QStringList _ret = self->families(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,13 +70,13 @@ struct miqt_array* QFontDatabase_Families(const QFontDatabase* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_Styles(const QFontDatabase* self, struct miqt_string family) { +struct miqt_array QFontDatabase_Styles(const QFontDatabase* self, struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QStringList _ret = self->styles(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -91,13 +91,13 @@ struct miqt_array* QFontDatabase_Styles(const QFontDatabase* self, struct miqt_s memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_PointSizes(QFontDatabase* self, struct miqt_string family) { +struct miqt_array QFontDatabase_PointSizes(QFontDatabase* self, struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QList _ret = self->pointSizes(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -105,13 +105,13 @@ struct miqt_array* QFontDatabase_PointSizes(QFontDatabase* self, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_SmoothSizes(QFontDatabase* self, struct miqt_string family, struct miqt_string style) { +struct miqt_array QFontDatabase_SmoothSizes(QFontDatabase* self, struct miqt_string family, struct miqt_string style) { QString family_QString = QString::fromUtf8(family.data, family.len); QString style_QString = QString::fromUtf8(style.data, style.len); QList _ret = self->smoothSizes(family_QString, style_QString); @@ -120,9 +120,9 @@ struct miqt_array* QFontDatabase_SmoothSizes(QFontDatabase* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -234,7 +234,7 @@ int QFontDatabase_AddApplicationFontFromData(struct miqt_string fontData) { return QFontDatabase::addApplicationFontFromData(fontData_QByteArray); } -struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id) { +struct miqt_array QFontDatabase_ApplicationFontFamilies(int id) { QStringList _ret = QFontDatabase::applicationFontFamilies(static_cast(id)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -248,9 +248,9 @@ struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -270,7 +270,7 @@ QFont* QFontDatabase_SystemFont(int typeVal) { return new QFont(QFontDatabase::systemFont(static_cast(typeVal))); } -struct miqt_array* QFontDatabase_Families1(const QFontDatabase* self, int writingSystem) { +struct miqt_array QFontDatabase_Families1(const QFontDatabase* self, int writingSystem) { QStringList _ret = self->families(static_cast(writingSystem)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -284,13 +284,13 @@ struct miqt_array* QFontDatabase_Families1(const QFontDatabase* self, int writin memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_PointSizes2(QFontDatabase* self, struct miqt_string family, struct miqt_string style) { +struct miqt_array QFontDatabase_PointSizes2(QFontDatabase* self, struct miqt_string family, struct miqt_string style) { QString family_QString = QString::fromUtf8(family.data, family.len); QString style_QString = QString::fromUtf8(style.data, style.len); QList _ret = self->pointSizes(family_QString, style_QString); @@ -299,9 +299,9 @@ struct miqt_array* QFontDatabase_PointSizes2(QFontDatabase* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qfontdatabase.go b/qt/gen_qfontdatabase.go index ef28b499..eb00e162 100644 --- a/qt/gen_qfontdatabase.go +++ b/qt/gen_qfontdatabase.go @@ -99,24 +99,22 @@ func NewQFontDatabase() *QFontDatabase { } func QFontDatabase_StandardSizes() []int { - var _ma *C.struct_miqt_array = C.QFontDatabase_StandardSizes() + var _ma C.struct_miqt_array = C.QFontDatabase_StandardSizes() _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFontDatabase) WritingSystems() []QFontDatabase__WritingSystem { - var _ma *C.struct_miqt_array = C.QFontDatabase_WritingSystems(this.h) + var _ma C.struct_miqt_array = C.QFontDatabase_WritingSystems(this.h) _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -125,18 +123,17 @@ func (this *QFontDatabase) WritingSystemsWithFamily(family string) []QFontDataba family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_WritingSystemsWithFamily(this.h, family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_WritingSystemsWithFamily(this.h, family_ms) _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFontDatabase) Families() []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_Families(this.h) + var _ma C.struct_miqt_array = C.QFontDatabase_Families(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -145,7 +142,6 @@ func (this *QFontDatabase) Families() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -154,7 +150,7 @@ func (this *QFontDatabase) Styles(family string) []string { family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_Styles(this.h, family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_Styles(this.h, family_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -163,7 +159,6 @@ func (this *QFontDatabase) Styles(family string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -172,13 +167,12 @@ func (this *QFontDatabase) PointSizes(family string) []int { family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_PointSizes(this.h, family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_PointSizes(this.h, family_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -191,13 +185,12 @@ func (this *QFontDatabase) SmoothSizes(family string, style string) []int { style_ms.data = C.CString(style) style_ms.len = C.size_t(len(style)) defer C.free(unsafe.Pointer(style_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_SmoothSizes(this.h, family_ms, style_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_SmoothSizes(this.h, family_ms, style_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -344,7 +337,7 @@ func QFontDatabase_AddApplicationFontFromData(fontData []byte) int { } func QFontDatabase_ApplicationFontFamilies(id int) []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_ApplicationFontFamilies((C.int)(id)) + var _ma C.struct_miqt_array = C.QFontDatabase_ApplicationFontFamilies((C.int)(id)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -353,7 +346,6 @@ func QFontDatabase_ApplicationFontFamilies(id int) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -377,7 +369,7 @@ func QFontDatabase_SystemFont(typeVal QFontDatabase__SystemFont) *QFont { } func (this *QFontDatabase) Families1(writingSystem QFontDatabase__WritingSystem) []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_Families1(this.h, (C.int)(writingSystem)) + var _ma C.struct_miqt_array = C.QFontDatabase_Families1(this.h, (C.int)(writingSystem)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -386,7 +378,6 @@ func (this *QFontDatabase) Families1(writingSystem QFontDatabase__WritingSystem) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -399,13 +390,12 @@ func (this *QFontDatabase) PointSizes2(family string, style string) []int { style_ms.data = C.CString(style) style_ms.len = C.size_t(len(style)) defer C.free(unsafe.Pointer(style_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_PointSizes2(this.h, family_ms, style_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_PointSizes2(this.h, family_ms, style_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qfontdatabase.h b/qt/gen_qfontdatabase.h index 2ef8a941..b486ce87 100644 --- a/qt/gen_qfontdatabase.h +++ b/qt/gen_qfontdatabase.h @@ -26,13 +26,13 @@ typedef struct QFontInfo QFontInfo; #endif QFontDatabase* QFontDatabase_new(); -struct miqt_array* QFontDatabase_StandardSizes(); -struct miqt_array* QFontDatabase_WritingSystems(const QFontDatabase* self); -struct miqt_array* QFontDatabase_WritingSystemsWithFamily(const QFontDatabase* self, struct miqt_string family); -struct miqt_array* QFontDatabase_Families(const QFontDatabase* self); -struct miqt_array* QFontDatabase_Styles(const QFontDatabase* self, struct miqt_string family); -struct miqt_array* QFontDatabase_PointSizes(QFontDatabase* self, struct miqt_string family); -struct miqt_array* QFontDatabase_SmoothSizes(QFontDatabase* self, struct miqt_string family, struct miqt_string style); +struct miqt_array QFontDatabase_StandardSizes(); +struct miqt_array QFontDatabase_WritingSystems(const QFontDatabase* self); +struct miqt_array QFontDatabase_WritingSystemsWithFamily(const QFontDatabase* self, struct miqt_string family); +struct miqt_array QFontDatabase_Families(const QFontDatabase* self); +struct miqt_array QFontDatabase_Styles(const QFontDatabase* self, struct miqt_string family); +struct miqt_array QFontDatabase_PointSizes(QFontDatabase* self, struct miqt_string family); +struct miqt_array QFontDatabase_SmoothSizes(QFontDatabase* self, struct miqt_string family, struct miqt_string style); struct miqt_string QFontDatabase_StyleString(QFontDatabase* self, QFont* font); struct miqt_string QFontDatabase_StyleStringWithFontInfo(QFontDatabase* self, QFontInfo* fontInfo); QFont* QFontDatabase_Font(const QFontDatabase* self, struct miqt_string family, struct miqt_string style, int pointSize); @@ -49,13 +49,13 @@ struct miqt_string QFontDatabase_WritingSystemName(int writingSystem); struct miqt_string QFontDatabase_WritingSystemSample(int writingSystem); int QFontDatabase_AddApplicationFont(struct miqt_string fileName); int QFontDatabase_AddApplicationFontFromData(struct miqt_string fontData); -struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id); +struct miqt_array QFontDatabase_ApplicationFontFamilies(int id); bool QFontDatabase_RemoveApplicationFont(int id); bool QFontDatabase_RemoveAllApplicationFonts(); bool QFontDatabase_SupportsThreadedFontRendering(); QFont* QFontDatabase_SystemFont(int typeVal); -struct miqt_array* QFontDatabase_Families1(const QFontDatabase* self, int writingSystem); -struct miqt_array* QFontDatabase_PointSizes2(QFontDatabase* self, struct miqt_string family, struct miqt_string style); +struct miqt_array QFontDatabase_Families1(const QFontDatabase* self, int writingSystem); +struct miqt_array QFontDatabase_PointSizes2(QFontDatabase* self, struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsBitmapScalable2(const QFontDatabase* self, struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsSmoothlyScalable2(const QFontDatabase* self, struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsScalable2(const QFontDatabase* self, struct miqt_string family, struct miqt_string style); diff --git a/qt/gen_qgenericpluginfactory.cpp b/qt/gen_qgenericpluginfactory.cpp index b88a0629..4292d5b1 100644 --- a/qt/gen_qgenericpluginfactory.cpp +++ b/qt/gen_qgenericpluginfactory.cpp @@ -8,7 +8,7 @@ #include "gen_qgenericpluginfactory.h" #include "_cgo_export.h" -struct miqt_array* QGenericPluginFactory_Keys() { +struct miqt_array QGenericPluginFactory_Keys() { QStringList _ret = QGenericPluginFactory::keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -22,9 +22,9 @@ struct miqt_array* QGenericPluginFactory_Keys() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgenericpluginfactory.go b/qt/gen_qgenericpluginfactory.go index 6947210c..35589494 100644 --- a/qt/gen_qgenericpluginfactory.go +++ b/qt/gen_qgenericpluginfactory.go @@ -43,7 +43,7 @@ func UnsafeNewQGenericPluginFactory(h unsafe.Pointer) *QGenericPluginFactory { } func QGenericPluginFactory_Keys() []string { - var _ma *C.struct_miqt_array = C.QGenericPluginFactory_Keys() + var _ma C.struct_miqt_array = C.QGenericPluginFactory_Keys() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func QGenericPluginFactory_Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgenericpluginfactory.h b/qt/gen_qgenericpluginfactory.h index 365e737a..f7974818 100644 --- a/qt/gen_qgenericpluginfactory.h +++ b/qt/gen_qgenericpluginfactory.h @@ -21,7 +21,7 @@ typedef struct QGenericPluginFactory QGenericPluginFactory; typedef struct QObject QObject; #endif -struct miqt_array* QGenericPluginFactory_Keys(); +struct miqt_array QGenericPluginFactory_Keys(); QObject* QGenericPluginFactory_Create(struct miqt_string param1, struct miqt_string param2); void QGenericPluginFactory_Delete(QGenericPluginFactory* self); diff --git a/qt/gen_qgesture.cpp b/qt/gen_qgesture.cpp index 68a743a2..8ec73f85 100644 --- a/qt/gen_qgesture.cpp +++ b/qt/gen_qgesture.cpp @@ -736,11 +736,11 @@ void QTapAndHoldGesture_Delete(QTapAndHoldGesture* self) { delete self; } -QGestureEvent* QGestureEvent_new(struct miqt_array* /* of QGesture* */ gestures) { +QGestureEvent* QGestureEvent_new(struct miqt_array /* of QGesture* */ gestures) { QList gestures_QList; - gestures_QList.reserve(gestures->len); - QGesture** gestures_arr = static_cast(gestures->data); - for(size_t i = 0; i < gestures->len; ++i) { + gestures_QList.reserve(gestures.len); + QGesture** gestures_arr = static_cast(gestures.data); + for(size_t i = 0; i < gestures.len; ++i) { gestures_QList.push_back(gestures_arr[i]); } return new QGestureEvent(gestures_QList); @@ -750,16 +750,16 @@ QGestureEvent* QGestureEvent_new2(QGestureEvent* param1) { return new QGestureEvent(*param1); } -struct miqt_array* QGestureEvent_Gestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_Gestures(const QGestureEvent* self) { QList _ret = self->gestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -767,29 +767,29 @@ QGesture* QGestureEvent_Gesture(const QGestureEvent* self, int typeVal) { return self->gesture(static_cast(typeVal)); } -struct miqt_array* QGestureEvent_ActiveGestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_ActiveGestures(const QGestureEvent* self) { QList _ret = self->activeGestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGestureEvent_CanceledGestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_CanceledGestures(const QGestureEvent* self) { QList _ret = self->canceledGestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgesture.go b/qt/gen_qgesture.go index fc042bda..058cd72d 100644 --- a/qt/gen_qgesture.go +++ b/qt/gen_qgesture.go @@ -1053,14 +1053,12 @@ func UnsafeNewQGestureEvent(h unsafe.Pointer) *QGestureEvent { // NewQGestureEvent constructs a new QGestureEvent object. func NewQGestureEvent(gestures []*QGesture) *QGestureEvent { - // For the C ABI, malloc a C array of raw pointers gestures_CArray := (*[0xffff]*C.QGesture)(C.malloc(C.size_t(8 * len(gestures)))) defer C.free(unsafe.Pointer(gestures_CArray)) for i := range gestures { gestures_CArray[i] = gestures[i].cPointer() } - gestures_ma := &C.struct_miqt_array{len: C.size_t(len(gestures)), data: unsafe.Pointer(gestures_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(gestures_ma)) + gestures_ma := C.struct_miqt_array{len: C.size_t(len(gestures)), data: unsafe.Pointer(gestures_CArray)} ret := C.QGestureEvent_new(gestures_ma) return newQGestureEvent(ret) } @@ -1072,13 +1070,12 @@ func NewQGestureEvent2(param1 *QGestureEvent) *QGestureEvent { } func (this *QGestureEvent) Gestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_Gestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_Gestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1087,24 +1084,22 @@ func (this *QGestureEvent) Gesture(typeVal GestureType) *QGesture { } func (this *QGestureEvent) ActiveGestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_ActiveGestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_ActiveGestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGestureEvent) CanceledGestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_CanceledGestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_CanceledGestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgesture.h b/qt/gen_qgesture.h index d2ac95c3..77d1b876 100644 --- a/qt/gen_qgesture.h +++ b/qt/gen_qgesture.h @@ -158,12 +158,12 @@ struct miqt_string QTapAndHoldGesture_TrUtf82(const char* s, const char* c); struct miqt_string QTapAndHoldGesture_TrUtf83(const char* s, const char* c, int n); void QTapAndHoldGesture_Delete(QTapAndHoldGesture* self); -QGestureEvent* QGestureEvent_new(struct miqt_array* /* of QGesture* */ gestures); +QGestureEvent* QGestureEvent_new(struct miqt_array /* of QGesture* */ gestures); QGestureEvent* QGestureEvent_new2(QGestureEvent* param1); -struct miqt_array* QGestureEvent_Gestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_Gestures(const QGestureEvent* self); QGesture* QGestureEvent_Gesture(const QGestureEvent* self, int typeVal); -struct miqt_array* QGestureEvent_ActiveGestures(const QGestureEvent* self); -struct miqt_array* QGestureEvent_CanceledGestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_ActiveGestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_CanceledGestures(const QGestureEvent* self); void QGestureEvent_SetAccepted(QGestureEvent* self, QGesture* param1, bool param2); void QGestureEvent_Accept(QGestureEvent* self, QGesture* param1); void QGestureEvent_Ignore(QGestureEvent* self, QGesture* param1); diff --git a/qt/gen_qglyphrun.cpp b/qt/gen_qglyphrun.cpp index 6a8480c5..a14ef44d 100644 --- a/qt/gen_qglyphrun.cpp +++ b/qt/gen_qglyphrun.cpp @@ -35,47 +35,47 @@ void QGlyphRun_SetRawData(QGlyphRun* self, const unsigned int* glyphIndexArray, self->setRawData(static_cast(glyphIndexArray), glyphPositionArray, static_cast(size)); } -struct miqt_array* QGlyphRun_GlyphIndexes(const QGlyphRun* self) { +struct miqt_array QGlyphRun_GlyphIndexes(const QGlyphRun* self) { QVector _ret = self->glyphIndexes(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array* /* of unsigned int */ glyphIndexes) { +void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array /* of unsigned int */ glyphIndexes) { QVector glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } self->setGlyphIndexes(glyphIndexes_QList); } -struct miqt_array* QGlyphRun_Positions(const QGlyphRun* self) { +struct miqt_array QGlyphRun_Positions(const QGlyphRun* self) { QVector _ret = self->positions(); // Convert QList<> from C++ memory to manually-managed C memory QPointF** _arr = static_cast(malloc(sizeof(QPointF*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array* /* of QPointF* */ positions) { +void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array /* of QPointF* */ positions) { QVector positions_QList; - positions_QList.reserve(positions->len); - QPointF** positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + QPointF** positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(*(positions_arr[i])); } self->setPositions(positions_QList); diff --git a/qt/gen_qglyphrun.go b/qt/gen_qglyphrun.go index e0f709be..476bd54f 100644 --- a/qt/gen_qglyphrun.go +++ b/qt/gen_qglyphrun.go @@ -88,30 +88,27 @@ func (this *QGlyphRun) SetRawData(glyphIndexArray *uint, glyphPositionArray *QPo } func (this *QGlyphRun) GlyphIndexes() []uint { - var _ma *C.struct_miqt_array = C.QGlyphRun_GlyphIndexes(this.h) + var _ma C.struct_miqt_array = C.QGlyphRun_GlyphIndexes(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGlyphRun) SetGlyphIndexes(glyphIndexes []uint) { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} C.QGlyphRun_SetGlyphIndexes(this.h, glyphIndexes_ma) } func (this *QGlyphRun) Positions() []QPointF { - var _ma *C.struct_miqt_array = C.QGlyphRun_Positions(this.h) + var _ma C.struct_miqt_array = C.QGlyphRun_Positions(this.h) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -120,19 +117,16 @@ func (this *QGlyphRun) Positions() []QPointF { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGlyphRun) SetPositions(positions []QPointF) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]*C.QPointF)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = positions[i].cPointer() } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QGlyphRun_SetPositions(this.h, positions_ma) } diff --git a/qt/gen_qglyphrun.h b/qt/gen_qglyphrun.h index 49ae89b7..88ba5bcd 100644 --- a/qt/gen_qglyphrun.h +++ b/qt/gen_qglyphrun.h @@ -32,10 +32,10 @@ void QGlyphRun_Swap(QGlyphRun* self, QGlyphRun* other); QRawFont* QGlyphRun_RawFont(const QGlyphRun* self); void QGlyphRun_SetRawFont(QGlyphRun* self, QRawFont* rawFont); void QGlyphRun_SetRawData(QGlyphRun* self, const unsigned int* glyphIndexArray, QPointF* glyphPositionArray, int size); -struct miqt_array* QGlyphRun_GlyphIndexes(const QGlyphRun* self); -void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array* /* of unsigned int */ glyphIndexes); -struct miqt_array* QGlyphRun_Positions(const QGlyphRun* self); -void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array* /* of QPointF* */ positions); +struct miqt_array QGlyphRun_GlyphIndexes(const QGlyphRun* self); +void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array /* of unsigned int */ glyphIndexes); +struct miqt_array QGlyphRun_Positions(const QGlyphRun* self); +void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array /* of QPointF* */ positions); void QGlyphRun_Clear(QGlyphRun* self); bool QGlyphRun_OperatorEqual(const QGlyphRun* self, QGlyphRun* other); bool QGlyphRun_OperatorNotEqual(const QGlyphRun* self, QGlyphRun* other); diff --git a/qt/gen_qgraphicsitem.cpp b/qt/gen_qgraphicsitem.cpp index 9fea7c2a..c1afcaff 100644 --- a/qt/gen_qgraphicsitem.cpp +++ b/qt/gen_qgraphicsitem.cpp @@ -79,16 +79,16 @@ void QGraphicsItem_SetParentItem(QGraphicsItem* self, QGraphicsItem* parent) { self->setParentItem(parent); } -struct miqt_array* QGraphicsItem_ChildItems(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_ChildItems(const QGraphicsItem* self) { QList _ret = self->childItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -450,24 +450,24 @@ double QGraphicsItem_Scale(const QGraphicsItem* self) { return static_cast(_ret); } -struct miqt_array* QGraphicsItem_Transformations(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_Transformations(const QGraphicsItem* self) { QList _ret = self->transformations(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsTransform** _arr = static_cast(malloc(sizeof(QGraphicsTransform*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array* /* of QGraphicsTransform* */ transformations) { +void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array /* of QGraphicsTransform* */ transformations) { QList transformations_QList; - transformations_QList.reserve(transformations->len); - QGraphicsTransform** transformations_arr = static_cast(transformations->data); - for(size_t i = 0; i < transformations->len; ++i) { + transformations_QList.reserve(transformations.len); + QGraphicsTransform** transformations_arr = static_cast(transformations.data); + for(size_t i = 0; i < transformations.len; ++i) { transformations_QList.push_back(transformations_arr[i]); } self->setTransformations(transformations_QList); @@ -538,16 +538,16 @@ bool QGraphicsItem_CollidesWithPath(const QGraphicsItem* self, QPainterPath* pat return self->collidesWithPath(*path); } -struct miqt_array* QGraphicsItem_CollidingItems(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_CollidingItems(const QGraphicsItem* self) { QList _ret = self->collidingItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -809,16 +809,16 @@ bool QGraphicsItem_CollidesWithPath2(const QGraphicsItem* self, QPainterPath* pa return self->collidesWithPath(*path, static_cast(mode)); } -struct miqt_array* QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode) { +struct miqt_array QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode) { QList _ret = self->collidingItems(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgraphicsitem.go b/qt/gen_qgraphicsitem.go index 2590f78e..7401de96 100644 --- a/qt/gen_qgraphicsitem.go +++ b/qt/gen_qgraphicsitem.go @@ -229,13 +229,12 @@ func (this *QGraphicsItem) SetParentItem(parent *QGraphicsItem) { } func (this *QGraphicsItem) ChildItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_ChildItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_ChildItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -614,25 +613,22 @@ func (this *QGraphicsItem) Scale() float64 { } func (this *QGraphicsItem) Transformations() []*QGraphicsTransform { - var _ma *C.struct_miqt_array = C.QGraphicsItem_Transformations(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_Transformations(this.h) _ret := make([]*QGraphicsTransform, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsTransform)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsTransform(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsItem) SetTransformations(transformations []*QGraphicsTransform) { - // For the C ABI, malloc a C array of raw pointers transformations_CArray := (*[0xffff]*C.QGraphicsTransform)(C.malloc(C.size_t(8 * len(transformations)))) defer C.free(unsafe.Pointer(transformations_CArray)) for i := range transformations { transformations_CArray[i] = transformations[i].cPointer() } - transformations_ma := &C.struct_miqt_array{len: C.size_t(len(transformations)), data: unsafe.Pointer(transformations_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transformations_ma)) + transformations_ma := C.struct_miqt_array{len: C.size_t(len(transformations)), data: unsafe.Pointer(transformations_CArray)} C.QGraphicsItem_SetTransformations(this.h, transformations_ma) } @@ -719,13 +715,12 @@ func (this *QGraphicsItem) CollidesWithPath(path *QPainterPath) bool { } func (this *QGraphicsItem) CollidingItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_CollidingItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_CollidingItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1088,13 +1083,12 @@ func (this *QGraphicsItem) CollidesWithPath2(path *QPainterPath, mode ItemSelect } func (this *QGraphicsItem) CollidingItems1(mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_CollidingItems1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsItem_CollidingItems1(this.h, (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgraphicsitem.h b/qt/gen_qgraphicsitem.h index 4067c40b..df63f90a 100644 --- a/qt/gen_qgraphicsitem.h +++ b/qt/gen_qgraphicsitem.h @@ -100,7 +100,7 @@ QGraphicsWidget* QGraphicsItem_TopLevelWidget(const QGraphicsItem* self); QGraphicsWidget* QGraphicsItem_Window(const QGraphicsItem* self); QGraphicsItem* QGraphicsItem_Panel(const QGraphicsItem* self); void QGraphicsItem_SetParentItem(QGraphicsItem* self, QGraphicsItem* parent); -struct miqt_array* QGraphicsItem_ChildItems(const QGraphicsItem* self); +struct miqt_array QGraphicsItem_ChildItems(const QGraphicsItem* self); bool QGraphicsItem_IsWidget(const QGraphicsItem* self); bool QGraphicsItem_IsWindow(const QGraphicsItem* self); bool QGraphicsItem_IsPanel(const QGraphicsItem* self); @@ -186,8 +186,8 @@ void QGraphicsItem_SetRotation(QGraphicsItem* self, double angle); double QGraphicsItem_Rotation(const QGraphicsItem* self); void QGraphicsItem_SetScale(QGraphicsItem* self, double scale); double QGraphicsItem_Scale(const QGraphicsItem* self); -struct miqt_array* QGraphicsItem_Transformations(const QGraphicsItem* self); -void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array* /* of QGraphicsTransform* */ transformations); +struct miqt_array QGraphicsItem_Transformations(const QGraphicsItem* self); +void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array /* of QGraphicsTransform* */ transformations); QPointF* QGraphicsItem_TransformOriginPoint(const QGraphicsItem* self); void QGraphicsItem_SetTransformOriginPoint(QGraphicsItem* self, QPointF* origin); void QGraphicsItem_SetTransformOriginPoint2(QGraphicsItem* self, double ax, double ay); @@ -204,7 +204,7 @@ QPainterPath* QGraphicsItem_ClipPath(const QGraphicsItem* self); bool QGraphicsItem_Contains(const QGraphicsItem* self, QPointF* point); bool QGraphicsItem_CollidesWithItem(const QGraphicsItem* self, QGraphicsItem* other); bool QGraphicsItem_CollidesWithPath(const QGraphicsItem* self, QPainterPath* path); -struct miqt_array* QGraphicsItem_CollidingItems(const QGraphicsItem* self); +struct miqt_array QGraphicsItem_CollidingItems(const QGraphicsItem* self); bool QGraphicsItem_IsObscured(const QGraphicsItem* self); bool QGraphicsItem_IsObscured2(const QGraphicsItem* self, double x, double y, double w, double h); bool QGraphicsItem_IsObscuredBy(const QGraphicsItem* self, QGraphicsItem* item); @@ -269,7 +269,7 @@ QTransform* QGraphicsItem_ItemTransform2(const QGraphicsItem* self, QGraphicsIte void QGraphicsItem_SetTransform2(QGraphicsItem* self, QTransform* matrix, bool combine); bool QGraphicsItem_CollidesWithItem2(const QGraphicsItem* self, QGraphicsItem* other, int mode); bool QGraphicsItem_CollidesWithPath2(const QGraphicsItem* self, QPainterPath* path, int mode); -struct miqt_array* QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode); +struct miqt_array QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode); bool QGraphicsItem_IsObscured1(const QGraphicsItem* self, QRectF* rect); void QGraphicsItem_Paint3(QGraphicsItem* self, QPainter* painter, QStyleOptionGraphicsItem* option, QWidget* widget); void QGraphicsItem_Update1(QGraphicsItem* self, QRectF* rect); diff --git a/qt/gen_qgraphicsscene.cpp b/qt/gen_qgraphicsscene.cpp index 7101bc81..ff20c023 100644 --- a/qt/gen_qgraphicsscene.cpp +++ b/qt/gen_qgraphicsscene.cpp @@ -145,68 +145,68 @@ QRectF* QGraphicsScene_ItemsBoundingRect(const QGraphicsScene* self) { return new QRectF(self->itemsBoundingRect()); } -struct miqt_array* QGraphicsScene_Items(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_Items(const QGraphicsScene* self) { QList _ret = self->items(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos) { +struct miqt_array QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos) { QList _ret = self->items(*pos); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect) { +struct miqt_array QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect) { QList _ret = self->items(*rect); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path) { +struct miqt_array QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path) { QList _ret = self->items(*path); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item) { +struct miqt_array QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item) { QList _ret = self->collidingItems(item); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -214,16 +214,16 @@ QGraphicsItem* QGraphicsScene_ItemAt(const QGraphicsScene* self, QPointF* pos, Q return self->itemAt(*pos, *deviceTransform); } -struct miqt_array* QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order) { +struct miqt_array QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -231,16 +231,16 @@ QGraphicsItem* QGraphicsScene_ItemAt2(const QGraphicsScene* self, double x, doub return self->itemAt(static_cast(x), static_cast(y), *deviceTransform); } -struct miqt_array* QGraphicsScene_SelectedItems(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_SelectedItems(const QGraphicsScene* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -260,11 +260,11 @@ void QGraphicsScene_SetSelectionArea2(QGraphicsScene* self, QPainterPath* path, self->setSelectionArea(*path, static_cast(selectionOperation)); } -QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array* /* of QGraphicsItem* */ items) { +QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array /* of QGraphicsItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QGraphicsItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QGraphicsItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } return self->createItemGroup(items_QList); @@ -380,16 +380,16 @@ QVariant* QGraphicsScene_InputMethodQuery(const QGraphicsScene* self, int query) return new QVariant(self->inputMethodQuery(static_cast(query))); } -struct miqt_array* QGraphicsScene_Views(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_Views(const QGraphicsScene* self) { QList _ret = self->views(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsView** _arr = static_cast(malloc(sizeof(QGraphicsView*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -486,11 +486,11 @@ void QGraphicsScene_Clear(QGraphicsScene* self) { self->clear(); } -void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array* /* of QRectF* */ region) { +void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array /* of QRectF* */ region) { QList region_QList; - region_QList.reserve(region->len); - QRectF** region_arr = static_cast(region->data); - for(size_t i = 0; i < region->len; ++i) { + region_QList.reserve(region.len); + QRectF** region_arr = static_cast(region.data); + for(size_t i = 0; i < region.len; ++i) { region_QList.push_back(*(region_arr[i])); } self->changed(region_QList); @@ -504,10 +504,10 @@ void QGraphicsScene_connect_Changed(QGraphicsScene* self, intptr_t slot) { for (size_t i = 0, e = region_ret.length(); i < e; ++i) { region_arr[i] = new QRectF(region_ret[i]); } - struct miqt_array* region_out = static_cast(malloc(sizeof(struct miqt_array))); - region_out->len = region_ret.length(); - region_out->data = static_cast(region_arr); - struct miqt_array* sigval1 = region_out; + struct miqt_array region_out; + region_out.len = region_ret.length(); + region_out.data = static_cast(region_arr); + struct miqt_array sigval1 = region_out; miqt_exec_callback_QGraphicsScene_Changed(slot, sigval1); }); } @@ -605,159 +605,159 @@ void QGraphicsScene_Render4(QGraphicsScene* self, QPainter* painter, QRectF* tar self->render(painter, *target, *source, static_cast(aspectRatioMode)); } -struct miqt_array* QGraphicsScene_Items1(const QGraphicsScene* self, int order) { +struct miqt_array QGraphicsScene_Items1(const QGraphicsScene* self, int order) { QList _ret = self->items(static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode) { +struct miqt_array QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode) { QList _ret = self->items(*pos, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order) { +struct miqt_array QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order) { QList _ret = self->items(*pos, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*pos, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode) { +struct miqt_array QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode) { QList _ret = self->items(*rect, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order) { +struct miqt_array QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order) { QList _ret = self->items(*rect, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*rect, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode) { +struct miqt_array QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode) { QList _ret = self->items(*path, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order) { +struct miqt_array QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order) { QList _ret = self->items(*path, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*path, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode) { +struct miqt_array QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode) { QList _ret = self->collidingItems(item, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgraphicsscene.go b/qt/gen_qgraphicsscene.go index cd1590fb..0d682b1a 100644 --- a/qt/gen_qgraphicsscene.go +++ b/qt/gen_qgraphicsscene.go @@ -183,57 +183,52 @@ func (this *QGraphicsScene) ItemsBoundingRect() *QRectF { } func (this *QGraphicsScene) Items() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithPos(pos *QPointF) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithPos(this.h, pos.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithPos(this.h, pos.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithRect(rect *QRectF) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithRect(this.h, rect.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithRect(this.h, rect.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithPath(path *QPainterPath) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithPath(this.h, path.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithPath(this.h, path.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) CollidingItems(item *QGraphicsItem) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_CollidingItems(this.h, item.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_CollidingItems(this.h, item.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -242,13 +237,12 @@ func (this *QGraphicsScene) ItemAt(pos *QPointF, deviceTransform *QTransform) *Q } func (this *QGraphicsScene) Items2(x float64, y float64, w float64, h float64, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items2(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items2(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -257,13 +251,12 @@ func (this *QGraphicsScene) ItemAt2(x float64, y float64, deviceTransform *QTran } func (this *QGraphicsScene) SelectedItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_SelectedItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -287,14 +280,12 @@ func (this *QGraphicsScene) SetSelectionArea2(path *QPainterPath, selectionOpera } func (this *QGraphicsScene) CreateItemGroup(items []*QGraphicsItem) *QGraphicsItemGroup { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QGraphicsItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} return UnsafeNewQGraphicsItemGroup(unsafe.Pointer(C.QGraphicsScene_CreateItemGroup(this.h, items_ma))) } @@ -424,13 +415,12 @@ func (this *QGraphicsScene) InputMethodQuery(query InputMethodQuery) *QVariant { } func (this *QGraphicsScene) Views() []*QGraphicsView { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Views(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_Views(this.h) _ret := make([]*QGraphicsView, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsView)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsView(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -533,14 +523,12 @@ func (this *QGraphicsScene) Clear() { } func (this *QGraphicsScene) Changed(region []QRectF) { - // For the C ABI, malloc a C array of raw pointers region_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(region)))) defer C.free(unsafe.Pointer(region_CArray)) for i := range region { region_CArray[i] = region[i].cPointer() } - region_ma := &C.struct_miqt_array{len: C.size_t(len(region)), data: unsafe.Pointer(region_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(region_ma)) + region_ma := C.struct_miqt_array{len: C.size_t(len(region)), data: unsafe.Pointer(region_CArray)} C.QGraphicsScene_Changed(this.h, region_ma) } func (this *QGraphicsScene) OnChanged(slot func(region []QRectF)) { @@ -548,14 +536,14 @@ func (this *QGraphicsScene) OnChanged(slot func(region []QRectF)) { } //export miqt_exec_callback_QGraphicsScene_Changed -func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region *C.struct_miqt_array) { +func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(region []QRectF)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var region_ma *C.struct_miqt_array = region + var region_ma C.struct_miqt_array = region region_ret := make([]QRectF, int(region_ma.len)) region_outCast := (*[0xffff]*C.QRectF)(unsafe.Pointer(region_ma.data)) // hey ya for i := 0; i < int(region_ma.len); i++ { @@ -564,7 +552,6 @@ func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region *C.struct_m region_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer region_ret[i] = *region_lv_goptr } - C.free(unsafe.Pointer(region_ma)) slotval1 := region_ret gofunc(slotval1) @@ -686,134 +673,122 @@ func (this *QGraphicsScene) Render4(painter *QPainter, target *QRectF, source *Q } func (this *QGraphicsScene) Items1(order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items1(this.h, (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items1(this.h, (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items22(pos *QPointF, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items22(this.h, pos.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items22(this.h, pos.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items3(pos *QPointF, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items3(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items3(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items4(pos *QPointF, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items4(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items4(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items23(rect *QRectF, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items23(this.h, rect.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items23(this.h, rect.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items32(rect *QRectF, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items32(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items32(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items42(rect *QRectF, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items42(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items42(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items25(path *QPainterPath, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items25(this.h, path.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items25(this.h, path.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items34(path *QPainterPath, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items34(this.h, path.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items34(this.h, path.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items44(path *QPainterPath, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items44(this.h, path.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items44(this.h, path.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) CollidingItems2(item *QGraphicsItem, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_CollidingItems2(this.h, item.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_CollidingItems2(this.h, item.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items7(x float64, y float64, w float64, h float64, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items7(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items7(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgraphicsscene.h b/qt/gen_qgraphicsscene.h index e582d43d..04ec433a 100644 --- a/qt/gen_qgraphicsscene.h +++ b/qt/gen_qgraphicsscene.h @@ -100,20 +100,20 @@ void QGraphicsScene_SetSortCacheEnabled(QGraphicsScene* self, bool enabled); int QGraphicsScene_BspTreeDepth(const QGraphicsScene* self); void QGraphicsScene_SetBspTreeDepth(QGraphicsScene* self, int depth); QRectF* QGraphicsScene_ItemsBoundingRect(const QGraphicsScene* self); -struct miqt_array* QGraphicsScene_Items(const QGraphicsScene* self); -struct miqt_array* QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos); -struct miqt_array* QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect); -struct miqt_array* QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path); -struct miqt_array* QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item); +struct miqt_array QGraphicsScene_Items(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos); +struct miqt_array QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect); +struct miqt_array QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path); +struct miqt_array QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item); QGraphicsItem* QGraphicsScene_ItemAt(const QGraphicsScene* self, QPointF* pos, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order); +struct miqt_array QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order); QGraphicsItem* QGraphicsScene_ItemAt2(const QGraphicsScene* self, double x, double y, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_SelectedItems(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_SelectedItems(const QGraphicsScene* self); QPainterPath* QGraphicsScene_SelectionArea(const QGraphicsScene* self); void QGraphicsScene_SetSelectionArea(QGraphicsScene* self, QPainterPath* path, QTransform* deviceTransform); void QGraphicsScene_SetSelectionAreaWithPath(QGraphicsScene* self, QPainterPath* path); void QGraphicsScene_SetSelectionArea2(QGraphicsScene* self, QPainterPath* path, int selectionOperation); -QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array* /* of QGraphicsItem* */ items); +QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array /* of QGraphicsItem* */ items); void QGraphicsScene_DestroyItemGroup(QGraphicsScene* self, QGraphicsItemGroup* group); void QGraphicsScene_AddItem(QGraphicsScene* self, QGraphicsItem* item); QGraphicsEllipseItem* QGraphicsScene_AddEllipse(QGraphicsScene* self, QRectF* rect); @@ -141,7 +141,7 @@ void QGraphicsScene_SetBackgroundBrush(QGraphicsScene* self, QBrush* brush); QBrush* QGraphicsScene_ForegroundBrush(const QGraphicsScene* self); void QGraphicsScene_SetForegroundBrush(QGraphicsScene* self, QBrush* brush); QVariant* QGraphicsScene_InputMethodQuery(const QGraphicsScene* self, int query); -struct miqt_array* QGraphicsScene_Views(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_Views(const QGraphicsScene* self); void QGraphicsScene_Update(QGraphicsScene* self, double x, double y, double w, double h); void QGraphicsScene_Invalidate(QGraphicsScene* self, double x, double y, double w, double h); QStyle* QGraphicsScene_Style(const QGraphicsScene* self); @@ -165,7 +165,7 @@ void QGraphicsScene_Invalidate2(QGraphicsScene* self); void QGraphicsScene_Advance(QGraphicsScene* self); void QGraphicsScene_ClearSelection(QGraphicsScene* self); void QGraphicsScene_Clear(QGraphicsScene* self); -void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array* /* of QRectF* */ region); +void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array /* of QRectF* */ region); void QGraphicsScene_connect_Changed(QGraphicsScene* self, intptr_t slot); void QGraphicsScene_SceneRectChanged(QGraphicsScene* self, QRectF* rect); void QGraphicsScene_connect_SceneRectChanged(QGraphicsScene* self, intptr_t slot); @@ -180,18 +180,18 @@ struct miqt_string QGraphicsScene_TrUtf83(const char* s, const char* c, int n); void QGraphicsScene_Render2(QGraphicsScene* self, QPainter* painter, QRectF* target); void QGraphicsScene_Render3(QGraphicsScene* self, QPainter* painter, QRectF* target, QRectF* source); void QGraphicsScene_Render4(QGraphicsScene* self, QPainter* painter, QRectF* target, QRectF* source, int aspectRatioMode); -struct miqt_array* QGraphicsScene_Items1(const QGraphicsScene* self, int order); -struct miqt_array* QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode); -struct miqt_array* QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order); -struct miqt_array* QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode); -struct miqt_array* QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order); -struct miqt_array* QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode); -struct miqt_array* QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order); -struct miqt_array* QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode); -struct miqt_array* QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items1(const QGraphicsScene* self, int order); +struct miqt_array QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode); +struct miqt_array QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order); +struct miqt_array QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode); +struct miqt_array QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order); +struct miqt_array QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode); +struct miqt_array QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order); +struct miqt_array QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode); +struct miqt_array QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform); void QGraphicsScene_SetSelectionArea22(QGraphicsScene* self, QPainterPath* path, int mode); void QGraphicsScene_SetSelectionArea3(QGraphicsScene* self, QPainterPath* path, int mode, QTransform* deviceTransform); void QGraphicsScene_SetSelectionArea32(QGraphicsScene* self, QPainterPath* path, int selectionOperation, int mode); diff --git a/qt/gen_qgraphicsview.cpp b/qt/gen_qgraphicsview.cpp index 117b0941..8f50f029 100644 --- a/qt/gen_qgraphicsview.cpp +++ b/qt/gen_qgraphicsview.cpp @@ -285,81 +285,81 @@ void QGraphicsView_Render(QGraphicsView* self, QPainter* painter) { self->render(painter); } -struct miqt_array* QGraphicsView_Items(const QGraphicsView* self) { +struct miqt_array QGraphicsView_Items(const QGraphicsView* self) { QList _ret = self->items(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos) { +struct miqt_array QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos) { QList _ret = self->items(*pos); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items2(const QGraphicsView* self, int x, int y) { +struct miqt_array QGraphicsView_Items2(const QGraphicsView* self, int x, int y) { QList _ret = self->items(static_cast(x), static_cast(y)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect) { +struct miqt_array QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect) { QList _ret = self->items(*rect); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h) { +struct miqt_array QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path) { +struct miqt_array QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path) { QList _ret = self->items(*path); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -415,11 +415,11 @@ void QGraphicsView_SetForegroundBrush(QGraphicsView* self, QBrush* brush) { self->setForegroundBrush(*brush); } -void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array* /* of QRectF* */ rects) { +void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array /* of QRectF* */ rects) { QList rects_QList; - rects_QList.reserve(rects->len); - QRectF** rects_arr = static_cast(rects->data); - for(size_t i = 0; i < rects->len; ++i) { + rects_QList.reserve(rects.len); + QRectF** rects_arr = static_cast(rects.data); + for(size_t i = 0; i < rects.len; ++i) { rects_QList.push_back(*(rects_arr[i])); } self->updateScene(rects_QList); @@ -554,42 +554,42 @@ void QGraphicsView_Render4(QGraphicsView* self, QPainter* painter, QRectF* targe self->render(painter, *target, *source, static_cast(aspectRatioMode)); } -struct miqt_array* QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode) { +struct miqt_array QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode) { QList _ret = self->items(*rect, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode) { +struct miqt_array QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode) { +struct miqt_array QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode) { QList _ret = self->items(*path, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgraphicsview.go b/qt/gen_qgraphicsview.go index ae00cc3a..499f3a42 100644 --- a/qt/gen_qgraphicsview.go +++ b/qt/gen_qgraphicsview.go @@ -365,68 +365,62 @@ func (this *QGraphicsView) Render(painter *QPainter) { } func (this *QGraphicsView) Items() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items(this.h) + var _ma C.struct_miqt_array = C.QGraphicsView_Items(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithPos(pos *QPoint) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithPos(this.h, pos.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithPos(this.h, pos.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items2(x int, y int) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items2(this.h, (C.int)(x), (C.int)(y)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items2(this.h, (C.int)(x), (C.int)(y)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithRect(rect *QRect) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithRect(this.h, rect.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithRect(this.h, rect.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items3(x int, y int, w int, h int) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items3(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items3(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithPath(path *QPainterPath) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithPath(this.h, path.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithPath(this.h, path.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -510,14 +504,12 @@ func (this *QGraphicsView) SetForegroundBrush(brush *QBrush) { } func (this *QGraphicsView) UpdateScene(rects []QRectF) { - // For the C ABI, malloc a C array of raw pointers rects_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(rects)))) defer C.free(unsafe.Pointer(rects_CArray)) for i := range rects { rects_CArray[i] = rects[i].cPointer() } - rects_ma := &C.struct_miqt_array{len: C.size_t(len(rects)), data: unsafe.Pointer(rects_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rects_ma)) + rects_ma := C.struct_miqt_array{len: C.size_t(len(rects)), data: unsafe.Pointer(rects_CArray)} C.QGraphicsView_UpdateScene(this.h, rects_ma) } @@ -671,35 +663,32 @@ func (this *QGraphicsView) Render4(painter *QPainter, target *QRectF, source *QR } func (this *QGraphicsView) Items22(rect *QRect, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items22(this.h, rect.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items22(this.h, rect.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items5(x int, y int, w int, h int, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items5(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items5(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items24(path *QPainterPath, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items24(this.h, path.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items24(this.h, path.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgraphicsview.h b/qt/gen_qgraphicsview.h index 83fdeacc..08739cd2 100644 --- a/qt/gen_qgraphicsview.h +++ b/qt/gen_qgraphicsview.h @@ -109,12 +109,12 @@ void QGraphicsView_FitInView(QGraphicsView* self, QRectF* rect); void QGraphicsView_FitInView2(QGraphicsView* self, double x, double y, double w, double h); void QGraphicsView_FitInViewWithItem(QGraphicsView* self, QGraphicsItem* item); void QGraphicsView_Render(QGraphicsView* self, QPainter* painter); -struct miqt_array* QGraphicsView_Items(const QGraphicsView* self); -struct miqt_array* QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos); -struct miqt_array* QGraphicsView_Items2(const QGraphicsView* self, int x, int y); -struct miqt_array* QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect); -struct miqt_array* QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h); -struct miqt_array* QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path); +struct miqt_array QGraphicsView_Items(const QGraphicsView* self); +struct miqt_array QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos); +struct miqt_array QGraphicsView_Items2(const QGraphicsView* self, int x, int y); +struct miqt_array QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect); +struct miqt_array QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h); +struct miqt_array QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path); QGraphicsItem* QGraphicsView_ItemAt(const QGraphicsView* self, QPoint* pos); QGraphicsItem* QGraphicsView_ItemAt2(const QGraphicsView* self, int x, int y); QPointF* QGraphicsView_MapToScene(const QGraphicsView* self, QPoint* point); @@ -128,7 +128,7 @@ QBrush* QGraphicsView_BackgroundBrush(const QGraphicsView* self); void QGraphicsView_SetBackgroundBrush(QGraphicsView* self, QBrush* brush); QBrush* QGraphicsView_ForegroundBrush(const QGraphicsView* self); void QGraphicsView_SetForegroundBrush(QGraphicsView* self, QBrush* brush); -void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array* /* of QRectF* */ rects); +void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array /* of QRectF* */ rects); void QGraphicsView_InvalidateScene(QGraphicsView* self); void QGraphicsView_UpdateSceneRect(QGraphicsView* self, QRectF* rect); void QGraphicsView_RubberBandChanged(QGraphicsView* self, QRect* viewportRect, QPointF* fromScenePoint, QPointF* toScenePoint); @@ -153,9 +153,9 @@ void QGraphicsView_FitInView23(QGraphicsView* self, QGraphicsItem* item, int asp void QGraphicsView_Render2(QGraphicsView* self, QPainter* painter, QRectF* target); void QGraphicsView_Render3(QGraphicsView* self, QPainter* painter, QRectF* target, QRect* source); void QGraphicsView_Render4(QGraphicsView* self, QPainter* painter, QRectF* target, QRect* source, int aspectRatioMode); -struct miqt_array* QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode); -struct miqt_array* QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode); -struct miqt_array* QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode); +struct miqt_array QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode); +struct miqt_array QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode); +struct miqt_array QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode); void QGraphicsView_InvalidateScene1(QGraphicsView* self, QRectF* rect); void QGraphicsView_InvalidateScene2(QGraphicsView* self, QRectF* rect, int layers); void QGraphicsView_Delete(QGraphicsView* self); diff --git a/qt/gen_qgraphicswidget.cpp b/qt/gen_qgraphicswidget.cpp index 00d37db2..a9c70dd3 100644 --- a/qt/gen_qgraphicswidget.cpp +++ b/qt/gen_qgraphicswidget.cpp @@ -252,21 +252,21 @@ void QGraphicsWidget_AddAction(QGraphicsWidget* self, QAction* action) { self->addAction(action); } -void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array* /* of QAction* */ actions) { +void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->addActions(actions_QList); } -void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions) { +void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->insertActions(before, actions_QList); @@ -280,16 +280,16 @@ void QGraphicsWidget_RemoveAction(QGraphicsWidget* self, QAction* action) { self->removeAction(action); } -struct miqt_array* QGraphicsWidget_Actions(const QGraphicsWidget* self) { +struct miqt_array QGraphicsWidget_Actions(const QGraphicsWidget* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qgraphicswidget.go b/qt/gen_qgraphicswidget.go index fc5cf9de..6307cfe5 100644 --- a/qt/gen_qgraphicswidget.go +++ b/qt/gen_qgraphicswidget.go @@ -299,26 +299,22 @@ func (this *QGraphicsWidget) AddAction(action *QAction) { } func (this *QGraphicsWidget) AddActions(actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QGraphicsWidget_AddActions(this.h, actions_ma) } func (this *QGraphicsWidget) InsertActions(before *QAction, actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QGraphicsWidget_InsertActions(this.h, before.cPointer(), actions_ma) } @@ -331,13 +327,12 @@ func (this *QGraphicsWidget) RemoveAction(action *QAction) { } func (this *QGraphicsWidget) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QGraphicsWidget_Actions(this.h) + var _ma C.struct_miqt_array = C.QGraphicsWidget_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qgraphicswidget.h b/qt/gen_qgraphicswidget.h index 1a461aec..fa32c711 100644 --- a/qt/gen_qgraphicswidget.h +++ b/qt/gen_qgraphicswidget.h @@ -100,11 +100,11 @@ void QGraphicsWidget_ReleaseShortcut(QGraphicsWidget* self, int id); void QGraphicsWidget_SetShortcutEnabled(QGraphicsWidget* self, int id); void QGraphicsWidget_SetShortcutAutoRepeat(QGraphicsWidget* self, int id); void QGraphicsWidget_AddAction(QGraphicsWidget* self, QAction* action); -void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array* /* of QAction* */ actions); -void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions); +void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array /* of QAction* */ actions); +void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions); void QGraphicsWidget_InsertAction(QGraphicsWidget* self, QAction* before, QAction* action); void QGraphicsWidget_RemoveAction(QGraphicsWidget* self, QAction* action); -struct miqt_array* QGraphicsWidget_Actions(const QGraphicsWidget* self); +struct miqt_array QGraphicsWidget_Actions(const QGraphicsWidget* self); void QGraphicsWidget_SetAttribute(QGraphicsWidget* self, int attribute); bool QGraphicsWidget_TestAttribute(const QGraphicsWidget* self, int attribute); int QGraphicsWidget_Type(const QGraphicsWidget* self); diff --git a/qt/gen_qguiapplication.cpp b/qt/gen_qguiapplication.cpp index 5d6ccf26..54cfff9a 100644 --- a/qt/gen_qguiapplication.cpp +++ b/qt/gen_qguiapplication.cpp @@ -91,29 +91,29 @@ struct miqt_string QGuiApplication_DesktopFileName() { return _ms; } -struct miqt_array* QGuiApplication_AllWindows() { +struct miqt_array QGuiApplication_AllWindows() { QWindowList _ret = QGuiApplication::allWindows(); // Convert QList<> from C++ memory to manually-managed C memory QWindow** _arr = static_cast(malloc(sizeof(QWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGuiApplication_TopLevelWindows() { +struct miqt_array QGuiApplication_TopLevelWindows() { QWindowList _ret = QGuiApplication::topLevelWindows(); // Convert QList<> from C++ memory to manually-managed C memory QWindow** _arr = static_cast(malloc(sizeof(QWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -156,16 +156,16 @@ QScreen* QGuiApplication_PrimaryScreen() { return QGuiApplication::primaryScreen(); } -struct miqt_array* QGuiApplication_Screens() { +struct miqt_array QGuiApplication_Screens() { QList _ret = QGuiApplication::screens(); // Convert QList<> from C++ memory to manually-managed C memory QScreen** _arr = static_cast(malloc(sizeof(QScreen*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qguiapplication.go b/qt/gen_qguiapplication.go index 0d19047d..cf486621 100644 --- a/qt/gen_qguiapplication.go +++ b/qt/gen_qguiapplication.go @@ -129,24 +129,22 @@ func QGuiApplication_DesktopFileName() string { } func QGuiApplication_AllWindows() []*QWindow { - var _ma *C.struct_miqt_array = C.QGuiApplication_AllWindows() + var _ma C.struct_miqt_array = C.QGuiApplication_AllWindows() _ret := make([]*QWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QGuiApplication_TopLevelWindows() []*QWindow { - var _ma *C.struct_miqt_array = C.QGuiApplication_TopLevelWindows() + var _ma C.struct_miqt_array = C.QGuiApplication_TopLevelWindows() _ret := make([]*QWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -189,13 +187,12 @@ func QGuiApplication_PrimaryScreen() *QScreen { } func QGuiApplication_Screens() []*QScreen { - var _ma *C.struct_miqt_array = C.QGuiApplication_Screens() + var _ma C.struct_miqt_array = C.QGuiApplication_Screens() _ret := make([]*QScreen, int(_ma.len)) _outCast := (*[0xffff]*C.QScreen)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScreen(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qguiapplication.h b/qt/gen_qguiapplication.h index 6a47a782..cca8bbb9 100644 --- a/qt/gen_qguiapplication.h +++ b/qt/gen_qguiapplication.h @@ -57,8 +57,8 @@ void QGuiApplication_SetApplicationDisplayName(struct miqt_string name); struct miqt_string QGuiApplication_ApplicationDisplayName(); void QGuiApplication_SetDesktopFileName(struct miqt_string name); struct miqt_string QGuiApplication_DesktopFileName(); -struct miqt_array* QGuiApplication_AllWindows(); -struct miqt_array* QGuiApplication_TopLevelWindows(); +struct miqt_array QGuiApplication_AllWindows(); +struct miqt_array QGuiApplication_TopLevelWindows(); QWindow* QGuiApplication_TopLevelAt(QPoint* pos); void QGuiApplication_SetWindowIcon(QIcon* icon); QIcon* QGuiApplication_WindowIcon(); @@ -67,7 +67,7 @@ QWindow* QGuiApplication_ModalWindow(); QWindow* QGuiApplication_FocusWindow(); QObject* QGuiApplication_FocusObject(); QScreen* QGuiApplication_PrimaryScreen(); -struct miqt_array* QGuiApplication_Screens(); +struct miqt_array QGuiApplication_Screens(); QScreen* QGuiApplication_ScreenAt(QPoint* point); double QGuiApplication_DevicePixelRatio(const QGuiApplication* self); QCursor* QGuiApplication_OverrideCursor(); diff --git a/qt/gen_qhash.cpp b/qt/gen_qhash.cpp deleted file mode 100644 index 990920c7..00000000 --- a/qt/gen_qhash.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#define WORKAROUND_INNER_CLASS_DEFINITION_QHashData__Node -#include -#include -#include "gen_qhash.h" -#include "_cgo_export.h" - -void* QHashData_AllocateNode(QHashData* self, int nodeAlign) { - return self->allocateNode(static_cast(nodeAlign)); -} - -void QHashData_FreeNode(QHashData* self, void* node) { - self->freeNode(node); -} - -bool QHashData_WillGrow(QHashData* self) { - return self->willGrow(); -} - -void QHashData_HasShrunk(QHashData* self) { - self->hasShrunk(); -} - -void QHashData_Rehash(QHashData* self, int hint) { - self->rehash(static_cast(hint)); -} - -QHashData__Node* QHashData_FirstNode(QHashData* self) { - return self->firstNode(); -} - -QHashData__Node* QHashData_NextNode(QHashData__Node* node) { - return QHashData::nextNode(node); -} - -QHashData__Node* QHashData_PreviousNode(QHashData__Node* node) { - return QHashData::previousNode(node); -} - -void QHashData_Delete(QHashData* self) { - delete self; -} - -QHashDummyValue* QHashDummyValue_new() { - return new QHashDummyValue(); -} - -QHashDummyValue* QHashDummyValue_new2(QHashDummyValue* param1) { - return new QHashDummyValue(*param1); -} - -void QHashDummyValue_Delete(QHashDummyValue* self) { - delete self; -} - -void QHashData__Node_Delete(QHashData__Node* self) { - delete self; -} - diff --git a/qt/gen_qhash.go b/qt/gen_qhash.go deleted file mode 100644 index c628e4bb..00000000 --- a/qt/gen_qhash.go +++ /dev/null @@ -1,187 +0,0 @@ -package qt - -/* - -#include "gen_qhash.h" -#include - -*/ -import "C" - -import ( - "runtime" - "unsafe" -) - -type QHashData struct { - h *C.QHashData -} - -func (this *QHashData) cPointer() *C.QHashData { - if this == nil { - return nil - } - return this.h -} - -func (this *QHashData) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQHashData(h *C.QHashData) *QHashData { - if h == nil { - return nil - } - return &QHashData{h: h} -} - -func UnsafeNewQHashData(h unsafe.Pointer) *QHashData { - return newQHashData((*C.QHashData)(h)) -} - -func (this *QHashData) AllocateNode(nodeAlign int) unsafe.Pointer { - return (unsafe.Pointer)(C.QHashData_AllocateNode(this.h, (C.int)(nodeAlign))) -} - -func (this *QHashData) FreeNode(node unsafe.Pointer) { - C.QHashData_FreeNode(this.h, node) -} - -func (this *QHashData) WillGrow() bool { - return (bool)(C.QHashData_WillGrow(this.h)) -} - -func (this *QHashData) HasShrunk() { - C.QHashData_HasShrunk(this.h) -} - -func (this *QHashData) Rehash(hint int) { - C.QHashData_Rehash(this.h, (C.int)(hint)) -} - -func (this *QHashData) FirstNode() *QHashData__Node { - return UnsafeNewQHashData__Node(unsafe.Pointer(C.QHashData_FirstNode(this.h))) -} - -func QHashData_NextNode(node *QHashData__Node) *QHashData__Node { - return UnsafeNewQHashData__Node(unsafe.Pointer(C.QHashData_NextNode(node.cPointer()))) -} - -func QHashData_PreviousNode(node *QHashData__Node) *QHashData__Node { - return UnsafeNewQHashData__Node(unsafe.Pointer(C.QHashData_PreviousNode(node.cPointer()))) -} - -// Delete this object from C++ memory. -func (this *QHashData) Delete() { - C.QHashData_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QHashData) GoGC() { - runtime.SetFinalizer(this, func(this *QHashData) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} - -type QHashDummyValue struct { - h *C.QHashDummyValue -} - -func (this *QHashDummyValue) cPointer() *C.QHashDummyValue { - if this == nil { - return nil - } - return this.h -} - -func (this *QHashDummyValue) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQHashDummyValue(h *C.QHashDummyValue) *QHashDummyValue { - if h == nil { - return nil - } - return &QHashDummyValue{h: h} -} - -func UnsafeNewQHashDummyValue(h unsafe.Pointer) *QHashDummyValue { - return newQHashDummyValue((*C.QHashDummyValue)(h)) -} - -// NewQHashDummyValue constructs a new QHashDummyValue object. -func NewQHashDummyValue() *QHashDummyValue { - ret := C.QHashDummyValue_new() - return newQHashDummyValue(ret) -} - -// NewQHashDummyValue2 constructs a new QHashDummyValue object. -func NewQHashDummyValue2(param1 *QHashDummyValue) *QHashDummyValue { - ret := C.QHashDummyValue_new2(param1.cPointer()) - return newQHashDummyValue(ret) -} - -// Delete this object from C++ memory. -func (this *QHashDummyValue) Delete() { - C.QHashDummyValue_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QHashDummyValue) GoGC() { - runtime.SetFinalizer(this, func(this *QHashDummyValue) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} - -type QHashData__Node struct { - h *C.QHashData__Node -} - -func (this *QHashData__Node) cPointer() *C.QHashData__Node { - if this == nil { - return nil - } - return this.h -} - -func (this *QHashData__Node) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQHashData__Node(h *C.QHashData__Node) *QHashData__Node { - if h == nil { - return nil - } - return &QHashData__Node{h: h} -} - -func UnsafeNewQHashData__Node(h unsafe.Pointer) *QHashData__Node { - return newQHashData__Node((*C.QHashData__Node)(h)) -} - -// Delete this object from C++ memory. -func (this *QHashData__Node) Delete() { - C.QHashData__Node_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QHashData__Node) GoGC() { - runtime.SetFinalizer(this, func(this *QHashData__Node) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} diff --git a/qt/gen_qhash.h b/qt/gen_qhash.h deleted file mode 100644 index a0bb7181..00000000 --- a/qt/gen_qhash.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef GEN_QHASH_H -#define GEN_QHASH_H - -#include -#include -#include - -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -#include "../libmiqt/libmiqt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -class QHashData; -#if defined(WORKAROUND_INNER_CLASS_DEFINITION_QHashData__Node) -typedef QHashData::Node QHashData__Node; -#else -class QHashData__Node; -#endif -class QHashDummyValue; -#else -typedef struct QHashData QHashData; -typedef struct QHashData__Node QHashData__Node; -typedef struct QHashDummyValue QHashDummyValue; -#endif - -void* QHashData_AllocateNode(QHashData* self, int nodeAlign); -void QHashData_FreeNode(QHashData* self, void* node); -bool QHashData_WillGrow(QHashData* self); -void QHashData_HasShrunk(QHashData* self); -void QHashData_Rehash(QHashData* self, int hint); -QHashData__Node* QHashData_FirstNode(QHashData* self); -QHashData__Node* QHashData_NextNode(QHashData__Node* node); -QHashData__Node* QHashData_PreviousNode(QHashData__Node* node); -void QHashData_Delete(QHashData* self); - -QHashDummyValue* QHashDummyValue_new(); -QHashDummyValue* QHashDummyValue_new2(QHashDummyValue* param1); -void QHashDummyValue_Delete(QHashDummyValue* self); - -void QHashData__Node_Delete(QHashData__Node* self); - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif diff --git a/qt/gen_qicon.cpp b/qt/gen_qicon.cpp index afd48032..1d960734 100644 --- a/qt/gen_qicon.cpp +++ b/qt/gen_qicon.cpp @@ -111,16 +111,16 @@ void QIcon_AddFile(QIcon* self, struct miqt_string fileName) { self->addFile(fileName_QString); } -struct miqt_array* QIcon_AvailableSizes(const QIcon* self) { +struct miqt_array QIcon_AvailableSizes(const QIcon* self) { QList _ret = self->availableSizes(); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -147,7 +147,7 @@ bool QIcon_HasThemeIcon(struct miqt_string name) { return QIcon::hasThemeIcon(name_QString); } -struct miqt_array* QIcon_ThemeSearchPaths() { +struct miqt_array QIcon_ThemeSearchPaths() { QStringList _ret = QIcon::themeSearchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -161,24 +161,24 @@ struct miqt_array* QIcon_ThemeSearchPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QIcon_SetThemeSearchPaths(struct miqt_array* /* of struct miqt_string */ searchpath) { +void QIcon_SetThemeSearchPaths(struct miqt_array /* of struct miqt_string */ searchpath) { QStringList searchpath_QList; - searchpath_QList.reserve(searchpath->len); - struct miqt_string* searchpath_arr = static_cast(searchpath->data); - for(size_t i = 0; i < searchpath->len; ++i) { + searchpath_QList.reserve(searchpath.len); + struct miqt_string* searchpath_arr = static_cast(searchpath.data); + for(size_t i = 0; i < searchpath.len; ++i) { QString searchpath_arr_i_QString = QString::fromUtf8(searchpath_arr[i].data, searchpath_arr[i].len); searchpath_QList.push_back(searchpath_arr_i_QString); } QIcon::setThemeSearchPaths(searchpath_QList); } -struct miqt_array* QIcon_FallbackSearchPaths() { +struct miqt_array QIcon_FallbackSearchPaths() { QStringList _ret = QIcon::fallbackSearchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -192,17 +192,17 @@ struct miqt_array* QIcon_FallbackSearchPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QIcon_SetFallbackSearchPaths(struct miqt_array* /* of struct miqt_string */ paths) { +void QIcon_SetFallbackSearchPaths(struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -336,29 +336,29 @@ void QIcon_AddFile4(QIcon* self, struct miqt_string fileName, QSize* size, int m self->addFile(fileName_QString, *size, static_cast(mode), static_cast(state)); } -struct miqt_array* QIcon_AvailableSizes1(const QIcon* self, int mode) { +struct miqt_array QIcon_AvailableSizes1(const QIcon* self, int mode) { QList _ret = self->availableSizes(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIcon_AvailableSizes2(const QIcon* self, int mode, int state) { +struct miqt_array QIcon_AvailableSizes2(const QIcon* self, int mode, int state) { QList _ret = self->availableSizes(static_cast(mode), static_cast(state)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qicon.go b/qt/gen_qicon.go index 67342c76..4edb5e90 100644 --- a/qt/gen_qicon.go +++ b/qt/gen_qicon.go @@ -186,7 +186,7 @@ func (this *QIcon) AddFile(fileName string) { } func (this *QIcon) AvailableSizes() []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes(this.h) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes(this.h) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -195,7 +195,6 @@ func (this *QIcon) AvailableSizes() []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -238,7 +237,7 @@ func QIcon_HasThemeIcon(name string) bool { } func QIcon_ThemeSearchPaths() []string { - var _ma *C.struct_miqt_array = C.QIcon_ThemeSearchPaths() + var _ma C.struct_miqt_array = C.QIcon_ThemeSearchPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -247,12 +246,10 @@ func QIcon_ThemeSearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QIcon_SetThemeSearchPaths(searchpath []string) { - // For the C ABI, malloc a C array of structs searchpath_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(searchpath)))) defer C.free(unsafe.Pointer(searchpath_CArray)) for i := range searchpath { @@ -262,13 +259,12 @@ func QIcon_SetThemeSearchPaths(searchpath []string) { defer C.free(unsafe.Pointer(searchpath_i_ms.data)) searchpath_CArray[i] = searchpath_i_ms } - searchpath_ma := &C.struct_miqt_array{len: C.size_t(len(searchpath)), data: unsafe.Pointer(searchpath_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(searchpath_ma)) + searchpath_ma := C.struct_miqt_array{len: C.size_t(len(searchpath)), data: unsafe.Pointer(searchpath_CArray)} C.QIcon_SetThemeSearchPaths(searchpath_ma) } func QIcon_FallbackSearchPaths() []string { - var _ma *C.struct_miqt_array = C.QIcon_FallbackSearchPaths() + var _ma C.struct_miqt_array = C.QIcon_FallbackSearchPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -277,12 +273,10 @@ func QIcon_FallbackSearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QIcon_SetFallbackSearchPaths(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -292,8 +286,7 @@ func QIcon_SetFallbackSearchPaths(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QIcon_SetFallbackSearchPaths(paths_ma) } @@ -468,7 +461,7 @@ func (this *QIcon) AddFile4(fileName string, size *QSize, mode QIcon__Mode, stat } func (this *QIcon) AvailableSizes1(mode QIcon__Mode) []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes1(this.h, (C.int)(mode)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -477,12 +470,11 @@ func (this *QIcon) AvailableSizes1(mode QIcon__Mode) []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIcon) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -491,7 +483,6 @@ func (this *QIcon) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qicon.h b/qt/gen_qicon.h index 1d2871ab..bb8f73ae 100644 --- a/qt/gen_qicon.h +++ b/qt/gen_qicon.h @@ -53,16 +53,16 @@ void QIcon_Detach(QIcon* self); long long QIcon_CacheKey(const QIcon* self); void QIcon_AddPixmap(QIcon* self, QPixmap* pixmap); void QIcon_AddFile(QIcon* self, struct miqt_string fileName); -struct miqt_array* QIcon_AvailableSizes(const QIcon* self); +struct miqt_array QIcon_AvailableSizes(const QIcon* self); void QIcon_SetIsMask(QIcon* self, bool isMask); bool QIcon_IsMask(const QIcon* self); QIcon* QIcon_FromTheme(struct miqt_string name); QIcon* QIcon_FromTheme2(struct miqt_string name, QIcon* fallback); bool QIcon_HasThemeIcon(struct miqt_string name); -struct miqt_array* QIcon_ThemeSearchPaths(); -void QIcon_SetThemeSearchPaths(struct miqt_array* /* of struct miqt_string */ searchpath); -struct miqt_array* QIcon_FallbackSearchPaths(); -void QIcon_SetFallbackSearchPaths(struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QIcon_ThemeSearchPaths(); +void QIcon_SetThemeSearchPaths(struct miqt_array /* of struct miqt_string */ searchpath); +struct miqt_array QIcon_FallbackSearchPaths(); +void QIcon_SetFallbackSearchPaths(struct miqt_array /* of struct miqt_string */ paths); struct miqt_string QIcon_ThemeName(); void QIcon_SetThemeName(struct miqt_string path); struct miqt_string QIcon_FallbackThemeName(); @@ -90,8 +90,8 @@ void QIcon_AddPixmap3(QIcon* self, QPixmap* pixmap, int mode, int state); void QIcon_AddFile2(QIcon* self, struct miqt_string fileName, QSize* size); void QIcon_AddFile3(QIcon* self, struct miqt_string fileName, QSize* size, int mode); void QIcon_AddFile4(QIcon* self, struct miqt_string fileName, QSize* size, int mode, int state); -struct miqt_array* QIcon_AvailableSizes1(const QIcon* self, int mode); -struct miqt_array* QIcon_AvailableSizes2(const QIcon* self, int mode, int state); +struct miqt_array QIcon_AvailableSizes1(const QIcon* self, int mode); +struct miqt_array QIcon_AvailableSizes2(const QIcon* self, int mode, int state); void QIcon_Delete(QIcon* self); #ifdef __cplusplus diff --git a/qt/gen_qiconengine.cpp b/qt/gen_qiconengine.cpp index 282bf751..d1fe6a35 100644 --- a/qt/gen_qiconengine.cpp +++ b/qt/gen_qiconengine.cpp @@ -58,16 +58,16 @@ bool QIconEngine_Write(const QIconEngine* self, QDataStream* out) { return self->write(*out); } -struct miqt_array* QIconEngine_AvailableSizes(const QIconEngine* self) { +struct miqt_array QIconEngine_AvailableSizes(const QIconEngine* self) { QList _ret = self->availableSizes(); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -94,29 +94,29 @@ void QIconEngine_VirtualHook(QIconEngine* self, int id, void* data) { self->virtual_hook(static_cast(id), data); } -struct miqt_array* QIconEngine_AvailableSizes1(const QIconEngine* self, int mode) { +struct miqt_array QIconEngine_AvailableSizes1(const QIconEngine* self, int mode) { QList _ret = self->availableSizes(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIconEngine_AvailableSizes2(const QIconEngine* self, int mode, int state) { +struct miqt_array QIconEngine_AvailableSizes2(const QIconEngine* self, int mode, int state) { QList _ret = self->availableSizes(static_cast(mode), static_cast(state)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qiconengine.go b/qt/gen_qiconengine.go index b1ef3d95..c6273870 100644 --- a/qt/gen_qiconengine.go +++ b/qt/gen_qiconengine.go @@ -101,7 +101,7 @@ func (this *QIconEngine) Write(out *QDataStream) bool { } func (this *QIconEngine) AvailableSizes() []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes(this.h) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes(this.h) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -110,7 +110,6 @@ func (this *QIconEngine) AvailableSizes() []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -137,7 +136,7 @@ func (this *QIconEngine) VirtualHook(id int, data unsafe.Pointer) { } func (this *QIconEngine) AvailableSizes1(mode QIcon__Mode) []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes1(this.h, (C.int)(mode)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -146,12 +145,11 @@ func (this *QIconEngine) AvailableSizes1(mode QIcon__Mode) []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIconEngine) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -160,7 +158,6 @@ func (this *QIconEngine) AvailableSizes2(mode QIcon__Mode, state QIcon__State) [ _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qiconengine.h b/qt/gen_qiconengine.h index cfab5908..91ed380f 100644 --- a/qt/gen_qiconengine.h +++ b/qt/gen_qiconengine.h @@ -50,13 +50,13 @@ struct miqt_string QIconEngine_Key(const QIconEngine* self); QIconEngine* QIconEngine_Clone(const QIconEngine* self); bool QIconEngine_Read(QIconEngine* self, QDataStream* in); bool QIconEngine_Write(const QIconEngine* self, QDataStream* out); -struct miqt_array* QIconEngine_AvailableSizes(const QIconEngine* self); +struct miqt_array QIconEngine_AvailableSizes(const QIconEngine* self); struct miqt_string QIconEngine_IconName(const QIconEngine* self); bool QIconEngine_IsNull(const QIconEngine* self); QPixmap* QIconEngine_ScaledPixmap(QIconEngine* self, QSize* size, int mode, int state, double scale); void QIconEngine_VirtualHook(QIconEngine* self, int id, void* data); -struct miqt_array* QIconEngine_AvailableSizes1(const QIconEngine* self, int mode); -struct miqt_array* QIconEngine_AvailableSizes2(const QIconEngine* self, int mode, int state); +struct miqt_array QIconEngine_AvailableSizes1(const QIconEngine* self, int mode); +struct miqt_array QIconEngine_AvailableSizes2(const QIconEngine* self, int mode, int state); void QIconEngine_Delete(QIconEngine* self); QIconEngine__AvailableSizesArgument* QIconEngine__AvailableSizesArgument_new(QIconEngine__AvailableSizesArgument* param1); diff --git a/qt/gen_qidentityproxymodel.cpp b/qt/gen_qidentityproxymodel.cpp index 2c8d34a9..2988d5b1 100644 --- a/qt/gen_qidentityproxymodel.cpp +++ b/qt/gen_qidentityproxymodel.cpp @@ -87,16 +87,16 @@ QModelIndex* QIdentityProxyModel_Sibling(const QIdentityProxyModel* self, int ro return new QModelIndex(self->sibling(static_cast(row), static_cast(column), *idx)); } -struct miqt_array* QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -188,29 +188,29 @@ QVariant* QIdentityProxyModel_HeaderData3(const QIdentityProxyModel* self, int s return new QVariant(self->headerData(static_cast(section), static_cast(orientation), static_cast(role))); } -struct miqt_array* QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qidentityproxymodel.go b/qt/gen_qidentityproxymodel.go index 0eeea198..5735a09f 100644 --- a/qt/gen_qidentityproxymodel.go +++ b/qt/gen_qidentityproxymodel.go @@ -138,7 +138,7 @@ func (this *QIdentityProxyModel) Sibling(row int, column int, idx *QModelIndex) } func (this *QIdentityProxyModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -147,7 +147,6 @@ func (this *QIdentityProxyModel) Match(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -246,7 +245,7 @@ func (this *QIdentityProxyModel) HeaderData3(section int, orientation Orientatio } func (this *QIdentityProxyModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -255,12 +254,11 @@ func (this *QIdentityProxyModel) Match4(start *QModelIndex, role int, value *QVa _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIdentityProxyModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -269,7 +267,6 @@ func (this *QIdentityProxyModel) Match5(start *QModelIndex, role int, value *QVa _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qidentityproxymodel.h b/qt/gen_qidentityproxymodel.h index db406e83..649231e4 100644 --- a/qt/gen_qidentityproxymodel.h +++ b/qt/gen_qidentityproxymodel.h @@ -46,7 +46,7 @@ int QIdentityProxyModel_RowCount(const QIdentityProxyModel* self); QVariant* QIdentityProxyModel_HeaderData(const QIdentityProxyModel* self, int section, int orientation); bool QIdentityProxyModel_DropMimeData(QIdentityProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); QModelIndex* QIdentityProxyModel_Sibling(const QIdentityProxyModel* self, int row, int column, QModelIndex* idx); -struct miqt_array* QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value); void QIdentityProxyModel_SetSourceModel(QIdentityProxyModel* self, QAbstractItemModel* sourceModel); bool QIdentityProxyModel_InsertColumns(QIdentityProxyModel* self, int column, int count); bool QIdentityProxyModel_InsertRows(QIdentityProxyModel* self, int row, int count); @@ -62,8 +62,8 @@ int QIdentityProxyModel_ColumnCount1(const QIdentityProxyModel* self, QModelInde QModelIndex* QIdentityProxyModel_Index3(const QIdentityProxyModel* self, int row, int column, QModelIndex* parent); int QIdentityProxyModel_RowCount1(const QIdentityProxyModel* self, QModelIndex* parent); QVariant* QIdentityProxyModel_HeaderData3(const QIdentityProxyModel* self, int section, int orientation, int role); -struct miqt_array* QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); bool QIdentityProxyModel_InsertColumns3(QIdentityProxyModel* self, int column, int count, QModelIndex* parent); bool QIdentityProxyModel_InsertRows3(QIdentityProxyModel* self, int row, int count, QModelIndex* parent); bool QIdentityProxyModel_RemoveColumns3(QIdentityProxyModel* self, int column, int count, QModelIndex* parent); diff --git a/qt/gen_qimage.cpp b/qt/gen_qimage.cpp index f53ae7aa..9acee4b6 100644 --- a/qt/gen_qimage.cpp +++ b/qt/gen_qimage.cpp @@ -110,11 +110,11 @@ QImage* QImage_ConvertToFormat(const QImage* self, int f) { return new QImage(self->convertToFormat(static_cast(f))); } -QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable) { +QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable) { QVector colorTable_QList; - colorTable_QList.reserve(colorTable->len); - unsigned int* colorTable_arr = static_cast(colorTable->data); - for(size_t i = 0; i < colorTable->len; ++i) { + colorTable_QList.reserve(colorTable.len); + unsigned int* colorTable_arr = static_cast(colorTable.data); + for(size_t i = 0; i < colorTable.len; ++i) { colorTable_QList.push_back(static_cast(colorTable_arr[i])); } return new QImage(self->convertToFormat(static_cast(f), colorTable_QList)); @@ -270,24 +270,24 @@ void QImage_SetPixelColor2(QImage* self, QPoint* pt, QColor* c) { self->setPixelColor(*pt, *c); } -struct miqt_array* QImage_ColorTable(const QImage* self) { +struct miqt_array QImage_ColorTable(const QImage* self) { QVector _ret = self->colorTable(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QImage_SetColorTable(QImage* self, struct miqt_array* /* of unsigned int */ colors) { +void QImage_SetColorTable(QImage* self, struct miqt_array /* of unsigned int */ colors) { QVector colors_QList; - colors_QList.reserve(colors->len); - unsigned int* colors_arr = static_cast(colors->data); - for(size_t i = 0; i < colors->len; ++i) { + colors_QList.reserve(colors.len); + unsigned int* colors_arr = static_cast(colors.data); + for(size_t i = 0; i < colors.len; ++i) { colors_QList.push_back(static_cast(colors_arr[i])); } self->setColorTable(colors_QList); @@ -471,7 +471,7 @@ void QImage_SetOffset(QImage* self, QPoint* offset) { self->setOffset(*offset); } -struct miqt_array* QImage_TextKeys(const QImage* self) { +struct miqt_array QImage_TextKeys(const QImage* self) { QStringList _ret = self->textKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -485,9 +485,9 @@ struct miqt_array* QImage_TextKeys(const QImage* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -529,11 +529,11 @@ QImage* QImage_ConvertToFormat22(const QImage* self, int f, int flags) { return new QImage(self->convertToFormat(static_cast(f), static_cast(flags))); } -QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable, int flags) { +QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable, int flags) { QVector colorTable_QList; - colorTable_QList.reserve(colorTable->len); - unsigned int* colorTable_arr = static_cast(colorTable->data); - for(size_t i = 0; i < colorTable->len; ++i) { + colorTable_QList.reserve(colorTable.len); + unsigned int* colorTable_arr = static_cast(colorTable.data); + for(size_t i = 0; i < colorTable.len; ++i) { colorTable_QList.push_back(static_cast(colorTable_arr[i])); } return new QImage(self->convertToFormat(static_cast(f), colorTable_QList, static_cast(flags))); diff --git a/qt/gen_qimage.go b/qt/gen_qimage.go index 5bea9ee8..dbcf3c9e 100644 --- a/qt/gen_qimage.go +++ b/qt/gen_qimage.go @@ -214,14 +214,12 @@ func (this *QImage) ConvertToFormat(f QImage__Format) *QImage { } func (this *QImage) ConvertToFormat2(f QImage__Format, colorTable []uint) *QImage { - // For the C ABI, malloc a C array of raw pointers colorTable_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colorTable)))) defer C.free(unsafe.Pointer(colorTable_CArray)) for i := range colorTable { colorTable_CArray[i] = (C.uint)(colorTable[i]) } - colorTable_ma := &C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colorTable_ma)) + colorTable_ma := C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} _ret := C.QImage_ConvertToFormat2(this.h, (C.int)(f), colorTable_ma) _goptr := newQImage(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer @@ -381,25 +379,22 @@ func (this *QImage) SetPixelColor2(pt *QPoint, c *QColor) { } func (this *QImage) ColorTable() []uint { - var _ma *C.struct_miqt_array = C.QImage_ColorTable(this.h) + var _ma C.struct_miqt_array = C.QImage_ColorTable(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QImage) SetColorTable(colors []uint) { - // For the C ABI, malloc a C array of raw pointers colors_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colors)))) defer C.free(unsafe.Pointer(colors_CArray)) for i := range colors { colors_CArray[i] = (C.uint)(colors[i]) } - colors_ma := &C.struct_miqt_array{len: C.size_t(len(colors)), data: unsafe.Pointer(colors_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colors_ma)) + colors_ma := C.struct_miqt_array{len: C.size_t(len(colors)), data: unsafe.Pointer(colors_CArray)} C.QImage_SetColorTable(this.h, colors_ma) } @@ -649,7 +644,7 @@ func (this *QImage) SetOffset(offset *QPoint) { } func (this *QImage) TextKeys() []string { - var _ma *C.struct_miqt_array = C.QImage_TextKeys(this.h) + var _ma C.struct_miqt_array = C.QImage_TextKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -658,7 +653,6 @@ func (this *QImage) TextKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -714,14 +708,12 @@ func (this *QImage) ConvertToFormat22(f QImage__Format, flags ImageConversionFla } func (this *QImage) ConvertToFormat3(f QImage__Format, colorTable []uint, flags ImageConversionFlag) *QImage { - // For the C ABI, malloc a C array of raw pointers colorTable_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colorTable)))) defer C.free(unsafe.Pointer(colorTable_CArray)) for i := range colorTable { colorTable_CArray[i] = (C.uint)(colorTable[i]) } - colorTable_ma := &C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colorTable_ma)) + colorTable_ma := C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} _ret := C.QImage_ConvertToFormat3(this.h, (C.int)(f), colorTable_ma, (C.int)(flags)) _goptr := newQImage(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt/gen_qimage.h b/qt/gen_qimage.h index f215f074..0465e211 100644 --- a/qt/gen_qimage.h +++ b/qt/gen_qimage.h @@ -65,7 +65,7 @@ QImage* QImage_Copy(const QImage* self); QImage* QImage_Copy2(const QImage* self, int x, int y, int w, int h); int QImage_Format(const QImage* self); QImage* QImage_ConvertToFormat(const QImage* self, int f); -QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable); +QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable); bool QImage_ReinterpretAsFormat(QImage* self, int f); void QImage_ConvertTo(QImage* self, int f); int QImage_Width(const QImage* self); @@ -101,8 +101,8 @@ QColor* QImage_PixelColor(const QImage* self, int x, int y); QColor* QImage_PixelColorWithPt(const QImage* self, QPoint* pt); void QImage_SetPixelColor(QImage* self, int x, int y, QColor* c); void QImage_SetPixelColor2(QImage* self, QPoint* pt, QColor* c); -struct miqt_array* QImage_ColorTable(const QImage* self); -void QImage_SetColorTable(QImage* self, struct miqt_array* /* of unsigned int */ colors); +struct miqt_array QImage_ColorTable(const QImage* self); +void QImage_SetColorTable(QImage* self, struct miqt_array /* of unsigned int */ colors); double QImage_DevicePixelRatio(const QImage* self); void QImage_SetDevicePixelRatio(QImage* self, double scaleFactor); void QImage_Fill(QImage* self, unsigned int pixel); @@ -146,7 +146,7 @@ void QImage_SetDotsPerMeterX(QImage* self, int dotsPerMeterX); void QImage_SetDotsPerMeterY(QImage* self, int dotsPerMeterY); QPoint* QImage_Offset(const QImage* self); void QImage_SetOffset(QImage* self, QPoint* offset); -struct miqt_array* QImage_TextKeys(const QImage* self); +struct miqt_array QImage_TextKeys(const QImage* self); struct miqt_string QImage_Text(const QImage* self); void QImage_SetText(QImage* self, struct miqt_string key, struct miqt_string value); QPixelFormat* QImage_PixelFormat(const QImage* self); @@ -154,7 +154,7 @@ QPixelFormat* QImage_ToPixelFormat(int format); int QImage_ToImageFormat(QPixelFormat* format); QImage* QImage_Copy1(const QImage* self, QRect* rect); QImage* QImage_ConvertToFormat22(const QImage* self, int f, int flags); -QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable, int flags); +QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable, int flags); void QImage_ConvertTo2(QImage* self, int f, int flags); QImage* QImage_CreateAlphaMask1(const QImage* self, int flags); QImage* QImage_CreateHeuristicMask1(const QImage* self, bool clipTight); diff --git a/qt/gen_qimagereader.cpp b/qt/gen_qimagereader.cpp index 388065d5..ae906ef5 100644 --- a/qt/gen_qimagereader.cpp +++ b/qt/gen_qimagereader.cpp @@ -122,7 +122,7 @@ int QImageReader_ImageFormat(const QImageReader* self) { return static_cast(_ret); } -struct miqt_array* QImageReader_TextKeys(const QImageReader* self) { +struct miqt_array QImageReader_TextKeys(const QImageReader* self) { QStringList _ret = self->textKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -136,9 +136,9 @@ struct miqt_array* QImageReader_TextKeys(const QImageReader* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -228,7 +228,7 @@ struct miqt_string QImageReader_SubType(const QImageReader* self) { return _ms; } -struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self) { +struct miqt_array QImageReader_SupportedSubTypes(const QImageReader* self) { QList _ret = self->supportedSubTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -240,9 +240,9 @@ struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -325,7 +325,7 @@ struct miqt_string QImageReader_ImageFormatWithDevice(QIODevice* device) { return _ms; } -struct miqt_array* QImageReader_SupportedImageFormats() { +struct miqt_array QImageReader_SupportedImageFormats() { QList _ret = QImageReader::supportedImageFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -337,13 +337,13 @@ struct miqt_array* QImageReader_SupportedImageFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageReader_SupportedMimeTypes() { +struct miqt_array QImageReader_SupportedMimeTypes() { QList _ret = QImageReader::supportedMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -355,13 +355,13 @@ struct miqt_array* QImageReader_SupportedMimeTypes() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType) { +struct miqt_array QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType) { QByteArray mimeType_QByteArray(mimeType.data, mimeType.len); QList _ret = QImageReader::imageFormatsForMimeType(mimeType_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -374,9 +374,9 @@ struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeT memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qimagereader.go b/qt/gen_qimagereader.go index bee32cb2..b20351c0 100644 --- a/qt/gen_qimagereader.go +++ b/qt/gen_qimagereader.go @@ -179,7 +179,7 @@ func (this *QImageReader) ImageFormat() QImage__Format { } func (this *QImageReader) TextKeys() []string { - var _ma *C.struct_miqt_array = C.QImageReader_TextKeys(this.h) + var _ma C.struct_miqt_array = C.QImageReader_TextKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -188,7 +188,6 @@ func (this *QImageReader) TextKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -287,7 +286,7 @@ func (this *QImageReader) SubType() []byte { } func (this *QImageReader) SupportedSubTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedSubTypes(this.h) + var _ma C.struct_miqt_array = C.QImageReader_SupportedSubTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -296,7 +295,6 @@ func (this *QImageReader) SupportedSubTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -380,7 +378,7 @@ func QImageReader_ImageFormatWithDevice(device *QIODevice) []byte { } func QImageReader_SupportedImageFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedImageFormats() + var _ma C.struct_miqt_array = C.QImageReader_SupportedImageFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -389,12 +387,11 @@ func QImageReader_SupportedImageFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QImageReader_SupportedMimeTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedMimeTypes() + var _ma C.struct_miqt_array = C.QImageReader_SupportedMimeTypes() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -403,7 +400,6 @@ func QImageReader_SupportedMimeTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -411,7 +407,7 @@ func QImageReader_ImageFormatsForMimeType(mimeType []byte) [][]byte { mimeType_alias := C.struct_miqt_string{} mimeType_alias.data = (*C.char)(unsafe.Pointer(&mimeType[0])) mimeType_alias.len = C.size_t(len(mimeType)) - var _ma *C.struct_miqt_array = C.QImageReader_ImageFormatsForMimeType(mimeType_alias) + var _ma C.struct_miqt_array = C.QImageReader_ImageFormatsForMimeType(mimeType_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -420,7 +416,6 @@ func QImageReader_ImageFormatsForMimeType(mimeType []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qimagereader.h b/qt/gen_qimagereader.h index 699a9f26..9114f512 100644 --- a/qt/gen_qimagereader.h +++ b/qt/gen_qimagereader.h @@ -50,7 +50,7 @@ void QImageReader_SetFileName(QImageReader* self, struct miqt_string fileName); struct miqt_string QImageReader_FileName(const QImageReader* self); QSize* QImageReader_Size(const QImageReader* self); int QImageReader_ImageFormat(const QImageReader* self); -struct miqt_array* QImageReader_TextKeys(const QImageReader* self); +struct miqt_array QImageReader_TextKeys(const QImageReader* self); struct miqt_string QImageReader_Text(const QImageReader* self, struct miqt_string key); void QImageReader_SetClipRect(QImageReader* self, QRect* rect); QRect* QImageReader_ClipRect(const QImageReader* self); @@ -69,7 +69,7 @@ bool QImageReader_AutoTransform(const QImageReader* self); void QImageReader_SetGamma(QImageReader* self, float gamma); float QImageReader_Gamma(const QImageReader* self); struct miqt_string QImageReader_SubType(const QImageReader* self); -struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self); +struct miqt_array QImageReader_SupportedSubTypes(const QImageReader* self); bool QImageReader_CanRead(const QImageReader* self); QImage* QImageReader_Read(QImageReader* self); bool QImageReader_ReadWithImage(QImageReader* self, QImage* image); @@ -85,9 +85,9 @@ struct miqt_string QImageReader_ErrorString(const QImageReader* self); bool QImageReader_SupportsOption(const QImageReader* self, int option); struct miqt_string QImageReader_ImageFormatWithFileName(struct miqt_string fileName); struct miqt_string QImageReader_ImageFormatWithDevice(QIODevice* device); -struct miqt_array* QImageReader_SupportedImageFormats(); -struct miqt_array* QImageReader_SupportedMimeTypes(); -struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType); +struct miqt_array QImageReader_SupportedImageFormats(); +struct miqt_array QImageReader_SupportedMimeTypes(); +struct miqt_array QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType); struct miqt_string QImageReader_Tr2(const char* sourceText, const char* disambiguation); struct miqt_string QImageReader_Tr3(const char* sourceText, const char* disambiguation, int n); struct miqt_string QImageReader_TrUtf82(const char* sourceText, const char* disambiguation); diff --git a/qt/gen_qimagewriter.cpp b/qt/gen_qimagewriter.cpp index 55d59758..2bda95a8 100644 --- a/qt/gen_qimagewriter.cpp +++ b/qt/gen_qimagewriter.cpp @@ -128,7 +128,7 @@ struct miqt_string QImageWriter_SubType(const QImageWriter* self) { return _ms; } -struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self) { +struct miqt_array QImageWriter_SupportedSubTypes(const QImageWriter* self) { QList _ret = self->supportedSubTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -140,9 +140,9 @@ struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -221,7 +221,7 @@ bool QImageWriter_SupportsOption(const QImageWriter* self, int option) { return self->supportsOption(static_cast(option)); } -struct miqt_array* QImageWriter_SupportedImageFormats() { +struct miqt_array QImageWriter_SupportedImageFormats() { QList _ret = QImageWriter::supportedImageFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -233,13 +233,13 @@ struct miqt_array* QImageWriter_SupportedImageFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageWriter_SupportedMimeTypes() { +struct miqt_array QImageWriter_SupportedMimeTypes() { QList _ret = QImageWriter::supportedMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -251,13 +251,13 @@ struct miqt_array* QImageWriter_SupportedMimeTypes() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType) { +struct miqt_array QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType) { QByteArray mimeType_QByteArray(mimeType.data, mimeType.len); QList _ret = QImageWriter::imageFormatsForMimeType(mimeType_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -270,9 +270,9 @@ struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeT memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qimagewriter.go b/qt/gen_qimagewriter.go index daf4a5b9..57a2921b 100644 --- a/qt/gen_qimagewriter.go +++ b/qt/gen_qimagewriter.go @@ -183,7 +183,7 @@ func (this *QImageWriter) SubType() []byte { } func (this *QImageWriter) SupportedSubTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedSubTypes(this.h) + var _ma C.struct_miqt_array = C.QImageWriter_SupportedSubTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -192,7 +192,6 @@ func (this *QImageWriter) SupportedSubTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -271,7 +270,7 @@ func (this *QImageWriter) SupportsOption(option QImageIOHandler__ImageOption) bo } func QImageWriter_SupportedImageFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedImageFormats() + var _ma C.struct_miqt_array = C.QImageWriter_SupportedImageFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -280,12 +279,11 @@ func QImageWriter_SupportedImageFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QImageWriter_SupportedMimeTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedMimeTypes() + var _ma C.struct_miqt_array = C.QImageWriter_SupportedMimeTypes() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -294,7 +292,6 @@ func QImageWriter_SupportedMimeTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -302,7 +299,7 @@ func QImageWriter_ImageFormatsForMimeType(mimeType []byte) [][]byte { mimeType_alias := C.struct_miqt_string{} mimeType_alias.data = (*C.char)(unsafe.Pointer(&mimeType[0])) mimeType_alias.len = C.size_t(len(mimeType)) - var _ma *C.struct_miqt_array = C.QImageWriter_ImageFormatsForMimeType(mimeType_alias) + var _ma C.struct_miqt_array = C.QImageWriter_ImageFormatsForMimeType(mimeType_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -311,7 +308,6 @@ func QImageWriter_ImageFormatsForMimeType(mimeType []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qimagewriter.h b/qt/gen_qimagewriter.h index 41de56f7..5e09675f 100644 --- a/qt/gen_qimagewriter.h +++ b/qt/gen_qimagewriter.h @@ -45,7 +45,7 @@ void QImageWriter_SetGamma(QImageWriter* self, float gamma); float QImageWriter_Gamma(const QImageWriter* self); void QImageWriter_SetSubType(QImageWriter* self, struct miqt_string typeVal); struct miqt_string QImageWriter_SubType(const QImageWriter* self); -struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self); +struct miqt_array QImageWriter_SupportedSubTypes(const QImageWriter* self); void QImageWriter_SetOptimizedWrite(QImageWriter* self, bool optimize); bool QImageWriter_OptimizedWrite(const QImageWriter* self); void QImageWriter_SetProgressiveScanWrite(QImageWriter* self, bool progressive); @@ -60,9 +60,9 @@ bool QImageWriter_Write(QImageWriter* self, QImage* image); int QImageWriter_Error(const QImageWriter* self); struct miqt_string QImageWriter_ErrorString(const QImageWriter* self); bool QImageWriter_SupportsOption(const QImageWriter* self, int option); -struct miqt_array* QImageWriter_SupportedImageFormats(); -struct miqt_array* QImageWriter_SupportedMimeTypes(); -struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType); +struct miqt_array QImageWriter_SupportedImageFormats(); +struct miqt_array QImageWriter_SupportedMimeTypes(); +struct miqt_array QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType); struct miqt_string QImageWriter_Tr2(const char* sourceText, const char* disambiguation); struct miqt_string QImageWriter_Tr3(const char* sourceText, const char* disambiguation, int n); struct miqt_string QImageWriter_TrUtf82(const char* sourceText, const char* disambiguation); diff --git a/qt/gen_qinputdialog.cpp b/qt/gen_qinputdialog.cpp index ea89cffa..d22e92b5 100644 --- a/qt/gen_qinputdialog.cpp +++ b/qt/gen_qinputdialog.cpp @@ -127,18 +127,18 @@ bool QInputDialog_IsComboBoxEditable(const QInputDialog* self) { return self->isComboBoxEditable(); } -void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array* /* of struct miqt_string */ items) { +void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array /* of struct miqt_string */ items) { QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } self->setComboBoxItems(items_QList); } -struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self) { +struct miqt_array QInputDialog_ComboBoxItems(const QInputDialog* self) { QStringList _ret = self->comboBoxItems(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -152,9 +152,9 @@ struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -300,13 +300,13 @@ struct miqt_string QInputDialog_GetMultiLineText(QWidget* parent, struct miqt_st return _ms; } -struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items) { +struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -605,13 +605,13 @@ struct miqt_string QInputDialog_GetMultiLineText7(QWidget* parent, struct miqt_s return _ms; } -struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current) { +struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -625,13 +625,13 @@ struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable) { +struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -645,13 +645,13 @@ struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok) { +struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -665,13 +665,13 @@ struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags) { +struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -685,13 +685,13 @@ struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints) { +struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } diff --git a/qt/gen_qinputdialog.go b/qt/gen_qinputdialog.go index 9d804899..5f349f95 100644 --- a/qt/gen_qinputdialog.go +++ b/qt/gen_qinputdialog.go @@ -177,7 +177,6 @@ func (this *QInputDialog) IsComboBoxEditable() bool { } func (this *QInputDialog) SetComboBoxItems(items []string) { - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -187,13 +186,12 @@ func (this *QInputDialog) SetComboBoxItems(items []string) { defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QInputDialog_SetComboBoxItems(this.h, items_ma) } func (this *QInputDialog) ComboBoxItems() []string { - var _ma *C.struct_miqt_array = C.QInputDialog_ComboBoxItems(this.h) + var _ma C.struct_miqt_array = C.QInputDialog_ComboBoxItems(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -202,7 +200,6 @@ func (this *QInputDialog) ComboBoxItems() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -365,7 +362,6 @@ func QInputDialog_GetItem(parent *QWidget, title string, label string, items []s label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -375,8 +371,7 @@ func QInputDialog_GetItem(parent *QWidget, title string, label string, items []s defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem(parent.cPointer(), title_ms, label_ms, items_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -789,7 +784,6 @@ func QInputDialog_GetItem5(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -799,8 +793,7 @@ func QInputDialog_GetItem5(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem5(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -816,7 +809,6 @@ func QInputDialog_GetItem6(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -826,8 +818,7 @@ func QInputDialog_GetItem6(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem6(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -843,7 +834,6 @@ func QInputDialog_GetItem7(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -853,8 +843,7 @@ func QInputDialog_GetItem7(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem7(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok))) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -870,7 +859,6 @@ func QInputDialog_GetItem8(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -880,8 +868,7 @@ func QInputDialog_GetItem8(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem8(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok)), (C.int)(flags)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -897,7 +884,6 @@ func QInputDialog_GetItem9(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -907,8 +893,7 @@ func QInputDialog_GetItem9(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem9(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok)), (C.int)(flags), (C.int)(inputMethodHints)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt/gen_qinputdialog.h b/qt/gen_qinputdialog.h index df08543b..ad4173f5 100644 --- a/qt/gen_qinputdialog.h +++ b/qt/gen_qinputdialog.h @@ -46,8 +46,8 @@ void QInputDialog_SetTextEchoMode(QInputDialog* self, int mode); int QInputDialog_TextEchoMode(const QInputDialog* self); void QInputDialog_SetComboBoxEditable(QInputDialog* self, bool editable); bool QInputDialog_IsComboBoxEditable(const QInputDialog* self); -void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array* /* of struct miqt_string */ items); -struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self); +void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array /* of struct miqt_string */ items); +struct miqt_array QInputDialog_ComboBoxItems(const QInputDialog* self); void QInputDialog_SetIntValue(QInputDialog* self, int value); int QInputDialog_IntValue(const QInputDialog* self); void QInputDialog_SetIntMinimum(QInputDialog* self, int min); @@ -75,7 +75,7 @@ QSize* QInputDialog_SizeHint(const QInputDialog* self); void QInputDialog_SetVisible(QInputDialog* self, bool visible); struct miqt_string QInputDialog_GetText(QWidget* parent, struct miqt_string title, struct miqt_string label); struct miqt_string QInputDialog_GetMultiLineText(QWidget* parent, struct miqt_string title, struct miqt_string label); -struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items); +struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items); int QInputDialog_GetInt(QWidget* parent, struct miqt_string title, struct miqt_string label); double QInputDialog_GetDouble(QWidget* parent, struct miqt_string title, struct miqt_string label); double QInputDialog_GetDouble2(QWidget* parent, struct miqt_string title, struct miqt_string label, double value, double minValue, double maxValue, int decimals, bool* ok, int flags, double step); @@ -108,11 +108,11 @@ struct miqt_string QInputDialog_GetMultiLineText4(QWidget* parent, struct miqt_s struct miqt_string QInputDialog_GetMultiLineText5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok); struct miqt_string QInputDialog_GetMultiLineText6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok, int flags); struct miqt_string QInputDialog_GetMultiLineText7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok, int flags, int inputMethodHints); -struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current); -struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable); -struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok); -struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags); -struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints); +struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current); +struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable); +struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok); +struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags); +struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints); int QInputDialog_GetInt4(QWidget* parent, struct miqt_string title, struct miqt_string label, int value); int QInputDialog_GetInt5(QWidget* parent, struct miqt_string title, struct miqt_string label, int value, int minValue); int QInputDialog_GetInt6(QWidget* parent, struct miqt_string title, struct miqt_string label, int value, int minValue, int maxValue); diff --git a/qt/gen_qitemselectionmodel.cpp b/qt/gen_qitemselectionmodel.cpp index 47347a2a..5b765f56 100644 --- a/qt/gen_qitemselectionmodel.cpp +++ b/qt/gen_qitemselectionmodel.cpp @@ -117,16 +117,16 @@ bool QItemSelectionRange_IsEmpty(const QItemSelectionRange* self) { return self->isEmpty(); } -struct miqt_array* QItemSelectionRange_Indexes(const QItemSelectionRange* self) { +struct miqt_array QItemSelectionRange_Indexes(const QItemSelectionRange* self) { QModelIndexList _ret = self->indexes(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -204,42 +204,42 @@ bool QItemSelectionModel_HasSelection(const QItemSelectionModel* self) { return self->hasSelection(); } -struct miqt_array* QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedIndexes(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedRows(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedRows(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedRows(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedColumns(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -398,29 +398,29 @@ bool QItemSelectionModel_ColumnIntersectsSelection2(const QItemSelectionModel* s return self->columnIntersectsSelection(static_cast(column), *parent); } -struct miqt_array* QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column) { +struct miqt_array QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column) { QModelIndexList _ret = self->selectedRows(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row) { +struct miqt_array QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row) { QModelIndexList _ret = self->selectedColumns(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qitemselectionmodel.go b/qt/gen_qitemselectionmodel.go index 91619e85..470af72c 100644 --- a/qt/gen_qitemselectionmodel.go +++ b/qt/gen_qitemselectionmodel.go @@ -174,7 +174,7 @@ func (this *QItemSelectionRange) IsEmpty() bool { } func (this *QItemSelectionRange) Indexes() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionRange_Indexes(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionRange_Indexes(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -183,7 +183,6 @@ func (this *QItemSelectionRange) Indexes() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -309,7 +308,7 @@ func (this *QItemSelectionModel) HasSelection() bool { } func (this *QItemSelectionModel) SelectedIndexes() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedIndexes(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedIndexes(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -318,12 +317,11 @@ func (this *QItemSelectionModel) SelectedIndexes() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedRows() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedRows(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedRows(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -332,12 +330,11 @@ func (this *QItemSelectionModel) SelectedRows() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedColumns() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -346,7 +343,6 @@ func (this *QItemSelectionModel) SelectedColumns() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -530,7 +526,7 @@ func (this *QItemSelectionModel) ColumnIntersectsSelection2(column int, parent * } func (this *QItemSelectionModel) SelectedRows1(column int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedRows1(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedRows1(this.h, (C.int)(column)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -539,12 +535,11 @@ func (this *QItemSelectionModel) SelectedRows1(column int) []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedColumns1(row int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns1(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns1(this.h, (C.int)(row)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -553,7 +548,6 @@ func (this *QItemSelectionModel) SelectedColumns1(row int) []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qitemselectionmodel.h b/qt/gen_qitemselectionmodel.h index a94b395b..cdf19d78 100644 --- a/qt/gen_qitemselectionmodel.h +++ b/qt/gen_qitemselectionmodel.h @@ -56,7 +56,7 @@ bool QItemSelectionRange_OperatorNotEqual(const QItemSelectionRange* self, QItem bool QItemSelectionRange_OperatorLesser(const QItemSelectionRange* self, QItemSelectionRange* other); bool QItemSelectionRange_IsValid(const QItemSelectionRange* self); bool QItemSelectionRange_IsEmpty(const QItemSelectionRange* self); -struct miqt_array* QItemSelectionRange_Indexes(const QItemSelectionRange* self); +struct miqt_array QItemSelectionRange_Indexes(const QItemSelectionRange* self); void QItemSelectionRange_Delete(QItemSelectionRange* self); QItemSelectionModel* QItemSelectionModel_new(); @@ -73,9 +73,9 @@ bool QItemSelectionModel_IsColumnSelected(const QItemSelectionModel* self, int c bool QItemSelectionModel_RowIntersectsSelection(const QItemSelectionModel* self, int row); bool QItemSelectionModel_ColumnIntersectsSelection(const QItemSelectionModel* self, int column); bool QItemSelectionModel_HasSelection(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedRows(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedRows(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self); QAbstractItemModel* QItemSelectionModel_Model(const QItemSelectionModel* self); QAbstractItemModel* QItemSelectionModel_Model2(QItemSelectionModel* self); void QItemSelectionModel_SetModel(QItemSelectionModel* self, QAbstractItemModel* model); @@ -101,8 +101,8 @@ bool QItemSelectionModel_IsRowSelected2(const QItemSelectionModel* self, int row bool QItemSelectionModel_IsColumnSelected2(const QItemSelectionModel* self, int column, QModelIndex* parent); bool QItemSelectionModel_RowIntersectsSelection2(const QItemSelectionModel* self, int row, QModelIndex* parent); bool QItemSelectionModel_ColumnIntersectsSelection2(const QItemSelectionModel* self, int column, QModelIndex* parent); -struct miqt_array* QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column); -struct miqt_array* QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row); +struct miqt_array QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column); +struct miqt_array QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row); void QItemSelectionModel_Delete(QItemSelectionModel* self); #ifdef __cplusplus diff --git a/qt/gen_qjsonarray.cpp b/qt/gen_qjsonarray.cpp index cd4c44a5..b447c0a5 100644 --- a/qt/gen_qjsonarray.cpp +++ b/qt/gen_qjsonarray.cpp @@ -25,11 +25,11 @@ void QJsonArray_OperatorAssign(QJsonArray* self, QJsonArray* other) { self->operator=(*other); } -QJsonArray* QJsonArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list) { +QJsonArray* QJsonArray_FromStringList(struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } diff --git a/qt/gen_qjsonarray.go b/qt/gen_qjsonarray.go index 8083d7af..9f23dfae 100644 --- a/qt/gen_qjsonarray.go +++ b/qt/gen_qjsonarray.go @@ -59,7 +59,6 @@ func (this *QJsonArray) OperatorAssign(other *QJsonArray) { } func QJsonArray_FromStringList(list []string) *QJsonArray { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -69,8 +68,7 @@ func QJsonArray_FromStringList(list []string) *QJsonArray { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} _ret := C.QJsonArray_FromStringList(list_ma) _goptr := newQJsonArray(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt/gen_qjsonarray.h b/qt/gen_qjsonarray.h index 2d02d510..3b49d298 100644 --- a/qt/gen_qjsonarray.h +++ b/qt/gen_qjsonarray.h @@ -42,7 +42,7 @@ typedef struct QJsonValueRefPtr QJsonValueRefPtr; QJsonArray* QJsonArray_new(); QJsonArray* QJsonArray_new2(QJsonArray* other); void QJsonArray_OperatorAssign(QJsonArray* self, QJsonArray* other); -QJsonArray* QJsonArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list); +QJsonArray* QJsonArray_FromStringList(struct miqt_array /* of struct miqt_string */ list); int QJsonArray_Size(const QJsonArray* self); int QJsonArray_Count(const QJsonArray* self); bool QJsonArray_IsEmpty(const QJsonArray* self); diff --git a/qt/gen_qjsonobject.cpp b/qt/gen_qjsonobject.cpp index 48fcec1e..d19db201 100644 --- a/qt/gen_qjsonobject.cpp +++ b/qt/gen_qjsonobject.cpp @@ -6,9 +6,11 @@ #include #include #include +#include #include #include #include +#include #include #include "gen_qjsonobject.h" #include "_cgo_export.h" @@ -29,7 +31,80 @@ void QJsonObject_Swap(QJsonObject* self, QJsonObject* other) { self->swap(*other); } -struct miqt_array* QJsonObject_Keys(const QJsonObject* self) { +QJsonObject* QJsonObject_FromVariantMap(struct miqt_map mapVal) { + QVariantMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QJsonObject(QJsonObject::fromVariantMap(mapVal_QMap)); +} + +struct miqt_map QJsonObject_ToVariantMap(const QJsonObject* self) { + QVariantMap _ret = self->toVariantMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +QJsonObject* QJsonObject_FromVariantHash(struct miqt_map mapVal) { + QVariantHash mapVal_QMap; + mapVal_QMap.reserve(mapVal.len); + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QJsonObject(QJsonObject::fromVariantHash(mapVal_QMap)); +} + +struct miqt_map QJsonObject_ToVariantHash(const QJsonObject* self) { + QVariantHash _ret = self->toVariantHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_array QJsonObject_Keys(const QJsonObject* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -43,9 +118,9 @@ struct miqt_array* QJsonObject_Keys(const QJsonObject* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qjsonobject.go b/qt/gen_qjsonobject.go index 0fc68fab..2db02046 100644 --- a/qt/gen_qjsonobject.go +++ b/qt/gen_qjsonobject.go @@ -62,8 +62,100 @@ func (this *QJsonObject) Swap(other *QJsonObject) { C.QJsonObject_Swap(this.h, other.cPointer()) } +func QJsonObject_FromVariantMap(mapVal map[string]QVariant) *QJsonObject { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QJsonObject_FromVariantMap(mapVal_mm) + _goptr := newQJsonObject(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func (this *QJsonObject) ToVariantMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QJsonObject_ToVariantMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func QJsonObject_FromVariantHash(mapVal map[string]QVariant) *QJsonObject { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QJsonObject_FromVariantHash(mapVal_mm) + _goptr := newQJsonObject(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func (this *QJsonObject) ToVariantHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QJsonObject_ToVariantHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QJsonObject) Keys() []string { - var _ma *C.struct_miqt_array = C.QJsonObject_Keys(this.h) + var _ma C.struct_miqt_array = C.QJsonObject_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -72,7 +164,6 @@ func (this *QJsonObject) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qjsonobject.h b/qt/gen_qjsonobject.h index f33e98fa..69662925 100644 --- a/qt/gen_qjsonobject.h +++ b/qt/gen_qjsonobject.h @@ -29,6 +29,7 @@ class QJsonValue; class QJsonValuePtr; class QJsonValueRef; class QJsonValueRefPtr; +class QVariant; #else typedef struct QJsonObject QJsonObject; typedef struct QJsonObject__const_iterator QJsonObject__const_iterator; @@ -37,13 +38,18 @@ typedef struct QJsonValue QJsonValue; typedef struct QJsonValuePtr QJsonValuePtr; typedef struct QJsonValueRef QJsonValueRef; typedef struct QJsonValueRefPtr QJsonValueRefPtr; +typedef struct QVariant QVariant; #endif QJsonObject* QJsonObject_new(); QJsonObject* QJsonObject_new2(QJsonObject* other); void QJsonObject_OperatorAssign(QJsonObject* self, QJsonObject* other); void QJsonObject_Swap(QJsonObject* self, QJsonObject* other); -struct miqt_array* QJsonObject_Keys(const QJsonObject* self); +QJsonObject* QJsonObject_FromVariantMap(struct miqt_map mapVal); +struct miqt_map QJsonObject_ToVariantMap(const QJsonObject* self); +QJsonObject* QJsonObject_FromVariantHash(struct miqt_map mapVal); +struct miqt_map QJsonObject_ToVariantHash(const QJsonObject* self); +struct miqt_array QJsonObject_Keys(const QJsonObject* self); int QJsonObject_Size(const QJsonObject* self); int QJsonObject_Count(const QJsonObject* self); int QJsonObject_Length(const QJsonObject* self); diff --git a/qt/gen_qkeysequence.cpp b/qt/gen_qkeysequence.cpp index 230cb265..e489487b 100644 --- a/qt/gen_qkeysequence.cpp +++ b/qt/gen_qkeysequence.cpp @@ -69,7 +69,7 @@ QKeySequence* QKeySequence_FromString(struct miqt_string str) { return new QKeySequence(QKeySequence::fromString(str_QString)); } -struct miqt_array* QKeySequence_ListFromString(struct miqt_string str) { +struct miqt_array QKeySequence_ListFromString(struct miqt_string str) { QString str_QString = QString::fromUtf8(str.data, str.len); QList _ret = QKeySequence::listFromString(str_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -77,17 +77,17 @@ struct miqt_array* QKeySequence_ListFromString(struct miqt_string str) { for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QKeySequence_ListToString(struct miqt_array* /* of QKeySequence* */ list) { +struct miqt_string QKeySequence_ListToString(struct miqt_array /* of QKeySequence* */ list) { QList list_QList; - list_QList.reserve(list->len); - QKeySequence** list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + QKeySequence** list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(*(list_arr[i])); } QString _ret = QKeySequence::listToString(list_QList); @@ -110,16 +110,16 @@ QKeySequence* QKeySequence_Mnemonic(struct miqt_string text) { return new QKeySequence(QKeySequence::mnemonic(text_QString)); } -struct miqt_array* QKeySequence_KeyBindings(int key) { +struct miqt_array QKeySequence_KeyBindings(int key) { QList _ret = QKeySequence::keyBindings(static_cast(key)); // Convert QList<> from C++ memory to manually-managed C memory QKeySequence** _arr = static_cast(malloc(sizeof(QKeySequence*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -179,7 +179,7 @@ QKeySequence* QKeySequence_FromString2(struct miqt_string str, int format) { return new QKeySequence(QKeySequence::fromString(str_QString, static_cast(format))); } -struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int format) { +struct miqt_array QKeySequence_ListFromString2(struct miqt_string str, int format) { QString str_QString = QString::fromUtf8(str.data, str.len); QList _ret = QKeySequence::listFromString(str_QString, static_cast(format)); // Convert QList<> from C++ memory to manually-managed C memory @@ -187,17 +187,17 @@ struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int form for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QKeySequence_ListToString2(struct miqt_array* /* of QKeySequence* */ list, int format) { +struct miqt_string QKeySequence_ListToString2(struct miqt_array /* of QKeySequence* */ list, int format) { QList list_QList; - list_QList.reserve(list->len); - QKeySequence** list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + QKeySequence** list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(*(list_arr[i])); } QString _ret = QKeySequence::listToString(list_QList, static_cast(format)); diff --git a/qt/gen_qkeysequence.go b/qt/gen_qkeysequence.go index 07a8ad4b..abd4d2dc 100644 --- a/qt/gen_qkeysequence.go +++ b/qt/gen_qkeysequence.go @@ -226,7 +226,7 @@ func QKeySequence_ListFromString(str string) []QKeySequence { str_ms.data = C.CString(str) str_ms.len = C.size_t(len(str)) defer C.free(unsafe.Pointer(str_ms.data)) - var _ma *C.struct_miqt_array = C.QKeySequence_ListFromString(str_ms) + var _ma C.struct_miqt_array = C.QKeySequence_ListFromString(str_ms) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -235,19 +235,16 @@ func QKeySequence_ListFromString(str string) []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QKeySequence_ListToString(list []QKeySequence) string { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = list[i].cPointer() } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} var _ms C.struct_miqt_string = C.QKeySequence_ListToString(list_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -270,7 +267,7 @@ func QKeySequence_Mnemonic(text string) *QKeySequence { } func QKeySequence_KeyBindings(key QKeySequence__StandardKey) []QKeySequence { - var _ma *C.struct_miqt_array = C.QKeySequence_KeyBindings((C.int)(key)) + var _ma C.struct_miqt_array = C.QKeySequence_KeyBindings((C.int)(key)) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -279,7 +276,6 @@ func QKeySequence_KeyBindings(key QKeySequence__StandardKey) []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -346,7 +342,7 @@ func QKeySequence_ListFromString2(str string, format QKeySequence__SequenceForma str_ms.data = C.CString(str) str_ms.len = C.size_t(len(str)) defer C.free(unsafe.Pointer(str_ms.data)) - var _ma *C.struct_miqt_array = C.QKeySequence_ListFromString2(str_ms, (C.int)(format)) + var _ma C.struct_miqt_array = C.QKeySequence_ListFromString2(str_ms, (C.int)(format)) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -355,19 +351,16 @@ func QKeySequence_ListFromString2(str string, format QKeySequence__SequenceForma _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QKeySequence_ListToString2(list []QKeySequence, format QKeySequence__SequenceFormat) string { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = list[i].cPointer() } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} var _ms C.struct_miqt_string = C.QKeySequence_ListToString2(list_ma, (C.int)(format)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt/gen_qkeysequence.h b/qt/gen_qkeysequence.h index 8f0a8739..4912eabc 100644 --- a/qt/gen_qkeysequence.h +++ b/qt/gen_qkeysequence.h @@ -32,11 +32,11 @@ int QKeySequence_Count(const QKeySequence* self); bool QKeySequence_IsEmpty(const QKeySequence* self); struct miqt_string QKeySequence_ToString(const QKeySequence* self); QKeySequence* QKeySequence_FromString(struct miqt_string str); -struct miqt_array* QKeySequence_ListFromString(struct miqt_string str); -struct miqt_string QKeySequence_ListToString(struct miqt_array* /* of QKeySequence* */ list); +struct miqt_array QKeySequence_ListFromString(struct miqt_string str); +struct miqt_string QKeySequence_ListToString(struct miqt_array /* of QKeySequence* */ list); int QKeySequence_Matches(const QKeySequence* self, QKeySequence* seq); QKeySequence* QKeySequence_Mnemonic(struct miqt_string text); -struct miqt_array* QKeySequence_KeyBindings(int key); +struct miqt_array QKeySequence_KeyBindings(int key); int QKeySequence_OperatorSubscript(const QKeySequence* self, unsigned int i); void QKeySequence_OperatorAssign(QKeySequence* self, QKeySequence* other); void QKeySequence_Swap(QKeySequence* self, QKeySequence* other); @@ -49,8 +49,8 @@ bool QKeySequence_OperatorGreaterOrEqual(const QKeySequence* self, QKeySequence* bool QKeySequence_IsDetached(const QKeySequence* self); struct miqt_string QKeySequence_ToString1(const QKeySequence* self, int format); QKeySequence* QKeySequence_FromString2(struct miqt_string str, int format); -struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int format); -struct miqt_string QKeySequence_ListToString2(struct miqt_array* /* of QKeySequence* */ list, int format); +struct miqt_array QKeySequence_ListFromString2(struct miqt_string str, int format); +struct miqt_string QKeySequence_ListToString2(struct miqt_array /* of QKeySequence* */ list, int format); void QKeySequence_Delete(QKeySequence* self); #ifdef __cplusplus diff --git a/qt/gen_qlibraryinfo.cpp b/qt/gen_qlibraryinfo.cpp index d1c3cd40..858fa062 100644 --- a/qt/gen_qlibraryinfo.cpp +++ b/qt/gen_qlibraryinfo.cpp @@ -58,7 +58,7 @@ struct miqt_string QLibraryInfo_Location(int param1) { return _ms; } -struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName) { +struct miqt_array QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName) { QString platformName_QString = QString::fromUtf8(platformName.data, platformName.len); QStringList _ret = QLibraryInfo::platformPluginArguments(platformName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -73,9 +73,9 @@ struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platf memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qlibraryinfo.go b/qt/gen_qlibraryinfo.go index 67f460e5..8301bb40 100644 --- a/qt/gen_qlibraryinfo.go +++ b/qt/gen_qlibraryinfo.go @@ -111,7 +111,7 @@ func QLibraryInfo_PlatformPluginArguments(platformName string) []string { platformName_ms.data = C.CString(platformName) platformName_ms.len = C.size_t(len(platformName)) defer C.free(unsafe.Pointer(platformName_ms.data)) - var _ma *C.struct_miqt_array = C.QLibraryInfo_PlatformPluginArguments(platformName_ms) + var _ma C.struct_miqt_array = C.QLibraryInfo_PlatformPluginArguments(platformName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -120,7 +120,6 @@ func QLibraryInfo_PlatformPluginArguments(platformName string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qlibraryinfo.h b/qt/gen_qlibraryinfo.h index f2d75b1d..d97a08ab 100644 --- a/qt/gen_qlibraryinfo.h +++ b/qt/gen_qlibraryinfo.h @@ -30,7 +30,7 @@ const char* QLibraryInfo_Build(); bool QLibraryInfo_IsDebugBuild(); QVersionNumber* QLibraryInfo_Version(); struct miqt_string QLibraryInfo_Location(int param1); -struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName); +struct miqt_array QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName); void QLibraryInfo_Delete(QLibraryInfo* self); #ifdef __cplusplus diff --git a/qt/gen_qlistview.cpp b/qt/gen_qlistview.cpp index ce74e4cb..1018d1e9 100644 --- a/qt/gen_qlistview.cpp +++ b/qt/gen_qlistview.cpp @@ -205,11 +205,11 @@ void QListView_SetRootIndex(QListView* self, QModelIndex* index) { self->setRootIndex(*index); } -void QListView_IndexesMoved(QListView* self, struct miqt_array* /* of QModelIndex* */ indexes) { +void QListView_IndexesMoved(QListView* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } self->indexesMoved(indexes_QList); @@ -223,10 +223,10 @@ void QListView_connect_IndexesMoved(QListView* self, intptr_t slot) { for (size_t i = 0, e = indexes_ret.length(); i < e; ++i) { indexes_arr[i] = new QModelIndex(indexes_ret[i]); } - struct miqt_array* indexes_out = static_cast(malloc(sizeof(struct miqt_array))); - indexes_out->len = indexes_ret.length(); - indexes_out->data = static_cast(indexes_arr); - struct miqt_array* sigval1 = indexes_out; + struct miqt_array indexes_out; + indexes_out.len = indexes_ret.length(); + indexes_out.data = static_cast(indexes_arr); + struct miqt_array sigval1 = indexes_out; miqt_exec_callback_QListView_IndexesMoved(slot, sigval1); }); } diff --git a/qt/gen_qlistview.go b/qt/gen_qlistview.go index 8e12290e..ffe48ea8 100644 --- a/qt/gen_qlistview.go +++ b/qt/gen_qlistview.go @@ -278,14 +278,12 @@ func (this *QListView) SetRootIndex(index *QModelIndex) { } func (this *QListView) IndexesMoved(indexes []QModelIndex) { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} C.QListView_IndexesMoved(this.h, indexes_ma) } func (this *QListView) OnIndexesMoved(slot func(indexes []QModelIndex)) { @@ -293,14 +291,14 @@ func (this *QListView) OnIndexesMoved(slot func(indexes []QModelIndex)) { } //export miqt_exec_callback_QListView_IndexesMoved -func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes *C.struct_miqt_array) { +func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(indexes []QModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var indexes_ma *C.struct_miqt_array = indexes + var indexes_ma C.struct_miqt_array = indexes indexes_ret := make([]QModelIndex, int(indexes_ma.len)) indexes_outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(indexes_ma.data)) // hey ya for i := 0; i < int(indexes_ma.len); i++ { @@ -309,7 +307,6 @@ func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes *C.struct_ indexes_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer indexes_ret[i] = *indexes_lv_goptr } - C.free(unsafe.Pointer(indexes_ma)) slotval1 := indexes_ret gofunc(slotval1) diff --git a/qt/gen_qlistview.h b/qt/gen_qlistview.h index b9874b5d..b479ce9d 100644 --- a/qt/gen_qlistview.h +++ b/qt/gen_qlistview.h @@ -74,7 +74,7 @@ QModelIndex* QListView_IndexAt(const QListView* self, QPoint* p); void QListView_DoItemsLayout(QListView* self); void QListView_Reset(QListView* self); void QListView_SetRootIndex(QListView* self, QModelIndex* index); -void QListView_IndexesMoved(QListView* self, struct miqt_array* /* of QModelIndex* */ indexes); +void QListView_IndexesMoved(QListView* self, struct miqt_array /* of QModelIndex* */ indexes); void QListView_connect_IndexesMoved(QListView* self, intptr_t slot); struct miqt_string QListView_Tr2(const char* s, const char* c); struct miqt_string QListView_Tr3(const char* s, const char* c, int n); diff --git a/qt/gen_qlistwidget.cpp b/qt/gen_qlistwidget.cpp index 624841e1..46e7d37e 100644 --- a/qt/gen_qlistwidget.cpp +++ b/qt/gen_qlistwidget.cpp @@ -328,11 +328,11 @@ void QListWidget_InsertItem2(QListWidget* self, int row, struct miqt_string labe self->insertItem(static_cast(row), label_QString); } -void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array* /* of struct miqt_string */ labels) { +void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -348,11 +348,11 @@ void QListWidget_AddItemWithItem(QListWidget* self, QListWidgetItem* item) { self->addItem(item); } -void QListWidget_AddItems(QListWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QListWidget_AddItems(QListWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -451,20 +451,20 @@ void QListWidget_SetItemSelected(QListWidget* self, QListWidgetItem* item, bool self->setItemSelected(item, selectVal); } -struct miqt_array* QListWidget_SelectedItems(const QListWidget* self) { +struct miqt_array QListWidget_SelectedItems(const QListWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QListWidgetItem** _arr = static_cast(malloc(sizeof(QListWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags) { +struct miqt_array QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -472,9 +472,9 @@ struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qlistwidget.go b/qt/gen_qlistwidget.go index c1fdb9b6..39504164 100644 --- a/qt/gen_qlistwidget.go +++ b/qt/gen_qlistwidget.go @@ -459,7 +459,6 @@ func (this *QListWidget) InsertItem2(row int, label string) { } func (this *QListWidget) InsertItems(row int, labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -469,8 +468,7 @@ func (this *QListWidget) InsertItems(row int, labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QListWidget_InsertItems(this.h, (C.int)(row), labels_ma) } @@ -487,7 +485,6 @@ func (this *QListWidget) AddItemWithItem(item *QListWidgetItem) { } func (this *QListWidget) AddItems(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -497,8 +494,7 @@ func (this *QListWidget) AddItems(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QListWidget_AddItems(this.h, labels_ma) } @@ -598,13 +594,12 @@ func (this *QListWidget) SetItemSelected(item *QListWidgetItem, selectVal bool) } func (this *QListWidget) SelectedItems() []*QListWidgetItem { - var _ma *C.struct_miqt_array = C.QListWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QListWidget_SelectedItems(this.h) _ret := make([]*QListWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QListWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQListWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -613,13 +608,12 @@ func (this *QListWidget) FindItems(text string, flags MatchFlag) []*QListWidgetI text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QListWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QListWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QListWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QListWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQListWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qlistwidget.h b/qt/gen_qlistwidget.h index 20bb0fc7..2ca95971 100644 --- a/qt/gen_qlistwidget.h +++ b/qt/gen_qlistwidget.h @@ -111,10 +111,10 @@ QListWidgetItem* QListWidget_Item(const QListWidget* self, int row); int QListWidget_Row(const QListWidget* self, QListWidgetItem* item); void QListWidget_InsertItem(QListWidget* self, int row, QListWidgetItem* item); void QListWidget_InsertItem2(QListWidget* self, int row, struct miqt_string label); -void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array* /* of struct miqt_string */ labels); +void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array /* of struct miqt_string */ labels); void QListWidget_AddItem(QListWidget* self, struct miqt_string label); void QListWidget_AddItemWithItem(QListWidget* self, QListWidgetItem* item); -void QListWidget_AddItems(QListWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QListWidget_AddItems(QListWidget* self, struct miqt_array /* of struct miqt_string */ labels); QListWidgetItem* QListWidget_TakeItem(QListWidget* self, int row); int QListWidget_Count(const QListWidget* self); QListWidgetItem* QListWidget_CurrentItem(const QListWidget* self); @@ -138,8 +138,8 @@ void QListWidget_SetItemWidget(QListWidget* self, QListWidgetItem* item, QWidget void QListWidget_RemoveItemWidget(QListWidget* self, QListWidgetItem* item); bool QListWidget_IsItemSelected(const QListWidget* self, QListWidgetItem* item); void QListWidget_SetItemSelected(QListWidget* self, QListWidgetItem* item, bool selectVal); -struct miqt_array* QListWidget_SelectedItems(const QListWidget* self); -struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags); +struct miqt_array QListWidget_SelectedItems(const QListWidget* self); +struct miqt_array QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags); bool QListWidget_IsItemHidden(const QListWidget* self, QListWidgetItem* item); void QListWidget_SetItemHidden(QListWidget* self, QListWidgetItem* item, bool hide); void QListWidget_DropEvent(QListWidget* self, QDropEvent* event); diff --git a/qt/gen_qlocale.cpp b/qt/gen_qlocale.cpp index 62a60a58..f7edd2ca 100644 --- a/qt/gen_qlocale.cpp +++ b/qt/gen_qlocale.cpp @@ -536,7 +536,7 @@ int QLocale_FirstDayOfWeek(const QLocale* self) { return static_cast(_ret); } -struct miqt_array* QLocale_Weekdays(const QLocale* self) { +struct miqt_array QLocale_Weekdays(const QLocale* self) { QList _ret = self->weekdays(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -544,9 +544,9 @@ struct miqt_array* QLocale_Weekdays(const QLocale* self) { Qt::DayOfWeek _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -755,7 +755,7 @@ struct miqt_string QLocale_FormattedDataSizeWithBytes(const QLocale* self, long return _ms; } -struct miqt_array* QLocale_UiLanguages(const QLocale* self) { +struct miqt_array QLocale_UiLanguages(const QLocale* self) { QStringList _ret = self->uiLanguages(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -769,9 +769,9 @@ struct miqt_array* QLocale_UiLanguages(const QLocale* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -828,20 +828,20 @@ QLocale* QLocale_System() { return new QLocale(QLocale::system()); } -struct miqt_array* QLocale_MatchingLocales(int language, int script, int country) { +struct miqt_array QLocale_MatchingLocales(int language, int script, int country) { QList _ret = QLocale::matchingLocales(static_cast(language), static_cast(script), static_cast(country)); // Convert QList<> from C++ memory to manually-managed C memory QLocale** _arr = static_cast(malloc(sizeof(QLocale*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QLocale(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QLocale_CountriesForLanguage(int lang) { +struct miqt_array QLocale_CountriesForLanguage(int lang) { QList _ret = QLocale::countriesForLanguage(static_cast(lang)); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -849,9 +849,9 @@ struct miqt_array* QLocale_CountriesForLanguage(int lang) { QLocale::Country _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -876,11 +876,11 @@ struct miqt_string QLocale_QuoteString(const QLocale* self, struct miqt_string s return _ms; } -struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array* /* of struct miqt_string */ strl) { +struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array /* of struct miqt_string */ strl) { QStringList strl_QList; - strl_QList.reserve(strl->len); - struct miqt_string* strl_arr = static_cast(strl->data); - for(size_t i = 0; i < strl->len; ++i) { + strl_QList.reserve(strl.len); + struct miqt_string* strl_arr = static_cast(strl.data); + for(size_t i = 0; i < strl.len; ++i) { QString strl_arr_i_QString = QString::fromUtf8(strl_arr[i].data, strl_arr[i].len); strl_QList.push_back(strl_arr_i_QString); } diff --git a/qt/gen_qlocale.go b/qt/gen_qlocale.go index dc68310d..647f4db8 100644 --- a/qt/gen_qlocale.go +++ b/qt/gen_qlocale.go @@ -1485,13 +1485,12 @@ func (this *QLocale) FirstDayOfWeek() DayOfWeek { } func (this *QLocale) Weekdays() []DayOfWeek { - var _ma *C.struct_miqt_array = C.QLocale_Weekdays(this.h) + var _ma C.struct_miqt_array = C.QLocale_Weekdays(this.h) _ret := make([]DayOfWeek, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (DayOfWeek)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1646,7 +1645,7 @@ func (this *QLocale) FormattedDataSizeWithBytes(bytes int64) string { } func (this *QLocale) UiLanguages() []string { - var _ma *C.struct_miqt_array = C.QLocale_UiLanguages(this.h) + var _ma C.struct_miqt_array = C.QLocale_UiLanguages(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1655,7 +1654,6 @@ func (this *QLocale) UiLanguages() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1707,7 +1705,7 @@ func QLocale_System() *QLocale { } func QLocale_MatchingLocales(language QLocale__Language, script QLocale__Script, country QLocale__Country) []QLocale { - var _ma *C.struct_miqt_array = C.QLocale_MatchingLocales((C.int)(language), (C.int)(script), (C.int)(country)) + var _ma C.struct_miqt_array = C.QLocale_MatchingLocales((C.int)(language), (C.int)(script), (C.int)(country)) _ret := make([]QLocale, int(_ma.len)) _outCast := (*[0xffff]*C.QLocale)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1716,18 +1714,16 @@ func QLocale_MatchingLocales(language QLocale__Language, script QLocale__Script, _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QLocale_CountriesForLanguage(lang QLocale__Language) []QLocale__Country { - var _ma *C.struct_miqt_array = C.QLocale_CountriesForLanguage((C.int)(lang)) + var _ma C.struct_miqt_array = C.QLocale_CountriesForLanguage((C.int)(lang)) _ret := make([]QLocale__Country, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QLocale__Country)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1751,7 +1747,6 @@ func (this *QLocale) QuoteString(str string) string { } func (this *QLocale) CreateSeparatedList(strl []string) string { - // For the C ABI, malloc a C array of structs strl_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strl)))) defer C.free(unsafe.Pointer(strl_CArray)) for i := range strl { @@ -1761,8 +1756,7 @@ func (this *QLocale) CreateSeparatedList(strl []string) string { defer C.free(unsafe.Pointer(strl_i_ms.data)) strl_CArray[i] = strl_i_ms } - strl_ma := &C.struct_miqt_array{len: C.size_t(len(strl)), data: unsafe.Pointer(strl_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strl_ma)) + strl_ma := C.struct_miqt_array{len: C.size_t(len(strl)), data: unsafe.Pointer(strl_CArray)} var _ms C.struct_miqt_string = C.QLocale_CreateSeparatedList(this.h, strl_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt/gen_qlocale.h b/qt/gen_qlocale.h index 21c4d271..ee9ad185 100644 --- a/qt/gen_qlocale.h +++ b/qt/gen_qlocale.h @@ -99,7 +99,7 @@ struct miqt_string QLocale_StandaloneMonthName(const QLocale* self, int param1); struct miqt_string QLocale_DayName(const QLocale* self, int param1); struct miqt_string QLocale_StandaloneDayName(const QLocale* self, int param1); int QLocale_FirstDayOfWeek(const QLocale* self); -struct miqt_array* QLocale_Weekdays(const QLocale* self); +struct miqt_array QLocale_Weekdays(const QLocale* self); struct miqt_string QLocale_AmText(const QLocale* self); struct miqt_string QLocale_PmText(const QLocale* self); int QLocale_MeasurementSystem(const QLocale* self); @@ -120,7 +120,7 @@ struct miqt_string QLocale_ToCurrencyStringWithFloat(const QLocale* self, float struct miqt_string QLocale_ToCurrencyString3(const QLocale* self, float i, struct miqt_string symbol, int precision); struct miqt_string QLocale_FormattedDataSize(QLocale* self, long long bytes); struct miqt_string QLocale_FormattedDataSizeWithBytes(const QLocale* self, long long bytes); -struct miqt_array* QLocale_UiLanguages(const QLocale* self); +struct miqt_array QLocale_UiLanguages(const QLocale* self); bool QLocale_OperatorEqual(const QLocale* self, QLocale* other); bool QLocale_OperatorNotEqual(const QLocale* self, QLocale* other); struct miqt_string QLocale_LanguageToString(int language); @@ -129,12 +129,12 @@ struct miqt_string QLocale_ScriptToString(int script); void QLocale_SetDefault(QLocale* locale); QLocale* QLocale_C(); QLocale* QLocale_System(); -struct miqt_array* QLocale_MatchingLocales(int language, int script, int country); -struct miqt_array* QLocale_CountriesForLanguage(int lang); +struct miqt_array QLocale_MatchingLocales(int language, int script, int country); +struct miqt_array QLocale_CountriesForLanguage(int lang); void QLocale_SetNumberOptions(QLocale* self, int options); int QLocale_NumberOptions(const QLocale* self); struct miqt_string QLocale_QuoteString(const QLocale* self, struct miqt_string str); -struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array* /* of struct miqt_string */ strl); +struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array /* of struct miqt_string */ strl); int16_t QLocale_ToShort2(const QLocale* self, struct miqt_string s, bool* ok); uint16_t QLocale_ToUShort2(const QLocale* self, struct miqt_string s, bool* ok); int QLocale_ToInt2(const QLocale* self, struct miqt_string s, bool* ok); diff --git a/qt/gen_qmainwindow.cpp b/qt/gen_qmainwindow.cpp index bd5ba7cc..505ad4bf 100644 --- a/qt/gen_qmainwindow.cpp +++ b/qt/gen_qmainwindow.cpp @@ -230,16 +230,16 @@ void QMainWindow_TabifyDockWidget(QMainWindow* self, QDockWidget* first, QDockWi self->tabifyDockWidget(first, second); } -struct miqt_array* QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget) { +struct miqt_array QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget) { QList _ret = self->tabifiedDockWidgets(dockwidget); // Convert QList<> from C++ memory to manually-managed C memory QDockWidget** _arr = static_cast(malloc(sizeof(QDockWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -256,17 +256,17 @@ int QMainWindow_DockWidgetArea(const QMainWindow* self, QDockWidget* dockwidget) return static_cast(_ret); } -void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array* /* of QDockWidget* */ docks, struct miqt_array* /* of int */ sizes, int orientation) { +void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array /* of QDockWidget* */ docks, struct miqt_array /* of int */ sizes, int orientation) { QList docks_QList; - docks_QList.reserve(docks->len); - QDockWidget** docks_arr = static_cast(docks->data); - for(size_t i = 0; i < docks->len; ++i) { + docks_QList.reserve(docks.len); + QDockWidget** docks_arr = static_cast(docks.data); + for(size_t i = 0; i < docks.len; ++i) { docks_QList.push_back(docks_arr[i]); } QList sizes_QList; - sizes_QList.reserve(sizes->len); - int* sizes_arr = static_cast(sizes->data); - for(size_t i = 0; i < sizes->len; ++i) { + sizes_QList.reserve(sizes.len); + int* sizes_arr = static_cast(sizes.data); + for(size_t i = 0; i < sizes.len; ++i) { sizes_QList.push_back(static_cast(sizes_arr[i])); } self->resizeDocks(docks_QList, sizes_QList, static_cast(orientation)); diff --git a/qt/gen_qmainwindow.go b/qt/gen_qmainwindow.go index 0750f66e..57ccf563 100644 --- a/qt/gen_qmainwindow.go +++ b/qt/gen_qmainwindow.go @@ -273,13 +273,12 @@ func (this *QMainWindow) TabifyDockWidget(first *QDockWidget, second *QDockWidge } func (this *QMainWindow) TabifiedDockWidgets(dockwidget *QDockWidget) []*QDockWidget { - var _ma *C.struct_miqt_array = C.QMainWindow_TabifiedDockWidgets(this.h, dockwidget.cPointer()) + var _ma C.struct_miqt_array = C.QMainWindow_TabifiedDockWidgets(this.h, dockwidget.cPointer()) _ret := make([]*QDockWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QDockWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQDockWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -296,22 +295,18 @@ func (this *QMainWindow) DockWidgetArea(dockwidget *QDockWidget) DockWidgetArea } func (this *QMainWindow) ResizeDocks(docks []*QDockWidget, sizes []int, orientation Orientation) { - // For the C ABI, malloc a C array of raw pointers docks_CArray := (*[0xffff]*C.QDockWidget)(C.malloc(C.size_t(8 * len(docks)))) defer C.free(unsafe.Pointer(docks_CArray)) for i := range docks { docks_CArray[i] = docks[i].cPointer() } - docks_ma := &C.struct_miqt_array{len: C.size_t(len(docks)), data: unsafe.Pointer(docks_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(docks_ma)) - // For the C ABI, malloc a C array of raw pointers + docks_ma := C.struct_miqt_array{len: C.size_t(len(docks)), data: unsafe.Pointer(docks_CArray)} sizes_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(sizes)))) defer C.free(unsafe.Pointer(sizes_CArray)) for i := range sizes { sizes_CArray[i] = (C.int)(sizes[i]) } - sizes_ma := &C.struct_miqt_array{len: C.size_t(len(sizes)), data: unsafe.Pointer(sizes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(sizes_ma)) + sizes_ma := C.struct_miqt_array{len: C.size_t(len(sizes)), data: unsafe.Pointer(sizes_CArray)} C.QMainWindow_ResizeDocks(this.h, docks_ma, sizes_ma, (C.int)(orientation)) } diff --git a/qt/gen_qmainwindow.h b/qt/gen_qmainwindow.h index 970db0b5..f09ed318 100644 --- a/qt/gen_qmainwindow.h +++ b/qt/gen_qmainwindow.h @@ -87,11 +87,11 @@ void QMainWindow_AddDockWidget(QMainWindow* self, int area, QDockWidget* dockwid void QMainWindow_AddDockWidget2(QMainWindow* self, int area, QDockWidget* dockwidget, int orientation); void QMainWindow_SplitDockWidget(QMainWindow* self, QDockWidget* after, QDockWidget* dockwidget, int orientation); void QMainWindow_TabifyDockWidget(QMainWindow* self, QDockWidget* first, QDockWidget* second); -struct miqt_array* QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget); +struct miqt_array QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget); void QMainWindow_RemoveDockWidget(QMainWindow* self, QDockWidget* dockwidget); bool QMainWindow_RestoreDockWidget(QMainWindow* self, QDockWidget* dockwidget); int QMainWindow_DockWidgetArea(const QMainWindow* self, QDockWidget* dockwidget); -void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array* /* of QDockWidget* */ docks, struct miqt_array* /* of int */ sizes, int orientation); +void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array /* of QDockWidget* */ docks, struct miqt_array /* of int */ sizes, int orientation); struct miqt_string QMainWindow_SaveState(const QMainWindow* self); bool QMainWindow_RestoreState(QMainWindow* self, struct miqt_string state); QMenu* QMainWindow_CreatePopupMenu(QMainWindow* self); diff --git a/qt/gen_qmap.cpp b/qt/gen_qmap.cpp deleted file mode 100644 index 17f13bd7..00000000 --- a/qt/gen_qmap.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include "gen_qmap.h" -#include "_cgo_export.h" - -QMapNodeBase* QMapNodeBase_new(QMapNodeBase* param1) { - return new QMapNodeBase(*param1); -} - -QMapNodeBase* QMapNodeBase_NextNode(const QMapNodeBase* self) { - return (QMapNodeBase*) self->nextNode(); -} - -QMapNodeBase* QMapNodeBase_NextNode2(QMapNodeBase* self) { - return self->nextNode(); -} - -QMapNodeBase* QMapNodeBase_PreviousNode(const QMapNodeBase* self) { - return (QMapNodeBase*) self->previousNode(); -} - -QMapNodeBase* QMapNodeBase_PreviousNode2(QMapNodeBase* self) { - return self->previousNode(); -} - -int QMapNodeBase_Color(const QMapNodeBase* self) { - QMapNodeBase::Color _ret = self->color(); - return static_cast(_ret); -} - -void QMapNodeBase_SetColor(QMapNodeBase* self, int c) { - self->setColor(static_cast(c)); -} - -QMapNodeBase* QMapNodeBase_Parent(const QMapNodeBase* self) { - return self->parent(); -} - -void QMapNodeBase_SetParent(QMapNodeBase* self, QMapNodeBase* pp) { - self->setParent(pp); -} - -void QMapNodeBase_OperatorAssign(QMapNodeBase* self, QMapNodeBase* param1) { - self->operator=(*param1); -} - -void QMapNodeBase_Delete(QMapNodeBase* self) { - delete self; -} - -void QMapDataBase_RotateLeft(QMapDataBase* self, QMapNodeBase* x) { - self->rotateLeft(x); -} - -void QMapDataBase_RotateRight(QMapDataBase* self, QMapNodeBase* x) { - self->rotateRight(x); -} - -void QMapDataBase_Rebalance(QMapDataBase* self, QMapNodeBase* x) { - self->rebalance(x); -} - -void QMapDataBase_FreeNodeAndRebalance(QMapDataBase* self, QMapNodeBase* z) { - self->freeNodeAndRebalance(z); -} - -void QMapDataBase_RecalcMostLeftNode(QMapDataBase* self) { - self->recalcMostLeftNode(); -} - -QMapNodeBase* QMapDataBase_CreateNode(QMapDataBase* self, int size, int alignment, QMapNodeBase* parent, bool left) { - return self->createNode(static_cast(size), static_cast(alignment), parent, left); -} - -void QMapDataBase_FreeTree(QMapDataBase* self, QMapNodeBase* root, int alignment) { - self->freeTree(root, static_cast(alignment)); -} - -QMapDataBase* QMapDataBase_CreateData() { - return QMapDataBase::createData(); -} - -void QMapDataBase_FreeData(QMapDataBase* d) { - QMapDataBase::freeData(d); -} - -void QMapDataBase_Delete(QMapDataBase* self) { - delete self; -} - diff --git a/qt/gen_qmap.go b/qt/gen_qmap.go deleted file mode 100644 index e5060b3a..00000000 --- a/qt/gen_qmap.go +++ /dev/null @@ -1,191 +0,0 @@ -package qt - -/* - -#include "gen_qmap.h" -#include - -*/ -import "C" - -import ( - "runtime" - "unsafe" -) - -type QMapNodeBase__Color int - -const ( - QMapNodeBase__Red QMapNodeBase__Color = 0 - QMapNodeBase__Black QMapNodeBase__Color = 1 -) - -type QMapNodeBase__ int - -const ( - QMapNodeBase__Mask QMapNodeBase__ = 3 -) - -type QMapNodeBase struct { - h *C.QMapNodeBase -} - -func (this *QMapNodeBase) cPointer() *C.QMapNodeBase { - if this == nil { - return nil - } - return this.h -} - -func (this *QMapNodeBase) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQMapNodeBase(h *C.QMapNodeBase) *QMapNodeBase { - if h == nil { - return nil - } - return &QMapNodeBase{h: h} -} - -func UnsafeNewQMapNodeBase(h unsafe.Pointer) *QMapNodeBase { - return newQMapNodeBase((*C.QMapNodeBase)(h)) -} - -// NewQMapNodeBase constructs a new QMapNodeBase object. -func NewQMapNodeBase(param1 *QMapNodeBase) *QMapNodeBase { - ret := C.QMapNodeBase_new(param1.cPointer()) - return newQMapNodeBase(ret) -} - -func (this *QMapNodeBase) NextNode() *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapNodeBase_NextNode(this.h))) -} - -func (this *QMapNodeBase) NextNode2() *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapNodeBase_NextNode2(this.h))) -} - -func (this *QMapNodeBase) PreviousNode() *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapNodeBase_PreviousNode(this.h))) -} - -func (this *QMapNodeBase) PreviousNode2() *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapNodeBase_PreviousNode2(this.h))) -} - -func (this *QMapNodeBase) Color() QMapNodeBase__Color { - return (QMapNodeBase__Color)(C.QMapNodeBase_Color(this.h)) -} - -func (this *QMapNodeBase) SetColor(c QMapNodeBase__Color) { - C.QMapNodeBase_SetColor(this.h, (C.int)(c)) -} - -func (this *QMapNodeBase) Parent() *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapNodeBase_Parent(this.h))) -} - -func (this *QMapNodeBase) SetParent(pp *QMapNodeBase) { - C.QMapNodeBase_SetParent(this.h, pp.cPointer()) -} - -func (this *QMapNodeBase) OperatorAssign(param1 *QMapNodeBase) { - C.QMapNodeBase_OperatorAssign(this.h, param1.cPointer()) -} - -// Delete this object from C++ memory. -func (this *QMapNodeBase) Delete() { - C.QMapNodeBase_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QMapNodeBase) GoGC() { - runtime.SetFinalizer(this, func(this *QMapNodeBase) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} - -type QMapDataBase struct { - h *C.QMapDataBase -} - -func (this *QMapDataBase) cPointer() *C.QMapDataBase { - if this == nil { - return nil - } - return this.h -} - -func (this *QMapDataBase) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQMapDataBase(h *C.QMapDataBase) *QMapDataBase { - if h == nil { - return nil - } - return &QMapDataBase{h: h} -} - -func UnsafeNewQMapDataBase(h unsafe.Pointer) *QMapDataBase { - return newQMapDataBase((*C.QMapDataBase)(h)) -} - -func (this *QMapDataBase) RotateLeft(x *QMapNodeBase) { - C.QMapDataBase_RotateLeft(this.h, x.cPointer()) -} - -func (this *QMapDataBase) RotateRight(x *QMapNodeBase) { - C.QMapDataBase_RotateRight(this.h, x.cPointer()) -} - -func (this *QMapDataBase) Rebalance(x *QMapNodeBase) { - C.QMapDataBase_Rebalance(this.h, x.cPointer()) -} - -func (this *QMapDataBase) FreeNodeAndRebalance(z *QMapNodeBase) { - C.QMapDataBase_FreeNodeAndRebalance(this.h, z.cPointer()) -} - -func (this *QMapDataBase) RecalcMostLeftNode() { - C.QMapDataBase_RecalcMostLeftNode(this.h) -} - -func (this *QMapDataBase) CreateNode(size int, alignment int, parent *QMapNodeBase, left bool) *QMapNodeBase { - return UnsafeNewQMapNodeBase(unsafe.Pointer(C.QMapDataBase_CreateNode(this.h, (C.int)(size), (C.int)(alignment), parent.cPointer(), (C.bool)(left)))) -} - -func (this *QMapDataBase) FreeTree(root *QMapNodeBase, alignment int) { - C.QMapDataBase_FreeTree(this.h, root.cPointer(), (C.int)(alignment)) -} - -func QMapDataBase_CreateData() *QMapDataBase { - return UnsafeNewQMapDataBase(unsafe.Pointer(C.QMapDataBase_CreateData())) -} - -func QMapDataBase_FreeData(d *QMapDataBase) { - C.QMapDataBase_FreeData(d.cPointer()) -} - -// Delete this object from C++ memory. -func (this *QMapDataBase) Delete() { - C.QMapDataBase_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QMapDataBase) GoGC() { - runtime.SetFinalizer(this, func(this *QMapDataBase) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} diff --git a/qt/gen_qmap.h b/qt/gen_qmap.h deleted file mode 100644 index b8b90891..00000000 --- a/qt/gen_qmap.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef GEN_QMAP_H -#define GEN_QMAP_H - -#include -#include -#include - -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -#include "../libmiqt/libmiqt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -class QMapDataBase; -class QMapNodeBase; -#else -typedef struct QMapDataBase QMapDataBase; -typedef struct QMapNodeBase QMapNodeBase; -#endif - -QMapNodeBase* QMapNodeBase_new(QMapNodeBase* param1); -QMapNodeBase* QMapNodeBase_NextNode(const QMapNodeBase* self); -QMapNodeBase* QMapNodeBase_NextNode2(QMapNodeBase* self); -QMapNodeBase* QMapNodeBase_PreviousNode(const QMapNodeBase* self); -QMapNodeBase* QMapNodeBase_PreviousNode2(QMapNodeBase* self); -int QMapNodeBase_Color(const QMapNodeBase* self); -void QMapNodeBase_SetColor(QMapNodeBase* self, int c); -QMapNodeBase* QMapNodeBase_Parent(const QMapNodeBase* self); -void QMapNodeBase_SetParent(QMapNodeBase* self, QMapNodeBase* pp); -void QMapNodeBase_OperatorAssign(QMapNodeBase* self, QMapNodeBase* param1); -void QMapNodeBase_Delete(QMapNodeBase* self); - -void QMapDataBase_RotateLeft(QMapDataBase* self, QMapNodeBase* x); -void QMapDataBase_RotateRight(QMapDataBase* self, QMapNodeBase* x); -void QMapDataBase_Rebalance(QMapDataBase* self, QMapNodeBase* x); -void QMapDataBase_FreeNodeAndRebalance(QMapDataBase* self, QMapNodeBase* z); -void QMapDataBase_RecalcMostLeftNode(QMapDataBase* self); -QMapNodeBase* QMapDataBase_CreateNode(QMapDataBase* self, int size, int alignment, QMapNodeBase* parent, bool left); -void QMapDataBase_FreeTree(QMapDataBase* self, QMapNodeBase* root, int alignment); -QMapDataBase* QMapDataBase_CreateData(); -void QMapDataBase_FreeData(QMapDataBase* d); -void QMapDataBase_Delete(QMapDataBase* self); - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif diff --git a/qt/gen_qmdiarea.cpp b/qt/gen_qmdiarea.cpp index 95290625..40b0cc96 100644 --- a/qt/gen_qmdiarea.cpp +++ b/qt/gen_qmdiarea.cpp @@ -66,16 +66,16 @@ QMdiSubWindow* QMdiArea_ActiveSubWindow(const QMdiArea* self) { return self->activeSubWindow(); } -struct miqt_array* QMdiArea_SubWindowList(const QMdiArea* self) { +struct miqt_array QMdiArea_SubWindowList(const QMdiArea* self) { QList _ret = self->subWindowList(); // Convert QList<> from C++ memory to manually-managed C memory QMdiSubWindow** _arr = static_cast(malloc(sizeof(QMdiSubWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -246,16 +246,16 @@ struct miqt_string QMdiArea_TrUtf83(const char* s, const char* c, int n) { return _ms; } -struct miqt_array* QMdiArea_SubWindowList1(const QMdiArea* self, int order) { +struct miqt_array QMdiArea_SubWindowList1(const QMdiArea* self, int order) { QList _ret = self->subWindowList(static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QMdiSubWindow** _arr = static_cast(malloc(sizeof(QMdiSubWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmdiarea.go b/qt/gen_qmdiarea.go index 83cf43d9..8626c1f0 100644 --- a/qt/gen_qmdiarea.go +++ b/qt/gen_qmdiarea.go @@ -128,13 +128,12 @@ func (this *QMdiArea) ActiveSubWindow() *QMdiSubWindow { } func (this *QMdiArea) SubWindowList() []*QMdiSubWindow { - var _ma *C.struct_miqt_array = C.QMdiArea_SubWindowList(this.h) + var _ma C.struct_miqt_array = C.QMdiArea_SubWindowList(this.h) _ret := make([]*QMdiSubWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QMdiSubWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQMdiSubWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -314,13 +313,12 @@ func QMdiArea_TrUtf83(s string, c string, n int) string { } func (this *QMdiArea) SubWindowList1(order QMdiArea__WindowOrder) []*QMdiSubWindow { - var _ma *C.struct_miqt_array = C.QMdiArea_SubWindowList1(this.h, (C.int)(order)) + var _ma C.struct_miqt_array = C.QMdiArea_SubWindowList1(this.h, (C.int)(order)) _ret := make([]*QMdiSubWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QMdiSubWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQMdiSubWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmdiarea.h b/qt/gen_qmdiarea.h index 5f739e1b..ed6bd2d7 100644 --- a/qt/gen_qmdiarea.h +++ b/qt/gen_qmdiarea.h @@ -39,7 +39,7 @@ QSize* QMdiArea_SizeHint(const QMdiArea* self); QSize* QMdiArea_MinimumSizeHint(const QMdiArea* self); QMdiSubWindow* QMdiArea_CurrentSubWindow(const QMdiArea* self); QMdiSubWindow* QMdiArea_ActiveSubWindow(const QMdiArea* self); -struct miqt_array* QMdiArea_SubWindowList(const QMdiArea* self); +struct miqt_array QMdiArea_SubWindowList(const QMdiArea* self); QMdiSubWindow* QMdiArea_AddSubWindow(QMdiArea* self, QWidget* widget); void QMdiArea_RemoveSubWindow(QMdiArea* self, QWidget* widget); QBrush* QMdiArea_Background(const QMdiArea* self); @@ -73,7 +73,7 @@ struct miqt_string QMdiArea_Tr2(const char* s, const char* c); struct miqt_string QMdiArea_Tr3(const char* s, const char* c, int n); struct miqt_string QMdiArea_TrUtf82(const char* s, const char* c); struct miqt_string QMdiArea_TrUtf83(const char* s, const char* c, int n); -struct miqt_array* QMdiArea_SubWindowList1(const QMdiArea* self, int order); +struct miqt_array QMdiArea_SubWindowList1(const QMdiArea* self, int order); QMdiSubWindow* QMdiArea_AddSubWindow2(QMdiArea* self, QWidget* widget, int flags); void QMdiArea_SetOption2(QMdiArea* self, int option, bool on); void QMdiArea_Delete(QMdiArea* self); diff --git a/qt/gen_qmenu.cpp b/qt/gen_qmenu.cpp index 519882c4..9203aed4 100644 --- a/qt/gen_qmenu.cpp +++ b/qt/gen_qmenu.cpp @@ -178,11 +178,11 @@ QAction* QMenu_ExecWithPos(QMenu* self, QPoint* pos) { return self->exec(*pos); } -QAction* QMenu_Exec2(struct miqt_array* /* of QAction* */ actions, QPoint* pos) { +QAction* QMenu_Exec2(struct miqt_array /* of QAction* */ actions, QPoint* pos) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos); @@ -342,21 +342,21 @@ QAction* QMenu_Exec22(QMenu* self, QPoint* pos, QAction* at) { return self->exec(*pos, at); } -QAction* QMenu_Exec3(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at) { +QAction* QMenu_Exec3(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos, at); } -QAction* QMenu_Exec4(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent) { +QAction* QMenu_Exec4(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos, at, parent); diff --git a/qt/gen_qmenu.go b/qt/gen_qmenu.go index 8a6ed053..94c0878f 100644 --- a/qt/gen_qmenu.go +++ b/qt/gen_qmenu.go @@ -245,14 +245,12 @@ func (this *QMenu) ExecWithPos(pos *QPoint) *QAction { } func QMenu_Exec2(actions []*QAction, pos *QPoint) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec2(actions_ma, pos.cPointer()))) } @@ -451,26 +449,22 @@ func (this *QMenu) Exec22(pos *QPoint, at *QAction) *QAction { } func QMenu_Exec3(actions []*QAction, pos *QPoint, at *QAction) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec3(actions_ma, pos.cPointer(), at.cPointer()))) } func QMenu_Exec4(actions []*QAction, pos *QPoint, at *QAction, parent *QWidget) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec4(actions_ma, pos.cPointer(), at.cPointer(), parent.cPointer()))) } diff --git a/qt/gen_qmenu.h b/qt/gen_qmenu.h index 5b7f3b47..14b4d980 100644 --- a/qt/gen_qmenu.h +++ b/qt/gen_qmenu.h @@ -68,7 +68,7 @@ QAction* QMenu_ActiveAction(const QMenu* self); void QMenu_Popup(QMenu* self, QPoint* pos); QAction* QMenu_Exec(QMenu* self); QAction* QMenu_ExecWithPos(QMenu* self, QPoint* pos); -QAction* QMenu_Exec2(struct miqt_array* /* of QAction* */ actions, QPoint* pos); +QAction* QMenu_Exec2(struct miqt_array /* of QAction* */ actions, QPoint* pos); QSize* QMenu_SizeHint(const QMenu* self); QRect* QMenu_ActionGeometry(const QMenu* self, QAction* param1); QAction* QMenu_ActionAt(const QMenu* self, QPoint* param1); @@ -96,8 +96,8 @@ struct miqt_string QMenu_TrUtf82(const char* s, const char* c); struct miqt_string QMenu_TrUtf83(const char* s, const char* c, int n); void QMenu_Popup2(QMenu* self, QPoint* pos, QAction* at); QAction* QMenu_Exec22(QMenu* self, QPoint* pos, QAction* at); -QAction* QMenu_Exec3(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at); -QAction* QMenu_Exec4(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent); +QAction* QMenu_Exec3(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at); +QAction* QMenu_Exec4(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent); void QMenu_Delete(QMenu* self); #ifdef __cplusplus diff --git a/qt/gen_qmessagebox.cpp b/qt/gen_qmessagebox.cpp index 2f8d204c..bc44bbb1 100644 --- a/qt/gen_qmessagebox.cpp +++ b/qt/gen_qmessagebox.cpp @@ -110,16 +110,16 @@ void QMessageBox_RemoveButton(QMessageBox* self, QAbstractButton* button) { self->removeButton(button); } -struct miqt_array* QMessageBox_Buttons(const QMessageBox* self) { +struct miqt_array QMessageBox_Buttons(const QMessageBox* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmessagebox.go b/qt/gen_qmessagebox.go index 261b466e..8e5d4415 100644 --- a/qt/gen_qmessagebox.go +++ b/qt/gen_qmessagebox.go @@ -261,13 +261,12 @@ func (this *QMessageBox) RemoveButton(button *QAbstractButton) { } func (this *QMessageBox) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QMessageBox_Buttons(this.h) + var _ma C.struct_miqt_array = C.QMessageBox_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmessagebox.h b/qt/gen_qmessagebox.h index baa03fb1..38ca3256 100644 --- a/qt/gen_qmessagebox.h +++ b/qt/gen_qmessagebox.h @@ -48,7 +48,7 @@ void QMessageBox_AddButton(QMessageBox* self, QAbstractButton* button, int role) QPushButton* QMessageBox_AddButton2(QMessageBox* self, struct miqt_string text, int role); QPushButton* QMessageBox_AddButtonWithButton(QMessageBox* self, int button); void QMessageBox_RemoveButton(QMessageBox* self, QAbstractButton* button); -struct miqt_array* QMessageBox_Buttons(const QMessageBox* self); +struct miqt_array QMessageBox_Buttons(const QMessageBox* self); int QMessageBox_ButtonRole(const QMessageBox* self, QAbstractButton* button); void QMessageBox_SetStandardButtons(QMessageBox* self, int buttons); int QMessageBox_StandardButtons(const QMessageBox* self); diff --git a/qt/gen_qmetaobject.cpp b/qt/gen_qmetaobject.cpp index c1ba12ca..e1a06c0f 100644 --- a/qt/gen_qmetaobject.cpp +++ b/qt/gen_qmetaobject.cpp @@ -59,7 +59,7 @@ void QMetaMethod_GetParameterTypes(const QMetaMethod* self, int* types) { self->getParameterTypes(static_cast(types)); } -struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self) { +struct miqt_array QMetaMethod_ParameterTypes(const QMetaMethod* self) { QList _ret = self->parameterTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -71,13 +71,13 @@ struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self) { +struct miqt_array QMetaMethod_ParameterNames(const QMetaMethod* self) { QList _ret = self->parameterNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -89,9 +89,9 @@ struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmetaobject.go b/qt/gen_qmetaobject.go index b3e481b3..a32c6973 100644 --- a/qt/gen_qmetaobject.go +++ b/qt/gen_qmetaobject.go @@ -115,7 +115,7 @@ func (this *QMetaMethod) GetParameterTypes(types *int) { } func (this *QMetaMethod) ParameterTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QMetaMethod_ParameterTypes(this.h) + var _ma C.struct_miqt_array = C.QMetaMethod_ParameterTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -124,12 +124,11 @@ func (this *QMetaMethod) ParameterTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMetaMethod) ParameterNames() [][]byte { - var _ma *C.struct_miqt_array = C.QMetaMethod_ParameterNames(this.h) + var _ma C.struct_miqt_array = C.QMetaMethod_ParameterNames(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -138,7 +137,6 @@ func (this *QMetaMethod) ParameterNames() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmetaobject.h b/qt/gen_qmetaobject.h index db210340..1db64fb5 100644 --- a/qt/gen_qmetaobject.h +++ b/qt/gen_qmetaobject.h @@ -46,8 +46,8 @@ int QMetaMethod_ReturnType(const QMetaMethod* self); int QMetaMethod_ParameterCount(const QMetaMethod* self); int QMetaMethod_ParameterType(const QMetaMethod* self, int index); void QMetaMethod_GetParameterTypes(const QMetaMethod* self, int* types); -struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self); -struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self); +struct miqt_array QMetaMethod_ParameterTypes(const QMetaMethod* self); +struct miqt_array QMetaMethod_ParameterNames(const QMetaMethod* self); const char* QMetaMethod_Tag(const QMetaMethod* self); int QMetaMethod_Access(const QMetaMethod* self); int QMetaMethod_MethodType(const QMetaMethod* self); diff --git a/qt/gen_qmimedata.cpp b/qt/gen_qmimedata.cpp index 97ff5484..46fdcc6d 100644 --- a/qt/gen_qmimedata.cpp +++ b/qt/gen_qmimedata.cpp @@ -45,24 +45,24 @@ struct miqt_string QMimeData_TrUtf8(const char* s) { return _ms; } -struct miqt_array* QMimeData_Urls(const QMimeData* self) { +struct miqt_array QMimeData_Urls(const QMimeData* self) { QList _ret = self->urls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QMimeData_SetUrls(QMimeData* self, struct miqt_array* /* of QUrl* */ urls) { +void QMimeData_SetUrls(QMimeData* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->setUrls(urls_QList); @@ -162,7 +162,7 @@ bool QMimeData_HasFormat(const QMimeData* self, struct miqt_string mimetype) { return self->hasFormat(mimetype_QString); } -struct miqt_array* QMimeData_Formats(const QMimeData* self) { +struct miqt_array QMimeData_Formats(const QMimeData* self) { QStringList _ret = self->formats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -176,9 +176,9 @@ struct miqt_array* QMimeData_Formats(const QMimeData* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmimedata.go b/qt/gen_qmimedata.go index 29a2174a..fdbd3b8c 100644 --- a/qt/gen_qmimedata.go +++ b/qt/gen_qmimedata.go @@ -78,7 +78,7 @@ func QMimeData_TrUtf8(s string) string { } func (this *QMimeData) Urls() []QUrl { - var _ma *C.struct_miqt_array = C.QMimeData_Urls(this.h) + var _ma C.struct_miqt_array = C.QMimeData_Urls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -87,19 +87,16 @@ func (this *QMimeData) Urls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeData) SetUrls(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QMimeData_SetUrls(this.h, urls_ma) } @@ -214,7 +211,7 @@ func (this *QMimeData) HasFormat(mimetype string) bool { } func (this *QMimeData) Formats() []string { - var _ma *C.struct_miqt_array = C.QMimeData_Formats(this.h) + var _ma C.struct_miqt_array = C.QMimeData_Formats(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -223,7 +220,6 @@ func (this *QMimeData) Formats() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmimedata.h b/qt/gen_qmimedata.h index c24fd156..a9a500ca 100644 --- a/qt/gen_qmimedata.h +++ b/qt/gen_qmimedata.h @@ -32,8 +32,8 @@ QMetaObject* QMimeData_MetaObject(const QMimeData* self); void* QMimeData_Metacast(QMimeData* self, const char* param1); struct miqt_string QMimeData_Tr(const char* s); struct miqt_string QMimeData_TrUtf8(const char* s); -struct miqt_array* QMimeData_Urls(const QMimeData* self); -void QMimeData_SetUrls(QMimeData* self, struct miqt_array* /* of QUrl* */ urls); +struct miqt_array QMimeData_Urls(const QMimeData* self); +void QMimeData_SetUrls(QMimeData* self, struct miqt_array /* of QUrl* */ urls); bool QMimeData_HasUrls(const QMimeData* self); struct miqt_string QMimeData_Text(const QMimeData* self); void QMimeData_SetText(QMimeData* self, struct miqt_string text); @@ -51,7 +51,7 @@ struct miqt_string QMimeData_Data(const QMimeData* self, struct miqt_string mime void QMimeData_SetData(QMimeData* self, struct miqt_string mimetype, struct miqt_string data); void QMimeData_RemoveFormat(QMimeData* self, struct miqt_string mimetype); bool QMimeData_HasFormat(const QMimeData* self, struct miqt_string mimetype); -struct miqt_array* QMimeData_Formats(const QMimeData* self); +struct miqt_array QMimeData_Formats(const QMimeData* self); void QMimeData_Clear(QMimeData* self); struct miqt_string QMimeData_Tr2(const char* s, const char* c); struct miqt_string QMimeData_Tr3(const char* s, const char* c, int n); diff --git a/qt/gen_qmimedatabase.cpp b/qt/gen_qmimedatabase.cpp index 968ba9bd..13efa053 100644 --- a/qt/gen_qmimedatabase.cpp +++ b/qt/gen_qmimedatabase.cpp @@ -30,7 +30,7 @@ QMimeType* QMimeDatabase_MimeTypeForFileWithFileInfo(const QMimeDatabase* self, return new QMimeType(self->mimeTypeForFile(*fileInfo)); } -struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName) { +struct miqt_array QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QList _ret = self->mimeTypesForFileName(fileName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -38,9 +38,9 @@ struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QMimeType(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -80,16 +80,16 @@ struct miqt_string QMimeDatabase_SuffixForFileName(const QMimeDatabase* self, st return _ms; } -struct miqt_array* QMimeDatabase_AllMimeTypes(const QMimeDatabase* self) { +struct miqt_array QMimeDatabase_AllMimeTypes(const QMimeDatabase* self) { QList _ret = self->allMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory QMimeType** _arr = static_cast(malloc(sizeof(QMimeType*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QMimeType(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmimedatabase.go b/qt/gen_qmimedatabase.go index f433ec41..8edba9c8 100644 --- a/qt/gen_qmimedatabase.go +++ b/qt/gen_qmimedatabase.go @@ -90,7 +90,7 @@ func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType { fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, fileName_ms) + var _ma C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, fileName_ms) _ret := make([]QMimeType, int(_ma.len)) _outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -99,7 +99,6 @@ func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -164,7 +163,7 @@ func (this *QMimeDatabase) SuffixForFileName(fileName string) string { } func (this *QMimeDatabase) AllMimeTypes() []QMimeType { - var _ma *C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h) + var _ma C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h) _ret := make([]QMimeType, int(_ma.len)) _outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -173,7 +172,6 @@ func (this *QMimeDatabase) AllMimeTypes() []QMimeType { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmimedatabase.h b/qt/gen_qmimedatabase.h index 6624fac4..4df66c7c 100644 --- a/qt/gen_qmimedatabase.h +++ b/qt/gen_qmimedatabase.h @@ -33,14 +33,14 @@ QMimeDatabase* QMimeDatabase_new(); QMimeType* QMimeDatabase_MimeTypeForName(const QMimeDatabase* self, struct miqt_string nameOrAlias); QMimeType* QMimeDatabase_MimeTypeForFile(const QMimeDatabase* self, struct miqt_string fileName); QMimeType* QMimeDatabase_MimeTypeForFileWithFileInfo(const QMimeDatabase* self, QFileInfo* fileInfo); -struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName); +struct miqt_array QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName); QMimeType* QMimeDatabase_MimeTypeForData(const QMimeDatabase* self, struct miqt_string data); QMimeType* QMimeDatabase_MimeTypeForDataWithDevice(const QMimeDatabase* self, QIODevice* device); QMimeType* QMimeDatabase_MimeTypeForUrl(const QMimeDatabase* self, QUrl* url); QMimeType* QMimeDatabase_MimeTypeForFileNameAndData(const QMimeDatabase* self, struct miqt_string fileName, QIODevice* device); QMimeType* QMimeDatabase_MimeTypeForFileNameAndData2(const QMimeDatabase* self, struct miqt_string fileName, struct miqt_string data); struct miqt_string QMimeDatabase_SuffixForFileName(const QMimeDatabase* self, struct miqt_string fileName); -struct miqt_array* QMimeDatabase_AllMimeTypes(const QMimeDatabase* self); +struct miqt_array QMimeDatabase_AllMimeTypes(const QMimeDatabase* self); QMimeType* QMimeDatabase_MimeTypeForFile2(const QMimeDatabase* self, struct miqt_string fileName, int mode); QMimeType* QMimeDatabase_MimeTypeForFile22(const QMimeDatabase* self, QFileInfo* fileInfo, int mode); void QMimeDatabase_Delete(QMimeDatabase* self); diff --git a/qt/gen_qmimetype.cpp b/qt/gen_qmimetype.cpp index ee883f82..b02978a3 100644 --- a/qt/gen_qmimetype.cpp +++ b/qt/gen_qmimetype.cpp @@ -83,7 +83,7 @@ struct miqt_string QMimeType_IconName(const QMimeType* self) { return _ms; } -struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self) { +struct miqt_array QMimeType_GlobPatterns(const QMimeType* self) { QStringList _ret = self->globPatterns(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -97,13 +97,13 @@ struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self) { +struct miqt_array QMimeType_ParentMimeTypes(const QMimeType* self) { QStringList _ret = self->parentMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -117,13 +117,13 @@ struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_AllAncestors(const QMimeType* self) { +struct miqt_array QMimeType_AllAncestors(const QMimeType* self) { QStringList _ret = self->allAncestors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -137,13 +137,13 @@ struct miqt_array* QMimeType_AllAncestors(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_Aliases(const QMimeType* self) { +struct miqt_array QMimeType_Aliases(const QMimeType* self) { QStringList _ret = self->aliases(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -157,13 +157,13 @@ struct miqt_array* QMimeType_Aliases(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_Suffixes(const QMimeType* self) { +struct miqt_array QMimeType_Suffixes(const QMimeType* self) { QStringList _ret = self->suffixes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -177,9 +177,9 @@ struct miqt_array* QMimeType_Suffixes(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmimetype.go b/qt/gen_qmimetype.go index b82831fa..eaab8a7d 100644 --- a/qt/gen_qmimetype.go +++ b/qt/gen_qmimetype.go @@ -107,7 +107,7 @@ func (this *QMimeType) IconName() string { } func (this *QMimeType) GlobPatterns() []string { - var _ma *C.struct_miqt_array = C.QMimeType_GlobPatterns(this.h) + var _ma C.struct_miqt_array = C.QMimeType_GlobPatterns(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -116,12 +116,11 @@ func (this *QMimeType) GlobPatterns() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) ParentMimeTypes() []string { - var _ma *C.struct_miqt_array = C.QMimeType_ParentMimeTypes(this.h) + var _ma C.struct_miqt_array = C.QMimeType_ParentMimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -130,12 +129,11 @@ func (this *QMimeType) ParentMimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) AllAncestors() []string { - var _ma *C.struct_miqt_array = C.QMimeType_AllAncestors(this.h) + var _ma C.struct_miqt_array = C.QMimeType_AllAncestors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -144,12 +142,11 @@ func (this *QMimeType) AllAncestors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) Aliases() []string { - var _ma *C.struct_miqt_array = C.QMimeType_Aliases(this.h) + var _ma C.struct_miqt_array = C.QMimeType_Aliases(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -158,12 +155,11 @@ func (this *QMimeType) Aliases() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) Suffixes() []string { - var _ma *C.struct_miqt_array = C.QMimeType_Suffixes(this.h) + var _ma C.struct_miqt_array = C.QMimeType_Suffixes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,7 +168,6 @@ func (this *QMimeType) Suffixes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmimetype.h b/qt/gen_qmimetype.h index 557272d7..eb2b597b 100644 --- a/qt/gen_qmimetype.h +++ b/qt/gen_qmimetype.h @@ -31,11 +31,11 @@ struct miqt_string QMimeType_Name(const QMimeType* self); struct miqt_string QMimeType_Comment(const QMimeType* self); struct miqt_string QMimeType_GenericIconName(const QMimeType* self); struct miqt_string QMimeType_IconName(const QMimeType* self); -struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self); -struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self); -struct miqt_array* QMimeType_AllAncestors(const QMimeType* self); -struct miqt_array* QMimeType_Aliases(const QMimeType* self); -struct miqt_array* QMimeType_Suffixes(const QMimeType* self); +struct miqt_array QMimeType_GlobPatterns(const QMimeType* self); +struct miqt_array QMimeType_ParentMimeTypes(const QMimeType* self); +struct miqt_array QMimeType_AllAncestors(const QMimeType* self); +struct miqt_array QMimeType_Aliases(const QMimeType* self); +struct miqt_array QMimeType_Suffixes(const QMimeType* self); struct miqt_string QMimeType_PreferredSuffix(const QMimeType* self); bool QMimeType_Inherits(const QMimeType* self, struct miqt_string mimeTypeName); struct miqt_string QMimeType_FilterString(const QMimeType* self); diff --git a/qt/gen_qmovie.cpp b/qt/gen_qmovie.cpp index 690de2f5..7cd5a688 100644 --- a/qt/gen_qmovie.cpp +++ b/qt/gen_qmovie.cpp @@ -85,7 +85,7 @@ struct miqt_string QMovie_TrUtf8(const char* s) { return _ms; } -struct miqt_array* QMovie_SupportedFormats() { +struct miqt_array QMovie_SupportedFormats() { QList _ret = QMovie::supportedFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -97,9 +97,9 @@ struct miqt_array* QMovie_SupportedFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qmovie.go b/qt/gen_qmovie.go index 60847be8..9ecf03ae 100644 --- a/qt/gen_qmovie.go +++ b/qt/gen_qmovie.go @@ -160,7 +160,7 @@ func QMovie_TrUtf8(s string) string { } func QMovie_SupportedFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QMovie_SupportedFormats() + var _ma C.struct_miqt_array = C.QMovie_SupportedFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -169,7 +169,6 @@ func QMovie_SupportedFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qmovie.h b/qt/gen_qmovie.h index d48ecf24..db68279f 100644 --- a/qt/gen_qmovie.h +++ b/qt/gen_qmovie.h @@ -49,7 +49,7 @@ QMetaObject* QMovie_MetaObject(const QMovie* self); void* QMovie_Metacast(QMovie* self, const char* param1); struct miqt_string QMovie_Tr(const char* s); struct miqt_string QMovie_TrUtf8(const char* s); -struct miqt_array* QMovie_SupportedFormats(); +struct miqt_array QMovie_SupportedFormats(); void QMovie_SetDevice(QMovie* self, QIODevice* device); QIODevice* QMovie_Device(const QMovie* self); void QMovie_SetFileName(QMovie* self, struct miqt_string fileName); diff --git a/qt/gen_qobject.cpp b/qt/gen_qobject.cpp index 77c88cb3..f6077599 100644 --- a/qt/gen_qobject.cpp +++ b/qt/gen_qobject.cpp @@ -119,16 +119,16 @@ void QObject_KillTimer(QObject* self, int id) { self->killTimer(static_cast(id)); } -struct miqt_array* QObject_Children(const QObject* self) { +struct miqt_array QObject_Children(const QObject* self) { const QObjectList& _ret = self->children(); // Convert QList<> from C++ memory to manually-managed C memory QObject** _arr = static_cast(malloc(sizeof(QObject*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -184,7 +184,7 @@ QVariant* QObject_Property(const QObject* self, const char* name) { return new QVariant(self->property(name)); } -struct miqt_array* QObject_DynamicPropertyNames(const QObject* self) { +struct miqt_array QObject_DynamicPropertyNames(const QObject* self) { QList _ret = self->dynamicPropertyNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -196,9 +196,9 @@ struct miqt_array* QObject_DynamicPropertyNames(const QObject* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qobject.go b/qt/gen_qobject.go index 3070493c..e16f023e 100644 --- a/qt/gen_qobject.go +++ b/qt/gen_qobject.go @@ -192,13 +192,12 @@ func (this *QObject) KillTimer(id int) { } func (this *QObject) Children() []*QObject { - var _ma *C.struct_miqt_array = C.QObject_Children(this.h) + var _ma C.struct_miqt_array = C.QObject_Children(this.h) _ret := make([]*QObject, int(_ma.len)) _outCast := (*[0xffff]*C.QObject)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQObject(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -272,7 +271,7 @@ func (this *QObject) Property(name string) *QVariant { } func (this *QObject) DynamicPropertyNames() [][]byte { - var _ma *C.struct_miqt_array = C.QObject_DynamicPropertyNames(this.h) + var _ma C.struct_miqt_array = C.QObject_DynamicPropertyNames(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -281,7 +280,6 @@ func (this *QObject) DynamicPropertyNames() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qobject.h b/qt/gen_qobject.h index 25fd2d90..bac7fbcb 100644 --- a/qt/gen_qobject.h +++ b/qt/gen_qobject.h @@ -64,7 +64,7 @@ QThread* QObject_Thread(const QObject* self); void QObject_MoveToThread(QObject* self, QThread* thread); int QObject_StartTimer(QObject* self, int interval); void QObject_KillTimer(QObject* self, int id); -struct miqt_array* QObject_Children(const QObject* self); +struct miqt_array QObject_Children(const QObject* self); void QObject_SetParent(QObject* self, QObject* parent); void QObject_InstallEventFilter(QObject* self, QObject* filterObj); void QObject_RemoveEventFilter(QObject* self, QObject* obj); @@ -78,7 +78,7 @@ void QObject_DumpObjectTree2(const QObject* self); void QObject_DumpObjectInfo2(const QObject* self); bool QObject_SetProperty(QObject* self, const char* name, QVariant* value); QVariant* QObject_Property(const QObject* self, const char* name); -struct miqt_array* QObject_DynamicPropertyNames(const QObject* self); +struct miqt_array QObject_DynamicPropertyNames(const QObject* self); unsigned int QObject_RegisterUserData(); void QObject_SetUserData(QObject* self, unsigned int id, QObjectUserData* data); QObjectUserData* QObject_UserData(const QObject* self, unsigned int id); diff --git a/qt/gen_qpainter.cpp b/qt/gen_qpainter.cpp index e9d49fbf..e374180c 100644 --- a/qt/gen_qpainter.cpp +++ b/qt/gen_qpainter.cpp @@ -408,11 +408,11 @@ void QPainter_DrawLines(QPainter* self, QLineF* lines, int lineCount) { self->drawLines(lines, static_cast(lineCount)); } -void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array* /* of QLineF* */ lines) { +void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array /* of QLineF* */ lines) { QVector lines_QList; - lines_QList.reserve(lines->len); - QLineF** lines_arr = static_cast(lines->data); - for(size_t i = 0; i < lines->len; ++i) { + lines_QList.reserve(lines.len); + QLineF** lines_arr = static_cast(lines.data); + for(size_t i = 0; i < lines.len; ++i) { lines_QList.push_back(*(lines_arr[i])); } self->drawLines(lines_QList); @@ -422,11 +422,11 @@ void QPainter_DrawLines2(QPainter* self, QPointF* pointPairs, int lineCount) { self->drawLines(pointPairs, static_cast(lineCount)); } -void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array* /* of QPointF* */ pointPairs) { +void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array /* of QPointF* */ pointPairs) { QVector pointPairs_QList; - pointPairs_QList.reserve(pointPairs->len); - QPointF** pointPairs_arr = static_cast(pointPairs->data); - for(size_t i = 0; i < pointPairs->len; ++i) { + pointPairs_QList.reserve(pointPairs.len); + QPointF** pointPairs_arr = static_cast(pointPairs.data); + for(size_t i = 0; i < pointPairs.len; ++i) { pointPairs_QList.push_back(*(pointPairs_arr[i])); } self->drawLines(pointPairs_QList); @@ -436,11 +436,11 @@ void QPainter_DrawLines3(QPainter* self, QLine* lines, int lineCount) { self->drawLines(lines, static_cast(lineCount)); } -void QPainter_DrawLines4(QPainter* self, struct miqt_array* /* of QLine* */ lines) { +void QPainter_DrawLines4(QPainter* self, struct miqt_array /* of QLine* */ lines) { QVector lines_QList; - lines_QList.reserve(lines->len); - QLine** lines_arr = static_cast(lines->data); - for(size_t i = 0; i < lines->len; ++i) { + lines_QList.reserve(lines.len); + QLine** lines_arr = static_cast(lines.data); + for(size_t i = 0; i < lines.len; ++i) { lines_QList.push_back(*(lines_arr[i])); } self->drawLines(lines_QList); @@ -450,11 +450,11 @@ void QPainter_DrawLines5(QPainter* self, QPoint* pointPairs, int lineCount) { self->drawLines(pointPairs, static_cast(lineCount)); } -void QPainter_DrawLines6(QPainter* self, struct miqt_array* /* of QPoint* */ pointPairs) { +void QPainter_DrawLines6(QPainter* self, struct miqt_array /* of QPoint* */ pointPairs) { QVector pointPairs_QList; - pointPairs_QList.reserve(pointPairs->len); - QPoint** pointPairs_arr = static_cast(pointPairs->data); - for(size_t i = 0; i < pointPairs->len; ++i) { + pointPairs_QList.reserve(pointPairs.len); + QPoint** pointPairs_arr = static_cast(pointPairs.data); + for(size_t i = 0; i < pointPairs.len; ++i) { pointPairs_QList.push_back(*(pointPairs_arr[i])); } self->drawLines(pointPairs_QList); @@ -476,11 +476,11 @@ void QPainter_DrawRects(QPainter* self, QRectF* rects, int rectCount) { self->drawRects(rects, static_cast(rectCount)); } -void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array* /* of QRectF* */ rectangles) { +void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array /* of QRectF* */ rectangles) { QVector rectangles_QList; - rectangles_QList.reserve(rectangles->len); - QRectF** rectangles_arr = static_cast(rectangles->data); - for(size_t i = 0; i < rectangles->len; ++i) { + rectangles_QList.reserve(rectangles.len); + QRectF** rectangles_arr = static_cast(rectangles.data); + for(size_t i = 0; i < rectangles.len; ++i) { rectangles_QList.push_back(*(rectangles_arr[i])); } self->drawRects(rectangles_QList); @@ -490,11 +490,11 @@ void QPainter_DrawRects2(QPainter* self, QRect* rects, int rectCount) { self->drawRects(rects, static_cast(rectCount)); } -void QPainter_DrawRects3(QPainter* self, struct miqt_array* /* of QRect* */ rectangles) { +void QPainter_DrawRects3(QPainter* self, struct miqt_array /* of QRect* */ rectangles) { QVector rectangles_QList; - rectangles_QList.reserve(rectangles->len); - QRect** rectangles_arr = static_cast(rectangles->data); - for(size_t i = 0; i < rectangles->len; ++i) { + rectangles_QList.reserve(rectangles.len); + QRect** rectangles_arr = static_cast(rectangles.data); + for(size_t i = 0; i < rectangles.len; ++i) { rectangles_QList.push_back(*(rectangles_arr[i])); } self->drawRects(rectangles_QList); diff --git a/qt/gen_qpainter.go b/qt/gen_qpainter.go index 61d1c4da..9ee0303c 100644 --- a/qt/gen_qpainter.go +++ b/qt/gen_qpainter.go @@ -490,14 +490,12 @@ func (this *QPainter) DrawLines(lines *QLineF, lineCount int) { } func (this *QPainter) DrawLinesWithLines(lines []QLineF) { - // For the C ABI, malloc a C array of raw pointers lines_CArray := (*[0xffff]*C.QLineF)(C.malloc(C.size_t(8 * len(lines)))) defer C.free(unsafe.Pointer(lines_CArray)) for i := range lines { lines_CArray[i] = lines[i].cPointer() } - lines_ma := &C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lines_ma)) + lines_ma := C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} C.QPainter_DrawLinesWithLines(this.h, lines_ma) } @@ -506,14 +504,12 @@ func (this *QPainter) DrawLines2(pointPairs *QPointF, lineCount int) { } func (this *QPainter) DrawLinesWithPointPairs(pointPairs []QPointF) { - // For the C ABI, malloc a C array of raw pointers pointPairs_CArray := (*[0xffff]*C.QPointF)(C.malloc(C.size_t(8 * len(pointPairs)))) defer C.free(unsafe.Pointer(pointPairs_CArray)) for i := range pointPairs { pointPairs_CArray[i] = pointPairs[i].cPointer() } - pointPairs_ma := &C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pointPairs_ma)) + pointPairs_ma := C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} C.QPainter_DrawLinesWithPointPairs(this.h, pointPairs_ma) } @@ -522,14 +518,12 @@ func (this *QPainter) DrawLines3(lines *QLine, lineCount int) { } func (this *QPainter) DrawLines4(lines []QLine) { - // For the C ABI, malloc a C array of raw pointers lines_CArray := (*[0xffff]*C.QLine)(C.malloc(C.size_t(8 * len(lines)))) defer C.free(unsafe.Pointer(lines_CArray)) for i := range lines { lines_CArray[i] = lines[i].cPointer() } - lines_ma := &C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lines_ma)) + lines_ma := C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} C.QPainter_DrawLines4(this.h, lines_ma) } @@ -538,14 +532,12 @@ func (this *QPainter) DrawLines5(pointPairs *QPoint, lineCount int) { } func (this *QPainter) DrawLines6(pointPairs []QPoint) { - // For the C ABI, malloc a C array of raw pointers pointPairs_CArray := (*[0xffff]*C.QPoint)(C.malloc(C.size_t(8 * len(pointPairs)))) defer C.free(unsafe.Pointer(pointPairs_CArray)) for i := range pointPairs { pointPairs_CArray[i] = pointPairs[i].cPointer() } - pointPairs_ma := &C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pointPairs_ma)) + pointPairs_ma := C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} C.QPainter_DrawLines6(this.h, pointPairs_ma) } @@ -566,14 +558,12 @@ func (this *QPainter) DrawRects(rects *QRectF, rectCount int) { } func (this *QPainter) DrawRectsWithRectangles(rectangles []QRectF) { - // For the C ABI, malloc a C array of raw pointers rectangles_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(rectangles)))) defer C.free(unsafe.Pointer(rectangles_CArray)) for i := range rectangles { rectangles_CArray[i] = rectangles[i].cPointer() } - rectangles_ma := &C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rectangles_ma)) + rectangles_ma := C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} C.QPainter_DrawRectsWithRectangles(this.h, rectangles_ma) } @@ -582,14 +572,12 @@ func (this *QPainter) DrawRects2(rects *QRect, rectCount int) { } func (this *QPainter) DrawRects3(rectangles []QRect) { - // For the C ABI, malloc a C array of raw pointers rectangles_CArray := (*[0xffff]*C.QRect)(C.malloc(C.size_t(8 * len(rectangles)))) defer C.free(unsafe.Pointer(rectangles_CArray)) for i := range rectangles { rectangles_CArray[i] = rectangles[i].cPointer() } - rectangles_ma := &C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rectangles_ma)) + rectangles_ma := C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} C.QPainter_DrawRects3(this.h, rectangles_ma) } diff --git a/qt/gen_qpainter.h b/qt/gen_qpainter.h index d3aae75d..02da7266 100644 --- a/qt/gen_qpainter.h +++ b/qt/gen_qpainter.h @@ -163,20 +163,20 @@ void QPainter_DrawLine2(QPainter* self, int x1, int y1, int x2, int y2); void QPainter_DrawLine3(QPainter* self, QPoint* p1, QPoint* p2); void QPainter_DrawLine4(QPainter* self, QPointF* p1, QPointF* p2); void QPainter_DrawLines(QPainter* self, QLineF* lines, int lineCount); -void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array* /* of QLineF* */ lines); +void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array /* of QLineF* */ lines); void QPainter_DrawLines2(QPainter* self, QPointF* pointPairs, int lineCount); -void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array* /* of QPointF* */ pointPairs); +void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array /* of QPointF* */ pointPairs); void QPainter_DrawLines3(QPainter* self, QLine* lines, int lineCount); -void QPainter_DrawLines4(QPainter* self, struct miqt_array* /* of QLine* */ lines); +void QPainter_DrawLines4(QPainter* self, struct miqt_array /* of QLine* */ lines); void QPainter_DrawLines5(QPainter* self, QPoint* pointPairs, int lineCount); -void QPainter_DrawLines6(QPainter* self, struct miqt_array* /* of QPoint* */ pointPairs); +void QPainter_DrawLines6(QPainter* self, struct miqt_array /* of QPoint* */ pointPairs); void QPainter_DrawRect(QPainter* self, QRectF* rect); void QPainter_DrawRect2(QPainter* self, int x1, int y1, int w, int h); void QPainter_DrawRectWithRect(QPainter* self, QRect* rect); void QPainter_DrawRects(QPainter* self, QRectF* rects, int rectCount); -void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array* /* of QRectF* */ rectangles); +void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array /* of QRectF* */ rectangles); void QPainter_DrawRects2(QPainter* self, QRect* rects, int rectCount); -void QPainter_DrawRects3(QPainter* self, struct miqt_array* /* of QRect* */ rectangles); +void QPainter_DrawRects3(QPainter* self, struct miqt_array /* of QRect* */ rectangles); void QPainter_DrawEllipse(QPainter* self, QRectF* r); void QPainter_DrawEllipseWithQRect(QPainter* self, QRect* r); void QPainter_DrawEllipse2(QPainter* self, int x, int y, int w, int h); diff --git a/qt/gen_qpainterpath.cpp b/qt/gen_qpainterpath.cpp index 4fab7e8d..0866704d 100644 --- a/qt/gen_qpainterpath.cpp +++ b/qt/gen_qpainterpath.cpp @@ -398,26 +398,26 @@ void QPainterPathStroker_SetDashPattern(QPainterPathStroker* self, int dashPatte self->setDashPattern(static_cast(dashPattern)); } -void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array* /* of double */ dashPattern) { +void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array /* of double */ dashPattern) { QVector dashPattern_QList; - dashPattern_QList.reserve(dashPattern->len); - double* dashPattern_arr = static_cast(dashPattern->data); - for(size_t i = 0; i < dashPattern->len; ++i) { + dashPattern_QList.reserve(dashPattern.len); + double* dashPattern_arr = static_cast(dashPattern.data); + for(size_t i = 0; i < dashPattern.len; ++i) { dashPattern_QList.push_back(static_cast(dashPattern_arr[i])); } self->setDashPattern(dashPattern_QList); } -struct miqt_array* QPainterPathStroker_DashPattern(const QPainterPathStroker* self) { +struct miqt_array QPainterPathStroker_DashPattern(const QPainterPathStroker* self) { QVector _ret = self->dashPattern(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qpainterpath.go b/qt/gen_qpainterpath.go index f46a65ec..e99ac6b6 100644 --- a/qt/gen_qpainterpath.go +++ b/qt/gen_qpainterpath.go @@ -528,25 +528,22 @@ func (this *QPainterPathStroker) SetDashPattern(dashPattern PenStyle) { } func (this *QPainterPathStroker) SetDashPatternWithDashPattern(dashPattern []float64) { - // For the C ABI, malloc a C array of raw pointers dashPattern_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(dashPattern)))) defer C.free(unsafe.Pointer(dashPattern_CArray)) for i := range dashPattern { dashPattern_CArray[i] = (C.double)(dashPattern[i]) } - dashPattern_ma := &C.struct_miqt_array{len: C.size_t(len(dashPattern)), data: unsafe.Pointer(dashPattern_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(dashPattern_ma)) + dashPattern_ma := C.struct_miqt_array{len: C.size_t(len(dashPattern)), data: unsafe.Pointer(dashPattern_CArray)} C.QPainterPathStroker_SetDashPatternWithDashPattern(this.h, dashPattern_ma) } func (this *QPainterPathStroker) DashPattern() []float64 { - var _ma *C.struct_miqt_array = C.QPainterPathStroker_DashPattern(this.h) + var _ma C.struct_miqt_array = C.QPainterPathStroker_DashPattern(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qpainterpath.h b/qt/gen_qpainterpath.h index 899831b4..d142e25c 100644 --- a/qt/gen_qpainterpath.h +++ b/qt/gen_qpainterpath.h @@ -130,8 +130,8 @@ double QPainterPathStroker_MiterLimit(const QPainterPathStroker* self); void QPainterPathStroker_SetCurveThreshold(QPainterPathStroker* self, double threshold); double QPainterPathStroker_CurveThreshold(const QPainterPathStroker* self); void QPainterPathStroker_SetDashPattern(QPainterPathStroker* self, int dashPattern); -void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array* /* of double */ dashPattern); -struct miqt_array* QPainterPathStroker_DashPattern(const QPainterPathStroker* self); +void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array /* of double */ dashPattern); +struct miqt_array QPainterPathStroker_DashPattern(const QPainterPathStroker* self); void QPainterPathStroker_SetDashOffset(QPainterPathStroker* self, double offset); double QPainterPathStroker_DashOffset(const QPainterPathStroker* self); QPainterPath* QPainterPathStroker_CreateStroke(const QPainterPathStroker* self, QPainterPath* path); diff --git a/qt/gen_qpen.cpp b/qt/gen_qpen.cpp index 21abbb97..5c3ad981 100644 --- a/qt/gen_qpen.cpp +++ b/qt/gen_qpen.cpp @@ -55,24 +55,24 @@ void QPen_SetStyle(QPen* self, int style) { self->setStyle(static_cast(style)); } -struct miqt_array* QPen_DashPattern(const QPen* self) { +struct miqt_array QPen_DashPattern(const QPen* self) { QVector _ret = self->dashPattern(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QPen_SetDashPattern(QPen* self, struct miqt_array* /* of double */ pattern) { +void QPen_SetDashPattern(QPen* self, struct miqt_array /* of double */ pattern) { QVector pattern_QList; - pattern_QList.reserve(pattern->len); - double* pattern_arr = static_cast(pattern->data); - for(size_t i = 0; i < pattern->len; ++i) { + pattern_QList.reserve(pattern.len); + double* pattern_arr = static_cast(pattern.data); + for(size_t i = 0; i < pattern.len; ++i) { pattern_QList.push_back(static_cast(pattern_arr[i])); } self->setDashPattern(pattern_QList); diff --git a/qt/gen_qpen.go b/qt/gen_qpen.go index a81be865..1354a556 100644 --- a/qt/gen_qpen.go +++ b/qt/gen_qpen.go @@ -107,25 +107,22 @@ func (this *QPen) SetStyle(style PenStyle) { } func (this *QPen) DashPattern() []float64 { - var _ma *C.struct_miqt_array = C.QPen_DashPattern(this.h) + var _ma C.struct_miqt_array = C.QPen_DashPattern(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QPen) SetDashPattern(pattern []float64) { - // For the C ABI, malloc a C array of raw pointers pattern_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(pattern)))) defer C.free(unsafe.Pointer(pattern_CArray)) for i := range pattern { pattern_CArray[i] = (C.double)(pattern[i]) } - pattern_ma := &C.struct_miqt_array{len: C.size_t(len(pattern)), data: unsafe.Pointer(pattern_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pattern_ma)) + pattern_ma := C.struct_miqt_array{len: C.size_t(len(pattern)), data: unsafe.Pointer(pattern_CArray)} C.QPen_SetDashPattern(this.h, pattern_ma) } diff --git a/qt/gen_qpen.h b/qt/gen_qpen.h index 4d0b6b1d..8c50b282 100644 --- a/qt/gen_qpen.h +++ b/qt/gen_qpen.h @@ -35,8 +35,8 @@ void QPen_OperatorAssign(QPen* self, QPen* pen); void QPen_Swap(QPen* self, QPen* other); int QPen_Style(const QPen* self); void QPen_SetStyle(QPen* self, int style); -struct miqt_array* QPen_DashPattern(const QPen* self); -void QPen_SetDashPattern(QPen* self, struct miqt_array* /* of double */ pattern); +struct miqt_array QPen_DashPattern(const QPen* self); +void QPen_SetDashPattern(QPen* self, struct miqt_array /* of double */ pattern); double QPen_DashOffset(const QPen* self); void QPen_SetDashOffset(QPen* self, double doffset); double QPen_MiterLimit(const QPen* self); diff --git a/qt/gen_qpicture.cpp b/qt/gen_qpicture.cpp index c824fc7a..0ddcdde2 100644 --- a/qt/gen_qpicture.cpp +++ b/qt/gen_qpicture.cpp @@ -97,7 +97,7 @@ const char* QPicture_PictureFormat(struct miqt_string fileName) { return (const char*) QPicture::pictureFormat(fileName_QString); } -struct miqt_array* QPicture_InputFormats() { +struct miqt_array QPicture_InputFormats() { QList _ret = QPicture::inputFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -109,13 +109,13 @@ struct miqt_array* QPicture_InputFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPicture_OutputFormats() { +struct miqt_array QPicture_OutputFormats() { QList _ret = QPicture::outputFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -127,13 +127,13 @@ struct miqt_array* QPicture_OutputFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPicture_InputFormatList() { +struct miqt_array QPicture_InputFormatList() { QStringList _ret = QPicture::inputFormatList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -147,13 +147,13 @@ struct miqt_array* QPicture_InputFormatList() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPicture_OutputFormatList() { +struct miqt_array QPicture_OutputFormatList() { QStringList _ret = QPicture::outputFormatList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -167,9 +167,9 @@ struct miqt_array* QPicture_OutputFormatList() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -329,7 +329,7 @@ struct miqt_string QPictureIO_PictureFormatWithQIODevice(QIODevice* param1) { return _ms; } -struct miqt_array* QPictureIO_InputFormats() { +struct miqt_array QPictureIO_InputFormats() { QList _ret = QPictureIO::inputFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -341,13 +341,13 @@ struct miqt_array* QPictureIO_InputFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPictureIO_OutputFormats() { +struct miqt_array QPictureIO_OutputFormats() { QList _ret = QPictureIO::outputFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -359,9 +359,9 @@ struct miqt_array* QPictureIO_OutputFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qpicture.go b/qt/gen_qpicture.go index 85f1546d..7fba6864 100644 --- a/qt/gen_qpicture.go +++ b/qt/gen_qpicture.go @@ -149,7 +149,7 @@ func QPicture_PictureFormat(fileName string) string { } func QPicture_InputFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QPicture_InputFormats() + var _ma C.struct_miqt_array = C.QPicture_InputFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -158,12 +158,11 @@ func QPicture_InputFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPicture_OutputFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QPicture_OutputFormats() + var _ma C.struct_miqt_array = C.QPicture_OutputFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,12 +171,11 @@ func QPicture_OutputFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPicture_InputFormatList() []string { - var _ma *C.struct_miqt_array = C.QPicture_InputFormatList() + var _ma C.struct_miqt_array = C.QPicture_InputFormatList() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -186,12 +184,11 @@ func QPicture_InputFormatList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPicture_OutputFormatList() []string { - var _ma *C.struct_miqt_array = C.QPicture_OutputFormatList() + var _ma C.struct_miqt_array = C.QPicture_OutputFormatList() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -200,7 +197,6 @@ func QPicture_OutputFormatList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -428,7 +424,7 @@ func QPictureIO_PictureFormatWithQIODevice(param1 *QIODevice) []byte { } func QPictureIO_InputFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QPictureIO_InputFormats() + var _ma C.struct_miqt_array = C.QPictureIO_InputFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -437,12 +433,11 @@ func QPictureIO_InputFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPictureIO_OutputFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QPictureIO_OutputFormats() + var _ma C.struct_miqt_array = C.QPictureIO_OutputFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -451,7 +446,6 @@ func QPictureIO_OutputFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qpicture.h b/qt/gen_qpicture.h index 14489d53..bee588b5 100644 --- a/qt/gen_qpicture.h +++ b/qt/gen_qpicture.h @@ -51,10 +51,10 @@ void QPicture_Swap(QPicture* self, QPicture* other); void QPicture_Detach(QPicture* self); bool QPicture_IsDetached(const QPicture* self); const char* QPicture_PictureFormat(struct miqt_string fileName); -struct miqt_array* QPicture_InputFormats(); -struct miqt_array* QPicture_OutputFormats(); -struct miqt_array* QPicture_InputFormatList(); -struct miqt_array* QPicture_OutputFormatList(); +struct miqt_array QPicture_InputFormats(); +struct miqt_array QPicture_OutputFormats(); +struct miqt_array QPicture_InputFormatList(); +struct miqt_array QPicture_OutputFormatList(); QPaintEngine* QPicture_PaintEngine(const QPicture* self); bool QPicture_Load2(QPicture* self, QIODevice* dev, const char* format); bool QPicture_Load22(QPicture* self, struct miqt_string fileName, const char* format); @@ -87,8 +87,8 @@ bool QPictureIO_Read(QPictureIO* self); bool QPictureIO_Write(QPictureIO* self); struct miqt_string QPictureIO_PictureFormat(struct miqt_string fileName); struct miqt_string QPictureIO_PictureFormatWithQIODevice(QIODevice* param1); -struct miqt_array* QPictureIO_InputFormats(); -struct miqt_array* QPictureIO_OutputFormats(); +struct miqt_array QPictureIO_InputFormats(); +struct miqt_array QPictureIO_OutputFormats(); void QPictureIO_Delete(QPictureIO* self); #ifdef __cplusplus diff --git a/qt/gen_qplaintextedit.cpp b/qt/gen_qplaintextedit.cpp index ccb103ca..dd8cc77d 100644 --- a/qt/gen_qplaintextedit.cpp +++ b/qt/gen_qplaintextedit.cpp @@ -308,26 +308,26 @@ void QPlainTextEdit_SetCursorWidth(QPlainTextEdit* self, int width) { self->setCursorWidth(static_cast(width)); } -void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections) { +void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextEdit__ExtraSelection** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextEdit__ExtraSelection** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->setExtraSelections(selections_QList); } -struct miqt_array* QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self) { +struct miqt_array QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self) { QList _ret = self->extraSelections(); // Convert QList<> from C++ memory to manually-managed C memory QTextEdit__ExtraSelection** _arr = static_cast(malloc(sizeof(QTextEdit__ExtraSelection*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextEdit::ExtraSelection(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qplaintextedit.go b/qt/gen_qplaintextedit.go index a6afa003..3c71252d 100644 --- a/qt/gen_qplaintextedit.go +++ b/qt/gen_qplaintextedit.go @@ -350,19 +350,17 @@ func (this *QPlainTextEdit) SetCursorWidth(width int) { } func (this *QPlainTextEdit) SetExtraSelections(selections []QTextEdit__ExtraSelection) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextEdit__ExtraSelection)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QPlainTextEdit_SetExtraSelections(this.h, selections_ma) } func (this *QPlainTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { - var _ma *C.struct_miqt_array = C.QPlainTextEdit_ExtraSelections(this.h) + var _ma C.struct_miqt_array = C.QPlainTextEdit_ExtraSelections(this.h) _ret := make([]QTextEdit__ExtraSelection, int(_ma.len)) _outCast := (*[0xffff]*C.QTextEdit__ExtraSelection)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -371,7 +369,6 @@ func (this *QPlainTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qplaintextedit.h b/qt/gen_qplaintextedit.h index d3d9e61f..c1945b92 100644 --- a/qt/gen_qplaintextedit.h +++ b/qt/gen_qplaintextedit.h @@ -128,8 +128,8 @@ double QPlainTextEdit_TabStopDistance(const QPlainTextEdit* self); void QPlainTextEdit_SetTabStopDistance(QPlainTextEdit* self, double distance); int QPlainTextEdit_CursorWidth(const QPlainTextEdit* self); void QPlainTextEdit_SetCursorWidth(QPlainTextEdit* self, int width); -void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections); -struct miqt_array* QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self); +void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections); +struct miqt_array QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self); void QPlainTextEdit_MoveCursor(QPlainTextEdit* self, int operation); bool QPlainTextEdit_CanPaste(const QPlainTextEdit* self); void QPlainTextEdit_Print(const QPlainTextEdit* self, QPagedPaintDevice* printer); diff --git a/qt/gen_qpluginloader.cpp b/qt/gen_qpluginloader.cpp index ba2af9bb..e4879ba1 100644 --- a/qt/gen_qpluginloader.cpp +++ b/qt/gen_qpluginloader.cpp @@ -67,29 +67,29 @@ QJsonObject* QPluginLoader_MetaData(const QPluginLoader* self) { return new QJsonObject(self->metaData()); } -struct miqt_array* QPluginLoader_StaticInstances() { +struct miqt_array QPluginLoader_StaticInstances() { QObjectList _ret = QPluginLoader::staticInstances(); // Convert QList<> from C++ memory to manually-managed C memory QObject** _arr = static_cast(malloc(sizeof(QObject*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPluginLoader_StaticPlugins() { +struct miqt_array QPluginLoader_StaticPlugins() { QVector _ret = QPluginLoader::staticPlugins(); // Convert QList<> from C++ memory to manually-managed C memory QStaticPlugin** _arr = static_cast(malloc(sizeof(QStaticPlugin*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QStaticPlugin(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qpluginloader.go b/qt/gen_qpluginloader.go index 25d79d92..58c378dd 100644 --- a/qt/gen_qpluginloader.go +++ b/qt/gen_qpluginloader.go @@ -115,18 +115,17 @@ func (this *QPluginLoader) MetaData() *QJsonObject { } func QPluginLoader_StaticInstances() []*QObject { - var _ma *C.struct_miqt_array = C.QPluginLoader_StaticInstances() + var _ma C.struct_miqt_array = C.QPluginLoader_StaticInstances() _ret := make([]*QObject, int(_ma.len)) _outCast := (*[0xffff]*C.QObject)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQObject(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QPluginLoader_StaticPlugins() []QStaticPlugin { - var _ma *C.struct_miqt_array = C.QPluginLoader_StaticPlugins() + var _ma C.struct_miqt_array = C.QPluginLoader_StaticPlugins() _ret := make([]QStaticPlugin, int(_ma.len)) _outCast := (*[0xffff]*C.QStaticPlugin)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -135,7 +134,6 @@ func QPluginLoader_StaticPlugins() []QStaticPlugin { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qpluginloader.h b/qt/gen_qpluginloader.h index 0a7d2db7..14aa471b 100644 --- a/qt/gen_qpluginloader.h +++ b/qt/gen_qpluginloader.h @@ -37,8 +37,8 @@ struct miqt_string QPluginLoader_Tr(const char* s); struct miqt_string QPluginLoader_TrUtf8(const char* s); QObject* QPluginLoader_Instance(QPluginLoader* self); QJsonObject* QPluginLoader_MetaData(const QPluginLoader* self); -struct miqt_array* QPluginLoader_StaticInstances(); -struct miqt_array* QPluginLoader_StaticPlugins(); +struct miqt_array QPluginLoader_StaticInstances(); +struct miqt_array QPluginLoader_StaticPlugins(); bool QPluginLoader_Load(QPluginLoader* self); bool QPluginLoader_Unload(QPluginLoader* self); bool QPluginLoader_IsLoaded(const QPluginLoader* self); diff --git a/qt/gen_qprocess.cpp b/qt/gen_qprocess.cpp index d13bde3d..76f6754d 100644 --- a/qt/gen_qprocess.cpp +++ b/qt/gen_qprocess.cpp @@ -71,7 +71,7 @@ struct miqt_string QProcessEnvironment_Value(const QProcessEnvironment* self, st return _ms; } -struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* self) { +struct miqt_array QProcessEnvironment_ToStringList(const QProcessEnvironment* self) { QStringList _ret = self->toStringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -85,13 +85,13 @@ struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* s memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self) { +struct miqt_array QProcessEnvironment_Keys(const QProcessEnvironment* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -105,9 +105,9 @@ struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -174,12 +174,12 @@ struct miqt_string QProcess_TrUtf8(const char* s) { return _ms; } -void QProcess_Start(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +void QProcess_Start(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -219,7 +219,7 @@ void QProcess_SetProgram(QProcess* self, struct miqt_string program) { self->setProgram(program_QString); } -struct miqt_array* QProcess_Arguments(const QProcess* self) { +struct miqt_array QProcess_Arguments(const QProcess* self) { QStringList _ret = self->arguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -233,17 +233,17 @@ struct miqt_array* QProcess_Arguments(const QProcess* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QProcess_SetArguments(QProcess* self, struct miqt_array* /* of struct miqt_string */ arguments) { +void QProcess_SetArguments(QProcess* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -329,18 +329,18 @@ void QProcess_SetWorkingDirectory(QProcess* self, struct miqt_string dir) { self->setWorkingDirectory(dir_QString); } -void QProcess_SetEnvironment(QProcess* self, struct miqt_array* /* of struct miqt_string */ environment) { +void QProcess_SetEnvironment(QProcess* self, struct miqt_array /* of struct miqt_string */ environment) { QStringList environment_QList; - environment_QList.reserve(environment->len); - struct miqt_string* environment_arr = static_cast(environment->data); - for(size_t i = 0; i < environment->len; ++i) { + environment_QList.reserve(environment.len); + struct miqt_string* environment_arr = static_cast(environment.data); + for(size_t i = 0; i < environment.len; ++i) { QString environment_arr_i_QString = QString::fromUtf8(environment_arr[i].data, environment_arr[i].len); environment_QList.push_back(environment_arr_i_QString); } self->setEnvironment(environment_QList); } -struct miqt_array* QProcess_Environment(const QProcess* self) { +struct miqt_array QProcess_Environment(const QProcess* self) { QStringList _ret = self->environment(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -354,9 +354,9 @@ struct miqt_array* QProcess_Environment(const QProcess* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -462,12 +462,12 @@ bool QProcess_AtEnd(const QProcess* self) { return self->atEnd(); } -int QProcess_Execute(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +int QProcess_Execute(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -479,12 +479,12 @@ int QProcess_ExecuteWithCommand(struct miqt_string command) { return QProcess::execute(command_QString); } -bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory) { +bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -492,12 +492,12 @@ bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array* /* o return QProcess::startDetached(program_QString, arguments_QList, workingDirectory_QString); } -bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -509,7 +509,7 @@ bool QProcess_StartDetachedWithCommand(struct miqt_string command) { return QProcess::startDetached(command_QString); } -struct miqt_array* QProcess_SystemEnvironment() { +struct miqt_array QProcess_SystemEnvironment() { QStringList _ret = QProcess::systemEnvironment(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -523,9 +523,9 @@ struct miqt_array* QProcess_SystemEnvironment() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -640,12 +640,12 @@ struct miqt_string QProcess_TrUtf83(const char* s, const char* c, int n) { return _ms; } -void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, int mode) { +void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, int mode) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -695,12 +695,12 @@ bool QProcess_WaitForFinished1(QProcess* self, int msecs) { return self->waitForFinished(static_cast(msecs)); } -bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid) { +bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } diff --git a/qt/gen_qprocess.go b/qt/gen_qprocess.go index 2f728739..ce04ae3c 100644 --- a/qt/gen_qprocess.go +++ b/qt/gen_qprocess.go @@ -169,7 +169,7 @@ func (this *QProcessEnvironment) Value(name string) string { } func (this *QProcessEnvironment) ToStringList() []string { - var _ma *C.struct_miqt_array = C.QProcessEnvironment_ToStringList(this.h) + var _ma C.struct_miqt_array = C.QProcessEnvironment_ToStringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -178,12 +178,11 @@ func (this *QProcessEnvironment) ToStringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QProcessEnvironment) Keys() []string { - var _ma *C.struct_miqt_array = C.QProcessEnvironment_Keys(this.h) + var _ma C.struct_miqt_array = C.QProcessEnvironment_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -192,7 +191,6 @@ func (this *QProcessEnvironment) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -311,7 +309,6 @@ func (this *QProcess) Start(program string, arguments []string) { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -321,8 +318,7 @@ func (this *QProcess) Start(program string, arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_Start(this.h, program_ms, arguments_ma) } @@ -362,7 +358,7 @@ func (this *QProcess) SetProgram(program string) { } func (this *QProcess) Arguments() []string { - var _ma *C.struct_miqt_array = C.QProcess_Arguments(this.h) + var _ma C.struct_miqt_array = C.QProcess_Arguments(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -371,12 +367,10 @@ func (this *QProcess) Arguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QProcess) SetArguments(arguments []string) { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -386,8 +380,7 @@ func (this *QProcess) SetArguments(arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_SetArguments(this.h, arguments_ma) } @@ -475,7 +468,6 @@ func (this *QProcess) SetWorkingDirectory(dir string) { } func (this *QProcess) SetEnvironment(environment []string) { - // For the C ABI, malloc a C array of structs environment_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(environment)))) defer C.free(unsafe.Pointer(environment_CArray)) for i := range environment { @@ -485,13 +477,12 @@ func (this *QProcess) SetEnvironment(environment []string) { defer C.free(unsafe.Pointer(environment_i_ms.data)) environment_CArray[i] = environment_i_ms } - environment_ma := &C.struct_miqt_array{len: C.size_t(len(environment)), data: unsafe.Pointer(environment_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(environment_ma)) + environment_ma := C.struct_miqt_array{len: C.size_t(len(environment)), data: unsafe.Pointer(environment_CArray)} C.QProcess_SetEnvironment(this.h, environment_ma) } func (this *QProcess) Environment() []string { - var _ma *C.struct_miqt_array = C.QProcess_Environment(this.h) + var _ma C.struct_miqt_array = C.QProcess_Environment(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -500,7 +491,6 @@ func (this *QProcess) Environment() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -602,7 +592,6 @@ func QProcess_Execute(program string, arguments []string) int { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -612,8 +601,7 @@ func QProcess_Execute(program string, arguments []string) int { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (int)(C.QProcess_Execute(program_ms, arguments_ma)) } @@ -630,7 +618,6 @@ func QProcess_StartDetached2(program string, arguments []string, workingDirector program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -640,8 +627,7 @@ func QProcess_StartDetached2(program string, arguments []string, workingDirector defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} workingDirectory_ms := C.struct_miqt_string{} workingDirectory_ms.data = C.CString(workingDirectory) workingDirectory_ms.len = C.size_t(len(workingDirectory)) @@ -654,7 +640,6 @@ func QProcess_StartDetached3(program string, arguments []string) bool { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -664,8 +649,7 @@ func QProcess_StartDetached3(program string, arguments []string) bool { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (bool)(C.QProcess_StartDetached3(program_ms, arguments_ma)) } @@ -678,7 +662,7 @@ func QProcess_StartDetachedWithCommand(command string) bool { } func QProcess_SystemEnvironment() []string { - var _ma *C.struct_miqt_array = C.QProcess_SystemEnvironment() + var _ma C.struct_miqt_array = C.QProcess_SystemEnvironment() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -687,7 +671,6 @@ func QProcess_SystemEnvironment() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -837,7 +820,6 @@ func (this *QProcess) Start3(program string, arguments []string, mode QIODevice_ program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -847,8 +829,7 @@ func (this *QProcess) Start3(program string, arguments []string, mode QIODevice_ defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_Start3(this.h, program_ms, arguments_ma, (C.int)(mode)) } @@ -909,7 +890,6 @@ func QProcess_StartDetached4(program string, arguments []string, workingDirector program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -919,8 +899,7 @@ func QProcess_StartDetached4(program string, arguments []string, workingDirector defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} workingDirectory_ms := C.struct_miqt_string{} workingDirectory_ms.data = C.CString(workingDirectory) workingDirectory_ms.len = C.size_t(len(workingDirectory)) diff --git a/qt/gen_qprocess.h b/qt/gen_qprocess.h index a963f752..5a5e7a25 100644 --- a/qt/gen_qprocess.h +++ b/qt/gen_qprocess.h @@ -39,8 +39,8 @@ bool QProcessEnvironment_Contains(const QProcessEnvironment* self, struct miqt_s void QProcessEnvironment_Insert(QProcessEnvironment* self, struct miqt_string name, struct miqt_string value); void QProcessEnvironment_Remove(QProcessEnvironment* self, struct miqt_string name); struct miqt_string QProcessEnvironment_Value(const QProcessEnvironment* self, struct miqt_string name); -struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* self); -struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self); +struct miqt_array QProcessEnvironment_ToStringList(const QProcessEnvironment* self); +struct miqt_array QProcessEnvironment_Keys(const QProcessEnvironment* self); void QProcessEnvironment_InsertWithQProcessEnvironment(QProcessEnvironment* self, QProcessEnvironment* e); QProcessEnvironment* QProcessEnvironment_SystemEnvironment(); struct miqt_string QProcessEnvironment_Value2(const QProcessEnvironment* self, struct miqt_string name, struct miqt_string defaultValue); @@ -52,15 +52,15 @@ QMetaObject* QProcess_MetaObject(const QProcess* self); void* QProcess_Metacast(QProcess* self, const char* param1); struct miqt_string QProcess_Tr(const char* s); struct miqt_string QProcess_TrUtf8(const char* s); -void QProcess_Start(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); +void QProcess_Start(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); void QProcess_StartWithCommand(QProcess* self, struct miqt_string command); void QProcess_Start2(QProcess* self); bool QProcess_StartDetached(QProcess* self); bool QProcess_Open(QProcess* self); struct miqt_string QProcess_Program(const QProcess* self); void QProcess_SetProgram(QProcess* self, struct miqt_string program); -struct miqt_array* QProcess_Arguments(const QProcess* self); -void QProcess_SetArguments(QProcess* self, struct miqt_array* /* of struct miqt_string */ arguments); +struct miqt_array QProcess_Arguments(const QProcess* self); +void QProcess_SetArguments(QProcess* self, struct miqt_array /* of struct miqt_string */ arguments); int QProcess_ReadChannelMode(const QProcess* self); void QProcess_SetReadChannelMode(QProcess* self, int mode); int QProcess_ProcessChannelMode(const QProcess* self); @@ -77,8 +77,8 @@ void QProcess_SetStandardErrorFile(QProcess* self, struct miqt_string fileName); void QProcess_SetStandardOutputProcess(QProcess* self, QProcess* destination); struct miqt_string QProcess_WorkingDirectory(const QProcess* self); void QProcess_SetWorkingDirectory(QProcess* self, struct miqt_string dir); -void QProcess_SetEnvironment(QProcess* self, struct miqt_array* /* of struct miqt_string */ environment); -struct miqt_array* QProcess_Environment(const QProcess* self); +void QProcess_SetEnvironment(QProcess* self, struct miqt_array /* of struct miqt_string */ environment); +struct miqt_array QProcess_Environment(const QProcess* self); void QProcess_SetProcessEnvironment(QProcess* self, QProcessEnvironment* environment); QProcessEnvironment* QProcess_ProcessEnvironment(const QProcess* self); int QProcess_Error(const QProcess* self); @@ -99,12 +99,12 @@ bool QProcess_IsSequential(const QProcess* self); bool QProcess_CanReadLine(const QProcess* self); void QProcess_Close(QProcess* self); bool QProcess_AtEnd(const QProcess* self); -int QProcess_Execute(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); +int QProcess_Execute(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); int QProcess_ExecuteWithCommand(struct miqt_string command); -bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory); -bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); +bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory); +bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); bool QProcess_StartDetachedWithCommand(struct miqt_string command); -struct miqt_array* QProcess_SystemEnvironment(); +struct miqt_array QProcess_SystemEnvironment(); struct miqt_string QProcess_NullDevice(); void QProcess_Terminate(QProcess* self); void QProcess_Kill(QProcess* self); @@ -120,7 +120,7 @@ struct miqt_string QProcess_Tr2(const char* s, const char* c); struct miqt_string QProcess_Tr3(const char* s, const char* c, int n); struct miqt_string QProcess_TrUtf82(const char* s, const char* c); struct miqt_string QProcess_TrUtf83(const char* s, const char* c, int n); -void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, int mode); +void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, int mode); void QProcess_Start22(QProcess* self, struct miqt_string command, int mode); void QProcess_Start1(QProcess* self, int mode); bool QProcess_StartDetached1(QProcess* self, long long* pid); @@ -131,7 +131,7 @@ bool QProcess_WaitForStarted1(QProcess* self, int msecs); bool QProcess_WaitForReadyRead1(QProcess* self, int msecs); bool QProcess_WaitForBytesWritten1(QProcess* self, int msecs); bool QProcess_WaitForFinished1(QProcess* self, int msecs); -bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid); +bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid); void QProcess_Delete(QProcess* self); #ifdef __cplusplus diff --git a/qt/gen_qrawfont.cpp b/qt/gen_qrawfont.cpp index d407d9d6..54557acb 100644 --- a/qt/gen_qrawfont.cpp +++ b/qt/gen_qrawfont.cpp @@ -94,7 +94,7 @@ int QRawFont_Weight(const QRawFont* self) { return self->weight(); } -struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text) { +struct miqt_array QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text) { QString text_QString = QString::fromUtf8(text.data, text.len); QVector _ret = self->glyphIndexesForString(text_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -102,17 +102,17 @@ struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct m for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes) { +struct miqt_array QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes) { QVector glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } QVector _ret = self->advancesForGlyphIndexes(glyphIndexes_QList); @@ -121,17 +121,17 @@ struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes, int layoutFlags) { +struct miqt_array QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes, int layoutFlags) { QVector glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } QVector _ret = self->advancesForGlyphIndexes(glyphIndexes_QList, static_cast(layoutFlags)); @@ -140,9 +140,9 @@ struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struc for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -252,7 +252,7 @@ bool QRawFont_SupportsCharacterWithCharacter(const QRawFont* self, QChar* charac return self->supportsCharacter(*character); } -struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self) { +struct miqt_array QRawFont_SupportedWritingSystems(const QRawFont* self) { QList _ret = self->supportedWritingSystems(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -260,9 +260,9 @@ struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self) { QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qrawfont.go b/qt/gen_qrawfont.go index 787c3090..80ef06f3 100644 --- a/qt/gen_qrawfont.go +++ b/qt/gen_qrawfont.go @@ -154,26 +154,23 @@ func (this *QRawFont) GlyphIndexesForString(text string) []uint { text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QRawFont_GlyphIndexesForString(this.h, text_ms) + var _ma C.struct_miqt_array = C.QRawFont_GlyphIndexesForString(this.h, text_ms) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QRawFont) AdvancesForGlyphIndexes(glyphIndexes []uint) []QPointF { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) - var _ma *C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes(this.h, glyphIndexes_ma) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} + var _ma C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes(this.h, glyphIndexes_ma) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -182,20 +179,17 @@ func (this *QRawFont) AdvancesForGlyphIndexes(glyphIndexes []uint) []QPointF { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QRawFont) AdvancesForGlyphIndexes2(glyphIndexes []uint, layoutFlags QRawFont__LayoutFlag) []QPointF { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) - var _ma *C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes2(this.h, glyphIndexes_ma, (C.int)(layoutFlags)) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} + var _ma C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes2(this.h, glyphIndexes_ma, (C.int)(layoutFlags)) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -204,7 +198,6 @@ func (this *QRawFont) AdvancesForGlyphIndexes2(glyphIndexes []uint, layoutFlags _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -317,13 +310,12 @@ func (this *QRawFont) SupportsCharacterWithCharacter(character QChar) bool { } func (this *QRawFont) SupportedWritingSystems() []QFontDatabase__WritingSystem { - var _ma *C.struct_miqt_array = C.QRawFont_SupportedWritingSystems(this.h) + var _ma C.struct_miqt_array = C.QRawFont_SupportedWritingSystems(this.h) _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qrawfont.h b/qt/gen_qrawfont.h index f9201f75..d13c72d4 100644 --- a/qt/gen_qrawfont.h +++ b/qt/gen_qrawfont.h @@ -50,9 +50,9 @@ struct miqt_string QRawFont_FamilyName(const QRawFont* self); struct miqt_string QRawFont_StyleName(const QRawFont* self); int QRawFont_Style(const QRawFont* self); int QRawFont_Weight(const QRawFont* self); -struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text); -struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes); -struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes, int layoutFlags); +struct miqt_array QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text); +struct miqt_array QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes); +struct miqt_array QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes, int layoutFlags); bool QRawFont_GlyphIndexesForChars(const QRawFont* self, QChar* chars, int numChars, unsigned int* glyphIndexes, int* numGlyphs); bool QRawFont_AdvancesForGlyphIndexes3(const QRawFont* self, const unsigned int* glyphIndexes, QPointF* advances, int numGlyphs); bool QRawFont_AdvancesForGlyphIndexes4(const QRawFont* self, const unsigned int* glyphIndexes, QPointF* advances, int numGlyphs, int layoutFlags); @@ -76,7 +76,7 @@ void QRawFont_LoadFromFile(QRawFont* self, struct miqt_string fileName, double p void QRawFont_LoadFromData(QRawFont* self, struct miqt_string fontData, double pixelSize, int hintingPreference); bool QRawFont_SupportsCharacter(const QRawFont* self, unsigned int ucs4); bool QRawFont_SupportsCharacterWithCharacter(const QRawFont* self, QChar* character); -struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self); +struct miqt_array QRawFont_SupportedWritingSystems(const QRawFont* self); struct miqt_string QRawFont_FontTable(const QRawFont* self, const char* tagName); QRawFont* QRawFont_FromFont(QFont* font); QImage* QRawFont_AlphaMapForGlyph2(const QRawFont* self, unsigned int glyphIndex, int antialiasingType); diff --git a/qt/gen_qregexp.cpp b/qt/gen_qregexp.cpp index ff311b09..85243281 100644 --- a/qt/gen_qregexp.cpp +++ b/qt/gen_qregexp.cpp @@ -119,7 +119,7 @@ int QRegExp_CaptureCount(const QRegExp* self) { return self->captureCount(); } -struct miqt_array* QRegExp_CapturedTexts(const QRegExp* self) { +struct miqt_array QRegExp_CapturedTexts(const QRegExp* self) { QStringList _ret = self->capturedTexts(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -133,13 +133,13 @@ struct miqt_array* QRegExp_CapturedTexts(const QRegExp* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QRegExp_CapturedTexts2(QRegExp* self) { +struct miqt_array QRegExp_CapturedTexts2(QRegExp* self) { QStringList _ret = self->capturedTexts(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -153,9 +153,9 @@ struct miqt_array* QRegExp_CapturedTexts2(QRegExp* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qregexp.go b/qt/gen_qregexp.go index 24a77780..7594a45c 100644 --- a/qt/gen_qregexp.go +++ b/qt/gen_qregexp.go @@ -199,7 +199,7 @@ func (this *QRegExp) CaptureCount() int { } func (this *QRegExp) CapturedTexts() []string { - var _ma *C.struct_miqt_array = C.QRegExp_CapturedTexts(this.h) + var _ma C.struct_miqt_array = C.QRegExp_CapturedTexts(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -208,12 +208,11 @@ func (this *QRegExp) CapturedTexts() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QRegExp) CapturedTexts2() []string { - var _ma *C.struct_miqt_array = C.QRegExp_CapturedTexts2(this.h) + var _ma C.struct_miqt_array = C.QRegExp_CapturedTexts2(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -222,7 +221,6 @@ func (this *QRegExp) CapturedTexts2() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qregexp.h b/qt/gen_qregexp.h index 1ade6b59..c9aef7a5 100644 --- a/qt/gen_qregexp.h +++ b/qt/gen_qregexp.h @@ -43,8 +43,8 @@ int QRegExp_IndexIn(const QRegExp* self, struct miqt_string str); int QRegExp_LastIndexIn(const QRegExp* self, struct miqt_string str); int QRegExp_MatchedLength(const QRegExp* self); int QRegExp_CaptureCount(const QRegExp* self); -struct miqt_array* QRegExp_CapturedTexts(const QRegExp* self); -struct miqt_array* QRegExp_CapturedTexts2(QRegExp* self); +struct miqt_array QRegExp_CapturedTexts(const QRegExp* self); +struct miqt_array QRegExp_CapturedTexts2(QRegExp* self); struct miqt_string QRegExp_Cap(const QRegExp* self); struct miqt_string QRegExp_Cap2(QRegExp* self); int QRegExp_Pos(const QRegExp* self); diff --git a/qt/gen_qregion.cpp b/qt/gen_qregion.cpp index e270240a..0b3e6b9c 100644 --- a/qt/gen_qregion.cpp +++ b/qt/gen_qregion.cpp @@ -131,16 +131,16 @@ QRect* QRegion_BoundingRect(const QRegion* self) { return new QRect(self->boundingRect()); } -struct miqt_array* QRegion_Rects(const QRegion* self) { +struct miqt_array QRegion_Rects(const QRegion* self) { QVector _ret = self->rects(); // Convert QList<> from C++ memory to manually-managed C memory QRect** _arr = static_cast(malloc(sizeof(QRect*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QRect(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qregion.go b/qt/gen_qregion.go index 73ea6198..388d46e7 100644 --- a/qt/gen_qregion.go +++ b/qt/gen_qregion.go @@ -211,7 +211,7 @@ func (this *QRegion) BoundingRect() *QRect { } func (this *QRegion) Rects() []QRect { - var _ma *C.struct_miqt_array = C.QRegion_Rects(this.h) + var _ma C.struct_miqt_array = C.QRegion_Rects(this.h) _ret := make([]QRect, int(_ma.len)) _outCast := (*[0xffff]*C.QRect)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -220,7 +220,6 @@ func (this *QRegion) Rects() []QRect { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qregion.h b/qt/gen_qregion.h index 4a6e25c7..cabf37c8 100644 --- a/qt/gen_qregion.h +++ b/qt/gen_qregion.h @@ -55,7 +55,7 @@ QRegion* QRegion_Xored(const QRegion* self, QRegion* r); bool QRegion_Intersects(const QRegion* self, QRegion* r); bool QRegion_IntersectsWithQRect(const QRegion* self, QRect* r); QRect* QRegion_BoundingRect(const QRegion* self); -struct miqt_array* QRegion_Rects(const QRegion* self); +struct miqt_array QRegion_Rects(const QRegion* self); void QRegion_SetRects(QRegion* self, QRect* rect, int num); int QRegion_RectCount(const QRegion* self); QRegion* QRegion_OperatorBitwiseOr(const QRegion* self, QRegion* r); diff --git a/qt/gen_qregularexpression.cpp b/qt/gen_qregularexpression.cpp index dbd513cf..85f6d76e 100644 --- a/qt/gen_qregularexpression.cpp +++ b/qt/gen_qregularexpression.cpp @@ -83,7 +83,7 @@ int QRegularExpression_CaptureCount(const QRegularExpression* self) { return self->captureCount(); } -struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpression* self) { +struct miqt_array QRegularExpression_NamedCaptureGroups(const QRegularExpression* self) { QStringList _ret = self->namedCaptureGroups(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -97,9 +97,9 @@ struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpressio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -264,7 +264,7 @@ struct miqt_string QRegularExpressionMatch_CapturedWithName(const QRegularExpres return _ms; } -struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self) { +struct miqt_array QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self) { QStringList _ret = self->capturedTexts(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -278,9 +278,9 @@ struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qregularexpression.go b/qt/gen_qregularexpression.go index 33c7d3ab..9aaf9e29 100644 --- a/qt/gen_qregularexpression.go +++ b/qt/gen_qregularexpression.go @@ -157,7 +157,7 @@ func (this *QRegularExpression) CaptureCount() int { } func (this *QRegularExpression) NamedCaptureGroups() []string { - var _ma *C.struct_miqt_array = C.QRegularExpression_NamedCaptureGroups(this.h) + var _ma C.struct_miqt_array = C.QRegularExpression_NamedCaptureGroups(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -166,7 +166,6 @@ func (this *QRegularExpression) NamedCaptureGroups() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -416,7 +415,7 @@ func (this *QRegularExpressionMatch) CapturedWithName(name string) string { } func (this *QRegularExpressionMatch) CapturedTexts() []string { - var _ma *C.struct_miqt_array = C.QRegularExpressionMatch_CapturedTexts(this.h) + var _ma C.struct_miqt_array = C.QRegularExpressionMatch_CapturedTexts(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -425,7 +424,6 @@ func (this *QRegularExpressionMatch) CapturedTexts() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qregularexpression.h b/qt/gen_qregularexpression.h index 8ecdd35f..f1ebcedf 100644 --- a/qt/gen_qregularexpression.h +++ b/qt/gen_qregularexpression.h @@ -37,7 +37,7 @@ bool QRegularExpression_IsValid(const QRegularExpression* self); int QRegularExpression_PatternErrorOffset(const QRegularExpression* self); struct miqt_string QRegularExpression_ErrorString(const QRegularExpression* self); int QRegularExpression_CaptureCount(const QRegularExpression* self); -struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpression* self); +struct miqt_array QRegularExpression_NamedCaptureGroups(const QRegularExpression* self); QRegularExpressionMatch* QRegularExpression_Match(const QRegularExpression* self, struct miqt_string subject); QRegularExpressionMatchIterator* QRegularExpression_GlobalMatch(const QRegularExpression* self, struct miqt_string subject); void QRegularExpression_Optimize(const QRegularExpression* self); @@ -67,7 +67,7 @@ bool QRegularExpressionMatch_IsValid(const QRegularExpressionMatch* self); int QRegularExpressionMatch_LastCapturedIndex(const QRegularExpressionMatch* self); struct miqt_string QRegularExpressionMatch_Captured(const QRegularExpressionMatch* self); struct miqt_string QRegularExpressionMatch_CapturedWithName(const QRegularExpressionMatch* self, struct miqt_string name); -struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self); +struct miqt_array QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self); int QRegularExpressionMatch_CapturedStart(const QRegularExpressionMatch* self); int QRegularExpressionMatch_CapturedLength(const QRegularExpressionMatch* self); int QRegularExpressionMatch_CapturedEnd(const QRegularExpressionMatch* self); diff --git a/qt/gen_qresource.cpp b/qt/gen_qresource.cpp index 7af01e56..6f121659 100644 --- a/qt/gen_qresource.cpp +++ b/qt/gen_qresource.cpp @@ -101,7 +101,7 @@ void QResource_AddSearchPath(struct miqt_string path) { QResource::addSearchPath(path_QString); } -struct miqt_array* QResource_SearchPaths() { +struct miqt_array QResource_SearchPaths() { QStringList _ret = QResource::searchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -115,9 +115,9 @@ struct miqt_array* QResource_SearchPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qresource.go b/qt/gen_qresource.go index 6e97fc83..477b17fe 100644 --- a/qt/gen_qresource.go +++ b/qt/gen_qresource.go @@ -152,7 +152,7 @@ func QResource_AddSearchPath(path string) { } func QResource_SearchPaths() []string { - var _ma *C.struct_miqt_array = C.QResource_SearchPaths() + var _ma C.struct_miqt_array = C.QResource_SearchPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -161,7 +161,6 @@ func QResource_SearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qresource.h b/qt/gen_qresource.h index 22582bb0..a8994545 100644 --- a/qt/gen_qresource.h +++ b/qt/gen_qresource.h @@ -41,7 +41,7 @@ long long QResource_UncompressedSize(const QResource* self); struct miqt_string QResource_UncompressedData(const QResource* self); QDateTime* QResource_LastModified(const QResource* self); void QResource_AddSearchPath(struct miqt_string path); -struct miqt_array* QResource_SearchPaths(); +struct miqt_array QResource_SearchPaths(); bool QResource_IsCompressed(const QResource* self); bool QResource_RegisterResource(struct miqt_string rccFilename); bool QResource_UnregisterResource(struct miqt_string rccFilename); diff --git a/qt/gen_qscreen.cpp b/qt/gen_qscreen.cpp index ce065ec7..f0a895dd 100644 --- a/qt/gen_qscreen.cpp +++ b/qt/gen_qscreen.cpp @@ -147,16 +147,16 @@ QRect* QScreen_AvailableGeometry(const QScreen* self) { return new QRect(self->availableGeometry()); } -struct miqt_array* QScreen_VirtualSiblings(const QScreen* self) { +struct miqt_array QScreen_VirtualSiblings(const QScreen* self) { QList _ret = self->virtualSiblings(); // Convert QList<> from C++ memory to manually-managed C memory QScreen** _arr = static_cast(malloc(sizeof(QScreen*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qscreen.go b/qt/gen_qscreen.go index 0d15dc04..ed26e7fe 100644 --- a/qt/gen_qscreen.go +++ b/qt/gen_qscreen.go @@ -168,13 +168,12 @@ func (this *QScreen) AvailableGeometry() *QRect { } func (this *QScreen) VirtualSiblings() []*QScreen { - var _ma *C.struct_miqt_array = C.QScreen_VirtualSiblings(this.h) + var _ma C.struct_miqt_array = C.QScreen_VirtualSiblings(this.h) _ret := make([]*QScreen, int(_ma.len)) _outCast := (*[0xffff]*C.QScreen)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScreen(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qscreen.h b/qt/gen_qscreen.h index 96846c69..8f165630 100644 --- a/qt/gen_qscreen.h +++ b/qt/gen_qscreen.h @@ -54,7 +54,7 @@ double QScreen_LogicalDotsPerInch(const QScreen* self); double QScreen_DevicePixelRatio(const QScreen* self); QSize* QScreen_AvailableSize(const QScreen* self); QRect* QScreen_AvailableGeometry(const QScreen* self); -struct miqt_array* QScreen_VirtualSiblings(const QScreen* self); +struct miqt_array QScreen_VirtualSiblings(const QScreen* self); QScreen* QScreen_VirtualSiblingAt(QScreen* self, QPoint* point); QSize* QScreen_VirtualSize(const QScreen* self); QRect* QScreen_VirtualGeometry(const QScreen* self); diff --git a/qt/gen_qscroller.cpp b/qt/gen_qscroller.cpp index 82fbdc3a..018fcb67 100644 --- a/qt/gen_qscroller.cpp +++ b/qt/gen_qscroller.cpp @@ -68,16 +68,16 @@ void QScroller_UngrabGesture(QObject* target) { QScroller::ungrabGesture(target); } -struct miqt_array* QScroller_ActiveScrollers() { +struct miqt_array QScroller_ActiveScrollers() { QList _ret = QScroller::activeScrollers(); // Convert QList<> from C++ memory to manually-managed C memory QScroller** _arr = static_cast(malloc(sizeof(QScroller*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -114,11 +114,11 @@ QScrollerProperties* QScroller_ScrollerProperties(const QScroller* self) { return new QScrollerProperties(self->scrollerProperties()); } -void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array* /* of double */ positions) { +void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array /* of double */ positions) { QList positions_QList; - positions_QList.reserve(positions->len); - double* positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + double* positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(static_cast(positions_arr[i])); } self->setSnapPositionsX(positions_QList); @@ -128,11 +128,11 @@ void QScroller_SetSnapPositionsX2(QScroller* self, double first, double interval self->setSnapPositionsX(static_cast(first), static_cast(interval)); } -void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array* /* of double */ positions) { +void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array /* of double */ positions) { QList positions_QList; - positions_QList.reserve(positions->len); - double* positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + double* positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(static_cast(positions_arr[i])); } self->setSnapPositionsY(positions_QList); diff --git a/qt/gen_qscroller.go b/qt/gen_qscroller.go index d7fee1e7..32b2da10 100644 --- a/qt/gen_qscroller.go +++ b/qt/gen_qscroller.go @@ -9,7 +9,6 @@ package qt import "C" import ( - "runtime" "runtime/cgo" "unsafe" ) @@ -123,13 +122,12 @@ func QScroller_UngrabGesture(target *QObject) { } func QScroller_ActiveScrollers() []*QScroller { - var _ma *C.struct_miqt_array = C.QScroller_ActiveScrollers() + var _ma C.struct_miqt_array = C.QScroller_ActiveScrollers() _ret := make([]*QScroller, int(_ma.len)) _outCast := (*[0xffff]*C.QScroller)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScroller(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -178,14 +176,12 @@ func (this *QScroller) ScrollerProperties() *QScrollerProperties { } func (this *QScroller) SetSnapPositionsX(positions []float64) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = (C.double)(positions[i]) } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QScroller_SetSnapPositionsX(this.h, positions_ma) } @@ -194,14 +190,12 @@ func (this *QScroller) SetSnapPositionsX2(first float64, interval float64) { } func (this *QScroller) SetSnapPositionsY(positions []float64) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = (C.double)(positions[i]) } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QScroller_SetSnapPositionsY(this.h, positions_ma) } diff --git a/qt/gen_qscroller.h b/qt/gen_qscroller.h index 82eb523f..cfb737c4 100644 --- a/qt/gen_qscroller.h +++ b/qt/gen_qscroller.h @@ -39,7 +39,7 @@ QScroller* QScroller_ScrollerWithTarget(QObject* target); int QScroller_GrabGesture(QObject* target); int QScroller_GrabbedGesture(QObject* target); void QScroller_UngrabGesture(QObject* target); -struct miqt_array* QScroller_ActiveScrollers(); +struct miqt_array QScroller_ActiveScrollers(); QObject* QScroller_Target(const QScroller* self); int QScroller_State(const QScroller* self); bool QScroller_HandleInput(QScroller* self, int input, QPointF* position); @@ -48,9 +48,9 @@ QPointF* QScroller_Velocity(const QScroller* self); QPointF* QScroller_FinalPosition(const QScroller* self); QPointF* QScroller_PixelPerMeter(const QScroller* self); QScrollerProperties* QScroller_ScrollerProperties(const QScroller* self); -void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array* /* of double */ positions); +void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array /* of double */ positions); void QScroller_SetSnapPositionsX2(QScroller* self, double first, double interval); -void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array* /* of double */ positions); +void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array /* of double */ positions); void QScroller_SetSnapPositionsY2(QScroller* self, double first, double interval); void QScroller_SetScrollerProperties(QScroller* self, QScrollerProperties* prop); void QScroller_ScrollTo(QScroller* self, QPointF* pos); diff --git a/qt/gen_qsessionmanager.cpp b/qt/gen_qsessionmanager.cpp index 8b3c0ceb..67600341 100644 --- a/qt/gen_qsessionmanager.cpp +++ b/qt/gen_qsessionmanager.cpp @@ -85,18 +85,18 @@ int QSessionManager_RestartHint(const QSessionManager* self) { return static_cast(_ret); } -void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ restartCommand) { +void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ restartCommand) { QStringList restartCommand_QList; - restartCommand_QList.reserve(restartCommand->len); - struct miqt_string* restartCommand_arr = static_cast(restartCommand->data); - for(size_t i = 0; i < restartCommand->len; ++i) { + restartCommand_QList.reserve(restartCommand.len); + struct miqt_string* restartCommand_arr = static_cast(restartCommand.data); + for(size_t i = 0; i < restartCommand.len; ++i) { QString restartCommand_arr_i_QString = QString::fromUtf8(restartCommand_arr[i].data, restartCommand_arr[i].len); restartCommand_QList.push_back(restartCommand_arr_i_QString); } self->setRestartCommand(restartCommand_QList); } -struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self) { +struct miqt_array QSessionManager_RestartCommand(const QSessionManager* self) { QStringList _ret = self->restartCommand(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -110,24 +110,24 @@ struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ discardCommand) { +void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ discardCommand) { QStringList discardCommand_QList; - discardCommand_QList.reserve(discardCommand->len); - struct miqt_string* discardCommand_arr = static_cast(discardCommand->data); - for(size_t i = 0; i < discardCommand->len; ++i) { + discardCommand_QList.reserve(discardCommand.len); + struct miqt_string* discardCommand_arr = static_cast(discardCommand.data); + for(size_t i = 0; i < discardCommand.len; ++i) { QString discardCommand_arr_i_QString = QString::fromUtf8(discardCommand_arr[i].data, discardCommand_arr[i].len); discardCommand_QList.push_back(discardCommand_arr_i_QString); } self->setDiscardCommand(discardCommand_QList); } -struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self) { +struct miqt_array QSessionManager_DiscardCommand(const QSessionManager* self) { QStringList _ret = self->discardCommand(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -141,9 +141,9 @@ struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -153,12 +153,12 @@ void QSessionManager_SetManagerProperty(QSessionManager* self, struct miqt_strin self->setManagerProperty(name_QString, value_QString); } -void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array* /* of struct miqt_string */ value) { +void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array /* of struct miqt_string */ value) { QString name_QString = QString::fromUtf8(name.data, name.len); QStringList value_QList; - value_QList.reserve(value->len); - struct miqt_string* value_arr = static_cast(value->data); - for(size_t i = 0; i < value->len; ++i) { + value_QList.reserve(value.len); + struct miqt_string* value_arr = static_cast(value.data); + for(size_t i = 0; i < value.len; ++i) { QString value_arr_i_QString = QString::fromUtf8(value_arr[i].data, value_arr[i].len); value_QList.push_back(value_arr_i_QString); } diff --git a/qt/gen_qsessionmanager.go b/qt/gen_qsessionmanager.go index e188d832..e40eb4bf 100644 --- a/qt/gen_qsessionmanager.go +++ b/qt/gen_qsessionmanager.go @@ -9,7 +9,6 @@ package qt import "C" import ( - "runtime" "unsafe" ) @@ -119,7 +118,6 @@ func (this *QSessionManager) RestartHint() QSessionManager__RestartHint { } func (this *QSessionManager) SetRestartCommand(restartCommand []string) { - // For the C ABI, malloc a C array of structs restartCommand_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(restartCommand)))) defer C.free(unsafe.Pointer(restartCommand_CArray)) for i := range restartCommand { @@ -129,13 +127,12 @@ func (this *QSessionManager) SetRestartCommand(restartCommand []string) { defer C.free(unsafe.Pointer(restartCommand_i_ms.data)) restartCommand_CArray[i] = restartCommand_i_ms } - restartCommand_ma := &C.struct_miqt_array{len: C.size_t(len(restartCommand)), data: unsafe.Pointer(restartCommand_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(restartCommand_ma)) + restartCommand_ma := C.struct_miqt_array{len: C.size_t(len(restartCommand)), data: unsafe.Pointer(restartCommand_CArray)} C.QSessionManager_SetRestartCommand(this.h, restartCommand_ma) } func (this *QSessionManager) RestartCommand() []string { - var _ma *C.struct_miqt_array = C.QSessionManager_RestartCommand(this.h) + var _ma C.struct_miqt_array = C.QSessionManager_RestartCommand(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -144,12 +141,10 @@ func (this *QSessionManager) RestartCommand() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSessionManager) SetDiscardCommand(discardCommand []string) { - // For the C ABI, malloc a C array of structs discardCommand_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(discardCommand)))) defer C.free(unsafe.Pointer(discardCommand_CArray)) for i := range discardCommand { @@ -159,13 +154,12 @@ func (this *QSessionManager) SetDiscardCommand(discardCommand []string) { defer C.free(unsafe.Pointer(discardCommand_i_ms.data)) discardCommand_CArray[i] = discardCommand_i_ms } - discardCommand_ma := &C.struct_miqt_array{len: C.size_t(len(discardCommand)), data: unsafe.Pointer(discardCommand_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(discardCommand_ma)) + discardCommand_ma := C.struct_miqt_array{len: C.size_t(len(discardCommand)), data: unsafe.Pointer(discardCommand_CArray)} C.QSessionManager_SetDiscardCommand(this.h, discardCommand_ma) } func (this *QSessionManager) DiscardCommand() []string { - var _ma *C.struct_miqt_array = C.QSessionManager_DiscardCommand(this.h) + var _ma C.struct_miqt_array = C.QSessionManager_DiscardCommand(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -174,7 +168,6 @@ func (this *QSessionManager) DiscardCommand() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -195,7 +188,6 @@ func (this *QSessionManager) SetManagerProperty2(name string, value []string) { name_ms.data = C.CString(name) name_ms.len = C.size_t(len(name)) defer C.free(unsafe.Pointer(name_ms.data)) - // For the C ABI, malloc a C array of structs value_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(value)))) defer C.free(unsafe.Pointer(value_CArray)) for i := range value { @@ -205,8 +197,7 @@ func (this *QSessionManager) SetManagerProperty2(name string, value []string) { defer C.free(unsafe.Pointer(value_i_ms.data)) value_CArray[i] = value_i_ms } - value_ma := &C.struct_miqt_array{len: C.size_t(len(value)), data: unsafe.Pointer(value_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(value_ma)) + value_ma := C.struct_miqt_array{len: C.size_t(len(value)), data: unsafe.Pointer(value_CArray)} C.QSessionManager_SetManagerProperty2(this.h, name_ms, value_ma) } diff --git a/qt/gen_qsessionmanager.h b/qt/gen_qsessionmanager.h index 01fc3639..b59a0a81 100644 --- a/qt/gen_qsessionmanager.h +++ b/qt/gen_qsessionmanager.h @@ -33,12 +33,12 @@ void QSessionManager_Release(QSessionManager* self); void QSessionManager_Cancel(QSessionManager* self); void QSessionManager_SetRestartHint(QSessionManager* self, int restartHint); int QSessionManager_RestartHint(const QSessionManager* self); -void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ restartCommand); -struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self); -void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ discardCommand); -struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self); +void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ restartCommand); +struct miqt_array QSessionManager_RestartCommand(const QSessionManager* self); +void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ discardCommand); +struct miqt_array QSessionManager_DiscardCommand(const QSessionManager* self); void QSessionManager_SetManagerProperty(QSessionManager* self, struct miqt_string name, struct miqt_string value); -void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array* /* of struct miqt_string */ value); +void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array /* of struct miqt_string */ value); bool QSessionManager_IsPhase2(const QSessionManager* self); void QSessionManager_RequestPhase2(QSessionManager* self); struct miqt_string QSessionManager_Tr2(const char* s, const char* c); diff --git a/qt/gen_qsettings.cpp b/qt/gen_qsettings.cpp index a84f45cf..f99f40b1 100644 --- a/qt/gen_qsettings.cpp +++ b/qt/gen_qsettings.cpp @@ -177,7 +177,7 @@ void QSettings_SetArrayIndex(QSettings* self, int i) { self->setArrayIndex(static_cast(i)); } -struct miqt_array* QSettings_AllKeys(const QSettings* self) { +struct miqt_array QSettings_AllKeys(const QSettings* self) { QStringList _ret = self->allKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -191,13 +191,13 @@ struct miqt_array* QSettings_AllKeys(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSettings_ChildKeys(const QSettings* self) { +struct miqt_array QSettings_ChildKeys(const QSettings* self) { QStringList _ret = self->childKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -211,13 +211,13 @@ struct miqt_array* QSettings_ChildKeys(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSettings_ChildGroups(const QSettings* self) { +struct miqt_array QSettings_ChildGroups(const QSettings* self) { QStringList _ret = self->childGroups(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -231,9 +231,9 @@ struct miqt_array* QSettings_ChildGroups(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qsettings.go b/qt/gen_qsettings.go index 7e1e5895..240f5cca 100644 --- a/qt/gen_qsettings.go +++ b/qt/gen_qsettings.go @@ -332,7 +332,7 @@ func (this *QSettings) SetArrayIndex(i int) { } func (this *QSettings) AllKeys() []string { - var _ma *C.struct_miqt_array = C.QSettings_AllKeys(this.h) + var _ma C.struct_miqt_array = C.QSettings_AllKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -341,12 +341,11 @@ func (this *QSettings) AllKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSettings) ChildKeys() []string { - var _ma *C.struct_miqt_array = C.QSettings_ChildKeys(this.h) + var _ma C.struct_miqt_array = C.QSettings_ChildKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -355,12 +354,11 @@ func (this *QSettings) ChildKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSettings) ChildGroups() []string { - var _ma *C.struct_miqt_array = C.QSettings_ChildGroups(this.h) + var _ma C.struct_miqt_array = C.QSettings_ChildGroups(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -369,7 +367,6 @@ func (this *QSettings) ChildGroups() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qsettings.h b/qt/gen_qsettings.h index cd9fcc2b..1d5c35ab 100644 --- a/qt/gen_qsettings.h +++ b/qt/gen_qsettings.h @@ -58,9 +58,9 @@ int QSettings_BeginReadArray(QSettings* self, struct miqt_string prefix); void QSettings_BeginWriteArray(QSettings* self, struct miqt_string prefix); void QSettings_EndArray(QSettings* self); void QSettings_SetArrayIndex(QSettings* self, int i); -struct miqt_array* QSettings_AllKeys(const QSettings* self); -struct miqt_array* QSettings_ChildKeys(const QSettings* self); -struct miqt_array* QSettings_ChildGroups(const QSettings* self); +struct miqt_array QSettings_AllKeys(const QSettings* self); +struct miqt_array QSettings_ChildKeys(const QSettings* self); +struct miqt_array QSettings_ChildGroups(const QSettings* self); bool QSettings_IsWritable(const QSettings* self); void QSettings_SetValue(QSettings* self, struct miqt_string key, QVariant* value); QVariant* QSettings_Value(const QSettings* self, struct miqt_string key); diff --git a/qt/gen_qsortfilterproxymodel.cpp b/qt/gen_qsortfilterproxymodel.cpp index 3f233c30..eb03ccf2 100644 --- a/qt/gen_qsortfilterproxymodel.cpp +++ b/qt/gen_qsortfilterproxymodel.cpp @@ -225,11 +225,11 @@ bool QSortFilterProxyModel_SetHeaderData(QSortFilterProxyModel* self, int sectio return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } -QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -272,16 +272,16 @@ QModelIndex* QSortFilterProxyModel_Buddy(const QSortFilterProxyModel* self, QMod return new QModelIndex(self->buddy(*index)); } -struct miqt_array* QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -293,7 +293,7 @@ void QSortFilterProxyModel_Sort(QSortFilterProxyModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self) { +struct miqt_array QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -307,9 +307,9 @@ struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -489,29 +489,29 @@ bool QSortFilterProxyModel_RemoveColumns3(QSortFilterProxyModel* self, int colum return self->removeColumns(static_cast(column), static_cast(count), *parent); } -struct miqt_array* QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qsortfilterproxymodel.go b/qt/gen_qsortfilterproxymodel.go index d5392867..385842f5 100644 --- a/qt/gen_qsortfilterproxymodel.go +++ b/qt/gen_qsortfilterproxymodel.go @@ -292,14 +292,12 @@ func (this *QSortFilterProxyModel) SetHeaderData(section int, orientation Orient } func (this *QSortFilterProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QSortFilterProxyModel_MimeData(this.h, indexes_ma))) } @@ -343,7 +341,7 @@ func (this *QSortFilterProxyModel) Buddy(index *QModelIndex) *QModelIndex { } func (this *QSortFilterProxyModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -352,7 +350,6 @@ func (this *QSortFilterProxyModel) Match(start *QModelIndex, role int, value *QV _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -368,7 +365,7 @@ func (this *QSortFilterProxyModel) Sort(column int) { } func (this *QSortFilterProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -377,7 +374,6 @@ func (this *QSortFilterProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -627,7 +623,7 @@ func (this *QSortFilterProxyModel) RemoveColumns3(column int, count int, parent } func (this *QSortFilterProxyModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -636,12 +632,11 @@ func (this *QSortFilterProxyModel) Match4(start *QModelIndex, role int, value *Q _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSortFilterProxyModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -650,7 +645,6 @@ func (this *QSortFilterProxyModel) Match5(start *QModelIndex, role int, value *Q _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qsortfilterproxymodel.h b/qt/gen_qsortfilterproxymodel.h index b847ee56..42a2988d 100644 --- a/qt/gen_qsortfilterproxymodel.h +++ b/qt/gen_qsortfilterproxymodel.h @@ -84,7 +84,7 @@ QVariant* QSortFilterProxyModel_Data(const QSortFilterProxyModel* self, QModelIn bool QSortFilterProxyModel_SetData(QSortFilterProxyModel* self, QModelIndex* index, QVariant* value); QVariant* QSortFilterProxyModel_HeaderData(const QSortFilterProxyModel* self, int section, int orientation); bool QSortFilterProxyModel_SetHeaderData(QSortFilterProxyModel* self, int section, int orientation, QVariant* value); -QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QSortFilterProxyModel_DropMimeData(QSortFilterProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QSortFilterProxyModel_InsertRows(QSortFilterProxyModel* self, int row, int count); bool QSortFilterProxyModel_InsertColumns(QSortFilterProxyModel* self, int column, int count); @@ -94,10 +94,10 @@ void QSortFilterProxyModel_FetchMore(QSortFilterProxyModel* self, QModelIndex* p bool QSortFilterProxyModel_CanFetchMore(const QSortFilterProxyModel* self, QModelIndex* parent); int QSortFilterProxyModel_Flags(const QSortFilterProxyModel* self, QModelIndex* index); QModelIndex* QSortFilterProxyModel_Buddy(const QSortFilterProxyModel* self, QModelIndex* index); -struct miqt_array* QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value); QSize* QSortFilterProxyModel_Span(const QSortFilterProxyModel* self, QModelIndex* index); void QSortFilterProxyModel_Sort(QSortFilterProxyModel* self, int column); -struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self); +struct miqt_array QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self); int QSortFilterProxyModel_SupportedDropActions(const QSortFilterProxyModel* self); void QSortFilterProxyModel_DynamicSortFilterChanged(QSortFilterProxyModel* self, bool dynamicSortFilter); void QSortFilterProxyModel_connect_DynamicSortFilterChanged(QSortFilterProxyModel* self, intptr_t slot); @@ -129,8 +129,8 @@ bool QSortFilterProxyModel_InsertRows3(QSortFilterProxyModel* self, int row, int bool QSortFilterProxyModel_InsertColumns3(QSortFilterProxyModel* self, int column, int count, QModelIndex* parent); bool QSortFilterProxyModel_RemoveRows3(QSortFilterProxyModel* self, int row, int count, QModelIndex* parent); bool QSortFilterProxyModel_RemoveColumns3(QSortFilterProxyModel* self, int column, int count, QModelIndex* parent); -struct miqt_array* QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); void QSortFilterProxyModel_Sort2(QSortFilterProxyModel* self, int column, int order); void QSortFilterProxyModel_Delete(QSortFilterProxyModel* self); diff --git a/qt/gen_qsplitter.cpp b/qt/gen_qsplitter.cpp index fc8ed166..c98ba072 100644 --- a/qt/gen_qsplitter.cpp +++ b/qt/gen_qsplitter.cpp @@ -115,24 +115,24 @@ QSize* QSplitter_MinimumSizeHint(const QSplitter* self) { return new QSize(self->minimumSizeHint()); } -struct miqt_array* QSplitter_Sizes(const QSplitter* self) { +struct miqt_array QSplitter_Sizes(const QSplitter* self) { QList _ret = self->sizes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QSplitter_SetSizes(QSplitter* self, struct miqt_array* /* of int */ list) { +void QSplitter_SetSizes(QSplitter* self, struct miqt_array /* of int */ list) { QList list_QList; - list_QList.reserve(list->len); - int* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + int* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(static_cast(list_arr[i])); } self->setSizes(list_QList); diff --git a/qt/gen_qsplitter.go b/qt/gen_qsplitter.go index 8f5d4672..6f52f31d 100644 --- a/qt/gen_qsplitter.go +++ b/qt/gen_qsplitter.go @@ -159,25 +159,22 @@ func (this *QSplitter) MinimumSizeHint() *QSize { } func (this *QSplitter) Sizes() []int { - var _ma *C.struct_miqt_array = C.QSplitter_Sizes(this.h) + var _ma C.struct_miqt_array = C.QSplitter_Sizes(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSplitter) SetSizes(list []int) { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = (C.int)(list[i]) } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QSplitter_SetSizes(this.h, list_ma) } diff --git a/qt/gen_qsplitter.h b/qt/gen_qsplitter.h index d28e15e5..098b14e4 100644 --- a/qt/gen_qsplitter.h +++ b/qt/gen_qsplitter.h @@ -51,8 +51,8 @@ bool QSplitter_OpaqueResize(const QSplitter* self); void QSplitter_Refresh(QSplitter* self); QSize* QSplitter_SizeHint(const QSplitter* self); QSize* QSplitter_MinimumSizeHint(const QSplitter* self); -struct miqt_array* QSplitter_Sizes(const QSplitter* self); -void QSplitter_SetSizes(QSplitter* self, struct miqt_array* /* of int */ list); +struct miqt_array QSplitter_Sizes(const QSplitter* self); +void QSplitter_SetSizes(QSplitter* self, struct miqt_array /* of int */ list); struct miqt_string QSplitter_SaveState(const QSplitter* self); bool QSplitter_RestoreState(QSplitter* self, struct miqt_string state); int QSplitter_HandleWidth(const QSplitter* self); diff --git a/qt/gen_qstandarditemmodel.cpp b/qt/gen_qstandarditemmodel.cpp index 300a694f..ceb4465d 100644 --- a/qt/gen_qstandarditemmodel.cpp +++ b/qt/gen_qstandarditemmodel.cpp @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -339,31 +341,31 @@ void QStandardItem_SetChild2(QStandardItem* self, int row, QStandardItem* item) self->setChild(static_cast(row), item); } -void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRow(static_cast(row), items_QList); } -void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertColumn(static_cast(column), items_QList); } -void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRows(static_cast(row), items_QList); @@ -393,31 +395,31 @@ void QStandardItem_RemoveColumns(QStandardItem* self, int column, int count) { self->removeColumns(static_cast(column), static_cast(count)); } -void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRow(items_QList); } -void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRows(items_QList); } -void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendColumn(items_QList); @@ -435,29 +437,29 @@ QStandardItem* QStandardItem_TakeChild(QStandardItem* self, int row) { return self->takeChild(static_cast(row)); } -struct miqt_array* QStandardItem_TakeRow(QStandardItem* self, int row) { +struct miqt_array QStandardItem_TakeRow(QStandardItem* self, int row) { QList _ret = self->takeRow(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItem_TakeColumn(QStandardItem* self, int column) { +struct miqt_array QStandardItem_TakeColumn(QStandardItem* self, int column) { QList _ret = self->takeColumn(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -555,6 +557,18 @@ struct miqt_string QStandardItemModel_TrUtf8(const char* s) { return _ms; } +void QStandardItemModel_SetItemRoleNames(QStandardItemModel* self, struct miqt_map roleNames) { + QHash roleNames_QMap; + roleNames_QMap.reserve(roleNames.len); + int* roleNames_karr = static_cast(roleNames.keys); + struct miqt_string* roleNames_varr = static_cast(roleNames.values); + for(size_t i = 0; i < roleNames.len; ++i) { + QByteArray roleNames_varr_i_QByteArray(roleNames_varr[i].data, roleNames_varr[i].len); + roleNames_QMap[static_cast(roleNames_karr[i])] = roleNames_varr_i_QByteArray; + } + self->setItemRoleNames(roleNames_QMap); +} + QModelIndex* QStandardItemModel_Index(const QStandardItemModel* self, int row, int column) { return new QModelIndex(self->index(static_cast(row), static_cast(column))); } @@ -625,6 +639,34 @@ int QStandardItemModel_SupportedDropActions(const QStandardItemModel* self) { return static_cast(_ret); } +struct miqt_map QStandardItemModel_ItemData(const QStandardItemModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QStandardItemModel_SetItemData(QStandardItemModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + void QStandardItemModel_Clear(QStandardItemModel* self) { self->clear(); } @@ -673,22 +715,22 @@ void QStandardItemModel_SetVerticalHeaderItem(QStandardItemModel* self, int row, self->setVerticalHeaderItem(static_cast(row), item); } -void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } self->setHorizontalHeaderLabels(labels_QList); } -void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -703,21 +745,21 @@ void QStandardItemModel_SetColumnCount(QStandardItemModel* self, int columns) { self->setColumnCount(static_cast(columns)); } -void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRow(items_QList); } -void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendColumn(items_QList); @@ -727,21 +769,21 @@ void QStandardItemModel_AppendRowWithItem(QStandardItemModel* self, QStandardIte self->appendRow(item); } -void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRow(static_cast(row), items_QList); } -void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertColumn(static_cast(column), items_QList); @@ -763,29 +805,29 @@ QStandardItem* QStandardItemModel_TakeItem(QStandardItemModel* self, int row) { return self->takeItem(static_cast(row)); } -struct miqt_array* QStandardItemModel_TakeRow(QStandardItemModel* self, int row) { +struct miqt_array QStandardItemModel_TakeRow(QStandardItemModel* self, int row) { QList _ret = self->takeRow(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItemModel_TakeColumn(QStandardItemModel* self, int column) { +struct miqt_array QStandardItemModel_TakeColumn(QStandardItemModel* self, int column) { QList _ret = self->takeColumn(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -805,7 +847,7 @@ void QStandardItemModel_SetItemPrototype(QStandardItemModel* self, QStandardItem self->setItemPrototype(item); } -struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text) { +struct miqt_array QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -813,9 +855,9 @@ struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -827,7 +869,7 @@ void QStandardItemModel_SetSortRole(QStandardItemModel* self, int role) { self->setSortRole(static_cast(role)); } -struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self) { +struct miqt_array QStandardItemModel_MimeTypes(const QStandardItemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -841,17 +883,17 @@ struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -984,7 +1026,7 @@ QStandardItem* QStandardItemModel_TakeItem2(QStandardItemModel* self, int row, i return self->takeItem(static_cast(row), static_cast(column)); } -struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags) { +struct miqt_array QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -992,13 +1034,13 @@ struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column) { +struct miqt_array QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags), static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory @@ -1006,9 +1048,9 @@ struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstandarditemmodel.go b/qt/gen_qstandarditemmodel.go index 58c4ffb9..0585eebc 100644 --- a/qt/gen_qstandarditemmodel.go +++ b/qt/gen_qstandarditemmodel.go @@ -400,38 +400,32 @@ func (this *QStandardItem) SetChild2(row int, item *QStandardItem) { } func (this *QStandardItem) InsertRow(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertRow(this.h, (C.int)(row), items_ma) } func (this *QStandardItem) InsertColumn(column int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertColumn(this.h, (C.int)(column), items_ma) } func (this *QStandardItem) InsertRows(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertRows(this.h, (C.int)(row), items_ma) } @@ -460,38 +454,32 @@ func (this *QStandardItem) RemoveColumns(column int, count int) { } func (this *QStandardItem) AppendRow(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendRow(this.h, items_ma) } func (this *QStandardItem) AppendRows(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendRows(this.h, items_ma) } func (this *QStandardItem) AppendColumn(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendColumn(this.h, items_ma) } @@ -508,24 +496,22 @@ func (this *QStandardItem) TakeChild(row int) *QStandardItem { } func (this *QStandardItem) TakeRow(row int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItem_TakeRow(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QStandardItem_TakeRow(this.h, (C.int)(row)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItem) TakeColumn(column int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItem_TakeColumn(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItem_TakeColumn(this.h, (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -672,6 +658,28 @@ func QStandardItemModel_TrUtf8(s string) string { return _ret } +func (this *QStandardItemModel) SetItemRoleNames(roleNames map[int][]byte) { + roleNames_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roleNames)))) + defer C.free(unsafe.Pointer(roleNames_Keys_CArray)) + roleNames_Values_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(roleNames)))) + defer C.free(unsafe.Pointer(roleNames_Values_CArray)) + roleNames_ctr := 0 + for roleNames_k, roleNames_v := range roleNames { + roleNames_Keys_CArray[roleNames_ctr] = (C.int)(roleNames_k) + roleNames_v_alias := C.struct_miqt_string{} + roleNames_v_alias.data = (*C.char)(unsafe.Pointer(&roleNames_v[0])) + roleNames_v_alias.len = C.size_t(len(roleNames_v)) + roleNames_Values_CArray[roleNames_ctr] = roleNames_v_alias + roleNames_ctr++ + } + roleNames_mm := C.struct_miqt_map{ + len: C.size_t(len(roleNames)), + keys: unsafe.Pointer(roleNames_Keys_CArray), + values: unsafe.Pointer(roleNames_Values_CArray), + } + C.QStandardItemModel_SetItemRoleNames(this.h, roleNames_mm) +} + func (this *QStandardItemModel) Index(row int, column int) *QModelIndex { _ret := C.QStandardItemModel_Index(this.h, (C.int)(row), (C.int)(column)) _goptr := newQModelIndex(_ret) @@ -755,6 +763,43 @@ func (this *QStandardItemModel) SupportedDropActions() DropAction { return (DropAction)(C.QStandardItemModel_SupportedDropActions(this.h)) } +func (this *QStandardItemModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QStandardItemModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QStandardItemModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QStandardItemModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QStandardItemModel) Clear() { C.QStandardItemModel_Clear(this.h) } @@ -807,7 +852,6 @@ func (this *QStandardItemModel) SetVerticalHeaderItem(row int, item *QStandardIt } func (this *QStandardItemModel) SetHorizontalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -817,13 +861,11 @@ func (this *QStandardItemModel) SetHorizontalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QStandardItemModel_SetHorizontalHeaderLabels(this.h, labels_ma) } func (this *QStandardItemModel) SetVerticalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -833,8 +875,7 @@ func (this *QStandardItemModel) SetVerticalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QStandardItemModel_SetVerticalHeaderLabels(this.h, labels_ma) } @@ -847,26 +888,22 @@ func (this *QStandardItemModel) SetColumnCount(columns int) { } func (this *QStandardItemModel) AppendRow(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_AppendRow(this.h, items_ma) } func (this *QStandardItemModel) AppendColumn(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_AppendColumn(this.h, items_ma) } @@ -875,26 +912,22 @@ func (this *QStandardItemModel) AppendRowWithItem(item *QStandardItem) { } func (this *QStandardItemModel) InsertRow(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_InsertRow(this.h, (C.int)(row), items_ma) } func (this *QStandardItemModel) InsertColumn(column int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_InsertColumn(this.h, (C.int)(column), items_ma) } @@ -915,24 +948,22 @@ func (this *QStandardItemModel) TakeItem(row int) *QStandardItem { } func (this *QStandardItemModel) TakeRow(row int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItemModel_TakeRow(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QStandardItemModel_TakeRow(this.h, (C.int)(row)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItemModel) TakeColumn(column int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItemModel_TakeColumn(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItemModel_TakeColumn(this.h, (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -957,13 +988,12 @@ func (this *QStandardItemModel) FindItems(text string) []*QStandardItem { text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems(this.h, text_ms) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems(this.h, text_ms) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -976,7 +1006,7 @@ func (this *QStandardItemModel) SetSortRole(role int) { } func (this *QStandardItemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QStandardItemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QStandardItemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -985,19 +1015,16 @@ func (this *QStandardItemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QStandardItemModel_MimeData(this.h, indexes_ma))) } @@ -1151,13 +1178,12 @@ func (this *QStandardItemModel) FindItems2(text string, flags MatchFlag) []*QSta text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems2(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems2(this.h, text_ms, (C.int)(flags)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1166,13 +1192,12 @@ func (this *QStandardItemModel) FindItems3(text string, flags MatchFlag, column text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstandarditemmodel.h b/qt/gen_qstandarditemmodel.h index 079d8d89..a91cadf4 100644 --- a/qt/gen_qstandarditemmodel.h +++ b/qt/gen_qstandarditemmodel.h @@ -15,6 +15,7 @@ extern "C" { #ifdef __cplusplus class QBrush; +class QByteArray; class QDataStream; class QFont; class QIcon; @@ -28,6 +29,7 @@ class QStandardItemModel; class QVariant; #else typedef struct QBrush QBrush; +typedef struct QByteArray QByteArray; typedef struct QDataStream QDataStream; typedef struct QFont QFont; typedef struct QIcon QIcon; @@ -108,23 +110,23 @@ bool QStandardItem_HasChildren(const QStandardItem* self); QStandardItem* QStandardItem_Child(const QStandardItem* self, int row); void QStandardItem_SetChild(QStandardItem* self, int row, int column, QStandardItem* item); void QStandardItem_SetChild2(QStandardItem* self, int row, QStandardItem* item); -void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items); void QStandardItem_InsertRows2(QStandardItem* self, int row, int count); void QStandardItem_InsertColumns(QStandardItem* self, int column, int count); void QStandardItem_RemoveRow(QStandardItem* self, int row); void QStandardItem_RemoveColumn(QStandardItem* self, int column); void QStandardItem_RemoveRows(QStandardItem* self, int row, int count); void QStandardItem_RemoveColumns(QStandardItem* self, int column, int count); -void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); void QStandardItem_InsertRow2(QStandardItem* self, int row, QStandardItem* item); void QStandardItem_AppendRowWithItem(QStandardItem* self, QStandardItem* item); QStandardItem* QStandardItem_TakeChild(QStandardItem* self, int row); -struct miqt_array* QStandardItem_TakeRow(QStandardItem* self, int row); -struct miqt_array* QStandardItem_TakeColumn(QStandardItem* self, int column); +struct miqt_array QStandardItem_TakeRow(QStandardItem* self, int row); +struct miqt_array QStandardItem_TakeColumn(QStandardItem* self, int column); void QStandardItem_SortChildren(QStandardItem* self, int column); QStandardItem* QStandardItem_Clone(const QStandardItem* self); int QStandardItem_Type(const QStandardItem* self); @@ -146,6 +148,7 @@ QMetaObject* QStandardItemModel_MetaObject(const QStandardItemModel* self); void* QStandardItemModel_Metacast(QStandardItemModel* self, const char* param1); struct miqt_string QStandardItemModel_Tr(const char* s); struct miqt_string QStandardItemModel_TrUtf8(const char* s); +void QStandardItemModel_SetItemRoleNames(QStandardItemModel* self, struct miqt_map roleNames); QModelIndex* QStandardItemModel_Index(const QStandardItemModel* self, int row, int column); QModelIndex* QStandardItemModel_Parent(const QStandardItemModel* self, QModelIndex* child); int QStandardItemModel_RowCount(const QStandardItemModel* self); @@ -163,6 +166,8 @@ bool QStandardItemModel_RemoveRows(QStandardItemModel* self, int row, int count) bool QStandardItemModel_RemoveColumns(QStandardItemModel* self, int column, int count); int QStandardItemModel_Flags(const QStandardItemModel* self, QModelIndex* index); int QStandardItemModel_SupportedDropActions(const QStandardItemModel* self); +struct miqt_map QStandardItemModel_ItemData(const QStandardItemModel* self, QModelIndex* index); +bool QStandardItemModel_SetItemData(QStandardItemModel* self, QModelIndex* index, struct miqt_map roles); void QStandardItemModel_Clear(QStandardItemModel* self); void QStandardItemModel_Sort(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_ItemFromIndex(const QStandardItemModel* self, QModelIndex* index); @@ -175,30 +180,30 @@ QStandardItem* QStandardItemModel_HorizontalHeaderItem(const QStandardItemModel* void QStandardItemModel_SetHorizontalHeaderItem(QStandardItemModel* self, int column, QStandardItem* item); QStandardItem* QStandardItemModel_VerticalHeaderItem(const QStandardItemModel* self, int row); void QStandardItemModel_SetVerticalHeaderItem(QStandardItemModel* self, int row, QStandardItem* item); -void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels); -void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels); +void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels); +void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels); void QStandardItemModel_SetRowCount(QStandardItemModel* self, int rows); void QStandardItemModel_SetColumnCount(QStandardItemModel* self, int columns); -void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items); void QStandardItemModel_AppendRowWithItem(QStandardItemModel* self, QStandardItem* item); -void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array /* of QStandardItem* */ items); +void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array /* of QStandardItem* */ items); void QStandardItemModel_InsertRow2(QStandardItemModel* self, int row, QStandardItem* item); bool QStandardItemModel_InsertRowWithRow(QStandardItemModel* self, int row); bool QStandardItemModel_InsertColumnWithColumn(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeItem(QStandardItemModel* self, int row); -struct miqt_array* QStandardItemModel_TakeRow(QStandardItemModel* self, int row); -struct miqt_array* QStandardItemModel_TakeColumn(QStandardItemModel* self, int column); +struct miqt_array QStandardItemModel_TakeRow(QStandardItemModel* self, int row); +struct miqt_array QStandardItemModel_TakeColumn(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeHorizontalHeaderItem(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeVerticalHeaderItem(QStandardItemModel* self, int row); QStandardItem* QStandardItemModel_ItemPrototype(const QStandardItemModel* self); void QStandardItemModel_SetItemPrototype(QStandardItemModel* self, QStandardItem* item); -struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text); +struct miqt_array QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text); int QStandardItemModel_SortRole(const QStandardItemModel* self); void QStandardItemModel_SetSortRole(QStandardItemModel* self, int role); -struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self); -QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QStandardItemModel_MimeTypes(const QStandardItemModel* self); +QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QStandardItemModel_DropMimeData(QStandardItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); void QStandardItemModel_ItemChanged(QStandardItemModel* self, QStandardItem* item); void QStandardItemModel_connect_ItemChanged(QStandardItemModel* self, intptr_t slot); @@ -223,8 +228,8 @@ QStandardItem* QStandardItemModel_Item2(const QStandardItemModel* self, int row, bool QStandardItemModel_InsertRow22(QStandardItemModel* self, int row, QModelIndex* parent); bool QStandardItemModel_InsertColumn2(QStandardItemModel* self, int column, QModelIndex* parent); QStandardItem* QStandardItemModel_TakeItem2(QStandardItemModel* self, int row, int column); -struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags); -struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column); +struct miqt_array QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags); +struct miqt_array QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column); void QStandardItemModel_Delete(QStandardItemModel* self); #ifdef __cplusplus diff --git a/qt/gen_qstandardpaths.cpp b/qt/gen_qstandardpaths.cpp index 542e5785..7f72f56e 100644 --- a/qt/gen_qstandardpaths.cpp +++ b/qt/gen_qstandardpaths.cpp @@ -18,7 +18,7 @@ struct miqt_string QStandardPaths_WritableLocation(int typeVal) { return _ms; } -struct miqt_array* QStandardPaths_StandardLocations(int typeVal) { +struct miqt_array QStandardPaths_StandardLocations(int typeVal) { QStringList _ret = QStandardPaths::standardLocations(static_cast(typeVal)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -32,9 +32,9 @@ struct miqt_array* QStandardPaths_StandardLocations(int typeVal) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -50,7 +50,7 @@ struct miqt_string QStandardPaths_Locate(int typeVal, struct miqt_string fileNam return _ms; } -struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName) { +struct miqt_array QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QStringList _ret = QStandardPaths::locateAll(static_cast(typeVal), fileName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -65,9 +65,9 @@ struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string file memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -118,7 +118,7 @@ struct miqt_string QStandardPaths_Locate3(int typeVal, struct miqt_string fileNa return _ms; } -struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options) { +struct miqt_array QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QStringList _ret = QStandardPaths::locateAll(static_cast(typeVal), fileName_QString, static_cast(options)); // Convert QList<> from C++ memory to manually-managed C memory @@ -133,18 +133,18 @@ struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fil memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array* /* of struct miqt_string */ paths) { +struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array /* of struct miqt_string */ paths) { QString executableName_QString = QString::fromUtf8(executableName.data, executableName.len); QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } diff --git a/qt/gen_qstandardpaths.go b/qt/gen_qstandardpaths.go index 6837d1b6..823c3ced 100644 --- a/qt/gen_qstandardpaths.go +++ b/qt/gen_qstandardpaths.go @@ -9,7 +9,6 @@ package qt import "C" import ( - "runtime" "unsafe" ) @@ -82,7 +81,7 @@ func QStandardPaths_WritableLocation(typeVal QStandardPaths__StandardLocation) s } func QStandardPaths_StandardLocations(typeVal QStandardPaths__StandardLocation) []string { - var _ma *C.struct_miqt_array = C.QStandardPaths_StandardLocations((C.int)(typeVal)) + var _ma C.struct_miqt_array = C.QStandardPaths_StandardLocations((C.int)(typeVal)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -91,7 +90,6 @@ func QStandardPaths_StandardLocations(typeVal QStandardPaths__StandardLocation) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -111,7 +109,7 @@ func QStandardPaths_LocateAll(typeVal QStandardPaths__StandardLocation, fileName fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardPaths_LocateAll((C.int)(typeVal), fileName_ms) + var _ma C.struct_miqt_array = C.QStandardPaths_LocateAll((C.int)(typeVal), fileName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -120,7 +118,6 @@ func QStandardPaths_LocateAll(typeVal QStandardPaths__StandardLocation, fileName C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -170,7 +167,7 @@ func QStandardPaths_LocateAll3(typeVal QStandardPaths__StandardLocation, fileNam fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardPaths_LocateAll3((C.int)(typeVal), fileName_ms, (C.int)(options)) + var _ma C.struct_miqt_array = C.QStandardPaths_LocateAll3((C.int)(typeVal), fileName_ms, (C.int)(options)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -179,7 +176,6 @@ func QStandardPaths_LocateAll3(typeVal QStandardPaths__StandardLocation, fileNam C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -188,7 +184,6 @@ func QStandardPaths_FindExecutable2(executableName string, paths []string) strin executableName_ms.data = C.CString(executableName) executableName_ms.len = C.size_t(len(executableName)) defer C.free(unsafe.Pointer(executableName_ms.data)) - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -198,8 +193,7 @@ func QStandardPaths_FindExecutable2(executableName string, paths []string) strin defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} var _ms C.struct_miqt_string = C.QStandardPaths_FindExecutable2(executableName_ms, paths_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt/gen_qstandardpaths.h b/qt/gen_qstandardpaths.h index 173736fa..0258fd06 100644 --- a/qt/gen_qstandardpaths.h +++ b/qt/gen_qstandardpaths.h @@ -20,17 +20,17 @@ typedef struct QStandardPaths QStandardPaths; #endif struct miqt_string QStandardPaths_WritableLocation(int typeVal); -struct miqt_array* QStandardPaths_StandardLocations(int typeVal); +struct miqt_array QStandardPaths_StandardLocations(int typeVal); struct miqt_string QStandardPaths_Locate(int typeVal, struct miqt_string fileName); -struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName); +struct miqt_array QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName); struct miqt_string QStandardPaths_DisplayName(int typeVal); struct miqt_string QStandardPaths_FindExecutable(struct miqt_string executableName); void QStandardPaths_EnableTestMode(bool testMode); void QStandardPaths_SetTestModeEnabled(bool testMode); bool QStandardPaths_IsTestModeEnabled(); struct miqt_string QStandardPaths_Locate3(int typeVal, struct miqt_string fileName, int options); -struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options); -struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options); +struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array /* of struct miqt_string */ paths); #ifdef __cplusplus } /* extern C */ diff --git a/qt/gen_qstate.cpp b/qt/gen_qstate.cpp index d8c873ba..08b172cc 100644 --- a/qt/gen_qstate.cpp +++ b/qt/gen_qstate.cpp @@ -83,16 +83,16 @@ void QState_RemoveTransition(QState* self, QAbstractTransition* transition) { self->removeTransition(transition); } -struct miqt_array* QState_Transitions(const QState* self) { +struct miqt_array QState_Transitions(const QState* self) { QList _ret = self->transitions(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractTransition** _arr = static_cast(malloc(sizeof(QAbstractTransition*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstate.go b/qt/gen_qstate.go index a33e55d3..ceab4c1b 100644 --- a/qt/gen_qstate.go +++ b/qt/gen_qstate.go @@ -136,13 +136,12 @@ func (this *QState) RemoveTransition(transition *QAbstractTransition) { } func (this *QState) Transitions() []*QAbstractTransition { - var _ma *C.struct_miqt_array = C.QState_Transitions(this.h) + var _ma C.struct_miqt_array = C.QState_Transitions(this.h) _ret := make([]*QAbstractTransition, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractTransition)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractTransition(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstate.h b/qt/gen_qstate.h index a0005833..8436979e 100644 --- a/qt/gen_qstate.h +++ b/qt/gen_qstate.h @@ -45,7 +45,7 @@ void QState_AddTransition(QState* self, QAbstractTransition* transition); QSignalTransition* QState_AddTransition2(QState* self, QObject* sender, const char* signal, QAbstractState* target); QAbstractTransition* QState_AddTransitionWithTarget(QState* self, QAbstractState* target); void QState_RemoveTransition(QState* self, QAbstractTransition* transition); -struct miqt_array* QState_Transitions(const QState* self); +struct miqt_array QState_Transitions(const QState* self); QAbstractState* QState_InitialState(const QState* self); void QState_SetInitialState(QState* self, QAbstractState* state); int QState_ChildMode(const QState* self); diff --git a/qt/gen_qstatemachine.cpp b/qt/gen_qstatemachine.cpp index 6e241b10..f0c81f7f 100644 --- a/qt/gen_qstatemachine.cpp +++ b/qt/gen_qstatemachine.cpp @@ -104,16 +104,16 @@ void QStateMachine_AddDefaultAnimation(QStateMachine* self, QAbstractAnimation* self->addDefaultAnimation(animation); } -struct miqt_array* QStateMachine_DefaultAnimations(const QStateMachine* self) { +struct miqt_array QStateMachine_DefaultAnimations(const QStateMachine* self) { QList _ret = self->defaultAnimations(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractAnimation** _arr = static_cast(malloc(sizeof(QAbstractAnimation*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -142,7 +142,7 @@ bool QStateMachine_CancelDelayedEvent(QStateMachine* self, int id) { return self->cancelDelayedEvent(static_cast(id)); } -struct miqt_array* QStateMachine_Configuration(const QStateMachine* self) { +struct miqt_array QStateMachine_Configuration(const QStateMachine* self) { QSet _ret = self->configuration(); // Convert QSet<> from C++ memory to manually-managed C memory QAbstractState** _arr = static_cast(malloc(sizeof(QAbstractState*) * _ret.size())); @@ -151,9 +151,9 @@ struct miqt_array* QStateMachine_Configuration(const QStateMachine* self) { while (_itr.hasNext()) { _arr[_ctr++] = _itr.next(); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.size(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.size(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstatemachine.go b/qt/gen_qstatemachine.go index d3c37c9b..6e99ff55 100644 --- a/qt/gen_qstatemachine.go +++ b/qt/gen_qstatemachine.go @@ -153,13 +153,12 @@ func (this *QStateMachine) AddDefaultAnimation(animation *QAbstractAnimation) { } func (this *QStateMachine) DefaultAnimations() []*QAbstractAnimation { - var _ma *C.struct_miqt_array = C.QStateMachine_DefaultAnimations(this.h) + var _ma C.struct_miqt_array = C.QStateMachine_DefaultAnimations(this.h) _ret := make([]*QAbstractAnimation, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractAnimation)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractAnimation(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -188,14 +187,13 @@ func (this *QStateMachine) CancelDelayedEvent(id int) bool { } func (this *QStateMachine) Configuration() map[*QAbstractState]struct{} { - var _ma *C.struct_miqt_array = C.QStateMachine_Configuration(this.h) + var _ma C.struct_miqt_array = C.QStateMachine_Configuration(this.h) _ret := make(map[*QAbstractState]struct{}, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractState)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _element := UnsafeNewQAbstractState(unsafe.Pointer(_outCast[i])) _ret[_element] = struct{}{} } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstatemachine.h b/qt/gen_qstatemachine.h index a0017fb6..88963d89 100644 --- a/qt/gen_qstatemachine.h +++ b/qt/gen_qstatemachine.h @@ -58,14 +58,14 @@ bool QStateMachine_IsRunning(const QStateMachine* self); bool QStateMachine_IsAnimated(const QStateMachine* self); void QStateMachine_SetAnimated(QStateMachine* self, bool enabled); void QStateMachine_AddDefaultAnimation(QStateMachine* self, QAbstractAnimation* animation); -struct miqt_array* QStateMachine_DefaultAnimations(const QStateMachine* self); +struct miqt_array QStateMachine_DefaultAnimations(const QStateMachine* self); void QStateMachine_RemoveDefaultAnimation(QStateMachine* self, QAbstractAnimation* animation); int QStateMachine_GlobalRestorePolicy(const QStateMachine* self); void QStateMachine_SetGlobalRestorePolicy(QStateMachine* self, int restorePolicy); void QStateMachine_PostEvent(QStateMachine* self, QEvent* event); int QStateMachine_PostDelayedEvent(QStateMachine* self, QEvent* event, int delay); bool QStateMachine_CancelDelayedEvent(QStateMachine* self, int id); -struct miqt_array* QStateMachine_Configuration(const QStateMachine* self); +struct miqt_array QStateMachine_Configuration(const QStateMachine* self); bool QStateMachine_EventFilter(QStateMachine* self, QObject* watched, QEvent* event); void QStateMachine_Start(QStateMachine* self); void QStateMachine_Stop(QStateMachine* self); diff --git a/qt/gen_qstorageinfo.cpp b/qt/gen_qstorageinfo.cpp index 4da16e0b..b5f91814 100644 --- a/qt/gen_qstorageinfo.cpp +++ b/qt/gen_qstorageinfo.cpp @@ -138,16 +138,16 @@ void QStorageInfo_Refresh(QStorageInfo* self) { self->refresh(); } -struct miqt_array* QStorageInfo_MountedVolumes() { +struct miqt_array QStorageInfo_MountedVolumes() { QList _ret = QStorageInfo::mountedVolumes(); // Convert QList<> from C++ memory to manually-managed C memory QStorageInfo** _arr = static_cast(malloc(sizeof(QStorageInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QStorageInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstorageinfo.go b/qt/gen_qstorageinfo.go index 029433ba..9916859c 100644 --- a/qt/gen_qstorageinfo.go +++ b/qt/gen_qstorageinfo.go @@ -165,7 +165,7 @@ func (this *QStorageInfo) Refresh() { } func QStorageInfo_MountedVolumes() []QStorageInfo { - var _ma *C.struct_miqt_array = C.QStorageInfo_MountedVolumes() + var _ma C.struct_miqt_array = C.QStorageInfo_MountedVolumes() _ret := make([]QStorageInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QStorageInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -174,7 +174,6 @@ func QStorageInfo_MountedVolumes() []QStorageInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstorageinfo.h b/qt/gen_qstorageinfo.h index c1eb70bc..03ebafa5 100644 --- a/qt/gen_qstorageinfo.h +++ b/qt/gen_qstorageinfo.h @@ -45,7 +45,7 @@ bool QStorageInfo_IsReadOnly(const QStorageInfo* self); bool QStorageInfo_IsReady(const QStorageInfo* self); bool QStorageInfo_IsValid(const QStorageInfo* self); void QStorageInfo_Refresh(QStorageInfo* self); -struct miqt_array* QStorageInfo_MountedVolumes(); +struct miqt_array QStorageInfo_MountedVolumes(); QStorageInfo* QStorageInfo_Root(); void QStorageInfo_Delete(QStorageInfo* self); diff --git a/qt/gen_qstringlistmodel.cpp b/qt/gen_qstringlistmodel.cpp index 34557f54..89d45c01 100644 --- a/qt/gen_qstringlistmodel.cpp +++ b/qt/gen_qstringlistmodel.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -15,11 +16,11 @@ QStringListModel* QStringListModel_new() { return new QStringListModel(); } -QStringListModel* QStringListModel_new2(struct miqt_array* /* of struct miqt_string */ strings) { +QStringListModel* QStringListModel_new2(struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -30,11 +31,11 @@ QStringListModel* QStringListModel_new3(QObject* parent) { return new QStringListModel(parent); } -QStringListModel* QStringListModel_new4(struct miqt_array* /* of struct miqt_string */ strings, QObject* parent) { +QStringListModel* QStringListModel_new4(struct miqt_array /* of struct miqt_string */ strings, QObject* parent) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -104,11 +105,39 @@ bool QStringListModel_MoveRows(QStringListModel* self, QModelIndex* sourceParent return self->moveRows(*sourceParent, static_cast(sourceRow), static_cast(count), *destinationParent, static_cast(destinationChild)); } +struct miqt_map QStringListModel_ItemData(const QStringListModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QStringListModel_SetItemData(QStringListModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + void QStringListModel_Sort(QStringListModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QStringListModel_StringList(const QStringListModel* self) { +struct miqt_array QStringListModel_StringList(const QStringListModel* self) { QStringList _ret = self->stringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -122,17 +151,17 @@ struct miqt_array* QStringListModel_StringList(const QStringListModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array* /* of struct miqt_string */ strings) { +void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } diff --git a/qt/gen_qstringlistmodel.go b/qt/gen_qstringlistmodel.go index e8a8cd92..2ac209a2 100644 --- a/qt/gen_qstringlistmodel.go +++ b/qt/gen_qstringlistmodel.go @@ -51,7 +51,6 @@ func NewQStringListModel() *QStringListModel { // NewQStringListModel2 constructs a new QStringListModel object. func NewQStringListModel2(strings []string) *QStringListModel { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -61,8 +60,7 @@ func NewQStringListModel2(strings []string) *QStringListModel { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QStringListModel_new2(strings_ma) return newQStringListModel(ret) } @@ -75,7 +73,6 @@ func NewQStringListModel3(parent *QObject) *QStringListModel { // NewQStringListModel4 constructs a new QStringListModel object. func NewQStringListModel4(strings []string, parent *QObject) *QStringListModel { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -85,8 +82,7 @@ func NewQStringListModel4(strings []string, parent *QObject) *QStringListModel { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QStringListModel_new4(strings_ma, parent.cPointer()) return newQStringListModel(ret) } @@ -157,12 +153,49 @@ func (this *QStringListModel) MoveRows(sourceParent *QModelIndex, sourceRow int, return (bool)(C.QStringListModel_MoveRows(this.h, sourceParent.cPointer(), (C.int)(sourceRow), (C.int)(count), destinationParent.cPointer(), (C.int)(destinationChild))) } +func (this *QStringListModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QStringListModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QStringListModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QStringListModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QStringListModel) Sort(column int) { C.QStringListModel_Sort(this.h, (C.int)(column)) } func (this *QStringListModel) StringList() []string { - var _ma *C.struct_miqt_array = C.QStringListModel_StringList(this.h) + var _ma C.struct_miqt_array = C.QStringListModel_StringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -171,12 +204,10 @@ func (this *QStringListModel) StringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStringListModel) SetStringList(strings []string) { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -186,8 +217,7 @@ func (this *QStringListModel) SetStringList(strings []string) { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} C.QStringListModel_SetStringList(this.h, strings_ma) } diff --git a/qt/gen_qstringlistmodel.h b/qt/gen_qstringlistmodel.h index 6f1cc072..5ed490ad 100644 --- a/qt/gen_qstringlistmodel.h +++ b/qt/gen_qstringlistmodel.h @@ -28,9 +28,9 @@ typedef struct QVariant QVariant; #endif QStringListModel* QStringListModel_new(); -QStringListModel* QStringListModel_new2(struct miqt_array* /* of struct miqt_string */ strings); +QStringListModel* QStringListModel_new2(struct miqt_array /* of struct miqt_string */ strings); QStringListModel* QStringListModel_new3(QObject* parent); -QStringListModel* QStringListModel_new4(struct miqt_array* /* of struct miqt_string */ strings, QObject* parent); +QStringListModel* QStringListModel_new4(struct miqt_array /* of struct miqt_string */ strings, QObject* parent); QMetaObject* QStringListModel_MetaObject(const QStringListModel* self); void* QStringListModel_Metacast(QStringListModel* self, const char* param1); struct miqt_string QStringListModel_Tr(const char* s); @@ -43,9 +43,11 @@ int QStringListModel_Flags(const QStringListModel* self, QModelIndex* index); bool QStringListModel_InsertRows(QStringListModel* self, int row, int count); bool QStringListModel_RemoveRows(QStringListModel* self, int row, int count); bool QStringListModel_MoveRows(QStringListModel* self, QModelIndex* sourceParent, int sourceRow, int count, QModelIndex* destinationParent, int destinationChild); +struct miqt_map QStringListModel_ItemData(const QStringListModel* self, QModelIndex* index); +bool QStringListModel_SetItemData(QStringListModel* self, QModelIndex* index, struct miqt_map roles); void QStringListModel_Sort(QStringListModel* self, int column); -struct miqt_array* QStringListModel_StringList(const QStringListModel* self); -void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array* /* of struct miqt_string */ strings); +struct miqt_array QStringListModel_StringList(const QStringListModel* self); +void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array /* of struct miqt_string */ strings); int QStringListModel_SupportedDropActions(const QStringListModel* self); struct miqt_string QStringListModel_Tr2(const char* s, const char* c); struct miqt_string QStringListModel_Tr3(const char* s, const char* c, int n); diff --git a/qt/gen_qstringview.cpp b/qt/gen_qstringview.cpp index 12ab4d4d..1feee5af 100644 --- a/qt/gen_qstringview.cpp +++ b/qt/gen_qstringview.cpp @@ -65,16 +65,16 @@ struct miqt_string QStringView_ToLocal8Bit(const QStringView* self) { return _ms; } -struct miqt_array* QStringView_ToUcs4(const QStringView* self) { +struct miqt_array QStringView_ToUcs4(const QStringView* self) { QVector _ret = self->toUcs4(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstringview.go b/qt/gen_qstringview.go index 8a6c2599..47d9e04e 100644 --- a/qt/gen_qstringview.go +++ b/qt/gen_qstringview.go @@ -92,13 +92,12 @@ func (this *QStringView) ToLocal8Bit() []byte { } func (this *QStringView) ToUcs4() []uint { - var _ma *C.struct_miqt_array = C.QStringView_ToUcs4(this.h) + var _ma C.struct_miqt_array = C.QStringView_ToUcs4(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstringview.h b/qt/gen_qstringview.h index 90827339..9c27b89c 100644 --- a/qt/gen_qstringview.h +++ b/qt/gen_qstringview.h @@ -31,7 +31,7 @@ QChar* QStringView_OperatorSubscript(const QStringView* self, ptrdiff_t n); struct miqt_string QStringView_ToLatin1(const QStringView* self); struct miqt_string QStringView_ToUtf8(const QStringView* self); struct miqt_string QStringView_ToLocal8Bit(const QStringView* self); -struct miqt_array* QStringView_ToUcs4(const QStringView* self); +struct miqt_array QStringView_ToUcs4(const QStringView* self); QChar* QStringView_At(const QStringView* self, ptrdiff_t n); void QStringView_Truncate(QStringView* self, ptrdiff_t n); void QStringView_Chop(QStringView* self, ptrdiff_t n); diff --git a/qt/gen_qstylefactory.cpp b/qt/gen_qstylefactory.cpp index 799aee8a..2a4035f8 100644 --- a/qt/gen_qstylefactory.cpp +++ b/qt/gen_qstylefactory.cpp @@ -8,7 +8,7 @@ #include "gen_qstylefactory.h" #include "_cgo_export.h" -struct miqt_array* QStyleFactory_Keys() { +struct miqt_array QStyleFactory_Keys() { QStringList _ret = QStyleFactory::keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -22,9 +22,9 @@ struct miqt_array* QStyleFactory_Keys() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qstylefactory.go b/qt/gen_qstylefactory.go index a41e7ca4..dc8ab470 100644 --- a/qt/gen_qstylefactory.go +++ b/qt/gen_qstylefactory.go @@ -43,7 +43,7 @@ func UnsafeNewQStyleFactory(h unsafe.Pointer) *QStyleFactory { } func QStyleFactory_Keys() []string { - var _ma *C.struct_miqt_array = C.QStyleFactory_Keys() + var _ma C.struct_miqt_array = C.QStyleFactory_Keys() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func QStyleFactory_Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qstylefactory.h b/qt/gen_qstylefactory.h index 609ea164..4e0ef7c7 100644 --- a/qt/gen_qstylefactory.h +++ b/qt/gen_qstylefactory.h @@ -21,7 +21,7 @@ typedef struct QStyle QStyle; typedef struct QStyleFactory QStyleFactory; #endif -struct miqt_array* QStyleFactory_Keys(); +struct miqt_array QStyleFactory_Keys(); QStyle* QStyleFactory_Create(struct miqt_string param1); void QStyleFactory_Delete(QStyleFactory* self); diff --git a/qt/gen_qtablewidget.cpp b/qt/gen_qtablewidget.cpp index 85a76c44..c9a841e3 100644 --- a/qt/gen_qtablewidget.cpp +++ b/qt/gen_qtablewidget.cpp @@ -404,22 +404,22 @@ QTableWidgetItem* QTableWidget_TakeHorizontalHeaderItem(QTableWidget* self, int return self->takeHorizontalHeaderItem(static_cast(column)); } -void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } self->setVerticalHeaderLabels(labels_QList); } -void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -506,33 +506,33 @@ void QTableWidget_SetRangeSelected(QTableWidget* self, QTableWidgetSelectionRang self->setRangeSelected(*rangeVal, selectVal); } -struct miqt_array* QTableWidget_SelectedRanges(const QTableWidget* self) { +struct miqt_array QTableWidget_SelectedRanges(const QTableWidget* self) { QList _ret = self->selectedRanges(); // Convert QList<> from C++ memory to manually-managed C memory QTableWidgetSelectionRange** _arr = static_cast(malloc(sizeof(QTableWidgetSelectionRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTableWidgetSelectionRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTableWidget_SelectedItems(const QTableWidget* self) { +struct miqt_array QTableWidget_SelectedItems(const QTableWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QTableWidgetItem** _arr = static_cast(malloc(sizeof(QTableWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags) { +struct miqt_array QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -540,9 +540,9 @@ struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_ for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtablewidget.go b/qt/gen_qtablewidget.go index 0288da6a..a545afe5 100644 --- a/qt/gen_qtablewidget.go +++ b/qt/gen_qtablewidget.go @@ -570,7 +570,6 @@ func (this *QTableWidget) TakeHorizontalHeaderItem(column int) *QTableWidgetItem } func (this *QTableWidget) SetVerticalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -580,13 +579,11 @@ func (this *QTableWidget) SetVerticalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTableWidget_SetVerticalHeaderLabels(this.h, labels_ma) } func (this *QTableWidget) SetHorizontalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -596,8 +593,7 @@ func (this *QTableWidget) SetHorizontalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTableWidget_SetHorizontalHeaderLabels(this.h, labels_ma) } @@ -682,7 +678,7 @@ func (this *QTableWidget) SetRangeSelected(rangeVal *QTableWidgetSelectionRange, } func (this *QTableWidget) SelectedRanges() []QTableWidgetSelectionRange { - var _ma *C.struct_miqt_array = C.QTableWidget_SelectedRanges(this.h) + var _ma C.struct_miqt_array = C.QTableWidget_SelectedRanges(this.h) _ret := make([]QTableWidgetSelectionRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetSelectionRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -691,18 +687,16 @@ func (this *QTableWidget) SelectedRanges() []QTableWidgetSelectionRange { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTableWidget) SelectedItems() []*QTableWidgetItem { - var _ma *C.struct_miqt_array = C.QTableWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QTableWidget_SelectedItems(this.h) _ret := make([]*QTableWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTableWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -711,13 +705,12 @@ func (this *QTableWidget) FindItems(text string, flags MatchFlag) []*QTableWidge text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTableWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QTableWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QTableWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTableWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtablewidget.h b/qt/gen_qtablewidget.h index de78fa51..022e0e78 100644 --- a/qt/gen_qtablewidget.h +++ b/qt/gen_qtablewidget.h @@ -130,8 +130,8 @@ QTableWidgetItem* QTableWidget_TakeVerticalHeaderItem(QTableWidget* self, int ro QTableWidgetItem* QTableWidget_HorizontalHeaderItem(const QTableWidget* self, int column); void QTableWidget_SetHorizontalHeaderItem(QTableWidget* self, int column, QTableWidgetItem* item); QTableWidgetItem* QTableWidget_TakeHorizontalHeaderItem(QTableWidget* self, int column); -void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels); -void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels); +void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels); int QTableWidget_CurrentRow(const QTableWidget* self); int QTableWidget_CurrentColumn(const QTableWidget* self); QTableWidgetItem* QTableWidget_CurrentItem(const QTableWidget* self); @@ -152,9 +152,9 @@ void QTableWidget_RemoveCellWidget(QTableWidget* self, int row, int column); bool QTableWidget_IsItemSelected(const QTableWidget* self, QTableWidgetItem* item); void QTableWidget_SetItemSelected(QTableWidget* self, QTableWidgetItem* item, bool selectVal); void QTableWidget_SetRangeSelected(QTableWidget* self, QTableWidgetSelectionRange* rangeVal, bool selectVal); -struct miqt_array* QTableWidget_SelectedRanges(const QTableWidget* self); -struct miqt_array* QTableWidget_SelectedItems(const QTableWidget* self); -struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags); +struct miqt_array QTableWidget_SelectedRanges(const QTableWidget* self); +struct miqt_array QTableWidget_SelectedItems(const QTableWidget* self); +struct miqt_array QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags); int QTableWidget_VisualRow(const QTableWidget* self, int logicalRow); int QTableWidget_VisualColumn(const QTableWidget* self, int logicalColumn); QTableWidgetItem* QTableWidget_ItemAt(const QTableWidget* self, QPoint* p); diff --git a/qt/gen_qtextbrowser.cpp b/qt/gen_qtextbrowser.cpp index c9cec58e..6e872e7a 100644 --- a/qt/gen_qtextbrowser.cpp +++ b/qt/gen_qtextbrowser.cpp @@ -58,7 +58,7 @@ int QTextBrowser_SourceType(const QTextBrowser* self) { return static_cast(_ret); } -struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self) { +struct miqt_array QTextBrowser_SearchPaths(const QTextBrowser* self) { QStringList _ret = self->searchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -72,17 +72,17 @@ struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array* /* of struct miqt_string */ paths) { +void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } diff --git a/qt/gen_qtextbrowser.go b/qt/gen_qtextbrowser.go index 91a07e47..1478c7c7 100644 --- a/qt/gen_qtextbrowser.go +++ b/qt/gen_qtextbrowser.go @@ -96,7 +96,7 @@ func (this *QTextBrowser) SourceType() QTextDocument__ResourceType { } func (this *QTextBrowser) SearchPaths() []string { - var _ma *C.struct_miqt_array = C.QTextBrowser_SearchPaths(this.h) + var _ma C.struct_miqt_array = C.QTextBrowser_SearchPaths(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -105,12 +105,10 @@ func (this *QTextBrowser) SearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextBrowser) SetSearchPaths(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -120,8 +118,7 @@ func (this *QTextBrowser) SetSearchPaths(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QTextBrowser_SetSearchPaths(this.h, paths_ma) } diff --git a/qt/gen_qtextbrowser.h b/qt/gen_qtextbrowser.h index 0fdc6532..239f8b21 100644 --- a/qt/gen_qtextbrowser.h +++ b/qt/gen_qtextbrowser.h @@ -35,8 +35,8 @@ struct miqt_string QTextBrowser_Tr(const char* s); struct miqt_string QTextBrowser_TrUtf8(const char* s); QUrl* QTextBrowser_Source(const QTextBrowser* self); int QTextBrowser_SourceType(const QTextBrowser* self); -struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self); -void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QTextBrowser_SearchPaths(const QTextBrowser* self); +void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array /* of struct miqt_string */ paths); QVariant* QTextBrowser_LoadResource(QTextBrowser* self, int typeVal, QUrl* name); bool QTextBrowser_IsBackwardAvailable(const QTextBrowser* self); bool QTextBrowser_IsForwardAvailable(const QTextBrowser* self); diff --git a/qt/gen_qtextcodec.cpp b/qt/gen_qtextcodec.cpp index 7f6e1164..c8c43e14 100644 --- a/qt/gen_qtextcodec.cpp +++ b/qt/gen_qtextcodec.cpp @@ -25,7 +25,7 @@ QTextCodec* QTextCodec_CodecForMib(int mib) { return QTextCodec::codecForMib(static_cast(mib)); } -struct miqt_array* QTextCodec_AvailableCodecs() { +struct miqt_array QTextCodec_AvailableCodecs() { QList _ret = QTextCodec::availableCodecs(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -37,22 +37,22 @@ struct miqt_array* QTextCodec_AvailableCodecs() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextCodec_AvailableMibs() { +struct miqt_array QTextCodec_AvailableMibs() { QList _ret = QTextCodec::availableMibs(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -163,7 +163,7 @@ struct miqt_string QTextCodec_Name(const QTextCodec* self) { return _ms; } -struct miqt_array* QTextCodec_Aliases(const QTextCodec* self) { +struct miqt_array QTextCodec_Aliases(const QTextCodec* self) { QList _ret = self->aliases(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -175,9 +175,9 @@ struct miqt_array* QTextCodec_Aliases(const QTextCodec* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextcodec.go b/qt/gen_qtextcodec.go index df5e3882..3ea0727d 100644 --- a/qt/gen_qtextcodec.go +++ b/qt/gen_qtextcodec.go @@ -69,7 +69,7 @@ func QTextCodec_CodecForMib(mib int) *QTextCodec { } func QTextCodec_AvailableCodecs() [][]byte { - var _ma *C.struct_miqt_array = C.QTextCodec_AvailableCodecs() + var _ma C.struct_miqt_array = C.QTextCodec_AvailableCodecs() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -78,18 +78,16 @@ func QTextCodec_AvailableCodecs() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QTextCodec_AvailableMibs() []int { - var _ma *C.struct_miqt_array = C.QTextCodec_AvailableMibs() + var _ma C.struct_miqt_array = C.QTextCodec_AvailableMibs() _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -203,7 +201,7 @@ func (this *QTextCodec) Name() []byte { } func (this *QTextCodec) Aliases() [][]byte { - var _ma *C.struct_miqt_array = C.QTextCodec_Aliases(this.h) + var _ma C.struct_miqt_array = C.QTextCodec_Aliases(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -212,7 +210,6 @@ func (this *QTextCodec) Aliases() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextcodec.h b/qt/gen_qtextcodec.h index e5cea3c7..106d974b 100644 --- a/qt/gen_qtextcodec.h +++ b/qt/gen_qtextcodec.h @@ -36,8 +36,8 @@ typedef struct QTextEncoder QTextEncoder; QTextCodec* QTextCodec_CodecForName(struct miqt_string name); QTextCodec* QTextCodec_CodecForNameWithName(const char* name); QTextCodec* QTextCodec_CodecForMib(int mib); -struct miqt_array* QTextCodec_AvailableCodecs(); -struct miqt_array* QTextCodec_AvailableMibs(); +struct miqt_array QTextCodec_AvailableCodecs(); +struct miqt_array QTextCodec_AvailableMibs(); QTextCodec* QTextCodec_CodecForLocale(); void QTextCodec_SetCodecForLocale(QTextCodec* c); QTextCodec* QTextCodec_CodecForHtml(struct miqt_string ba); @@ -54,7 +54,7 @@ struct miqt_string QTextCodec_FromUnicode2(const QTextCodec* self, QChar* in, in QTextDecoder* QTextCodec_MakeDecoder(const QTextCodec* self); QTextEncoder* QTextCodec_MakeEncoder(const QTextCodec* self); struct miqt_string QTextCodec_Name(const QTextCodec* self); -struct miqt_array* QTextCodec_Aliases(const QTextCodec* self); +struct miqt_array QTextCodec_Aliases(const QTextCodec* self); int QTextCodec_MibEnum(const QTextCodec* self); struct miqt_string QTextCodec_ToUnicode3(const QTextCodec* self, const char* in, int length, QTextCodec__ConverterState* state); struct miqt_string QTextCodec_FromUnicode3(const QTextCodec* self, QChar* in, int length, QTextCodec__ConverterState* state); diff --git a/qt/gen_qtextdocument.cpp b/qt/gen_qtextdocument.cpp index 36840b4b..f57132ac 100644 --- a/qt/gen_qtextdocument.cpp +++ b/qt/gen_qtextdocument.cpp @@ -325,16 +325,16 @@ void QTextDocument_AddResource(QTextDocument* self, int typeVal, QUrl* name, QVa self->addResource(static_cast(typeVal), *name, *resource); } -struct miqt_array* QTextDocument_AllFormats(const QTextDocument* self) { +struct miqt_array QTextDocument_AllFormats(const QTextDocument* self) { QVector _ret = self->allFormats(); // Convert QList<> from C++ memory to manually-managed C memory QTextFormat** _arr = static_cast(malloc(sizeof(QTextFormat*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextFormat(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextdocument.go b/qt/gen_qtextdocument.go index 3f695fe2..6eba8aaf 100644 --- a/qt/gen_qtextdocument.go +++ b/qt/gen_qtextdocument.go @@ -484,7 +484,7 @@ func (this *QTextDocument) AddResource(typeVal int, name *QUrl, resource *QVaria } func (this *QTextDocument) AllFormats() []QTextFormat { - var _ma *C.struct_miqt_array = C.QTextDocument_AllFormats(this.h) + var _ma C.struct_miqt_array = C.QTextDocument_AllFormats(this.h) _ret := make([]QTextFormat, int(_ma.len)) _outCast := (*[0xffff]*C.QTextFormat)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -493,7 +493,6 @@ func (this *QTextDocument) AllFormats() []QTextFormat { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextdocument.h b/qt/gen_qtextdocument.h index cab25be5..29a40241 100644 --- a/qt/gen_qtextdocument.h +++ b/qt/gen_qtextdocument.h @@ -122,7 +122,7 @@ bool QTextDocument_IsModified(const QTextDocument* self); void QTextDocument_Print(const QTextDocument* self, QPagedPaintDevice* printer); QVariant* QTextDocument_Resource(const QTextDocument* self, int typeVal, QUrl* name); void QTextDocument_AddResource(QTextDocument* self, int typeVal, QUrl* name, QVariant* resource); -struct miqt_array* QTextDocument_AllFormats(const QTextDocument* self); +struct miqt_array QTextDocument_AllFormats(const QTextDocument* self); void QTextDocument_MarkContentsDirty(QTextDocument* self, int from, int length); void QTextDocument_SetUseDesignMetrics(QTextDocument* self, bool b); bool QTextDocument_UseDesignMetrics(const QTextDocument* self); diff --git a/qt/gen_qtextdocumentwriter.cpp b/qt/gen_qtextdocumentwriter.cpp index 64d125fa..de68a11f 100644 --- a/qt/gen_qtextdocumentwriter.cpp +++ b/qt/gen_qtextdocumentwriter.cpp @@ -86,7 +86,7 @@ QTextCodec* QTextDocumentWriter_Codec(const QTextDocumentWriter* self) { return self->codec(); } -struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats() { +struct miqt_array QTextDocumentWriter_SupportedDocumentFormats() { QList _ret = QTextDocumentWriter::supportedDocumentFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -98,9 +98,9 @@ struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextdocumentwriter.go b/qt/gen_qtextdocumentwriter.go index 89a5b158..5dcf1fa9 100644 --- a/qt/gen_qtextdocumentwriter.go +++ b/qt/gen_qtextdocumentwriter.go @@ -134,7 +134,7 @@ func (this *QTextDocumentWriter) Codec() *QTextCodec { } func QTextDocumentWriter_SupportedDocumentFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QTextDocumentWriter_SupportedDocumentFormats() + var _ma C.struct_miqt_array = C.QTextDocumentWriter_SupportedDocumentFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -143,7 +143,6 @@ func QTextDocumentWriter_SupportedDocumentFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextdocumentwriter.h b/qt/gen_qtextdocumentwriter.h index 0226f0b4..824e7c43 100644 --- a/qt/gen_qtextdocumentwriter.h +++ b/qt/gen_qtextdocumentwriter.h @@ -43,7 +43,7 @@ bool QTextDocumentWriter_Write(QTextDocumentWriter* self, QTextDocument* documen bool QTextDocumentWriter_WriteWithFragment(QTextDocumentWriter* self, QTextDocumentFragment* fragment); void QTextDocumentWriter_SetCodec(QTextDocumentWriter* self, QTextCodec* codec); QTextCodec* QTextDocumentWriter_Codec(const QTextDocumentWriter* self); -struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats(); +struct miqt_array QTextDocumentWriter_SupportedDocumentFormats(); void QTextDocumentWriter_Delete(QTextDocumentWriter* self); #ifdef __cplusplus diff --git a/qt/gen_qtextedit.cpp b/qt/gen_qtextedit.cpp index 8c509f5a..82283b26 100644 --- a/qt/gen_qtextedit.cpp +++ b/qt/gen_qtextedit.cpp @@ -370,26 +370,26 @@ void QTextEdit_SetAcceptRichText(QTextEdit* self, bool accept) { self->setAcceptRichText(accept); } -void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections) { +void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextEdit__ExtraSelection** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextEdit__ExtraSelection** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->setExtraSelections(selections_QList); } -struct miqt_array* QTextEdit_ExtraSelections(const QTextEdit* self) { +struct miqt_array QTextEdit_ExtraSelections(const QTextEdit* self) { QList _ret = self->extraSelections(); // Convert QList<> from C++ memory to manually-managed C memory QTextEdit__ExtraSelection** _arr = static_cast(malloc(sizeof(QTextEdit__ExtraSelection*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextEdit::ExtraSelection(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextedit.go b/qt/gen_qtextedit.go index 0e01d77c..ce44756d 100644 --- a/qt/gen_qtextedit.go +++ b/qt/gen_qtextedit.go @@ -422,19 +422,17 @@ func (this *QTextEdit) SetAcceptRichText(accept bool) { } func (this *QTextEdit) SetExtraSelections(selections []QTextEdit__ExtraSelection) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextEdit__ExtraSelection)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextEdit_SetExtraSelections(this.h, selections_ma) } func (this *QTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { - var _ma *C.struct_miqt_array = C.QTextEdit_ExtraSelections(this.h) + var _ma C.struct_miqt_array = C.QTextEdit_ExtraSelections(this.h) _ret := make([]QTextEdit__ExtraSelection, int(_ma.len)) _outCast := (*[0xffff]*C.QTextEdit__ExtraSelection)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -443,7 +441,6 @@ func (this *QTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextedit.h b/qt/gen_qtextedit.h index 4ff866f1..b97caa08 100644 --- a/qt/gen_qtextedit.h +++ b/qt/gen_qtextedit.h @@ -123,8 +123,8 @@ int QTextEdit_CursorWidth(const QTextEdit* self); void QTextEdit_SetCursorWidth(QTextEdit* self, int width); bool QTextEdit_AcceptRichText(const QTextEdit* self); void QTextEdit_SetAcceptRichText(QTextEdit* self, bool accept); -void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections); -struct miqt_array* QTextEdit_ExtraSelections(const QTextEdit* self); +void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections); +struct miqt_array QTextEdit_ExtraSelections(const QTextEdit* self); void QTextEdit_MoveCursor(QTextEdit* self, int operation); bool QTextEdit_CanPaste(const QTextEdit* self); void QTextEdit_Print(const QTextEdit* self, QPagedPaintDevice* printer); diff --git a/qt/gen_qtextformat.cpp b/qt/gen_qtextformat.cpp index 7c74a9e8..ea06dd89 100644 --- a/qt/gen_qtextformat.cpp +++ b/qt/gen_qtextformat.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -160,29 +161,47 @@ QTextLength* QTextFormat_LengthProperty(const QTextFormat* self, int propertyId) return new QTextLength(self->lengthProperty(static_cast(propertyId))); } -struct miqt_array* QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId) { +struct miqt_array QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId) { QVector _ret = self->lengthVectorProperty(static_cast(propertyId)); // Convert QList<> from C++ memory to manually-managed C memory QTextLength** _arr = static_cast(malloc(sizeof(QTextLength*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLength(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array* /* of QTextLength* */ lengths) { +void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array /* of QTextLength* */ lengths) { QVector lengths_QList; - lengths_QList.reserve(lengths->len); - QTextLength** lengths_arr = static_cast(lengths->data); - for(size_t i = 0; i < lengths->len; ++i) { + lengths_QList.reserve(lengths.len); + QTextLength** lengths_arr = static_cast(lengths.data); + for(size_t i = 0; i < lengths.len; ++i) { lengths_QList.push_back(*(lengths_arr[i])); } self->setProperty(static_cast(propertyId), lengths_QList); } +struct miqt_map QTextFormat_Properties(const QTextFormat* self) { + QMap _ret = self->properties(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + int QTextFormat_PropertyCount(const QTextFormat* self) { return self->propertyCount(); } @@ -336,11 +355,11 @@ struct miqt_string QTextCharFormat_FontFamily(const QTextCharFormat* self) { return _ms; } -void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ families) { +void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ families) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -586,18 +605,18 @@ struct miqt_string QTextCharFormat_AnchorName(const QTextCharFormat* self) { return _ms; } -void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ names) { +void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ names) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } self->setAnchorNames(names_QList); } -struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self) { +struct miqt_array QTextCharFormat_AnchorNames(const QTextCharFormat* self) { QStringList _ret = self->anchorNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -611,9 +630,9 @@ struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -758,26 +777,26 @@ int QTextBlockFormat_PageBreakPolicy(const QTextBlockFormat* self) { return static_cast(_ret); } -void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array* /* of QTextOption__Tab* */ tabs) { +void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array /* of QTextOption__Tab* */ tabs) { QList tabs_QList; - tabs_QList.reserve(tabs->len); - QTextOption__Tab** tabs_arr = static_cast(tabs->data); - for(size_t i = 0; i < tabs->len; ++i) { + tabs_QList.reserve(tabs.len); + QTextOption__Tab** tabs_arr = static_cast(tabs.data); + for(size_t i = 0; i < tabs.len; ++i) { tabs_QList.push_back(*(tabs_arr[i])); } self->setTabPositions(tabs_QList); } -struct miqt_array* QTextBlockFormat_TabPositions(const QTextBlockFormat* self) { +struct miqt_array QTextBlockFormat_TabPositions(const QTextBlockFormat* self) { QList _ret = self->tabPositions(); // Convert QList<> from C++ memory to manually-managed C memory QTextOption__Tab** _arr = static_cast(malloc(sizeof(QTextOption__Tab*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextOption::Tab(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1071,26 +1090,26 @@ void QTextTableFormat_SetColumns(QTextTableFormat* self, int columns) { self->setColumns(static_cast(columns)); } -void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array* /* of QTextLength* */ constraints) { +void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array /* of QTextLength* */ constraints) { QVector constraints_QList; - constraints_QList.reserve(constraints->len); - QTextLength** constraints_arr = static_cast(constraints->data); - for(size_t i = 0; i < constraints->len; ++i) { + constraints_QList.reserve(constraints.len); + QTextLength** constraints_arr = static_cast(constraints.data); + for(size_t i = 0; i < constraints.len; ++i) { constraints_QList.push_back(*(constraints_arr[i])); } self->setColumnWidthConstraints(constraints_QList); } -struct miqt_array* QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self) { +struct miqt_array QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self) { QVector _ret = self->columnWidthConstraints(); // Convert QList<> from C++ memory to manually-managed C memory QTextLength** _arr = static_cast(malloc(sizeof(QTextLength*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLength(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextformat.go b/qt/gen_qtextformat.go index 52d9f445..f704fd89 100644 --- a/qt/gen_qtextformat.go +++ b/qt/gen_qtextformat.go @@ -476,7 +476,7 @@ func (this *QTextFormat) LengthProperty(propertyId int) *QTextLength { } func (this *QTextFormat) LengthVectorProperty(propertyId int) []QTextLength { - var _ma *C.struct_miqt_array = C.QTextFormat_LengthVectorProperty(this.h, (C.int)(propertyId)) + var _ma C.struct_miqt_array = C.QTextFormat_LengthVectorProperty(this.h, (C.int)(propertyId)) _ret := make([]QTextLength, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLength)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -485,22 +485,37 @@ func (this *QTextFormat) LengthVectorProperty(propertyId int) []QTextLength { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFormat) SetProperty2(propertyId int, lengths []QTextLength) { - // For the C ABI, malloc a C array of raw pointers lengths_CArray := (*[0xffff]*C.QTextLength)(C.malloc(C.size_t(8 * len(lengths)))) defer C.free(unsafe.Pointer(lengths_CArray)) for i := range lengths { lengths_CArray[i] = lengths[i].cPointer() } - lengths_ma := &C.struct_miqt_array{len: C.size_t(len(lengths)), data: unsafe.Pointer(lengths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lengths_ma)) + lengths_ma := C.struct_miqt_array{len: C.size_t(len(lengths)), data: unsafe.Pointer(lengths_CArray)} C.QTextFormat_SetProperty2(this.h, (C.int)(propertyId), lengths_ma) } +func (this *QTextFormat) Properties() map[int]QVariant { + var _mm C.struct_miqt_map = C.QTextFormat_Properties(this.h) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QTextFormat) PropertyCount() int { return (int)(C.QTextFormat_PropertyCount(this.h)) } @@ -727,7 +742,6 @@ func (this *QTextCharFormat) FontFamily() string { } func (this *QTextCharFormat) SetFontFamilies(families []string) { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -737,8 +751,7 @@ func (this *QTextCharFormat) SetFontFamilies(families []string) { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} C.QTextCharFormat_SetFontFamilies(this.h, families_ma) } @@ -984,7 +997,6 @@ func (this *QTextCharFormat) AnchorName() string { } func (this *QTextCharFormat) SetAnchorNames(names []string) { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -994,13 +1006,12 @@ func (this *QTextCharFormat) SetAnchorNames(names []string) { defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} C.QTextCharFormat_SetAnchorNames(this.h, names_ma) } func (this *QTextCharFormat) AnchorNames() []string { - var _ma *C.struct_miqt_array = C.QTextCharFormat_AnchorNames(this.h) + var _ma C.struct_miqt_array = C.QTextCharFormat_AnchorNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1009,7 +1020,6 @@ func (this *QTextCharFormat) AnchorNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1190,19 +1200,17 @@ func (this *QTextBlockFormat) PageBreakPolicy() QTextFormat__PageBreakFlag { } func (this *QTextBlockFormat) SetTabPositions(tabs []QTextOption__Tab) { - // For the C ABI, malloc a C array of raw pointers tabs_CArray := (*[0xffff]*C.QTextOption__Tab)(C.malloc(C.size_t(8 * len(tabs)))) defer C.free(unsafe.Pointer(tabs_CArray)) for i := range tabs { tabs_CArray[i] = tabs[i].cPointer() } - tabs_ma := &C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabs_ma)) + tabs_ma := C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} C.QTextBlockFormat_SetTabPositions(this.h, tabs_ma) } func (this *QTextBlockFormat) TabPositions() []QTextOption__Tab { - var _ma *C.struct_miqt_array = C.QTextBlockFormat_TabPositions(this.h) + var _ma C.struct_miqt_array = C.QTextBlockFormat_TabPositions(this.h) _ret := make([]QTextOption__Tab, int(_ma.len)) _outCast := (*[0xffff]*C.QTextOption__Tab)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1211,7 +1219,6 @@ func (this *QTextBlockFormat) TabPositions() []QTextOption__Tab { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1670,19 +1677,17 @@ func (this *QTextTableFormat) SetColumns(columns int) { } func (this *QTextTableFormat) SetColumnWidthConstraints(constraints []QTextLength) { - // For the C ABI, malloc a C array of raw pointers constraints_CArray := (*[0xffff]*C.QTextLength)(C.malloc(C.size_t(8 * len(constraints)))) defer C.free(unsafe.Pointer(constraints_CArray)) for i := range constraints { constraints_CArray[i] = constraints[i].cPointer() } - constraints_ma := &C.struct_miqt_array{len: C.size_t(len(constraints)), data: unsafe.Pointer(constraints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(constraints_ma)) + constraints_ma := C.struct_miqt_array{len: C.size_t(len(constraints)), data: unsafe.Pointer(constraints_CArray)} C.QTextTableFormat_SetColumnWidthConstraints(this.h, constraints_ma) } func (this *QTextTableFormat) ColumnWidthConstraints() []QTextLength { - var _ma *C.struct_miqt_array = C.QTextTableFormat_ColumnWidthConstraints(this.h) + var _ma C.struct_miqt_array = C.QTextTableFormat_ColumnWidthConstraints(this.h) _ret := make([]QTextLength, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLength)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1691,7 +1696,6 @@ func (this *QTextTableFormat) ColumnWidthConstraints() []QTextLength { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextformat.h b/qt/gen_qtextformat.h index 1e0e1eda..41e06146 100644 --- a/qt/gen_qtextformat.h +++ b/qt/gen_qtextformat.h @@ -84,8 +84,9 @@ QColor* QTextFormat_ColorProperty(const QTextFormat* self, int propertyId); QPen* QTextFormat_PenProperty(const QTextFormat* self, int propertyId); QBrush* QTextFormat_BrushProperty(const QTextFormat* self, int propertyId); QTextLength* QTextFormat_LengthProperty(const QTextFormat* self, int propertyId); -struct miqt_array* QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId); -void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array* /* of QTextLength* */ lengths); +struct miqt_array QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId); +void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array /* of QTextLength* */ lengths); +struct miqt_map QTextFormat_Properties(const QTextFormat* self); int QTextFormat_PropertyCount(const QTextFormat* self); void QTextFormat_SetObjectType(QTextFormat* self, int typeVal); int QTextFormat_ObjectType(const QTextFormat* self); @@ -123,7 +124,7 @@ void QTextCharFormat_SetFontWithFont(QTextCharFormat* self, QFont* font); QFont* QTextCharFormat_Font(const QTextCharFormat* self); void QTextCharFormat_SetFontFamily(QTextCharFormat* self, struct miqt_string family); struct miqt_string QTextCharFormat_FontFamily(const QTextCharFormat* self); -void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ families); +void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ families); QVariant* QTextCharFormat_FontFamilies(const QTextCharFormat* self); void QTextCharFormat_SetFontStyleName(QTextCharFormat* self, struct miqt_string styleName); QVariant* QTextCharFormat_FontStyleName(const QTextCharFormat* self); @@ -175,8 +176,8 @@ void QTextCharFormat_SetAnchorHref(QTextCharFormat* self, struct miqt_string val struct miqt_string QTextCharFormat_AnchorHref(const QTextCharFormat* self); void QTextCharFormat_SetAnchorName(QTextCharFormat* self, struct miqt_string name); struct miqt_string QTextCharFormat_AnchorName(const QTextCharFormat* self); -void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ names); -struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self); +void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ names); +struct miqt_array QTextCharFormat_AnchorNames(const QTextCharFormat* self); void QTextCharFormat_SetTableCellRowSpan(QTextCharFormat* self, int tableCellRowSpan); int QTextCharFormat_TableCellRowSpan(const QTextCharFormat* self); void QTextCharFormat_SetTableCellColumnSpan(QTextCharFormat* self, int tableCellColumnSpan); @@ -211,8 +212,8 @@ void QTextBlockFormat_SetNonBreakableLines(QTextBlockFormat* self, bool b); bool QTextBlockFormat_NonBreakableLines(const QTextBlockFormat* self); void QTextBlockFormat_SetPageBreakPolicy(QTextBlockFormat* self, int flags); int QTextBlockFormat_PageBreakPolicy(const QTextBlockFormat* self); -void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array* /* of QTextOption__Tab* */ tabs); -struct miqt_array* QTextBlockFormat_TabPositions(const QTextBlockFormat* self); +void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array /* of QTextOption__Tab* */ tabs); +struct miqt_array QTextBlockFormat_TabPositions(const QTextBlockFormat* self); void QTextBlockFormat_SetMarker(QTextBlockFormat* self, int marker); int QTextBlockFormat_Marker(const QTextBlockFormat* self); void QTextBlockFormat_Delete(QTextBlockFormat* self); @@ -280,8 +281,8 @@ QTextTableFormat* QTextTableFormat_new(); bool QTextTableFormat_IsValid(const QTextTableFormat* self); int QTextTableFormat_Columns(const QTextTableFormat* self); void QTextTableFormat_SetColumns(QTextTableFormat* self, int columns); -void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array* /* of QTextLength* */ constraints); -struct miqt_array* QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self); +void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array /* of QTextLength* */ constraints); +struct miqt_array QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self); void QTextTableFormat_ClearColumnWidthConstraints(QTextTableFormat* self); double QTextTableFormat_CellSpacing(const QTextTableFormat* self); void QTextTableFormat_SetCellSpacing(QTextTableFormat* self, double spacing); diff --git a/qt/gen_qtextlayout.cpp b/qt/gen_qtextlayout.cpp index d681d7fe..21d7ba51 100644 --- a/qt/gen_qtextlayout.cpp +++ b/qt/gen_qtextlayout.cpp @@ -166,26 +166,26 @@ struct miqt_string QTextLayout_PreeditAreaText(const QTextLayout* self) { return _ms; } -void QTextLayout_SetAdditionalFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides) { +void QTextLayout_SetAdditionalFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides) { QList overrides_QList; - overrides_QList.reserve(overrides->len); - QTextLayout__FormatRange** overrides_arr = static_cast(overrides->data); - for(size_t i = 0; i < overrides->len; ++i) { + overrides_QList.reserve(overrides.len); + QTextLayout__FormatRange** overrides_arr = static_cast(overrides.data); + for(size_t i = 0; i < overrides.len; ++i) { overrides_QList.push_back(*(overrides_arr[i])); } self->setAdditionalFormats(overrides_QList); } -struct miqt_array* QTextLayout_AdditionalFormats(const QTextLayout* self) { +struct miqt_array QTextLayout_AdditionalFormats(const QTextLayout* self) { QList _ret = self->additionalFormats(); // Convert QList<> from C++ memory to manually-managed C memory QTextLayout__FormatRange** _arr = static_cast(malloc(sizeof(QTextLayout__FormatRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLayout::FormatRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -193,26 +193,26 @@ void QTextLayout_ClearAdditionalFormats(QTextLayout* self) { self->clearAdditionalFormats(); } -void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides) { +void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides) { QVector overrides_QList; - overrides_QList.reserve(overrides->len); - QTextLayout__FormatRange** overrides_arr = static_cast(overrides->data); - for(size_t i = 0; i < overrides->len; ++i) { + overrides_QList.reserve(overrides.len); + QTextLayout__FormatRange** overrides_arr = static_cast(overrides.data); + for(size_t i = 0; i < overrides.len; ++i) { overrides_QList.push_back(*(overrides_arr[i])); } self->setFormats(overrides_QList); } -struct miqt_array* QTextLayout_Formats(const QTextLayout* self) { +struct miqt_array QTextLayout_Formats(const QTextLayout* self) { QVector _ret = self->formats(); // Convert QList<> from C++ memory to manually-managed C memory QTextLayout__FormatRange** _arr = static_cast(malloc(sizeof(QTextLayout__FormatRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLayout::FormatRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -319,16 +319,16 @@ double QTextLayout_MaximumWidth(const QTextLayout* self) { return static_cast(_ret); } -struct miqt_array* QTextLayout_GlyphRuns(const QTextLayout* self) { +struct miqt_array QTextLayout_GlyphRuns(const QTextLayout* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -344,49 +344,49 @@ int QTextLayout_PreviousCursorPosition2(const QTextLayout* self, int oldPos, int return self->previousCursorPosition(static_cast(oldPos), static_cast(mode)); } -void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections) { +void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections) { QVector selections_QList; - selections_QList.reserve(selections->len); - QTextLayout__FormatRange** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextLayout__FormatRange** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->draw(p, *pos, selections_QList); } -void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections, QRectF* clip) { +void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections, QRectF* clip) { QVector selections_QList; - selections_QList.reserve(selections->len); - QTextLayout__FormatRange** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextLayout__FormatRange** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->draw(p, *pos, selections_QList, *clip); } -struct miqt_array* QTextLayout_GlyphRuns1(const QTextLayout* self, int from) { +struct miqt_array QTextLayout_GlyphRuns1(const QTextLayout* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length) { +struct miqt_array QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -513,16 +513,16 @@ void QTextLine_Draw(const QTextLine* self, QPainter* p, QPointF* point) { self->draw(p, *point); } -struct miqt_array* QTextLine_GlyphRuns(const QTextLine* self) { +struct miqt_array QTextLine_GlyphRuns(const QTextLine* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -544,29 +544,29 @@ void QTextLine_Draw3(const QTextLine* self, QPainter* p, QPointF* point, QTextLa self->draw(p, *point, selection); } -struct miqt_array* QTextLine_GlyphRuns1(const QTextLine* self, int from) { +struct miqt_array QTextLine_GlyphRuns1(const QTextLine* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextLine_GlyphRuns2(const QTextLine* self, int from, int length) { +struct miqt_array QTextLine_GlyphRuns2(const QTextLine* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextlayout.go b/qt/gen_qtextlayout.go index 372cc375..6d5cd1f3 100644 --- a/qt/gen_qtextlayout.go +++ b/qt/gen_qtextlayout.go @@ -270,19 +270,17 @@ func (this *QTextLayout) PreeditAreaText() string { } func (this *QTextLayout) SetAdditionalFormats(overrides []QTextLayout__FormatRange) { - // For the C ABI, malloc a C array of raw pointers overrides_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(overrides)))) defer C.free(unsafe.Pointer(overrides_CArray)) for i := range overrides { overrides_CArray[i] = overrides[i].cPointer() } - overrides_ma := &C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(overrides_ma)) + overrides_ma := C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} C.QTextLayout_SetAdditionalFormats(this.h, overrides_ma) } func (this *QTextLayout) AdditionalFormats() []QTextLayout__FormatRange { - var _ma *C.struct_miqt_array = C.QTextLayout_AdditionalFormats(this.h) + var _ma C.struct_miqt_array = C.QTextLayout_AdditionalFormats(this.h) _ret := make([]QTextLayout__FormatRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLayout__FormatRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -291,7 +289,6 @@ func (this *QTextLayout) AdditionalFormats() []QTextLayout__FormatRange { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -300,19 +297,17 @@ func (this *QTextLayout) ClearAdditionalFormats() { } func (this *QTextLayout) SetFormats(overrides []QTextLayout__FormatRange) { - // For the C ABI, malloc a C array of raw pointers overrides_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(overrides)))) defer C.free(unsafe.Pointer(overrides_CArray)) for i := range overrides { overrides_CArray[i] = overrides[i].cPointer() } - overrides_ma := &C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(overrides_ma)) + overrides_ma := C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} C.QTextLayout_SetFormats(this.h, overrides_ma) } func (this *QTextLayout) Formats() []QTextLayout__FormatRange { - var _ma *C.struct_miqt_array = C.QTextLayout_Formats(this.h) + var _ma C.struct_miqt_array = C.QTextLayout_Formats(this.h) _ret := make([]QTextLayout__FormatRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLayout__FormatRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -321,7 +316,6 @@ func (this *QTextLayout) Formats() []QTextLayout__FormatRange { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -441,7 +435,7 @@ func (this *QTextLayout) MaximumWidth() float64 { } func (this *QTextLayout) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -450,7 +444,6 @@ func (this *QTextLayout) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -467,31 +460,27 @@ func (this *QTextLayout) PreviousCursorPosition2(oldPos int, mode QTextLayout__C } func (this *QTextLayout) Draw3(p *QPainter, pos *QPointF, selections []QTextLayout__FormatRange) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextLayout_Draw3(this.h, p.cPointer(), pos.cPointer(), selections_ma) } func (this *QTextLayout) Draw4(p *QPainter, pos *QPointF, selections []QTextLayout__FormatRange, clip *QRectF) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextLayout_Draw4(this.h, p.cPointer(), pos.cPointer(), selections_ma, clip.cPointer()) } func (this *QTextLayout) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -500,12 +489,11 @@ func (this *QTextLayout) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextLayout) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -514,7 +502,6 @@ func (this *QTextLayout) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -681,7 +668,7 @@ func (this *QTextLine) Draw(p *QPainter, point *QPointF) { } func (this *QTextLine) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -690,7 +677,6 @@ func (this *QTextLine) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -711,7 +697,7 @@ func (this *QTextLine) Draw3(p *QPainter, point *QPointF, selection *QTextLayout } func (this *QTextLine) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -720,12 +706,11 @@ func (this *QTextLine) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextLine) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -734,7 +719,6 @@ func (this *QTextLine) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextlayout.h b/qt/gen_qtextlayout.h index 630022a3..4e9dccf6 100644 --- a/qt/gen_qtextlayout.h +++ b/qt/gen_qtextlayout.h @@ -80,11 +80,11 @@ QTextOption* QTextLayout_TextOption(const QTextLayout* self); void QTextLayout_SetPreeditArea(QTextLayout* self, int position, struct miqt_string text); int QTextLayout_PreeditAreaPosition(const QTextLayout* self); struct miqt_string QTextLayout_PreeditAreaText(const QTextLayout* self); -void QTextLayout_SetAdditionalFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides); -struct miqt_array* QTextLayout_AdditionalFormats(const QTextLayout* self); +void QTextLayout_SetAdditionalFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides); +struct miqt_array QTextLayout_AdditionalFormats(const QTextLayout* self); void QTextLayout_ClearAdditionalFormats(QTextLayout* self); -void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides); -struct miqt_array* QTextLayout_Formats(const QTextLayout* self); +void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides); +struct miqt_array QTextLayout_Formats(const QTextLayout* self); void QTextLayout_ClearFormats(QTextLayout* self); void QTextLayout_SetCacheEnabled(QTextLayout* self, bool enable); bool QTextLayout_CacheEnabled(const QTextLayout* self); @@ -110,14 +110,14 @@ void QTextLayout_SetPosition(QTextLayout* self, QPointF* p); QRectF* QTextLayout_BoundingRect(const QTextLayout* self); double QTextLayout_MinimumWidth(const QTextLayout* self); double QTextLayout_MaximumWidth(const QTextLayout* self); -struct miqt_array* QTextLayout_GlyphRuns(const QTextLayout* self); +struct miqt_array QTextLayout_GlyphRuns(const QTextLayout* self); void QTextLayout_SetFlags(QTextLayout* self, int flags); int QTextLayout_NextCursorPosition2(const QTextLayout* self, int oldPos, int mode); int QTextLayout_PreviousCursorPosition2(const QTextLayout* self, int oldPos, int mode); -void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections); -void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections, QRectF* clip); -struct miqt_array* QTextLayout_GlyphRuns1(const QTextLayout* self, int from); -struct miqt_array* QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length); +void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections); +void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections, QRectF* clip); +struct miqt_array QTextLayout_GlyphRuns1(const QTextLayout* self, int from); +struct miqt_array QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length); void QTextLayout_Delete(QTextLayout* self); QTextLine* QTextLine_new(); @@ -147,13 +147,13 @@ int QTextLine_TextStart(const QTextLine* self); int QTextLine_TextLength(const QTextLine* self); int QTextLine_LineNumber(const QTextLine* self); void QTextLine_Draw(const QTextLine* self, QPainter* p, QPointF* point); -struct miqt_array* QTextLine_GlyphRuns(const QTextLine* self); +struct miqt_array QTextLine_GlyphRuns(const QTextLine* self); double QTextLine_CursorToX2(const QTextLine* self, int* cursorPos, int edge); double QTextLine_CursorToX22(const QTextLine* self, int cursorPos, int edge); int QTextLine_XToCursor2(const QTextLine* self, double x, int param2); void QTextLine_Draw3(const QTextLine* self, QPainter* p, QPointF* point, QTextLayout__FormatRange* selection); -struct miqt_array* QTextLine_GlyphRuns1(const QTextLine* self, int from); -struct miqt_array* QTextLine_GlyphRuns2(const QTextLine* self, int from, int length); +struct miqt_array QTextLine_GlyphRuns1(const QTextLine* self, int from); +struct miqt_array QTextLine_GlyphRuns2(const QTextLine* self, int from, int length); void QTextLine_Delete(QTextLine* self); void QTextLayout__FormatRange_Delete(QTextLayout__FormatRange* self); diff --git a/qt/gen_qtextobject.cpp b/qt/gen_qtextobject.cpp index 4c552538..6ee4e9d3 100644 --- a/qt/gen_qtextobject.cpp +++ b/qt/gen_qtextobject.cpp @@ -264,16 +264,16 @@ void QTextFrame_SetLayoutData(QTextFrame* self, QTextFrameLayoutData* data) { self->setLayoutData(data); } -struct miqt_array* QTextFrame_ChildFrames(const QTextFrame* self) { +struct miqt_array QTextFrame_ChildFrames(const QTextFrame* self) { QList _ret = self->childFrames(); // Convert QList<> from C++ memory to manually-managed C memory QTextFrame** _arr = static_cast(malloc(sizeof(QTextFrame*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -425,16 +425,16 @@ struct miqt_string QTextBlock_Text(const QTextBlock* self) { return _ms; } -struct miqt_array* QTextBlock_TextFormats(const QTextBlock* self) { +struct miqt_array QTextBlock_TextFormats(const QTextBlock* self) { QVector _ret = self->textFormats(); // Convert QList<> from C++ memory to manually-managed C memory QTextLayout__FormatRange** _arr = static_cast(malloc(sizeof(QTextLayout__FormatRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLayout::FormatRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -577,42 +577,42 @@ struct miqt_string QTextFragment_Text(const QTextFragment* self) { return _ms; } -struct miqt_array* QTextFragment_GlyphRuns(const QTextFragment* self) { +struct miqt_array QTextFragment_GlyphRuns(const QTextFragment* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextFragment_GlyphRuns1(const QTextFragment* self, int from) { +struct miqt_array QTextFragment_GlyphRuns1(const QTextFragment* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length) { +struct miqt_array QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextobject.go b/qt/gen_qtextobject.go index 9c0099b6..bc53353b 100644 --- a/qt/gen_qtextobject.go +++ b/qt/gen_qtextobject.go @@ -389,13 +389,12 @@ func (this *QTextFrame) SetLayoutData(data *QTextFrameLayoutData) { } func (this *QTextFrame) ChildFrames() []*QTextFrame { - var _ma *C.struct_miqt_array = C.QTextFrame_ChildFrames(this.h) + var _ma C.struct_miqt_array = C.QTextFrame_ChildFrames(this.h) _ret := make([]*QTextFrame, int(_ma.len)) _outCast := (*[0xffff]*C.QTextFrame)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTextFrame(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -637,7 +636,7 @@ func (this *QTextBlock) Text() string { } func (this *QTextBlock) TextFormats() []QTextLayout__FormatRange { - var _ma *C.struct_miqt_array = C.QTextBlock_TextFormats(this.h) + var _ma C.struct_miqt_array = C.QTextBlock_TextFormats(this.h) _ret := make([]QTextLayout__FormatRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLayout__FormatRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -646,7 +645,6 @@ func (this *QTextBlock) TextFormats() []QTextLayout__FormatRange { _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -844,7 +842,7 @@ func (this *QTextFragment) Text() string { } func (this *QTextFragment) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -853,12 +851,11 @@ func (this *QTextFragment) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFragment) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -867,12 +864,11 @@ func (this *QTextFragment) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFragment) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -881,7 +877,6 @@ func (this *QTextFragment) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextobject.h b/qt/gen_qtextobject.h index 63d3d3b6..b4a4a009 100644 --- a/qt/gen_qtextobject.h +++ b/qt/gen_qtextobject.h @@ -107,7 +107,7 @@ int QTextFrame_FirstPosition(const QTextFrame* self); int QTextFrame_LastPosition(const QTextFrame* self); QTextFrameLayoutData* QTextFrame_LayoutData(const QTextFrame* self); void QTextFrame_SetLayoutData(QTextFrame* self, QTextFrameLayoutData* data); -struct miqt_array* QTextFrame_ChildFrames(const QTextFrame* self); +struct miqt_array QTextFrame_ChildFrames(const QTextFrame* self); QTextFrame* QTextFrame_ParentFrame(const QTextFrame* self); QTextFrame__iterator* QTextFrame_Begin(const QTextFrame* self); QTextFrame__iterator* QTextFrame_End(const QTextFrame* self); @@ -138,7 +138,7 @@ QTextCharFormat* QTextBlock_CharFormat(const QTextBlock* self); int QTextBlock_CharFormatIndex(const QTextBlock* self); int QTextBlock_TextDirection(const QTextBlock* self); struct miqt_string QTextBlock_Text(const QTextBlock* self); -struct miqt_array* QTextBlock_TextFormats(const QTextBlock* self); +struct miqt_array QTextBlock_TextFormats(const QTextBlock* self); QTextDocument* QTextBlock_Document(const QTextBlock* self); QTextList* QTextBlock_TextList(const QTextBlock* self); QTextBlockUserData* QTextBlock_UserData(const QTextBlock* self); @@ -173,9 +173,9 @@ bool QTextFragment_Contains(const QTextFragment* self, int position); QTextCharFormat* QTextFragment_CharFormat(const QTextFragment* self); int QTextFragment_CharFormatIndex(const QTextFragment* self); struct miqt_string QTextFragment_Text(const QTextFragment* self); -struct miqt_array* QTextFragment_GlyphRuns(const QTextFragment* self); -struct miqt_array* QTextFragment_GlyphRuns1(const QTextFragment* self, int from); -struct miqt_array* QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length); +struct miqt_array QTextFragment_GlyphRuns(const QTextFragment* self); +struct miqt_array QTextFragment_GlyphRuns1(const QTextFragment* self, int from); +struct miqt_array QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length); void QTextFragment_Delete(QTextFragment* self); QTextFrame__iterator* QTextFrame__iterator_new(); diff --git a/qt/gen_qtextoption.cpp b/qt/gen_qtextoption.cpp index e134b722..b2a1008f 100644 --- a/qt/gen_qtextoption.cpp +++ b/qt/gen_qtextoption.cpp @@ -76,49 +76,49 @@ double QTextOption_TabStopDistance(const QTextOption* self) { return static_cast(_ret); } -void QTextOption_SetTabArray(QTextOption* self, struct miqt_array* /* of double */ tabStops) { +void QTextOption_SetTabArray(QTextOption* self, struct miqt_array /* of double */ tabStops) { QList tabStops_QList; - tabStops_QList.reserve(tabStops->len); - double* tabStops_arr = static_cast(tabStops->data); - for(size_t i = 0; i < tabStops->len; ++i) { + tabStops_QList.reserve(tabStops.len); + double* tabStops_arr = static_cast(tabStops.data); + for(size_t i = 0; i < tabStops.len; ++i) { tabStops_QList.push_back(static_cast(tabStops_arr[i])); } self->setTabArray(tabStops_QList); } -struct miqt_array* QTextOption_TabArray(const QTextOption* self) { +struct miqt_array QTextOption_TabArray(const QTextOption* self) { QList _ret = self->tabArray(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextOption_SetTabs(QTextOption* self, struct miqt_array* /* of QTextOption__Tab* */ tabStops) { +void QTextOption_SetTabs(QTextOption* self, struct miqt_array /* of QTextOption__Tab* */ tabStops) { QList tabStops_QList; - tabStops_QList.reserve(tabStops->len); - QTextOption__Tab** tabStops_arr = static_cast(tabStops->data); - for(size_t i = 0; i < tabStops->len; ++i) { + tabStops_QList.reserve(tabStops.len); + QTextOption__Tab** tabStops_arr = static_cast(tabStops.data); + for(size_t i = 0; i < tabStops.len; ++i) { tabStops_QList.push_back(*(tabStops_arr[i])); } self->setTabs(tabStops_QList); } -struct miqt_array* QTextOption_Tabs(const QTextOption* self) { +struct miqt_array QTextOption_Tabs(const QTextOption* self) { QList _ret = self->tabs(); // Convert QList<> from C++ memory to manually-managed C memory QTextOption__Tab** _arr = static_cast(malloc(sizeof(QTextOption__Tab*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextOption::Tab(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtextoption.go b/qt/gen_qtextoption.go index 483bf188..1e398883 100644 --- a/qt/gen_qtextoption.go +++ b/qt/gen_qtextoption.go @@ -143,42 +143,37 @@ func (this *QTextOption) TabStopDistance() float64 { } func (this *QTextOption) SetTabArray(tabStops []float64) { - // For the C ABI, malloc a C array of raw pointers tabStops_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(tabStops)))) defer C.free(unsafe.Pointer(tabStops_CArray)) for i := range tabStops { tabStops_CArray[i] = (C.double)(tabStops[i]) } - tabStops_ma := &C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabStops_ma)) + tabStops_ma := C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} C.QTextOption_SetTabArray(this.h, tabStops_ma) } func (this *QTextOption) TabArray() []float64 { - var _ma *C.struct_miqt_array = C.QTextOption_TabArray(this.h) + var _ma C.struct_miqt_array = C.QTextOption_TabArray(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextOption) SetTabs(tabStops []QTextOption__Tab) { - // For the C ABI, malloc a C array of raw pointers tabStops_CArray := (*[0xffff]*C.QTextOption__Tab)(C.malloc(C.size_t(8 * len(tabStops)))) defer C.free(unsafe.Pointer(tabStops_CArray)) for i := range tabStops { tabStops_CArray[i] = tabStops[i].cPointer() } - tabStops_ma := &C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabStops_ma)) + tabStops_ma := C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} C.QTextOption_SetTabs(this.h, tabStops_ma) } func (this *QTextOption) Tabs() []QTextOption__Tab { - var _ma *C.struct_miqt_array = C.QTextOption_Tabs(this.h) + var _ma C.struct_miqt_array = C.QTextOption_Tabs(this.h) _ret := make([]QTextOption__Tab, int(_ma.len)) _outCast := (*[0xffff]*C.QTextOption__Tab)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -187,7 +182,6 @@ func (this *QTextOption) Tabs() []QTextOption__Tab { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtextoption.h b/qt/gen_qtextoption.h index 8c9c0581..cbf4e02b 100644 --- a/qt/gen_qtextoption.h +++ b/qt/gen_qtextoption.h @@ -43,10 +43,10 @@ void QTextOption_SetTabStop(QTextOption* self, double tabStop); double QTextOption_TabStop(const QTextOption* self); void QTextOption_SetTabStopDistance(QTextOption* self, double tabStopDistance); double QTextOption_TabStopDistance(const QTextOption* self); -void QTextOption_SetTabArray(QTextOption* self, struct miqt_array* /* of double */ tabStops); -struct miqt_array* QTextOption_TabArray(const QTextOption* self); -void QTextOption_SetTabs(QTextOption* self, struct miqt_array* /* of QTextOption__Tab* */ tabStops); -struct miqt_array* QTextOption_Tabs(const QTextOption* self); +void QTextOption_SetTabArray(QTextOption* self, struct miqt_array /* of double */ tabStops); +struct miqt_array QTextOption_TabArray(const QTextOption* self); +void QTextOption_SetTabs(QTextOption* self, struct miqt_array /* of QTextOption__Tab* */ tabStops); +struct miqt_array QTextOption_Tabs(const QTextOption* self); void QTextOption_SetUseDesignMetrics(QTextOption* self, bool b); bool QTextOption_UseDesignMetrics(const QTextOption* self); void QTextOption_Delete(QTextOption* self); diff --git a/qt/gen_qtimezone.cpp b/qt/gen_qtimezone.cpp index 15b54539..26d4a5ee 100644 --- a/qt/gen_qtimezone.cpp +++ b/qt/gen_qtimezone.cpp @@ -156,16 +156,16 @@ QTimeZone__OffsetData* QTimeZone_PreviousTransition(const QTimeZone* self, QDate return new QTimeZone::OffsetData(self->previousTransition(*beforeDateTime)); } -struct miqt_array* QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime) { +struct miqt_array QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime) { QTimeZone::OffsetDataList _ret = self->transitions(*fromDateTime, *toDateTime); // Convert QList<> from C++ memory to manually-managed C memory QTimeZone__OffsetData** _arr = static_cast(malloc(sizeof(QTimeZone__OffsetData*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTimeZone::OffsetData(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -191,7 +191,7 @@ bool QTimeZone_IsTimeZoneIdAvailable(struct miqt_string ianaId) { return QTimeZone::isTimeZoneIdAvailable(ianaId_QByteArray); } -struct miqt_array* QTimeZone_AvailableTimeZoneIds() { +struct miqt_array QTimeZone_AvailableTimeZoneIds() { QList _ret = QTimeZone::availableTimeZoneIds(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -203,13 +203,13 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIds() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithCountry(int country) { +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithCountry(int country) { QList _ret = QTimeZone::availableTimeZoneIds(static_cast(country)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -221,13 +221,13 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithCountry(int country) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds) { +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds) { QList _ret = QTimeZone::availableTimeZoneIds(static_cast(offsetSeconds)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -239,9 +239,9 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSec memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -275,7 +275,7 @@ struct miqt_string QTimeZone_WindowsIdToDefaultIanaId2(struct miqt_string window return _ms; } -struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { +struct miqt_array QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { QByteArray windowsId_QByteArray(windowsId.data, windowsId.len); QList _ret = QTimeZone::windowsIdToIanaIds(windowsId_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -288,13 +288,13 @@ struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, int country) { +struct miqt_array QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, int country) { QByteArray windowsId_QByteArray(windowsId.data, windowsId.len); QList _ret = QTimeZone::windowsIdToIanaIds(windowsId_QByteArray, static_cast(country)); // Convert QList<> from C++ memory to manually-managed C memory @@ -307,9 +307,9 @@ struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, i memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtimezone.go b/qt/gen_qtimezone.go index e43c6710..3538f100 100644 --- a/qt/gen_qtimezone.go +++ b/qt/gen_qtimezone.go @@ -245,7 +245,7 @@ func (this *QTimeZone) PreviousTransition(beforeDateTime *QDateTime) *QTimeZone_ } func (this *QTimeZone) Transitions(fromDateTime *QDateTime, toDateTime *QDateTime) []QTimeZone__OffsetData { - var _ma *C.struct_miqt_array = C.QTimeZone_Transitions(this.h, fromDateTime.cPointer(), toDateTime.cPointer()) + var _ma C.struct_miqt_array = C.QTimeZone_Transitions(this.h, fromDateTime.cPointer(), toDateTime.cPointer()) _ret := make([]QTimeZone__OffsetData, int(_ma.len)) _outCast := (*[0xffff]*C.QTimeZone__OffsetData)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -254,7 +254,6 @@ func (this *QTimeZone) Transitions(fromDateTime *QDateTime, toDateTime *QDateTim _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -287,7 +286,7 @@ func QTimeZone_IsTimeZoneIdAvailable(ianaId []byte) bool { } func QTimeZone_AvailableTimeZoneIds() [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIds() + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIds() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -296,12 +295,11 @@ func QTimeZone_AvailableTimeZoneIds() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QTimeZone_AvailableTimeZoneIdsWithCountry(country QLocale__Country) [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithCountry((C.int)(country)) + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithCountry((C.int)(country)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -310,12 +308,11 @@ func QTimeZone_AvailableTimeZoneIdsWithCountry(country QLocale__Country) [][]byt C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(offsetSeconds int) [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds((C.int)(offsetSeconds)) + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds((C.int)(offsetSeconds)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -324,7 +321,6 @@ func QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(offsetSeconds int) [][]byte C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -362,7 +358,7 @@ func QTimeZone_WindowsIdToIanaIds(windowsId []byte) [][]byte { windowsId_alias := C.struct_miqt_string{} windowsId_alias.data = (*C.char)(unsafe.Pointer(&windowsId[0])) windowsId_alias.len = C.size_t(len(windowsId)) - var _ma *C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds(windowsId_alias) + var _ma C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds(windowsId_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -371,7 +367,6 @@ func QTimeZone_WindowsIdToIanaIds(windowsId []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -379,7 +374,7 @@ func QTimeZone_WindowsIdToIanaIds2(windowsId []byte, country QLocale__Country) [ windowsId_alias := C.struct_miqt_string{} windowsId_alias.data = (*C.char)(unsafe.Pointer(&windowsId[0])) windowsId_alias.len = C.size_t(len(windowsId)) - var _ma *C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds2(windowsId_alias, (C.int)(country)) + var _ma C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds2(windowsId_alias, (C.int)(country)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -388,7 +383,6 @@ func QTimeZone_WindowsIdToIanaIds2(windowsId []byte, country QLocale__Country) [ C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtimezone.h b/qt/gen_qtimezone.h index 3e019987..477021e3 100644 --- a/qt/gen_qtimezone.h +++ b/qt/gen_qtimezone.h @@ -56,19 +56,19 @@ QTimeZone__OffsetData* QTimeZone_OffsetData(const QTimeZone* self, QDateTime* fo bool QTimeZone_HasTransitions(const QTimeZone* self); QTimeZone__OffsetData* QTimeZone_NextTransition(const QTimeZone* self, QDateTime* afterDateTime); QTimeZone__OffsetData* QTimeZone_PreviousTransition(const QTimeZone* self, QDateTime* beforeDateTime); -struct miqt_array* QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime); +struct miqt_array QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime); struct miqt_string QTimeZone_SystemTimeZoneId(); QTimeZone* QTimeZone_SystemTimeZone(); QTimeZone* QTimeZone_Utc(); bool QTimeZone_IsTimeZoneIdAvailable(struct miqt_string ianaId); -struct miqt_array* QTimeZone_AvailableTimeZoneIds(); -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithCountry(int country); -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds); +struct miqt_array QTimeZone_AvailableTimeZoneIds(); +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithCountry(int country); +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds); struct miqt_string QTimeZone_IanaIdToWindowsId(struct miqt_string ianaId); struct miqt_string QTimeZone_WindowsIdToDefaultIanaId(struct miqt_string windowsId); struct miqt_string QTimeZone_WindowsIdToDefaultIanaId2(struct miqt_string windowsId, int country); -struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId); -struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, int country); +struct miqt_array QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId); +struct miqt_array QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, int country); struct miqt_string QTimeZone_DisplayName2(const QTimeZone* self, QDateTime* atDateTime, int nameType); struct miqt_string QTimeZone_DisplayName3(const QTimeZone* self, QDateTime* atDateTime, int nameType, QLocale* locale); struct miqt_string QTimeZone_DisplayName22(const QTimeZone* self, int timeType, int nameType); diff --git a/qt/gen_qtouchdevice.cpp b/qt/gen_qtouchdevice.cpp index 15c20d46..afe7db7a 100644 --- a/qt/gen_qtouchdevice.cpp +++ b/qt/gen_qtouchdevice.cpp @@ -11,16 +11,16 @@ QTouchDevice* QTouchDevice_new() { return new QTouchDevice(); } -struct miqt_array* QTouchDevice_Devices() { +struct miqt_array QTouchDevice_Devices() { QList _ret = QTouchDevice::devices(); // Convert QList<> from C++ memory to manually-managed C memory QTouchDevice** _arr = static_cast(malloc(sizeof(QTouchDevice*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = (QTouchDevice*) _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtouchdevice.go b/qt/gen_qtouchdevice.go index 692d5a35..fadaa305 100644 --- a/qt/gen_qtouchdevice.go +++ b/qt/gen_qtouchdevice.go @@ -68,13 +68,12 @@ func NewQTouchDevice() *QTouchDevice { } func QTouchDevice_Devices() []*QTouchDevice { - var _ma *C.struct_miqt_array = C.QTouchDevice_Devices() + var _ma C.struct_miqt_array = C.QTouchDevice_Devices() _ret := make([]*QTouchDevice, int(_ma.len)) _outCast := (*[0xffff]*C.QTouchDevice)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTouchDevice(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtouchdevice.h b/qt/gen_qtouchdevice.h index 59b52ea1..7345b193 100644 --- a/qt/gen_qtouchdevice.h +++ b/qt/gen_qtouchdevice.h @@ -20,7 +20,7 @@ typedef struct QTouchDevice QTouchDevice; #endif QTouchDevice* QTouchDevice_new(); -struct miqt_array* QTouchDevice_Devices(); +struct miqt_array QTouchDevice_Devices(); struct miqt_string QTouchDevice_Name(const QTouchDevice* self); int QTouchDevice_Type(const QTouchDevice* self); int QTouchDevice_Capabilities(const QTouchDevice* self); diff --git a/qt/gen_qtransposeproxymodel.cpp b/qt/gen_qtransposeproxymodel.cpp index 5cd86353..9fe0bbac 100644 --- a/qt/gen_qtransposeproxymodel.cpp +++ b/qt/gen_qtransposeproxymodel.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -70,10 +71,38 @@ bool QTransposeProxyModel_SetHeaderData(QTransposeProxyModel* self, int section, return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } +bool QTransposeProxyModel_SetItemData(QTransposeProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + QSize* QTransposeProxyModel_Span(const QTransposeProxyModel* self, QModelIndex* index) { return new QSize(self->span(*index)); } +struct miqt_map QTransposeProxyModel_ItemData(const QTransposeProxyModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QModelIndex* QTransposeProxyModel_MapFromSource(const QTransposeProxyModel* self, QModelIndex* sourceIndex) { return new QModelIndex(self->mapFromSource(*sourceIndex)); } diff --git a/qt/gen_qtransposeproxymodel.go b/qt/gen_qtransposeproxymodel.go index d07c7335..be719f85 100644 --- a/qt/gen_qtransposeproxymodel.go +++ b/qt/gen_qtransposeproxymodel.go @@ -106,6 +106,25 @@ func (this *QTransposeProxyModel) SetHeaderData(section int, orientation Orienta return (bool)(C.QTransposeProxyModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } +func (this *QTransposeProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QTransposeProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QTransposeProxyModel) Span(index *QModelIndex) *QSize { _ret := C.QTransposeProxyModel_Span(this.h, index.cPointer()) _goptr := newQSize(_ret) @@ -113,6 +132,24 @@ func (this *QTransposeProxyModel) Span(index *QModelIndex) *QSize { return _goptr } +func (this *QTransposeProxyModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QTransposeProxyModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QTransposeProxyModel) MapFromSource(sourceIndex *QModelIndex) *QModelIndex { _ret := C.QTransposeProxyModel_MapFromSource(this.h, sourceIndex.cPointer()) _goptr := newQModelIndex(_ret) diff --git a/qt/gen_qtransposeproxymodel.h b/qt/gen_qtransposeproxymodel.h index cd96e004..e5e11ed0 100644 --- a/qt/gen_qtransposeproxymodel.h +++ b/qt/gen_qtransposeproxymodel.h @@ -42,7 +42,9 @@ int QTransposeProxyModel_RowCount(const QTransposeProxyModel* self); int QTransposeProxyModel_ColumnCount(const QTransposeProxyModel* self); QVariant* QTransposeProxyModel_HeaderData(const QTransposeProxyModel* self, int section, int orientation); bool QTransposeProxyModel_SetHeaderData(QTransposeProxyModel* self, int section, int orientation, QVariant* value); +bool QTransposeProxyModel_SetItemData(QTransposeProxyModel* self, QModelIndex* index, struct miqt_map roles); QSize* QTransposeProxyModel_Span(const QTransposeProxyModel* self, QModelIndex* index); +struct miqt_map QTransposeProxyModel_ItemData(const QTransposeProxyModel* self, QModelIndex* index); QModelIndex* QTransposeProxyModel_MapFromSource(const QTransposeProxyModel* self, QModelIndex* sourceIndex); QModelIndex* QTransposeProxyModel_MapToSource(const QTransposeProxyModel* self, QModelIndex* proxyIndex); QModelIndex* QTransposeProxyModel_Parent(const QTransposeProxyModel* self, QModelIndex* index); diff --git a/qt/gen_qtreeview.cpp b/qt/gen_qtreeview.cpp index 3c71fd83..63b60dcd 100644 --- a/qt/gen_qtreeview.cpp +++ b/qt/gen_qtreeview.cpp @@ -380,11 +380,11 @@ void QTreeView_ScrollTo2(QTreeView* self, QModelIndex* index, int hint) { self->scrollTo(*index, static_cast(hint)); } -void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles) { +void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles) { QVector roles_QList; - roles_QList.reserve(roles->len); - int* roles_arr = static_cast(roles->data); - for(size_t i = 0; i < roles->len; ++i) { + roles_QList.reserve(roles.len); + int* roles_arr = static_cast(roles.data); + for(size_t i = 0; i < roles.len; ++i) { roles_QList.push_back(static_cast(roles_arr[i])); } self->dataChanged(*topLeft, *bottomRight, roles_QList); diff --git a/qt/gen_qtreeview.go b/qt/gen_qtreeview.go index b1b18d3c..bc9be9f0 100644 --- a/qt/gen_qtreeview.go +++ b/qt/gen_qtreeview.go @@ -441,14 +441,12 @@ func (this *QTreeView) ScrollTo2(index *QModelIndex, hint QAbstractItemView__Scr } func (this *QTreeView) DataChanged3(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int) { - // For the C ABI, malloc a C array of raw pointers roles_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) defer C.free(unsafe.Pointer(roles_CArray)) for i := range roles { roles_CArray[i] = (C.int)(roles[i]) } - roles_ma := &C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(roles_ma)) + roles_ma := C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} C.QTreeView_DataChanged3(this.h, topLeft.cPointer(), bottomRight.cPointer(), roles_ma) } diff --git a/qt/gen_qtreeview.h b/qt/gen_qtreeview.h index a513085a..333f4789 100644 --- a/qt/gen_qtreeview.h +++ b/qt/gen_qtreeview.h @@ -113,7 +113,7 @@ struct miqt_string QTreeView_Tr3(const char* s, const char* c, int n); struct miqt_string QTreeView_TrUtf82(const char* s, const char* c); struct miqt_string QTreeView_TrUtf83(const char* s, const char* c, int n); void QTreeView_ScrollTo2(QTreeView* self, QModelIndex* index, int hint); -void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles); +void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles); void QTreeView_ExpandRecursively2(QTreeView* self, QModelIndex* index, int depth); void QTreeView_Delete(QTreeView* self); diff --git a/qt/gen_qtreewidget.cpp b/qt/gen_qtreewidget.cpp index bccc688e..df3e36e9 100644 --- a/qt/gen_qtreewidget.cpp +++ b/qt/gen_qtreewidget.cpp @@ -24,11 +24,11 @@ QTreeWidgetItem* QTreeWidgetItem_new() { return new QTreeWidgetItem(); } -QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -39,11 +39,11 @@ QTreeWidgetItem* QTreeWidgetItem_new3(QTreeWidget* treeview) { return new QTreeWidgetItem(treeview); } -QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -58,11 +58,11 @@ QTreeWidgetItem* QTreeWidgetItem_new6(QTreeWidgetItem* parent) { return new QTreeWidgetItem(parent); } -QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -81,11 +81,11 @@ QTreeWidgetItem* QTreeWidgetItem_new10(int typeVal) { return new QTreeWidgetItem(static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -96,11 +96,11 @@ QTreeWidgetItem* QTreeWidgetItem_new12(QTreeWidget* treeview, int typeVal) { return new QTreeWidgetItem(treeview, static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -115,11 +115,11 @@ QTreeWidgetItem* QTreeWidgetItem_new15(QTreeWidgetItem* parent, int typeVal) { return new QTreeWidgetItem(parent, static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -393,36 +393,36 @@ QTreeWidgetItem* QTreeWidgetItem_TakeChild(QTreeWidgetItem* self, int index) { return self->takeChild(static_cast(index)); } -void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array* /* of QTreeWidgetItem* */ children) { +void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array /* of QTreeWidgetItem* */ children) { QList children_QList; - children_QList.reserve(children->len); - QTreeWidgetItem** children_arr = static_cast(children->data); - for(size_t i = 0; i < children->len; ++i) { + children_QList.reserve(children.len); + QTreeWidgetItem** children_arr = static_cast(children.data); + for(size_t i = 0; i < children.len; ++i) { children_QList.push_back(children_arr[i]); } self->addChildren(children_QList); } -void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ children) { +void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array /* of QTreeWidgetItem* */ children) { QList children_QList; - children_QList.reserve(children->len); - QTreeWidgetItem** children_arr = static_cast(children->data); - for(size_t i = 0; i < children->len; ++i) { + children_QList.reserve(children.len); + QTreeWidgetItem** children_arr = static_cast(children.data); + for(size_t i = 0; i < children.len; ++i) { children_QList.push_back(children_arr[i]); } self->insertChildren(static_cast(index), children_QList); } -struct miqt_array* QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self) { +struct miqt_array QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self) { QList _ret = self->takeChildren(); // Convert QList<> from C++ memory to manually-managed C memory QTreeWidgetItem** _arr = static_cast(malloc(sizeof(QTreeWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -512,21 +512,21 @@ int QTreeWidget_IndexOfTopLevelItem(const QTreeWidget* self, QTreeWidgetItem* it return self->indexOfTopLevelItem(item); } -void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ items) { +void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array /* of QTreeWidgetItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QTreeWidgetItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QTreeWidgetItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertTopLevelItems(static_cast(index), items_QList); } -void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array* /* of QTreeWidgetItem* */ items) { +void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array /* of QTreeWidgetItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QTreeWidgetItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QTreeWidgetItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->addTopLevelItems(items_QList); @@ -540,11 +540,11 @@ void QTreeWidget_SetHeaderItem(QTreeWidget* self, QTreeWidgetItem* item) { self->setHeaderItem(item); } -void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -632,20 +632,20 @@ void QTreeWidget_SetItemSelected(QTreeWidget* self, QTreeWidgetItem* item, bool self->setItemSelected(item, selectVal); } -struct miqt_array* QTreeWidget_SelectedItems(const QTreeWidget* self) { +struct miqt_array QTreeWidget_SelectedItems(const QTreeWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QTreeWidgetItem** _arr = static_cast(malloc(sizeof(QTreeWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags) { +struct miqt_array QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -653,9 +653,9 @@ struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -887,7 +887,7 @@ bool QTreeWidget_IsPersistentEditorOpen2(const QTreeWidget* self, QTreeWidgetIte return self->isPersistentEditorOpen(item, static_cast(column)); } -struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column) { +struct miqt_array QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags), static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory @@ -895,9 +895,9 @@ struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_s for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qtreewidget.go b/qt/gen_qtreewidget.go index ab087e9a..ec0198d6 100644 --- a/qt/gen_qtreewidget.go +++ b/qt/gen_qtreewidget.go @@ -66,7 +66,6 @@ func NewQTreeWidgetItem() *QTreeWidgetItem { // NewQTreeWidgetItem2 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem2(strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -76,8 +75,7 @@ func NewQTreeWidgetItem2(strings []string) *QTreeWidgetItem { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new2(strings_ma) return newQTreeWidgetItem(ret) } @@ -90,7 +88,6 @@ func NewQTreeWidgetItem3(treeview *QTreeWidget) *QTreeWidgetItem { // NewQTreeWidgetItem4 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem4(treeview *QTreeWidget, strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -100,8 +97,7 @@ func NewQTreeWidgetItem4(treeview *QTreeWidget, strings []string) *QTreeWidgetIt defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new4(treeview.cPointer(), strings_ma) return newQTreeWidgetItem(ret) } @@ -120,7 +116,6 @@ func NewQTreeWidgetItem6(parent *QTreeWidgetItem) *QTreeWidgetItem { // NewQTreeWidgetItem7 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem7(parent *QTreeWidgetItem, strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -130,8 +125,7 @@ func NewQTreeWidgetItem7(parent *QTreeWidgetItem, strings []string) *QTreeWidget defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new7(parent.cPointer(), strings_ma) return newQTreeWidgetItem(ret) } @@ -156,7 +150,6 @@ func NewQTreeWidgetItem10(typeVal int) *QTreeWidgetItem { // NewQTreeWidgetItem11 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem11(strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -166,8 +159,7 @@ func NewQTreeWidgetItem11(strings []string, typeVal int) *QTreeWidgetItem { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new11(strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -180,7 +172,6 @@ func NewQTreeWidgetItem12(treeview *QTreeWidget, typeVal int) *QTreeWidgetItem { // NewQTreeWidgetItem13 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem13(treeview *QTreeWidget, strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -190,8 +181,7 @@ func NewQTreeWidgetItem13(treeview *QTreeWidget, strings []string, typeVal int) defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new13(treeview.cPointer(), strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -210,7 +200,6 @@ func NewQTreeWidgetItem15(parent *QTreeWidgetItem, typeVal int) *QTreeWidgetItem // NewQTreeWidgetItem16 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem16(parent *QTreeWidgetItem, strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -220,8 +209,7 @@ func NewQTreeWidgetItem16(parent *QTreeWidgetItem, strings []string, typeVal int defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new16(parent.cPointer(), strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -513,37 +501,32 @@ func (this *QTreeWidgetItem) TakeChild(index int) *QTreeWidgetItem { } func (this *QTreeWidgetItem) AddChildren(children []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers children_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(children)))) defer C.free(unsafe.Pointer(children_CArray)) for i := range children { children_CArray[i] = children[i].cPointer() } - children_ma := &C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(children_ma)) + children_ma := C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} C.QTreeWidgetItem_AddChildren(this.h, children_ma) } func (this *QTreeWidgetItem) InsertChildren(index int, children []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers children_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(children)))) defer C.free(unsafe.Pointer(children_CArray)) for i := range children { children_CArray[i] = children[i].cPointer() } - children_ma := &C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(children_ma)) + children_ma := C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} C.QTreeWidgetItem_InsertChildren(this.h, (C.int)(index), children_ma) } func (this *QTreeWidgetItem) TakeChildren() []*QTreeWidgetItem { - var _ma *C.struct_miqt_array = C.QTreeWidgetItem_TakeChildren(this.h) + var _ma C.struct_miqt_array = C.QTreeWidgetItem_TakeChildren(this.h) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -676,26 +659,22 @@ func (this *QTreeWidget) IndexOfTopLevelItem(item *QTreeWidgetItem) int { } func (this *QTreeWidget) InsertTopLevelItems(index int, items []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QTreeWidget_InsertTopLevelItems(this.h, (C.int)(index), items_ma) } func (this *QTreeWidget) AddTopLevelItems(items []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QTreeWidget_AddTopLevelItems(this.h, items_ma) } @@ -708,7 +687,6 @@ func (this *QTreeWidget) SetHeaderItem(item *QTreeWidgetItem) { } func (this *QTreeWidget) SetHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -718,8 +696,7 @@ func (this *QTreeWidget) SetHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTreeWidget_SetHeaderLabels(this.h, labels_ma) } @@ -811,13 +788,12 @@ func (this *QTreeWidget) SetItemSelected(item *QTreeWidgetItem, selectVal bool) } func (this *QTreeWidget) SelectedItems() []*QTreeWidgetItem { - var _ma *C.struct_miqt_array = C.QTreeWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QTreeWidget_SelectedItems(this.h) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -826,13 +802,12 @@ func (this *QTreeWidget) FindItems(text string, flags MatchFlag) []*QTreeWidgetI text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTreeWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QTreeWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1157,13 +1132,12 @@ func (this *QTreeWidget) FindItems3(text string, flags MatchFlag, column int) [] text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTreeWidget_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) + var _ma C.struct_miqt_array = C.QTreeWidget_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qtreewidget.h b/qt/gen_qtreewidget.h index 8b74ced5..c3a5c91f 100644 --- a/qt/gen_qtreewidget.h +++ b/qt/gen_qtreewidget.h @@ -46,21 +46,21 @@ typedef struct QWidget QWidget; #endif QTreeWidgetItem* QTreeWidgetItem_new(); -QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new3(QTreeWidget* treeview); -QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new5(QTreeWidget* treeview, QTreeWidgetItem* after); QTreeWidgetItem* QTreeWidgetItem_new6(QTreeWidgetItem* parent); -QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new8(QTreeWidgetItem* parent, QTreeWidgetItem* after); QTreeWidgetItem* QTreeWidgetItem_new9(QTreeWidgetItem* other); QTreeWidgetItem* QTreeWidgetItem_new10(int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new12(QTreeWidget* treeview, int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new14(QTreeWidget* treeview, QTreeWidgetItem* after, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new15(QTreeWidgetItem* parent, int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new17(QTreeWidgetItem* parent, QTreeWidgetItem* after, int typeVal); QTreeWidgetItem* QTreeWidgetItem_Clone(const QTreeWidgetItem* self); QTreeWidget* QTreeWidgetItem_TreeWidget(const QTreeWidgetItem* self); @@ -119,9 +119,9 @@ void QTreeWidgetItem_AddChild(QTreeWidgetItem* self, QTreeWidgetItem* child); void QTreeWidgetItem_InsertChild(QTreeWidgetItem* self, int index, QTreeWidgetItem* child); void QTreeWidgetItem_RemoveChild(QTreeWidgetItem* self, QTreeWidgetItem* child); QTreeWidgetItem* QTreeWidgetItem_TakeChild(QTreeWidgetItem* self, int index); -void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array* /* of QTreeWidgetItem* */ children); -void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ children); -struct miqt_array* QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self); +void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array /* of QTreeWidgetItem* */ children); +void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array /* of QTreeWidgetItem* */ children); +struct miqt_array QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self); int QTreeWidgetItem_Type(const QTreeWidgetItem* self); void QTreeWidgetItem_SortChildren(QTreeWidgetItem* self, int column, int order); void QTreeWidgetItem_Delete(QTreeWidgetItem* self); @@ -141,11 +141,11 @@ void QTreeWidget_InsertTopLevelItem(QTreeWidget* self, int index, QTreeWidgetIte void QTreeWidget_AddTopLevelItem(QTreeWidget* self, QTreeWidgetItem* item); QTreeWidgetItem* QTreeWidget_TakeTopLevelItem(QTreeWidget* self, int index); int QTreeWidget_IndexOfTopLevelItem(const QTreeWidget* self, QTreeWidgetItem* item); -void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ items); -void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array* /* of QTreeWidgetItem* */ items); +void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array /* of QTreeWidgetItem* */ items); +void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array /* of QTreeWidgetItem* */ items); QTreeWidgetItem* QTreeWidget_HeaderItem(const QTreeWidget* self); void QTreeWidget_SetHeaderItem(QTreeWidget* self, QTreeWidgetItem* item); -void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array /* of struct miqt_string */ labels); void QTreeWidget_SetHeaderLabel(QTreeWidget* self, struct miqt_string label); QTreeWidgetItem* QTreeWidget_CurrentItem(const QTreeWidget* self); int QTreeWidget_CurrentColumn(const QTreeWidget* self); @@ -166,8 +166,8 @@ void QTreeWidget_SetItemWidget(QTreeWidget* self, QTreeWidgetItem* item, int col void QTreeWidget_RemoveItemWidget(QTreeWidget* self, QTreeWidgetItem* item, int column); bool QTreeWidget_IsItemSelected(const QTreeWidget* self, QTreeWidgetItem* item); void QTreeWidget_SetItemSelected(QTreeWidget* self, QTreeWidgetItem* item, bool selectVal); -struct miqt_array* QTreeWidget_SelectedItems(const QTreeWidget* self); -struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags); +struct miqt_array QTreeWidget_SelectedItems(const QTreeWidget* self); +struct miqt_array QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags); bool QTreeWidget_IsItemHidden(const QTreeWidget* self, QTreeWidgetItem* item); void QTreeWidget_SetItemHidden(QTreeWidget* self, QTreeWidgetItem* item, bool hide); bool QTreeWidget_IsItemExpanded(const QTreeWidget* self, QTreeWidgetItem* item); @@ -209,7 +209,7 @@ void QTreeWidget_EditItem2(QTreeWidget* self, QTreeWidgetItem* item, int column) void QTreeWidget_OpenPersistentEditor2(QTreeWidget* self, QTreeWidgetItem* item, int column); void QTreeWidget_ClosePersistentEditor2(QTreeWidget* self, QTreeWidgetItem* item, int column); bool QTreeWidget_IsPersistentEditorOpen2(const QTreeWidget* self, QTreeWidgetItem* item, int column); -struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column); +struct miqt_array QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column); void QTreeWidget_ScrollToItem2(QTreeWidget* self, QTreeWidgetItem* item, int hint); void QTreeWidget_Delete(QTreeWidget* self); diff --git a/qt/gen_qundogroup.cpp b/qt/gen_qundogroup.cpp index baf8b106..6e8f01c7 100644 --- a/qt/gen_qundogroup.cpp +++ b/qt/gen_qundogroup.cpp @@ -57,16 +57,16 @@ void QUndoGroup_RemoveStack(QUndoGroup* self, QUndoStack* stack) { self->removeStack(stack); } -struct miqt_array* QUndoGroup_Stacks(const QUndoGroup* self) { +struct miqt_array QUndoGroup_Stacks(const QUndoGroup* self) { QList _ret = self->stacks(); // Convert QList<> from C++ memory to manually-managed C memory QUndoStack** _arr = static_cast(malloc(sizeof(QUndoStack*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qundogroup.go b/qt/gen_qundogroup.go index f2235257..58b11ec1 100644 --- a/qt/gen_qundogroup.go +++ b/qt/gen_qundogroup.go @@ -93,13 +93,12 @@ func (this *QUndoGroup) RemoveStack(stack *QUndoStack) { } func (this *QUndoGroup) Stacks() []*QUndoStack { - var _ma *C.struct_miqt_array = C.QUndoGroup_Stacks(this.h) + var _ma C.struct_miqt_array = C.QUndoGroup_Stacks(this.h) _ret := make([]*QUndoStack, int(_ma.len)) _outCast := (*[0xffff]*C.QUndoStack)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQUndoStack(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qundogroup.h b/qt/gen_qundogroup.h index 4f4fef31..7a333ee1 100644 --- a/qt/gen_qundogroup.h +++ b/qt/gen_qundogroup.h @@ -35,7 +35,7 @@ struct miqt_string QUndoGroup_Tr(const char* s); struct miqt_string QUndoGroup_TrUtf8(const char* s); void QUndoGroup_AddStack(QUndoGroup* self, QUndoStack* stack); void QUndoGroup_RemoveStack(QUndoGroup* self, QUndoStack* stack); -struct miqt_array* QUndoGroup_Stacks(const QUndoGroup* self); +struct miqt_array QUndoGroup_Stacks(const QUndoGroup* self); QUndoStack* QUndoGroup_ActiveStack(const QUndoGroup* self); QAction* QUndoGroup_CreateUndoAction(const QUndoGroup* self, QObject* parent); QAction* QUndoGroup_CreateRedoAction(const QUndoGroup* self, QObject* parent); diff --git a/qt/gen_qurl.cpp b/qt/gen_qurl.cpp index 74b230d0..5fa72983 100644 --- a/qt/gen_qurl.cpp +++ b/qt/gen_qurl.cpp @@ -408,7 +408,7 @@ struct miqt_string QUrl_ToAce(struct miqt_string param1) { return _ms; } -struct miqt_array* QUrl_IdnWhitelist() { +struct miqt_array QUrl_IdnWhitelist() { QStringList _ret = QUrl::idnWhitelist(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -422,17 +422,17 @@ struct miqt_array* QUrl_IdnWhitelist() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris) { +struct miqt_array QUrl_ToStringList(struct miqt_array /* of QUrl* */ uris) { QList uris_QList; - uris_QList.reserve(uris->len); - QUrl** uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + QUrl** uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { uris_QList.push_back(*(uris_arr[i])); } QStringList _ret = QUrl::toStringList(uris_QList); @@ -448,17 +448,17 @@ struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_string */ uris) { +struct miqt_array QUrl_FromStringList(struct miqt_array /* of struct miqt_string */ uris) { QStringList uris_QList; - uris_QList.reserve(uris->len); - struct miqt_string* uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + struct miqt_string* uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { QString uris_arr_i_QString = QString::fromUtf8(uris_arr[i].data, uris_arr[i].len); uris_QList.push_back(uris_arr_i_QString); } @@ -468,17 +468,17 @@ struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_stri for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QUrl_SetIdnWhitelist(struct miqt_array* /* of struct miqt_string */ idnWhitelist) { +void QUrl_SetIdnWhitelist(struct miqt_array /* of struct miqt_string */ idnWhitelist) { QStringList idnWhitelist_QList; - idnWhitelist_QList.reserve(idnWhitelist->len); - struct miqt_string* idnWhitelist_arr = static_cast(idnWhitelist->data); - for(size_t i = 0; i < idnWhitelist->len; ++i) { + idnWhitelist_QList.reserve(idnWhitelist.len); + struct miqt_string* idnWhitelist_arr = static_cast(idnWhitelist.data); + for(size_t i = 0; i < idnWhitelist.len; ++i) { QString idnWhitelist_arr_i_QString = QString::fromUtf8(idnWhitelist_arr[i].data, idnWhitelist_arr[i].len); idnWhitelist_QList.push_back(idnWhitelist_arr_i_QString); } @@ -678,11 +678,11 @@ struct miqt_string QUrl_ToPercentEncoding3(struct miqt_string param1, struct miq return _ms; } -struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_string */ uris, int mode) { +struct miqt_array QUrl_FromStringList2(struct miqt_array /* of struct miqt_string */ uris, int mode) { QStringList uris_QList; - uris_QList.reserve(uris->len); - struct miqt_string* uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + struct miqt_string* uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { QString uris_arr_i_QString = QString::fromUtf8(uris_arr[i].data, uris_arr[i].len); uris_QList.push_back(uris_arr_i_QString); } @@ -692,9 +692,9 @@ struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qurl.go b/qt/gen_qurl.go index 9aac2147..6009fc77 100644 --- a/qt/gen_qurl.go +++ b/qt/gen_qurl.go @@ -496,7 +496,7 @@ func QUrl_ToAce(param1 string) []byte { } func QUrl_IdnWhitelist() []string { - var _ma *C.struct_miqt_array = C.QUrl_IdnWhitelist() + var _ma C.struct_miqt_array = C.QUrl_IdnWhitelist() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -505,20 +505,17 @@ func QUrl_IdnWhitelist() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_ToStringList(uris []QUrl) []string { - // For the C ABI, malloc a C array of raw pointers uris_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { uris_CArray[i] = uris[i].cPointer() } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_ToStringList(uris_ma) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_ToStringList(uris_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -527,12 +524,10 @@ func QUrl_ToStringList(uris []QUrl) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_FromStringList(uris []string) []QUrl { - // For the C ABI, malloc a C array of structs uris_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { @@ -542,9 +537,8 @@ func QUrl_FromStringList(uris []string) []QUrl { defer C.free(unsafe.Pointer(uris_i_ms.data)) uris_CArray[i] = uris_i_ms } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_FromStringList(uris_ma) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_FromStringList(uris_ma) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -553,12 +547,10 @@ func QUrl_FromStringList(uris []string) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_SetIdnWhitelist(idnWhitelist []string) { - // For the C ABI, malloc a C array of structs idnWhitelist_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(idnWhitelist)))) defer C.free(unsafe.Pointer(idnWhitelist_CArray)) for i := range idnWhitelist { @@ -568,8 +560,7 @@ func QUrl_SetIdnWhitelist(idnWhitelist []string) { defer C.free(unsafe.Pointer(idnWhitelist_i_ms.data)) idnWhitelist_CArray[i] = idnWhitelist_i_ms } - idnWhitelist_ma := &C.struct_miqt_array{len: C.size_t(len(idnWhitelist)), data: unsafe.Pointer(idnWhitelist_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(idnWhitelist_ma)) + idnWhitelist_ma := C.struct_miqt_array{len: C.size_t(len(idnWhitelist)), data: unsafe.Pointer(idnWhitelist_CArray)} C.QUrl_SetIdnWhitelist(idnWhitelist_ma) } @@ -776,7 +767,6 @@ func QUrl_ToPercentEncoding3(param1 string, exclude []byte, include []byte) []by } func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { - // For the C ABI, malloc a C array of structs uris_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { @@ -786,9 +776,8 @@ func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { defer C.free(unsafe.Pointer(uris_i_ms.data)) uris_CArray[i] = uris_i_ms } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_FromStringList2(uris_ma, (C.int)(mode)) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_FromStringList2(uris_ma, (C.int)(mode)) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -797,7 +786,6 @@ func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qurl.h b/qt/gen_qurl.h index aa5bc5e3..4c6595ac 100644 --- a/qt/gen_qurl.h +++ b/qt/gen_qurl.h @@ -82,10 +82,10 @@ struct miqt_string QUrl_FromPercentEncoding(struct miqt_string param1); struct miqt_string QUrl_ToPercentEncoding(struct miqt_string param1); struct miqt_string QUrl_FromAce(struct miqt_string param1); struct miqt_string QUrl_ToAce(struct miqt_string param1); -struct miqt_array* QUrl_IdnWhitelist(); -struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris); -struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_string */ uris); -void QUrl_SetIdnWhitelist(struct miqt_array* /* of struct miqt_string */ idnWhitelist); +struct miqt_array QUrl_IdnWhitelist(); +struct miqt_array QUrl_ToStringList(struct miqt_array /* of QUrl* */ uris); +struct miqt_array QUrl_FromStringList(struct miqt_array /* of struct miqt_string */ uris); +void QUrl_SetIdnWhitelist(struct miqt_array /* of struct miqt_string */ idnWhitelist); void QUrl_SetUrl2(QUrl* self, struct miqt_string url, int mode); QUrl* QUrl_FromEncoded2(struct miqt_string url, int mode); QUrl* QUrl_FromUserInput3(struct miqt_string userInput, struct miqt_string workingDirectory, int options); @@ -110,7 +110,7 @@ struct miqt_string QUrl_Fragment1(const QUrl* self, int options); void QUrl_SetFragment2(QUrl* self, struct miqt_string fragment, int mode); struct miqt_string QUrl_ToPercentEncoding2(struct miqt_string param1, struct miqt_string exclude); struct miqt_string QUrl_ToPercentEncoding3(struct miqt_string param1, struct miqt_string exclude, struct miqt_string include); -struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_string */ uris, int mode); +struct miqt_array QUrl_FromStringList2(struct miqt_array /* of struct miqt_string */ uris, int mode); void QUrl_Delete(QUrl* self); #ifdef __cplusplus diff --git a/qt/gen_qurlquery.cpp b/qt/gen_qurlquery.cpp index da3d0c9f..82a16dbc 100644 --- a/qt/gen_qurlquery.cpp +++ b/qt/gen_qurlquery.cpp @@ -121,7 +121,7 @@ struct miqt_string QUrlQuery_QueryItemValue(const QUrlQuery* self, struct miqt_s return _ms; } -struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key) { +struct miqt_array QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key) { QString key_QString = QString::fromUtf8(key.data, key.len); QStringList _ret = self->allQueryItemValues(key_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -136,9 +136,9 @@ struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct mi memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -189,7 +189,7 @@ struct miqt_string QUrlQuery_QueryItemValue2(const QUrlQuery* self, struct miqt_ return _ms; } -struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, int encoding) { +struct miqt_array QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, int encoding) { QString key_QString = QString::fromUtf8(key.data, key.len); QStringList _ret = self->allQueryItemValues(key_QString, static_cast(encoding)); // Convert QList<> from C++ memory to manually-managed C memory @@ -204,9 +204,9 @@ struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct m memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qurlquery.go b/qt/gen_qurlquery.go index a85af5f6..380c3a7d 100644 --- a/qt/gen_qurlquery.go +++ b/qt/gen_qurlquery.go @@ -182,7 +182,7 @@ func (this *QUrlQuery) AllQueryItemValues(key string) []string { key_ms.data = C.CString(key) key_ms.len = C.size_t(len(key)) defer C.free(unsafe.Pointer(key_ms.data)) - var _ma *C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues(this.h, key_ms) + var _ma C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues(this.h, key_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -191,7 +191,6 @@ func (this *QUrlQuery) AllQueryItemValues(key string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -247,7 +246,7 @@ func (this *QUrlQuery) AllQueryItemValues2(key string, encoding QUrl__ComponentF key_ms.data = C.CString(key) key_ms.len = C.size_t(len(key)) defer C.free(unsafe.Pointer(key_ms.data)) - var _ma *C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues2(this.h, key_ms, (C.int)(encoding)) + var _ma C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues2(this.h, key_ms, (C.int)(encoding)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -256,7 +255,6 @@ func (this *QUrlQuery) AllQueryItemValues2(key string, encoding QUrl__ComponentF C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qurlquery.h b/qt/gen_qurlquery.h index 5d287fee..415b1da4 100644 --- a/qt/gen_qurlquery.h +++ b/qt/gen_qurlquery.h @@ -44,14 +44,14 @@ bool QUrlQuery_HasQueryItem(const QUrlQuery* self, struct miqt_string key); void QUrlQuery_AddQueryItem(QUrlQuery* self, struct miqt_string key, struct miqt_string value); void QUrlQuery_RemoveQueryItem(QUrlQuery* self, struct miqt_string key); struct miqt_string QUrlQuery_QueryItemValue(const QUrlQuery* self, struct miqt_string key); -struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key); +struct miqt_array QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key); void QUrlQuery_RemoveAllQueryItems(QUrlQuery* self, struct miqt_string key); QChar* QUrlQuery_DefaultQueryValueDelimiter(); QChar* QUrlQuery_DefaultQueryPairDelimiter(); struct miqt_string QUrlQuery_Query1(const QUrlQuery* self, int encoding); struct miqt_string QUrlQuery_ToString1(const QUrlQuery* self, int encoding); struct miqt_string QUrlQuery_QueryItemValue2(const QUrlQuery* self, struct miqt_string key, int encoding); -struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, int encoding); +struct miqt_array QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, int encoding); void QUrlQuery_Delete(QUrlQuery* self); #ifdef __cplusplus diff --git a/qt/gen_qvariant.cpp b/qt/gen_qvariant.cpp index e7f868fd..d8371b16 100644 --- a/qt/gen_qvariant.cpp +++ b/qt/gen_qvariant.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -109,11 +110,11 @@ QVariant* QVariant_new17(struct miqt_string stringVal) { return new QVariant(stringVal_QString); } -QVariant* QVariant_new18(struct miqt_array* /* of struct miqt_string */ stringlist) { +QVariant* QVariant_new18(struct miqt_array /* of struct miqt_string */ stringlist) { QStringList stringlist_QList; - stringlist_QList.reserve(stringlist->len); - struct miqt_string* stringlist_arr = static_cast(stringlist->data); - for(size_t i = 0; i < stringlist->len; ++i) { + stringlist_QList.reserve(stringlist.len); + struct miqt_string* stringlist_arr = static_cast(stringlist.data); + for(size_t i = 0; i < stringlist.len; ++i) { QString stringlist_arr_i_QString = QString::fromUtf8(stringlist_arr[i].data, stringlist_arr[i].len); stringlist_QList.push_back(stringlist_arr_i_QString); } @@ -136,83 +137,106 @@ QVariant* QVariant_new22(QDateTime* datetime) { return new QVariant(*datetime); } -QVariant* QVariant_new23(QSize* size) { +QVariant* QVariant_new23(struct miqt_map mapVal) { + QMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QVariant(mapVal_QMap); +} + +QVariant* QVariant_new24(struct miqt_map hash) { + QHash hash_QMap; + hash_QMap.reserve(hash.len); + struct miqt_string* hash_karr = static_cast(hash.keys); + QVariant** hash_varr = static_cast(hash.values); + for(size_t i = 0; i < hash.len; ++i) { + QString hash_karr_i_QString = QString::fromUtf8(hash_karr[i].data, hash_karr[i].len); + hash_QMap[hash_karr_i_QString] = *(hash_varr[i]); + } + return new QVariant(hash_QMap); +} + +QVariant* QVariant_new25(QSize* size) { return new QVariant(*size); } -QVariant* QVariant_new24(QSizeF* size) { +QVariant* QVariant_new26(QSizeF* size) { return new QVariant(*size); } -QVariant* QVariant_new25(QPoint* pt) { +QVariant* QVariant_new27(QPoint* pt) { return new QVariant(*pt); } -QVariant* QVariant_new26(QPointF* pt) { +QVariant* QVariant_new28(QPointF* pt) { return new QVariant(*pt); } -QVariant* QVariant_new27(QLine* line) { +QVariant* QVariant_new29(QLine* line) { return new QVariant(*line); } -QVariant* QVariant_new28(QLineF* line) { +QVariant* QVariant_new30(QLineF* line) { return new QVariant(*line); } -QVariant* QVariant_new29(QRect* rect) { +QVariant* QVariant_new31(QRect* rect) { return new QVariant(*rect); } -QVariant* QVariant_new30(QRectF* rect) { +QVariant* QVariant_new32(QRectF* rect) { return new QVariant(*rect); } -QVariant* QVariant_new31(QLocale* locale) { +QVariant* QVariant_new33(QLocale* locale) { return new QVariant(*locale); } -QVariant* QVariant_new32(QRegExp* regExp) { +QVariant* QVariant_new34(QRegExp* regExp) { return new QVariant(*regExp); } -QVariant* QVariant_new33(QRegularExpression* re) { +QVariant* QVariant_new35(QRegularExpression* re) { return new QVariant(*re); } -QVariant* QVariant_new34(QEasingCurve* easing) { +QVariant* QVariant_new36(QEasingCurve* easing) { return new QVariant(*easing); } -QVariant* QVariant_new35(QUuid* uuid) { +QVariant* QVariant_new37(QUuid* uuid) { return new QVariant(*uuid); } -QVariant* QVariant_new36(QUrl* url) { +QVariant* QVariant_new38(QUrl* url) { return new QVariant(*url); } -QVariant* QVariant_new37(QJsonValue* jsonValue) { +QVariant* QVariant_new39(QJsonValue* jsonValue) { return new QVariant(*jsonValue); } -QVariant* QVariant_new38(QJsonObject* jsonObject) { +QVariant* QVariant_new40(QJsonObject* jsonObject) { return new QVariant(*jsonObject); } -QVariant* QVariant_new39(QJsonArray* jsonArray) { +QVariant* QVariant_new41(QJsonArray* jsonArray) { return new QVariant(*jsonArray); } -QVariant* QVariant_new40(QJsonDocument* jsonDocument) { +QVariant* QVariant_new42(QJsonDocument* jsonDocument) { return new QVariant(*jsonDocument); } -QVariant* QVariant_new41(QModelIndex* modelIndex) { +QVariant* QVariant_new43(QModelIndex* modelIndex) { return new QVariant(*modelIndex); } -QVariant* QVariant_new42(QPersistentModelIndex* modelIndex) { +QVariant* QVariant_new44(QPersistentModelIndex* modelIndex) { return new QVariant(*modelIndex); } @@ -325,7 +349,7 @@ struct miqt_string QVariant_ToString(const QVariant* self) { return _ms; } -struct miqt_array* QVariant_ToStringList(const QVariant* self) { +struct miqt_array QVariant_ToStringList(const QVariant* self) { QStringList _ret = self->toStringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -339,9 +363,9 @@ struct miqt_array* QVariant_ToStringList(const QVariant* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -361,6 +385,56 @@ QDateTime* QVariant_ToDateTime(const QVariant* self) { return new QDateTime(self->toDateTime()); } +struct miqt_map QVariant_ToMap(const QVariant* self) { + QMap _ret = self->toMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_map QVariant_ToHash(const QVariant* self) { + QHash _ret = self->toHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QPoint* QVariant_ToPoint(const QVariant* self) { return new QPoint(self->toPoint()); } diff --git a/qt/gen_qvariant.go b/qt/gen_qvariant.go index 8c67a7d6..0453a096 100644 --- a/qt/gen_qvariant.go +++ b/qt/gen_qvariant.go @@ -222,7 +222,6 @@ func NewQVariant17(stringVal string) *QVariant { // NewQVariant18 constructs a new QVariant object. func NewQVariant18(stringlist []string) *QVariant { - // For the C ABI, malloc a C array of structs stringlist_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(stringlist)))) defer C.free(unsafe.Pointer(stringlist_CArray)) for i := range stringlist { @@ -232,8 +231,7 @@ func NewQVariant18(stringlist []string) *QVariant { defer C.free(unsafe.Pointer(stringlist_i_ms.data)) stringlist_CArray[i] = stringlist_i_ms } - stringlist_ma := &C.struct_miqt_array{len: C.size_t(len(stringlist)), data: unsafe.Pointer(stringlist_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(stringlist_ma)) + stringlist_ma := C.struct_miqt_array{len: C.size_t(len(stringlist)), data: unsafe.Pointer(stringlist_CArray)} ret := C.QVariant_new18(stringlist_ma) return newQVariant(ret) } @@ -263,122 +261,172 @@ func NewQVariant22(datetime *QDateTime) *QVariant { } // NewQVariant23 constructs a new QVariant object. -func NewQVariant23(size *QSize) *QVariant { - ret := C.QVariant_new23(size.cPointer()) +func NewQVariant23(mapVal map[string]QVariant) *QVariant { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + ret := C.QVariant_new23(mapVal_mm) return newQVariant(ret) } // NewQVariant24 constructs a new QVariant object. -func NewQVariant24(size *QSizeF) *QVariant { - ret := C.QVariant_new24(size.cPointer()) +func NewQVariant24(hash map[string]QVariant) *QVariant { + hash_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(hash)))) + defer C.free(unsafe.Pointer(hash_Keys_CArray)) + hash_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(hash)))) + defer C.free(unsafe.Pointer(hash_Values_CArray)) + hash_ctr := 0 + for hash_k, hash_v := range hash { + hash_k_ms := C.struct_miqt_string{} + hash_k_ms.data = C.CString(hash_k) + hash_k_ms.len = C.size_t(len(hash_k)) + defer C.free(unsafe.Pointer(hash_k_ms.data)) + hash_Keys_CArray[hash_ctr] = hash_k_ms + hash_Values_CArray[hash_ctr] = hash_v.cPointer() + hash_ctr++ + } + hash_mm := C.struct_miqt_map{ + len: C.size_t(len(hash)), + keys: unsafe.Pointer(hash_Keys_CArray), + values: unsafe.Pointer(hash_Values_CArray), + } + ret := C.QVariant_new24(hash_mm) return newQVariant(ret) } // NewQVariant25 constructs a new QVariant object. -func NewQVariant25(pt *QPoint) *QVariant { - ret := C.QVariant_new25(pt.cPointer()) +func NewQVariant25(size *QSize) *QVariant { + ret := C.QVariant_new25(size.cPointer()) return newQVariant(ret) } // NewQVariant26 constructs a new QVariant object. -func NewQVariant26(pt *QPointF) *QVariant { - ret := C.QVariant_new26(pt.cPointer()) +func NewQVariant26(size *QSizeF) *QVariant { + ret := C.QVariant_new26(size.cPointer()) return newQVariant(ret) } // NewQVariant27 constructs a new QVariant object. -func NewQVariant27(line *QLine) *QVariant { - ret := C.QVariant_new27(line.cPointer()) +func NewQVariant27(pt *QPoint) *QVariant { + ret := C.QVariant_new27(pt.cPointer()) return newQVariant(ret) } // NewQVariant28 constructs a new QVariant object. -func NewQVariant28(line *QLineF) *QVariant { - ret := C.QVariant_new28(line.cPointer()) +func NewQVariant28(pt *QPointF) *QVariant { + ret := C.QVariant_new28(pt.cPointer()) return newQVariant(ret) } // NewQVariant29 constructs a new QVariant object. -func NewQVariant29(rect *QRect) *QVariant { - ret := C.QVariant_new29(rect.cPointer()) +func NewQVariant29(line *QLine) *QVariant { + ret := C.QVariant_new29(line.cPointer()) return newQVariant(ret) } // NewQVariant30 constructs a new QVariant object. -func NewQVariant30(rect *QRectF) *QVariant { - ret := C.QVariant_new30(rect.cPointer()) +func NewQVariant30(line *QLineF) *QVariant { + ret := C.QVariant_new30(line.cPointer()) return newQVariant(ret) } // NewQVariant31 constructs a new QVariant object. -func NewQVariant31(locale *QLocale) *QVariant { - ret := C.QVariant_new31(locale.cPointer()) +func NewQVariant31(rect *QRect) *QVariant { + ret := C.QVariant_new31(rect.cPointer()) return newQVariant(ret) } // NewQVariant32 constructs a new QVariant object. -func NewQVariant32(regExp *QRegExp) *QVariant { - ret := C.QVariant_new32(regExp.cPointer()) +func NewQVariant32(rect *QRectF) *QVariant { + ret := C.QVariant_new32(rect.cPointer()) return newQVariant(ret) } // NewQVariant33 constructs a new QVariant object. -func NewQVariant33(re *QRegularExpression) *QVariant { - ret := C.QVariant_new33(re.cPointer()) +func NewQVariant33(locale *QLocale) *QVariant { + ret := C.QVariant_new33(locale.cPointer()) return newQVariant(ret) } // NewQVariant34 constructs a new QVariant object. -func NewQVariant34(easing *QEasingCurve) *QVariant { - ret := C.QVariant_new34(easing.cPointer()) +func NewQVariant34(regExp *QRegExp) *QVariant { + ret := C.QVariant_new34(regExp.cPointer()) return newQVariant(ret) } // NewQVariant35 constructs a new QVariant object. -func NewQVariant35(uuid *QUuid) *QVariant { - ret := C.QVariant_new35(uuid.cPointer()) +func NewQVariant35(re *QRegularExpression) *QVariant { + ret := C.QVariant_new35(re.cPointer()) return newQVariant(ret) } // NewQVariant36 constructs a new QVariant object. -func NewQVariant36(url *QUrl) *QVariant { - ret := C.QVariant_new36(url.cPointer()) +func NewQVariant36(easing *QEasingCurve) *QVariant { + ret := C.QVariant_new36(easing.cPointer()) return newQVariant(ret) } // NewQVariant37 constructs a new QVariant object. -func NewQVariant37(jsonValue *QJsonValue) *QVariant { - ret := C.QVariant_new37(jsonValue.cPointer()) +func NewQVariant37(uuid *QUuid) *QVariant { + ret := C.QVariant_new37(uuid.cPointer()) return newQVariant(ret) } // NewQVariant38 constructs a new QVariant object. -func NewQVariant38(jsonObject *QJsonObject) *QVariant { - ret := C.QVariant_new38(jsonObject.cPointer()) +func NewQVariant38(url *QUrl) *QVariant { + ret := C.QVariant_new38(url.cPointer()) return newQVariant(ret) } // NewQVariant39 constructs a new QVariant object. -func NewQVariant39(jsonArray *QJsonArray) *QVariant { - ret := C.QVariant_new39(jsonArray.cPointer()) +func NewQVariant39(jsonValue *QJsonValue) *QVariant { + ret := C.QVariant_new39(jsonValue.cPointer()) return newQVariant(ret) } // NewQVariant40 constructs a new QVariant object. -func NewQVariant40(jsonDocument *QJsonDocument) *QVariant { - ret := C.QVariant_new40(jsonDocument.cPointer()) +func NewQVariant40(jsonObject *QJsonObject) *QVariant { + ret := C.QVariant_new40(jsonObject.cPointer()) return newQVariant(ret) } // NewQVariant41 constructs a new QVariant object. -func NewQVariant41(modelIndex *QModelIndex) *QVariant { - ret := C.QVariant_new41(modelIndex.cPointer()) +func NewQVariant41(jsonArray *QJsonArray) *QVariant { + ret := C.QVariant_new41(jsonArray.cPointer()) return newQVariant(ret) } // NewQVariant42 constructs a new QVariant object. -func NewQVariant42(modelIndex *QPersistentModelIndex) *QVariant { - ret := C.QVariant_new42(modelIndex.cPointer()) +func NewQVariant42(jsonDocument *QJsonDocument) *QVariant { + ret := C.QVariant_new42(jsonDocument.cPointer()) + return newQVariant(ret) +} + +// NewQVariant43 constructs a new QVariant object. +func NewQVariant43(modelIndex *QModelIndex) *QVariant { + ret := C.QVariant_new43(modelIndex.cPointer()) + return newQVariant(ret) +} + +// NewQVariant44 constructs a new QVariant object. +func NewQVariant44(modelIndex *QPersistentModelIndex) *QVariant { + ret := C.QVariant_new44(modelIndex.cPointer()) return newQVariant(ret) } @@ -485,7 +533,7 @@ func (this *QVariant) ToString() string { } func (this *QVariant) ToStringList() []string { - var _ma *C.struct_miqt_array = C.QVariant_ToStringList(this.h) + var _ma C.struct_miqt_array = C.QVariant_ToStringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -494,7 +542,6 @@ func (this *QVariant) ToStringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -526,6 +573,46 @@ func (this *QVariant) ToDateTime() *QDateTime { return _goptr } +func (this *QVariant) ToMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QVariant_ToMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QVariant) ToHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QVariant_ToHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QVariant) ToPoint() *QPoint { _ret := C.QVariant_ToPoint(this.h) _goptr := newQPoint(_ret) diff --git a/qt/gen_qvariant.h b/qt/gen_qvariant.h index 5f9b5213..30d2b83a 100644 --- a/qt/gen_qvariant.h +++ b/qt/gen_qvariant.h @@ -116,31 +116,33 @@ QVariant* QVariant_new14(const char* str); QVariant* QVariant_new15(struct miqt_string bytearray); QVariant* QVariant_new16(QBitArray* bitarray); QVariant* QVariant_new17(struct miqt_string stringVal); -QVariant* QVariant_new18(struct miqt_array* /* of struct miqt_string */ stringlist); +QVariant* QVariant_new18(struct miqt_array /* of struct miqt_string */ stringlist); QVariant* QVariant_new19(QChar* qchar); QVariant* QVariant_new20(QDate* date); QVariant* QVariant_new21(QTime* time); QVariant* QVariant_new22(QDateTime* datetime); -QVariant* QVariant_new23(QSize* size); -QVariant* QVariant_new24(QSizeF* size); -QVariant* QVariant_new25(QPoint* pt); -QVariant* QVariant_new26(QPointF* pt); -QVariant* QVariant_new27(QLine* line); -QVariant* QVariant_new28(QLineF* line); -QVariant* QVariant_new29(QRect* rect); -QVariant* QVariant_new30(QRectF* rect); -QVariant* QVariant_new31(QLocale* locale); -QVariant* QVariant_new32(QRegExp* regExp); -QVariant* QVariant_new33(QRegularExpression* re); -QVariant* QVariant_new34(QEasingCurve* easing); -QVariant* QVariant_new35(QUuid* uuid); -QVariant* QVariant_new36(QUrl* url); -QVariant* QVariant_new37(QJsonValue* jsonValue); -QVariant* QVariant_new38(QJsonObject* jsonObject); -QVariant* QVariant_new39(QJsonArray* jsonArray); -QVariant* QVariant_new40(QJsonDocument* jsonDocument); -QVariant* QVariant_new41(QModelIndex* modelIndex); -QVariant* QVariant_new42(QPersistentModelIndex* modelIndex); +QVariant* QVariant_new23(struct miqt_map mapVal); +QVariant* QVariant_new24(struct miqt_map hash); +QVariant* QVariant_new25(QSize* size); +QVariant* QVariant_new26(QSizeF* size); +QVariant* QVariant_new27(QPoint* pt); +QVariant* QVariant_new28(QPointF* pt); +QVariant* QVariant_new29(QLine* line); +QVariant* QVariant_new30(QLineF* line); +QVariant* QVariant_new31(QRect* rect); +QVariant* QVariant_new32(QRectF* rect); +QVariant* QVariant_new33(QLocale* locale); +QVariant* QVariant_new34(QRegExp* regExp); +QVariant* QVariant_new35(QRegularExpression* re); +QVariant* QVariant_new36(QEasingCurve* easing); +QVariant* QVariant_new37(QUuid* uuid); +QVariant* QVariant_new38(QUrl* url); +QVariant* QVariant_new39(QJsonValue* jsonValue); +QVariant* QVariant_new40(QJsonObject* jsonObject); +QVariant* QVariant_new41(QJsonArray* jsonArray); +QVariant* QVariant_new42(QJsonDocument* jsonDocument); +QVariant* QVariant_new43(QModelIndex* modelIndex); +QVariant* QVariant_new44(QPersistentModelIndex* modelIndex); void QVariant_OperatorAssign(QVariant* self, QVariant* other); void QVariant_Swap(QVariant* self, QVariant* other); int QVariant_Type(const QVariant* self); @@ -164,11 +166,13 @@ double QVariant_ToReal(const QVariant* self); struct miqt_string QVariant_ToByteArray(const QVariant* self); QBitArray* QVariant_ToBitArray(const QVariant* self); struct miqt_string QVariant_ToString(const QVariant* self); -struct miqt_array* QVariant_ToStringList(const QVariant* self); +struct miqt_array QVariant_ToStringList(const QVariant* self); QChar* QVariant_ToChar(const QVariant* self); QDate* QVariant_ToDate(const QVariant* self); QTime* QVariant_ToTime(const QVariant* self); QDateTime* QVariant_ToDateTime(const QVariant* self); +struct miqt_map QVariant_ToMap(const QVariant* self); +struct miqt_map QVariant_ToHash(const QVariant* self); QPoint* QVariant_ToPoint(const QVariant* self); QPointF* QVariant_ToPointF(const QVariant* self); QRect* QVariant_ToRect(const QVariant* self); diff --git a/qt/gen_qversionnumber.cpp b/qt/gen_qversionnumber.cpp index 12f17b3b..b7bc000a 100644 --- a/qt/gen_qversionnumber.cpp +++ b/qt/gen_qversionnumber.cpp @@ -11,11 +11,11 @@ QVersionNumber* QVersionNumber_new() { return new QVersionNumber(); } -QVersionNumber* QVersionNumber_new2(struct miqt_array* /* of int */ seg) { +QVersionNumber* QVersionNumber_new2(struct miqt_array /* of int */ seg) { QVector seg_QList; - seg_QList.reserve(seg->len); - int* seg_arr = static_cast(seg->data); - for(size_t i = 0; i < seg->len; ++i) { + seg_QList.reserve(seg.len); + int* seg_arr = static_cast(seg.data); + for(size_t i = 0; i < seg.len; ++i) { seg_QList.push_back(static_cast(seg_arr[i])); } return new QVersionNumber(seg_QList); @@ -57,16 +57,16 @@ QVersionNumber* QVersionNumber_Normalized(const QVersionNumber* self) { return new QVersionNumber(self->normalized()); } -struct miqt_array* QVersionNumber_Segments(const QVersionNumber* self) { +struct miqt_array QVersionNumber_Segments(const QVersionNumber* self) { QVector _ret = self->segments(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qversionnumber.go b/qt/gen_qversionnumber.go index c151c0b5..d01e2386 100644 --- a/qt/gen_qversionnumber.go +++ b/qt/gen_qversionnumber.go @@ -50,14 +50,12 @@ func NewQVersionNumber() *QVersionNumber { // NewQVersionNumber2 constructs a new QVersionNumber object. func NewQVersionNumber2(seg []int) *QVersionNumber { - // For the C ABI, malloc a C array of raw pointers seg_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(seg)))) defer C.free(unsafe.Pointer(seg_CArray)) for i := range seg { seg_CArray[i] = (C.int)(seg[i]) } - seg_ma := &C.struct_miqt_array{len: C.size_t(len(seg)), data: unsafe.Pointer(seg_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(seg_ma)) + seg_ma := C.struct_miqt_array{len: C.size_t(len(seg)), data: unsafe.Pointer(seg_CArray)} ret := C.QVersionNumber_new2(seg_ma) return newQVersionNumber(ret) } @@ -108,13 +106,12 @@ func (this *QVersionNumber) Normalized() *QVersionNumber { } func (this *QVersionNumber) Segments() []int { - var _ma *C.struct_miqt_array = C.QVersionNumber_Segments(this.h) + var _ma C.struct_miqt_array = C.QVersionNumber_Segments(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qversionnumber.h b/qt/gen_qversionnumber.h index 57b807b6..624ce2d0 100644 --- a/qt/gen_qversionnumber.h +++ b/qt/gen_qversionnumber.h @@ -20,7 +20,7 @@ typedef struct QVersionNumber QVersionNumber; #endif QVersionNumber* QVersionNumber_new(); -QVersionNumber* QVersionNumber_new2(struct miqt_array* /* of int */ seg); +QVersionNumber* QVersionNumber_new2(struct miqt_array /* of int */ seg); QVersionNumber* QVersionNumber_new3(int maj); QVersionNumber* QVersionNumber_new4(int maj, int min); QVersionNumber* QVersionNumber_new5(int maj, int min, int mic); @@ -30,7 +30,7 @@ int QVersionNumber_MajorVersion(const QVersionNumber* self); int QVersionNumber_MinorVersion(const QVersionNumber* self); int QVersionNumber_MicroVersion(const QVersionNumber* self); QVersionNumber* QVersionNumber_Normalized(const QVersionNumber* self); -struct miqt_array* QVersionNumber_Segments(const QVersionNumber* self); +struct miqt_array QVersionNumber_Segments(const QVersionNumber* self); int QVersionNumber_SegmentAt(const QVersionNumber* self, int index); int QVersionNumber_SegmentCount(const QVersionNumber* self); bool QVersionNumber_IsPrefixOf(const QVersionNumber* self, QVersionNumber* other); diff --git a/qt/gen_qwidget.cpp b/qt/gen_qwidget.cpp index 5bd7afff..da52a3a3 100644 --- a/qt/gen_qwidget.cpp +++ b/qt/gen_qwidget.cpp @@ -1071,21 +1071,21 @@ void QWidget_AddAction(QWidget* self, QAction* action) { self->addAction(action); } -void QWidget_AddActions(QWidget* self, struct miqt_array* /* of QAction* */ actions) { +void QWidget_AddActions(QWidget* self, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->addActions(actions_QList); } -void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions) { +void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->insertActions(before, actions_QList); @@ -1099,16 +1099,16 @@ void QWidget_RemoveAction(QWidget* self, QAction* action) { self->removeAction(action); } -struct miqt_array* QWidget_Actions(const QWidget* self) { +struct miqt_array QWidget_Actions(const QWidget* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qwidget.go b/qt/gen_qwidget.go index 87a587b1..c5caeac7 100644 --- a/qt/gen_qwidget.go +++ b/qt/gen_qwidget.go @@ -1198,26 +1198,22 @@ func (this *QWidget) AddAction(action *QAction) { } func (this *QWidget) AddActions(actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QWidget_AddActions(this.h, actions_ma) } func (this *QWidget) InsertActions(before *QAction, actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QWidget_InsertActions(this.h, before.cPointer(), actions_ma) } @@ -1230,13 +1226,12 @@ func (this *QWidget) RemoveAction(action *QAction) { } func (this *QWidget) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QWidget_Actions(this.h) + var _ma C.struct_miqt_array = C.QWidget_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qwidget.h b/qt/gen_qwidget.h index 3f1cf0fc..ac924644 100644 --- a/qt/gen_qwidget.h +++ b/qt/gen_qwidget.h @@ -311,11 +311,11 @@ QWidget* QWidget_PreviousInFocusChain(const QWidget* self); bool QWidget_AcceptDrops(const QWidget* self); void QWidget_SetAcceptDrops(QWidget* self, bool on); void QWidget_AddAction(QWidget* self, QAction* action); -void QWidget_AddActions(QWidget* self, struct miqt_array* /* of QAction* */ actions); -void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions); +void QWidget_AddActions(QWidget* self, struct miqt_array /* of QAction* */ actions); +void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions); void QWidget_InsertAction(QWidget* self, QAction* before, QAction* action); void QWidget_RemoveAction(QWidget* self, QAction* action); -struct miqt_array* QWidget_Actions(const QWidget* self); +struct miqt_array QWidget_Actions(const QWidget* self); QWidget* QWidget_ParentWidget(const QWidget* self); void QWidget_SetWindowFlags(QWidget* self, int typeVal); int QWidget_WindowFlags(const QWidget* self); diff --git a/qt/gen_qwizard.cpp b/qt/gen_qwizard.cpp index 6c631504..2e202e97 100644 --- a/qt/gen_qwizard.cpp +++ b/qt/gen_qwizard.cpp @@ -76,42 +76,42 @@ bool QWizard_HasVisitedPage(const QWizard* self, int id) { return self->hasVisitedPage(static_cast(id)); } -struct miqt_array* QWizard_VisitedPages(const QWizard* self) { +struct miqt_array QWizard_VisitedPages(const QWizard* self) { QList _ret = self->visitedPages(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QWizard_VisitedIds(const QWizard* self) { +struct miqt_array QWizard_VisitedIds(const QWizard* self) { QList _ret = self->visitedIds(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QWizard_PageIds(const QWizard* self) { +struct miqt_array QWizard_PageIds(const QWizard* self) { QList _ret = self->pageIds(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -191,11 +191,11 @@ struct miqt_string QWizard_ButtonText(const QWizard* self, int which) { return _ms; } -void QWizard_SetButtonLayout(QWizard* self, struct miqt_array* /* of int */ layout) { +void QWizard_SetButtonLayout(QWizard* self, struct miqt_array /* of int */ layout) { QList layout_QList; - layout_QList.reserve(layout->len); - int* layout_arr = static_cast(layout->data); - for(size_t i = 0; i < layout->len; ++i) { + layout_QList.reserve(layout.len); + int* layout_arr = static_cast(layout.data); + for(size_t i = 0; i < layout.len; ++i) { layout_QList.push_back(static_cast(layout_arr[i])); } self->setButtonLayout(layout_QList); diff --git a/qt/gen_qwizard.go b/qt/gen_qwizard.go index b68b53c0..01912958 100644 --- a/qt/gen_qwizard.go +++ b/qt/gen_qwizard.go @@ -171,35 +171,32 @@ func (this *QWizard) HasVisitedPage(id int) bool { } func (this *QWizard) VisitedPages() []int { - var _ma *C.struct_miqt_array = C.QWizard_VisitedPages(this.h) + var _ma C.struct_miqt_array = C.QWizard_VisitedPages(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QWizard) VisitedIds() []int { - var _ma *C.struct_miqt_array = C.QWizard_VisitedIds(this.h) + var _ma C.struct_miqt_array = C.QWizard_VisitedIds(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QWizard) PageIds() []int { - var _ma *C.struct_miqt_array = C.QWizard_PageIds(this.h) + var _ma C.struct_miqt_array = C.QWizard_PageIds(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -286,14 +283,12 @@ func (this *QWizard) ButtonText(which QWizard__WizardButton) string { } func (this *QWizard) SetButtonLayout(layout []QWizard__WizardButton) { - // For the C ABI, malloc a C array of raw pointers layout_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(layout)))) defer C.free(unsafe.Pointer(layout_CArray)) for i := range layout { layout_CArray[i] = (C.int)(layout[i]) } - layout_ma := &C.struct_miqt_array{len: C.size_t(len(layout)), data: unsafe.Pointer(layout_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(layout_ma)) + layout_ma := C.struct_miqt_array{len: C.size_t(len(layout)), data: unsafe.Pointer(layout_CArray)} C.QWizard_SetButtonLayout(this.h, layout_ma) } diff --git a/qt/gen_qwizard.h b/qt/gen_qwizard.h index 7b3f1f13..2251a684 100644 --- a/qt/gen_qwizard.h +++ b/qt/gen_qwizard.h @@ -45,9 +45,9 @@ void QWizard_SetPage(QWizard* self, int id, QWizardPage* page); void QWizard_RemovePage(QWizard* self, int id); QWizardPage* QWizard_Page(const QWizard* self, int id); bool QWizard_HasVisitedPage(const QWizard* self, int id); -struct miqt_array* QWizard_VisitedPages(const QWizard* self); -struct miqt_array* QWizard_VisitedIds(const QWizard* self); -struct miqt_array* QWizard_PageIds(const QWizard* self); +struct miqt_array QWizard_VisitedPages(const QWizard* self); +struct miqt_array QWizard_VisitedIds(const QWizard* self); +struct miqt_array QWizard_PageIds(const QWizard* self); void QWizard_SetStartId(QWizard* self, int id); int QWizard_StartId(const QWizard* self); QWizardPage* QWizard_CurrentPage(const QWizard* self); @@ -64,7 +64,7 @@ void QWizard_SetOptions(QWizard* self, int options); int QWizard_Options(const QWizard* self); void QWizard_SetButtonText(QWizard* self, int which, struct miqt_string text); struct miqt_string QWizard_ButtonText(const QWizard* self, int which); -void QWizard_SetButtonLayout(QWizard* self, struct miqt_array* /* of int */ layout); +void QWizard_SetButtonLayout(QWizard* self, struct miqt_array /* of int */ layout); void QWizard_SetButton(QWizard* self, int which, QAbstractButton* button); QAbstractButton* QWizard_Button(const QWizard* self, int which); void QWizard_SetTitleFormat(QWizard* self, int format); diff --git a/qt/gen_qxmlstream.cpp b/qt/gen_qxmlstream.cpp index 44d37df9..51059922 100644 --- a/qt/gen_qxmlstream.cpp +++ b/qt/gen_qxmlstream.cpp @@ -380,16 +380,16 @@ struct miqt_string QXmlStreamReader_ReadElementText(QXmlStreamReader* self) { return _ms; } -struct miqt_array* QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self) { QXmlStreamNamespaceDeclarations _ret = self->namespaceDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamNamespaceDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamNamespaceDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamNamespaceDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -397,39 +397,39 @@ void QXmlStreamReader_AddExtraNamespaceDeclaration(QXmlStreamReader* self, QXmlS self->addExtraNamespaceDeclaration(*extraNamespaceDeclaraction); } -void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array* /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions) { +void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions) { QXmlStreamNamespaceDeclarations extraNamespaceDeclaractions_QList; - extraNamespaceDeclaractions_QList.reserve(extraNamespaceDeclaractions->len); - QXmlStreamNamespaceDeclaration** extraNamespaceDeclaractions_arr = static_cast(extraNamespaceDeclaractions->data); - for(size_t i = 0; i < extraNamespaceDeclaractions->len; ++i) { + extraNamespaceDeclaractions_QList.reserve(extraNamespaceDeclaractions.len); + QXmlStreamNamespaceDeclaration** extraNamespaceDeclaractions_arr = static_cast(extraNamespaceDeclaractions.data); + for(size_t i = 0; i < extraNamespaceDeclaractions.len; ++i) { extraNamespaceDeclaractions_QList.push_back(*(extraNamespaceDeclaractions_arr[i])); } self->addExtraNamespaceDeclarations(extraNamespaceDeclaractions_QList); } -struct miqt_array* QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self) { QXmlStreamNotationDeclarations _ret = self->notationDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamNotationDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamNotationDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamNotationDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self) { QXmlStreamEntityDeclarations _ret = self->entityDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamEntityDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamEntityDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamEntityDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/gen_qxmlstream.go b/qt/gen_qxmlstream.go index 0661050c..1b2f2e2c 100644 --- a/qt/gen_qxmlstream.go +++ b/qt/gen_qxmlstream.go @@ -734,7 +734,7 @@ func (this *QXmlStreamReader) ReadElementText() string { } func (this *QXmlStreamReader) NamespaceDeclarations() []QXmlStreamNamespaceDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_NamespaceDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_NamespaceDeclarations(this.h) _ret := make([]QXmlStreamNamespaceDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamNamespaceDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -743,7 +743,6 @@ func (this *QXmlStreamReader) NamespaceDeclarations() []QXmlStreamNamespaceDecla _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -752,19 +751,17 @@ func (this *QXmlStreamReader) AddExtraNamespaceDeclaration(extraNamespaceDeclara } func (this *QXmlStreamReader) AddExtraNamespaceDeclarations(extraNamespaceDeclaractions []QXmlStreamNamespaceDeclaration) { - // For the C ABI, malloc a C array of raw pointers extraNamespaceDeclaractions_CArray := (*[0xffff]*C.QXmlStreamNamespaceDeclaration)(C.malloc(C.size_t(8 * len(extraNamespaceDeclaractions)))) defer C.free(unsafe.Pointer(extraNamespaceDeclaractions_CArray)) for i := range extraNamespaceDeclaractions { extraNamespaceDeclaractions_CArray[i] = extraNamespaceDeclaractions[i].cPointer() } - extraNamespaceDeclaractions_ma := &C.struct_miqt_array{len: C.size_t(len(extraNamespaceDeclaractions)), data: unsafe.Pointer(extraNamespaceDeclaractions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(extraNamespaceDeclaractions_ma)) + extraNamespaceDeclaractions_ma := C.struct_miqt_array{len: C.size_t(len(extraNamespaceDeclaractions)), data: unsafe.Pointer(extraNamespaceDeclaractions_CArray)} C.QXmlStreamReader_AddExtraNamespaceDeclarations(this.h, extraNamespaceDeclaractions_ma) } func (this *QXmlStreamReader) NotationDeclarations() []QXmlStreamNotationDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_NotationDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_NotationDeclarations(this.h) _ret := make([]QXmlStreamNotationDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamNotationDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -773,12 +770,11 @@ func (this *QXmlStreamReader) NotationDeclarations() []QXmlStreamNotationDeclara _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QXmlStreamReader) EntityDeclarations() []QXmlStreamEntityDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_EntityDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_EntityDeclarations(this.h) _ret := make([]QXmlStreamEntityDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamEntityDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -787,7 +783,6 @@ func (this *QXmlStreamReader) EntityDeclarations() []QXmlStreamEntityDeclaration _vv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_vv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/gen_qxmlstream.h b/qt/gen_qxmlstream.h index c09df4b4..a6d27efc 100644 --- a/qt/gen_qxmlstream.h +++ b/qt/gen_qxmlstream.h @@ -122,11 +122,11 @@ long long QXmlStreamReader_LineNumber(const QXmlStreamReader* self); long long QXmlStreamReader_ColumnNumber(const QXmlStreamReader* self); long long QXmlStreamReader_CharacterOffset(const QXmlStreamReader* self); struct miqt_string QXmlStreamReader_ReadElementText(QXmlStreamReader* self); -struct miqt_array* QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self); +struct miqt_array QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self); void QXmlStreamReader_AddExtraNamespaceDeclaration(QXmlStreamReader* self, QXmlStreamNamespaceDeclaration* extraNamespaceDeclaraction); -void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array* /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions); -struct miqt_array* QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self); -struct miqt_array* QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self); +void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions); +struct miqt_array QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self); +struct miqt_array QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self); int QXmlStreamReader_EntityExpansionLimit(const QXmlStreamReader* self); void QXmlStreamReader_SetEntityExpansionLimit(QXmlStreamReader* self, int limit); void QXmlStreamReader_RaiseError(QXmlStreamReader* self); diff --git a/qt/qprintsupport/gen_qabstractprintdialog.cpp b/qt/qprintsupport/gen_qabstractprintdialog.cpp index 12f52b10..45c1cb73 100644 --- a/qt/qprintsupport/gen_qabstractprintdialog.cpp +++ b/qt/qprintsupport/gen_qabstractprintdialog.cpp @@ -65,11 +65,11 @@ bool QAbstractPrintDialog_IsOptionEnabled(const QAbstractPrintDialog* self, int return self->isOptionEnabled(static_cast(option)); } -void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array* /* of QWidget* */ tabs) { +void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array /* of QWidget* */ tabs) { QList tabs_QList; - tabs_QList.reserve(tabs->len); - QWidget** tabs_arr = static_cast(tabs->data); - for(size_t i = 0; i < tabs->len; ++i) { + tabs_QList.reserve(tabs.len); + QWidget** tabs_arr = static_cast(tabs.data); + for(size_t i = 0; i < tabs.len; ++i) { tabs_QList.push_back(tabs_arr[i]); } self->setOptionTabs(tabs_QList); diff --git a/qt/qprintsupport/gen_qabstractprintdialog.go b/qt/qprintsupport/gen_qabstractprintdialog.go index cab6a6e2..ce366bb5 100644 --- a/qt/qprintsupport/gen_qabstractprintdialog.go +++ b/qt/qprintsupport/gen_qabstractprintdialog.go @@ -123,14 +123,12 @@ func (this *QAbstractPrintDialog) IsOptionEnabled(option QAbstractPrintDialog__P } func (this *QAbstractPrintDialog) SetOptionTabs(tabs []*qt.QWidget) { - // For the C ABI, malloc a C array of raw pointers tabs_CArray := (*[0xffff]*C.QWidget)(C.malloc(C.size_t(8 * len(tabs)))) defer C.free(unsafe.Pointer(tabs_CArray)) for i := range tabs { tabs_CArray[i] = (*C.QWidget)(tabs[i].UnsafePointer()) } - tabs_ma := &C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabs_ma)) + tabs_ma := C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} C.QAbstractPrintDialog_SetOptionTabs(this.h, tabs_ma) } diff --git a/qt/qprintsupport/gen_qabstractprintdialog.h b/qt/qprintsupport/gen_qabstractprintdialog.h index 05d878b2..b083e649 100644 --- a/qt/qprintsupport/gen_qabstractprintdialog.h +++ b/qt/qprintsupport/gen_qabstractprintdialog.h @@ -35,7 +35,7 @@ void QAbstractPrintDialog_AddEnabledOption(QAbstractPrintDialog* self, int optio void QAbstractPrintDialog_SetEnabledOptions(QAbstractPrintDialog* self, int options); int QAbstractPrintDialog_EnabledOptions(const QAbstractPrintDialog* self); bool QAbstractPrintDialog_IsOptionEnabled(const QAbstractPrintDialog* self, int option); -void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array* /* of QWidget* */ tabs); +void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array /* of QWidget* */ tabs); void QAbstractPrintDialog_SetPrintRange(QAbstractPrintDialog* self, int rangeVal); int QAbstractPrintDialog_PrintRange(const QAbstractPrintDialog* self); void QAbstractPrintDialog_SetMinMax(QAbstractPrintDialog* self, int min, int max); diff --git a/qt/qprintsupport/gen_qprinter.cpp b/qt/qprintsupport/gen_qprinter.cpp index 9ec3e92c..02b7edb9 100644 --- a/qt/qprintsupport/gen_qprinter.cpp +++ b/qt/qprintsupport/gen_qprinter.cpp @@ -275,16 +275,16 @@ int QPrinter_Duplex(const QPrinter* self) { return static_cast(_ret); } -struct miqt_array* QPrinter_SupportedResolutions(const QPrinter* self) { +struct miqt_array QPrinter_SupportedResolutions(const QPrinter* self) { QList _ret = self->supportedResolutions(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/qprintsupport/gen_qprinter.go b/qt/qprintsupport/gen_qprinter.go index f4cc3754..314632bf 100644 --- a/qt/qprintsupport/gen_qprinter.go +++ b/qt/qprintsupport/gen_qprinter.go @@ -399,13 +399,12 @@ func (this *QPrinter) Duplex() QPrinter__DuplexMode { } func (this *QPrinter) SupportedResolutions() []int { - var _ma *C.struct_miqt_array = C.QPrinter_SupportedResolutions(this.h) + var _ma C.struct_miqt_array = C.QPrinter_SupportedResolutions(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/qprintsupport/gen_qprinter.h b/qt/qprintsupport/gen_qprinter.h index a463cab6..489d2ce2 100644 --- a/qt/qprintsupport/gen_qprinter.h +++ b/qt/qprintsupport/gen_qprinter.h @@ -88,7 +88,7 @@ void QPrinter_SetPaperSource(QPrinter* self, int paperSource); int QPrinter_PaperSource(const QPrinter* self); void QPrinter_SetDuplex(QPrinter* self, int duplex); int QPrinter_Duplex(const QPrinter* self); -struct miqt_array* QPrinter_SupportedResolutions(const QPrinter* self); +struct miqt_array QPrinter_SupportedResolutions(const QPrinter* self); void QPrinter_SetFontEmbeddingEnabled(QPrinter* self, bool enable); bool QPrinter_FontEmbeddingEnabled(const QPrinter* self); void QPrinter_SetDoubleSidedPrinting(QPrinter* self, bool enable); diff --git a/qt/qprintsupport/gen_qprinterinfo.cpp b/qt/qprintsupport/gen_qprinterinfo.cpp index 52963c49..b76eb58a 100644 --- a/qt/qprintsupport/gen_qprinterinfo.cpp +++ b/qt/qprintsupport/gen_qprinterinfo.cpp @@ -86,16 +86,16 @@ int QPrinterInfo_State(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self) { QList _ret = self->supportedPageSizes(); // Convert QList<> from C++ memory to manually-managed C memory QPageSize** _arr = static_cast(malloc(sizeof(QPageSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPageSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -115,7 +115,7 @@ QPageSize* QPrinterInfo_MaximumPhysicalPageSize(const QPrinterInfo* self) { return new QPageSize(self->maximumPhysicalPageSize()); } -struct miqt_array* QPrinterInfo_SupportedPaperSizes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedPaperSizes(const QPrinterInfo* self) { QList _ret = self->supportedPaperSizes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -123,22 +123,22 @@ struct miqt_array* QPrinterInfo_SupportedPaperSizes(const QPrinterInfo* self) { QPagedPaintDevice::PageSize _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPrinterInfo_SupportedResolutions(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedResolutions(const QPrinterInfo* self) { QList _ret = self->supportedResolutions(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -147,7 +147,7 @@ int QPrinterInfo_DefaultDuplexMode(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { QList _ret = self->supportedDuplexModes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -155,9 +155,9 @@ struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { QPrinter::DuplexMode _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -166,7 +166,7 @@ int QPrinterInfo_DefaultColorMode(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { QList _ret = self->supportedColorModes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -174,13 +174,13 @@ struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { QPrinter::ColorMode _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPrinterInfo_AvailablePrinterNames() { +struct miqt_array QPrinterInfo_AvailablePrinterNames() { QStringList _ret = QPrinterInfo::availablePrinterNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -194,22 +194,22 @@ struct miqt_array* QPrinterInfo_AvailablePrinterNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPrinterInfo_AvailablePrinters() { +struct miqt_array QPrinterInfo_AvailablePrinters() { QList _ret = QPrinterInfo::availablePrinters(); // Convert QList<> from C++ memory to manually-managed C memory QPrinterInfo** _arr = static_cast(malloc(sizeof(QPrinterInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPrinterInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt/qprintsupport/gen_qprinterinfo.go b/qt/qprintsupport/gen_qprinterinfo.go index 89bfb6cd..5520335b 100644 --- a/qt/qprintsupport/gen_qprinterinfo.go +++ b/qt/qprintsupport/gen_qprinterinfo.go @@ -110,7 +110,7 @@ func (this *QPrinterInfo) State() QPrinter__PrinterState { } func (this *QPrinterInfo) SupportedPageSizes() []qt.QPageSize { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedPageSizes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedPageSizes(this.h) _ret := make([]qt.QPageSize, int(_ma.len)) _outCast := (*[0xffff]*C.QPageSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -119,7 +119,6 @@ func (this *QPrinterInfo) SupportedPageSizes() []qt.QPageSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -149,24 +148,22 @@ func (this *QPrinterInfo) MaximumPhysicalPageSize() *qt.QPageSize { } func (this *QPrinterInfo) SupportedPaperSizes() []qt.QPagedPaintDevice__PageSize { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedPaperSizes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedPaperSizes(this.h) _ret := make([]qt.QPagedPaintDevice__PageSize, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (qt.QPagedPaintDevice__PageSize)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QPrinterInfo) SupportedResolutions() []int { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedResolutions(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedResolutions(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -175,13 +172,12 @@ func (this *QPrinterInfo) DefaultDuplexMode() QPrinter__DuplexMode { } func (this *QPrinterInfo) SupportedDuplexModes() []QPrinter__DuplexMode { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedDuplexModes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedDuplexModes(this.h) _ret := make([]QPrinter__DuplexMode, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QPrinter__DuplexMode)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -190,18 +186,17 @@ func (this *QPrinterInfo) DefaultColorMode() QPrinter__ColorMode { } func (this *QPrinterInfo) SupportedColorModes() []QPrinter__ColorMode { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedColorModes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedColorModes(this.h) _ret := make([]QPrinter__ColorMode, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QPrinter__ColorMode)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func QPrinterInfo_AvailablePrinterNames() []string { - var _ma *C.struct_miqt_array = C.QPrinterInfo_AvailablePrinterNames() + var _ma C.struct_miqt_array = C.QPrinterInfo_AvailablePrinterNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -210,12 +205,11 @@ func QPrinterInfo_AvailablePrinterNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPrinterInfo_AvailablePrinters() []QPrinterInfo { - var _ma *C.struct_miqt_array = C.QPrinterInfo_AvailablePrinters() + var _ma C.struct_miqt_array = C.QPrinterInfo_AvailablePrinters() _ret := make([]QPrinterInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QPrinterInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -224,7 +218,6 @@ func QPrinterInfo_AvailablePrinters() []QPrinterInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt/qprintsupport/gen_qprinterinfo.h b/qt/qprintsupport/gen_qprinterinfo.h index 3603e653..59860629 100644 --- a/qt/qprintsupport/gen_qprinterinfo.h +++ b/qt/qprintsupport/gen_qprinterinfo.h @@ -35,19 +35,19 @@ bool QPrinterInfo_IsNull(const QPrinterInfo* self); bool QPrinterInfo_IsDefault(const QPrinterInfo* self); bool QPrinterInfo_IsRemote(const QPrinterInfo* self); int QPrinterInfo_State(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self); QPageSize* QPrinterInfo_DefaultPageSize(const QPrinterInfo* self); bool QPrinterInfo_SupportsCustomPageSizes(const QPrinterInfo* self); QPageSize* QPrinterInfo_MinimumPhysicalPageSize(const QPrinterInfo* self); QPageSize* QPrinterInfo_MaximumPhysicalPageSize(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedPaperSizes(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedResolutions(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedPaperSizes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedResolutions(const QPrinterInfo* self); int QPrinterInfo_DefaultDuplexMode(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self); int QPrinterInfo_DefaultColorMode(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_AvailablePrinterNames(); -struct miqt_array* QPrinterInfo_AvailablePrinters(); +struct miqt_array QPrinterInfo_SupportedColorModes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_AvailablePrinterNames(); +struct miqt_array QPrinterInfo_AvailablePrinters(); struct miqt_string QPrinterInfo_DefaultPrinterName(); QPrinterInfo* QPrinterInfo_DefaultPrinter(); QPrinterInfo* QPrinterInfo_PrinterInfo(struct miqt_string printerName); diff --git a/qt6/gen_qabstracteventdispatcher.cpp b/qt6/gen_qabstracteventdispatcher.cpp index 85b1149b..637a9109 100644 --- a/qt6/gen_qabstracteventdispatcher.cpp +++ b/qt6/gen_qabstracteventdispatcher.cpp @@ -65,16 +65,16 @@ bool QAbstractEventDispatcher_UnregisterTimers(QAbstractEventDispatcher* self, Q return self->unregisterTimers(object); } -struct miqt_array* QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object) { +struct miqt_array QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object) { QList _ret = self->registeredTimers(object); // Convert QList<> from C++ memory to manually-managed C memory QAbstractEventDispatcher__TimerInfo** _arr = static_cast(malloc(sizeof(QAbstractEventDispatcher__TimerInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QAbstractEventDispatcher::TimerInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qabstracteventdispatcher.go b/qt6/gen_qabstracteventdispatcher.go index 4013d43e..a6eae42b 100644 --- a/qt6/gen_qabstracteventdispatcher.go +++ b/qt6/gen_qabstracteventdispatcher.go @@ -96,7 +96,7 @@ func (this *QAbstractEventDispatcher) UnregisterTimers(object *QObject) bool { } func (this *QAbstractEventDispatcher) RegisteredTimers(object *QObject) []QAbstractEventDispatcher__TimerInfo { - var _ma *C.struct_miqt_array = C.QAbstractEventDispatcher_RegisteredTimers(this.h, object.cPointer()) + var _ma C.struct_miqt_array = C.QAbstractEventDispatcher_RegisteredTimers(this.h, object.cPointer()) _ret := make([]QAbstractEventDispatcher__TimerInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractEventDispatcher__TimerInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -105,7 +105,6 @@ func (this *QAbstractEventDispatcher) RegisteredTimers(object *QObject) []QAbstr _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qabstracteventdispatcher.h b/qt6/gen_qabstracteventdispatcher.h index 34b860fe..dbae1d7e 100644 --- a/qt6/gen_qabstracteventdispatcher.h +++ b/qt6/gen_qabstracteventdispatcher.h @@ -48,7 +48,7 @@ int QAbstractEventDispatcher_RegisterTimer(QAbstractEventDispatcher* self, long void QAbstractEventDispatcher_RegisterTimer2(QAbstractEventDispatcher* self, int timerId, long long interval, int timerType, QObject* object); bool QAbstractEventDispatcher_UnregisterTimer(QAbstractEventDispatcher* self, int timerId); bool QAbstractEventDispatcher_UnregisterTimers(QAbstractEventDispatcher* self, QObject* object); -struct miqt_array* QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object); +struct miqt_array QAbstractEventDispatcher_RegisteredTimers(const QAbstractEventDispatcher* self, QObject* object); int QAbstractEventDispatcher_RemainingTime(QAbstractEventDispatcher* self, int timerId); void QAbstractEventDispatcher_WakeUp(QAbstractEventDispatcher* self); void QAbstractEventDispatcher_Interrupt(QAbstractEventDispatcher* self); diff --git a/qt6/gen_qabstractitemdelegate.cpp b/qt6/gen_qabstractitemdelegate.cpp index 1a1847f0..a7912017 100644 --- a/qt6/gen_qabstractitemdelegate.cpp +++ b/qt6/gen_qabstractitemdelegate.cpp @@ -72,16 +72,16 @@ bool QAbstractItemDelegate_HelpEvent(QAbstractItemDelegate* self, QHelpEvent* ev return self->helpEvent(event, view, *option, *index); } -struct miqt_array* QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self) { +struct miqt_array QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self) { QList _ret = self->paintingRoles(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qabstractitemdelegate.go b/qt6/gen_qabstractitemdelegate.go index a62b3877..0a45ab80 100644 --- a/qt6/gen_qabstractitemdelegate.go +++ b/qt6/gen_qabstractitemdelegate.go @@ -113,13 +113,12 @@ func (this *QAbstractItemDelegate) HelpEvent(event *QHelpEvent, view *QAbstractI } func (this *QAbstractItemDelegate) PaintingRoles() []int { - var _ma *C.struct_miqt_array = C.QAbstractItemDelegate_PaintingRoles(this.h) + var _ma C.struct_miqt_array = C.QAbstractItemDelegate_PaintingRoles(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qabstractitemdelegate.h b/qt6/gen_qabstractitemdelegate.h index 89eb015c..1f670dbe 100644 --- a/qt6/gen_qabstractitemdelegate.h +++ b/qt6/gen_qabstractitemdelegate.h @@ -51,7 +51,7 @@ void QAbstractItemDelegate_SetModelData(const QAbstractItemDelegate* self, QWidg void QAbstractItemDelegate_UpdateEditorGeometry(const QAbstractItemDelegate* self, QWidget* editor, QStyleOptionViewItem* option, QModelIndex* index); bool QAbstractItemDelegate_EditorEvent(QAbstractItemDelegate* self, QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem* option, QModelIndex* index); bool QAbstractItemDelegate_HelpEvent(QAbstractItemDelegate* self, QHelpEvent* event, QAbstractItemView* view, QStyleOptionViewItem* option, QModelIndex* index); -struct miqt_array* QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self); +struct miqt_array QAbstractItemDelegate_PaintingRoles(const QAbstractItemDelegate* self); void QAbstractItemDelegate_CommitData(QAbstractItemDelegate* self, QWidget* editor); void QAbstractItemDelegate_connect_CommitData(QAbstractItemDelegate* self, intptr_t slot); void QAbstractItemDelegate_CloseEditor(QAbstractItemDelegate* self, QWidget* editor); diff --git a/qt6/gen_qabstractitemmodel.cpp b/qt6/gen_qabstractitemmodel.cpp index 0b943415..84d69948 100644 --- a/qt6/gen_qabstractitemmodel.cpp +++ b/qt6/gen_qabstractitemmodel.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -356,11 +358,39 @@ bool QAbstractItemModel_SetHeaderData(QAbstractItemModel* self, int section, int return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } +struct miqt_map QAbstractItemModel_ItemData(const QAbstractItemModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QAbstractItemModel_SetItemData(QAbstractItemModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + bool QAbstractItemModel_ClearItemData(QAbstractItemModel* self, QModelIndex* index) { return self->clearItemData(*index); } -struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) { +struct miqt_array QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -374,17 +404,17 @@ struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -477,16 +507,16 @@ QModelIndex* QAbstractItemModel_Buddy(const QAbstractItemModel* self, QModelInde return new QModelIndex(self->buddy(*index)); } -struct miqt_array* QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -494,6 +524,29 @@ QSize* QAbstractItemModel_Span(const QAbstractItemModel* self, QModelIndex* inde return new QSize(self->span(*index)); } +struct miqt_map QAbstractItemModel_RoleNames(const QAbstractItemModel* self) { + QHash _ret = self->roleNames(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + struct miqt_string* _varr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + QByteArray _hashval_qb = _itr->second; + struct miqt_string _hashval_ms; + _hashval_ms.len = _hashval_qb.length(); + _hashval_ms.data = static_cast(malloc(_hashval_ms.len)); + memcpy(_hashval_ms.data, _hashval_qb.data(), _hashval_ms.len); + _varr[_ctr] = _hashval_ms; + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + bool QAbstractItemModel_CheckIndex(const QAbstractItemModel* self, QModelIndex* index) { return self->checkIndex(*index); } @@ -654,29 +707,29 @@ void QAbstractItemModel_Sort2(QAbstractItemModel* self, int column, int order) { self->sort(static_cast(column), static_cast(order)); } -struct miqt_array* QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -684,11 +737,11 @@ bool QAbstractItemModel_CheckIndex2(const QAbstractItemModel* self, QModelIndex* return self->checkIndex(*index, static_cast(options)); } -void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles) { +void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles) { QList roles_QList; - roles_QList.reserve(roles->len); - int* roles_arr = static_cast(roles->data); - for(size_t i = 0; i < roles->len; ++i) { + roles_QList.reserve(roles.len); + int* roles_arr = static_cast(roles.data); + for(size_t i = 0; i < roles.len; ++i) { roles_QList.push_back(static_cast(roles_arr[i])); } self->dataChanged(*topLeft, *bottomRight, roles_QList); @@ -708,19 +761,19 @@ void QAbstractItemModel_connect_DataChanged3(QAbstractItemModel* self, intptr_t for (size_t i = 0, e = roles_ret.length(); i < e; ++i) { roles_arr[i] = roles_ret[i]; } - struct miqt_array* roles_out = static_cast(malloc(sizeof(struct miqt_array))); - roles_out->len = roles_ret.length(); - roles_out->data = static_cast(roles_arr); - struct miqt_array* sigval3 = roles_out; + struct miqt_array roles_out; + roles_out.len = roles_ret.length(); + roles_out.data = static_cast(roles_arr); + struct miqt_array sigval3 = roles_out; miqt_exec_callback_QAbstractItemModel_DataChanged3(slot, sigval1, sigval2, sigval3); }); } -void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents) { +void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutChanged(parents_QList); @@ -734,19 +787,19 @@ void QAbstractItemModel_connect_LayoutChanged1(QAbstractItemModel* self, intptr_ for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; miqt_exec_callback_QAbstractItemModel_LayoutChanged1(slot, sigval1); }); } -void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint) { +void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutChanged(parents_QList, static_cast(hint)); @@ -760,21 +813,21 @@ void QAbstractItemModel_connect_LayoutChanged2(QAbstractItemModel* self, intptr_ for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; QAbstractItemModel::LayoutChangeHint hint_ret = hint; int sigval2 = static_cast(hint_ret); miqt_exec_callback_QAbstractItemModel_LayoutChanged2(slot, sigval1, sigval2); }); } -void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents) { +void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutAboutToBeChanged(parents_QList); @@ -788,19 +841,19 @@ void QAbstractItemModel_connect_LayoutAboutToBeChanged1(QAbstractItemModel* self for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(slot, sigval1); }); } -void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint) { +void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint) { QList parents_QList; - parents_QList.reserve(parents->len); - QPersistentModelIndex** parents_arr = static_cast(parents->data); - for(size_t i = 0; i < parents->len; ++i) { + parents_QList.reserve(parents.len); + QPersistentModelIndex** parents_arr = static_cast(parents.data); + for(size_t i = 0; i < parents.len; ++i) { parents_QList.push_back(*(parents_arr[i])); } self->layoutAboutToBeChanged(parents_QList, static_cast(hint)); @@ -814,10 +867,10 @@ void QAbstractItemModel_connect_LayoutAboutToBeChanged2(QAbstractItemModel* self for (size_t i = 0, e = parents_ret.length(); i < e; ++i) { parents_arr[i] = new QPersistentModelIndex(parents_ret[i]); } - struct miqt_array* parents_out = static_cast(malloc(sizeof(struct miqt_array))); - parents_out->len = parents_ret.length(); - parents_out->data = static_cast(parents_arr); - struct miqt_array* sigval1 = parents_out; + struct miqt_array parents_out; + parents_out.len = parents_ret.length(); + parents_out.data = static_cast(parents_arr); + struct miqt_array sigval1 = parents_out; QAbstractItemModel::LayoutChangeHint hint_ret = hint; int sigval2 = static_cast(hint_ret); miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(slot, sigval1, sigval2); diff --git a/qt6/gen_qabstractitemmodel.go b/qt6/gen_qabstractitemmodel.go index 53f4ad91..0749fe4e 100644 --- a/qt6/gen_qabstractitemmodel.go +++ b/qt6/gen_qabstractitemmodel.go @@ -611,12 +611,49 @@ func (this *QAbstractItemModel) SetHeaderData(section int, orientation Orientati return (bool)(C.QAbstractItemModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } +func (this *QAbstractItemModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QAbstractItemModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QAbstractItemModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QAbstractItemModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QAbstractItemModel) ClearItemData(index *QModelIndex) bool { return (bool)(C.QAbstractItemModel_ClearItemData(this.h, index.cPointer())) } func (this *QAbstractItemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QAbstractItemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -625,19 +662,16 @@ func (this *QAbstractItemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAbstractItemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QAbstractItemModel_MimeData(this.h, indexes_ma))) } @@ -729,7 +763,7 @@ func (this *QAbstractItemModel) Buddy(index *QModelIndex) *QModelIndex { } func (this *QAbstractItemModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -738,7 +772,6 @@ func (this *QAbstractItemModel) Match(start *QModelIndex, role int, value *QVari _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -749,6 +782,23 @@ func (this *QAbstractItemModel) Span(index *QModelIndex) *QSize { return _goptr } +func (this *QAbstractItemModel) RoleNames() map[int][]byte { + var _mm C.struct_miqt_map = C.QAbstractItemModel_RoleNames(this.h) + _ret := make(map[int][]byte, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + var _hashval_bytearray C.struct_miqt_string = _Values[i] + _hashval_ret := C.GoBytes(unsafe.Pointer(_hashval_bytearray.data), C.int(int64(_hashval_bytearray.len))) + C.free(unsafe.Pointer(_hashval_bytearray.data)) + _entry_Value := _hashval_ret + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QAbstractItemModel) CheckIndex(index *QModelIndex) bool { return (bool)(C.QAbstractItemModel_CheckIndex(this.h, index.cPointer())) } @@ -948,7 +998,7 @@ func (this *QAbstractItemModel) Sort2(column int, order SortOrder) { } func (this *QAbstractItemModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -957,12 +1007,11 @@ func (this *QAbstractItemModel) Match4(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAbstractItemModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QAbstractItemModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QAbstractItemModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -971,7 +1020,6 @@ func (this *QAbstractItemModel) Match5(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -980,14 +1028,12 @@ func (this *QAbstractItemModel) CheckIndex2(index *QModelIndex, options QAbstrac } func (this *QAbstractItemModel) DataChanged3(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int) { - // For the C ABI, malloc a C array of raw pointers roles_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) defer C.free(unsafe.Pointer(roles_CArray)) for i := range roles { roles_CArray[i] = (C.int)(roles[i]) } - roles_ma := &C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(roles_ma)) + roles_ma := C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} C.QAbstractItemModel_DataChanged3(this.h, topLeft.cPointer(), bottomRight.cPointer(), roles_ma) } func (this *QAbstractItemModel) OnDataChanged3(slot func(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int)) { @@ -995,7 +1041,7 @@ func (this *QAbstractItemModel) OnDataChanged3(slot func(topLeft *QModelIndex, b } //export miqt_exec_callback_QAbstractItemModel_DataChanged3 -func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft *C.QModelIndex, bottomRight *C.QModelIndex, roles *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft *C.QModelIndex, bottomRight *C.QModelIndex, roles C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") @@ -1004,27 +1050,24 @@ func miqt_exec_callback_QAbstractItemModel_DataChanged3(cb C.intptr_t, topLeft * // Convert all CABI parameters to Go parameters slotval1 := UnsafeNewQModelIndex(unsafe.Pointer(topLeft)) slotval2 := UnsafeNewQModelIndex(unsafe.Pointer(bottomRight)) - var roles_ma *C.struct_miqt_array = roles + var roles_ma C.struct_miqt_array = roles roles_ret := make([]int, int(roles_ma.len)) roles_outCast := (*[0xffff]C.int)(unsafe.Pointer(roles_ma.data)) // hey ya for i := 0; i < int(roles_ma.len); i++ { roles_ret[i] = (int)(roles_outCast[i]) } - C.free(unsafe.Pointer(roles_ma)) slotval3 := roles_ret gofunc(slotval1, slotval2, slotval3) } func (this *QAbstractItemModel) LayoutChanged1(parents []QPersistentModelIndex) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutChanged1(this.h, parents_ma) } func (this *QAbstractItemModel) OnLayoutChanged1(slot func(parents []QPersistentModelIndex)) { @@ -1032,14 +1075,14 @@ func (this *QAbstractItemModel) OnLayoutChanged1(slot func(parents []QPersistent } //export miqt_exec_callback_QAbstractItemModel_LayoutChanged1 -func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -1048,21 +1091,18 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged1(cb C.intptr_t, parents parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret gofunc(slotval1) } func (this *QAbstractItemModel) LayoutChanged2(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutChanged2(this.h, parents_ma, (C.int)(hint)) } func (this *QAbstractItemModel) OnLayoutChanged2(slot func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) { @@ -1070,14 +1110,14 @@ func (this *QAbstractItemModel) OnLayoutChanged2(slot func(parents []QPersistent } //export miqt_exec_callback_QAbstractItemModel_LayoutChanged2 -func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents *C.struct_miqt_array, hint C.int) { +func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents C.struct_miqt_array, hint C.int) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -1086,7 +1126,6 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret slotval2 := (QAbstractItemModel__LayoutChangeHint)(hint) @@ -1095,14 +1134,12 @@ func miqt_exec_callback_QAbstractItemModel_LayoutChanged2(cb C.intptr_t, parents } func (this *QAbstractItemModel) LayoutAboutToBeChanged1(parents []QPersistentModelIndex) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutAboutToBeChanged1(this.h, parents_ma) } func (this *QAbstractItemModel) OnLayoutAboutToBeChanged1(slot func(parents []QPersistentModelIndex)) { @@ -1110,14 +1147,14 @@ func (this *QAbstractItemModel) OnLayoutAboutToBeChanged1(slot func(parents []QP } //export miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1 -func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t, parents *C.struct_miqt_array) { +func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t, parents C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -1126,21 +1163,18 @@ func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged1(cb C.intptr_t parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret gofunc(slotval1) } func (this *QAbstractItemModel) LayoutAboutToBeChanged2(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint) { - // For the C ABI, malloc a C array of raw pointers parents_CArray := (*[0xffff]*C.QPersistentModelIndex)(C.malloc(C.size_t(8 * len(parents)))) defer C.free(unsafe.Pointer(parents_CArray)) for i := range parents { parents_CArray[i] = parents[i].cPointer() } - parents_ma := &C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(parents_ma)) + parents_ma := C.struct_miqt_array{len: C.size_t(len(parents)), data: unsafe.Pointer(parents_CArray)} C.QAbstractItemModel_LayoutAboutToBeChanged2(this.h, parents_ma, (C.int)(hint)) } func (this *QAbstractItemModel) OnLayoutAboutToBeChanged2(slot func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) { @@ -1148,14 +1182,14 @@ func (this *QAbstractItemModel) OnLayoutAboutToBeChanged2(slot func(parents []QP } //export miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2 -func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t, parents *C.struct_miqt_array, hint C.int) { +func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t, parents C.struct_miqt_array, hint C.int) { gofunc, ok := cgo.Handle(cb).Value().(func(parents []QPersistentModelIndex, hint QAbstractItemModel__LayoutChangeHint)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var parents_ma *C.struct_miqt_array = parents + var parents_ma C.struct_miqt_array = parents parents_ret := make([]QPersistentModelIndex, int(parents_ma.len)) parents_outCast := (*[0xffff]*C.QPersistentModelIndex)(unsafe.Pointer(parents_ma.data)) // hey ya for i := 0; i < int(parents_ma.len); i++ { @@ -1164,7 +1198,6 @@ func miqt_exec_callback_QAbstractItemModel_LayoutAboutToBeChanged2(cb C.intptr_t parents_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer parents_ret[i] = *parents_lv_goptr } - C.free(unsafe.Pointer(parents_ma)) slotval1 := parents_ret slotval2 := (QAbstractItemModel__LayoutChangeHint)(hint) diff --git a/qt6/gen_qabstractitemmodel.h b/qt6/gen_qabstractitemmodel.h index cc36d2c6..d1d455e3 100644 --- a/qt6/gen_qabstractitemmodel.h +++ b/qt6/gen_qabstractitemmodel.h @@ -17,6 +17,7 @@ extern "C" { class QAbstractItemModel; class QAbstractListModel; class QAbstractTableModel; +class QByteArray; class QMetaObject; class QMimeData; class QModelIndex; @@ -29,6 +30,7 @@ class QVariant; typedef struct QAbstractItemModel QAbstractItemModel; typedef struct QAbstractListModel QAbstractListModel; typedef struct QAbstractTableModel QAbstractTableModel; +typedef struct QByteArray QByteArray; typedef struct QMetaObject QMetaObject; typedef struct QMimeData QMimeData; typedef struct QModelIndex QModelIndex; @@ -123,9 +125,11 @@ QVariant* QAbstractItemModel_Data(const QAbstractItemModel* self, QModelIndex* i bool QAbstractItemModel_SetData(QAbstractItemModel* self, QModelIndex* index, QVariant* value); QVariant* QAbstractItemModel_HeaderData(const QAbstractItemModel* self, int section, int orientation); bool QAbstractItemModel_SetHeaderData(QAbstractItemModel* self, int section, int orientation, QVariant* value); +struct miqt_map QAbstractItemModel_ItemData(const QAbstractItemModel* self, QModelIndex* index); +bool QAbstractItemModel_SetItemData(QAbstractItemModel* self, QModelIndex* index, struct miqt_map roles); bool QAbstractItemModel_ClearItemData(QAbstractItemModel* self, QModelIndex* index); -struct miqt_array* QAbstractItemModel_MimeTypes(const QAbstractItemModel* self); -QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QAbstractItemModel_MimeTypes(const QAbstractItemModel* self); +QMimeData* QAbstractItemModel_MimeData(const QAbstractItemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QAbstractItemModel_CanDropMimeData(const QAbstractItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QAbstractItemModel_DropMimeData(QAbstractItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); int QAbstractItemModel_SupportedDropActions(const QAbstractItemModel* self); @@ -147,8 +151,9 @@ bool QAbstractItemModel_CanFetchMore(const QAbstractItemModel* self, QModelIndex int QAbstractItemModel_Flags(const QAbstractItemModel* self, QModelIndex* index); void QAbstractItemModel_Sort(QAbstractItemModel* self, int column); QModelIndex* QAbstractItemModel_Buddy(const QAbstractItemModel* self, QModelIndex* index); -struct miqt_array* QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QAbstractItemModel_Match(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value); QSize* QAbstractItemModel_Span(const QAbstractItemModel* self, QModelIndex* index); +struct miqt_map QAbstractItemModel_RoleNames(const QAbstractItemModel* self); bool QAbstractItemModel_CheckIndex(const QAbstractItemModel* self, QModelIndex* index); void QAbstractItemModel_MultiData(const QAbstractItemModel* self, QModelIndex* index, QModelRoleDataSpan* roleDataSpan); void QAbstractItemModel_DataChanged(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight); @@ -181,18 +186,18 @@ bool QAbstractItemModel_InsertColumn2(QAbstractItemModel* self, int column, QMod bool QAbstractItemModel_RemoveRow2(QAbstractItemModel* self, int row, QModelIndex* parent); bool QAbstractItemModel_RemoveColumn2(QAbstractItemModel* self, int column, QModelIndex* parent); void QAbstractItemModel_Sort2(QAbstractItemModel* self, int column, int order); -struct miqt_array* QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QAbstractItemModel_Match4(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QAbstractItemModel_Match5(const QAbstractItemModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); bool QAbstractItemModel_CheckIndex2(const QAbstractItemModel* self, QModelIndex* index, int options); -void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles); +void QAbstractItemModel_DataChanged3(QAbstractItemModel* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles); void QAbstractItemModel_connect_DataChanged3(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents); +void QAbstractItemModel_LayoutChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents); void QAbstractItemModel_connect_LayoutChanged1(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint); +void QAbstractItemModel_LayoutChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint); void QAbstractItemModel_connect_LayoutChanged2(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents); +void QAbstractItemModel_LayoutAboutToBeChanged1(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents); void QAbstractItemModel_connect_LayoutAboutToBeChanged1(QAbstractItemModel* self, intptr_t slot); -void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array* /* of QPersistentModelIndex* */ parents, int hint); +void QAbstractItemModel_LayoutAboutToBeChanged2(QAbstractItemModel* self, struct miqt_array /* of QPersistentModelIndex* */ parents, int hint); void QAbstractItemModel_connect_LayoutAboutToBeChanged2(QAbstractItemModel* self, intptr_t slot); void QAbstractItemModel_Delete(QAbstractItemModel* self); diff --git a/qt6/gen_qabstractproxymodel.cpp b/qt6/gen_qabstractproxymodel.cpp index b12b3b66..017acf29 100644 --- a/qt6/gen_qabstractproxymodel.cpp +++ b/qt6/gen_qabstractproxymodel.cpp @@ -1,6 +1,8 @@ #include #include +#include #include +#include #include #include #include @@ -64,6 +66,24 @@ QVariant* QAbstractProxyModel_HeaderData(const QAbstractProxyModel* self, int se return new QVariant(self->headerData(static_cast(section), static_cast(orientation))); } +struct miqt_map QAbstractProxyModel_ItemData(const QAbstractProxyModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + int QAbstractProxyModel_Flags(const QAbstractProxyModel* self, QModelIndex* index) { Qt::ItemFlags _ret = self->flags(*index); return static_cast(_ret); @@ -73,6 +93,16 @@ bool QAbstractProxyModel_SetData(QAbstractProxyModel* self, QModelIndex* index, return self->setData(*index, *value); } +bool QAbstractProxyModel_SetItemData(QAbstractProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + bool QAbstractProxyModel_SetHeaderData(QAbstractProxyModel* self, int section, int orientation, QVariant* value) { return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } @@ -109,11 +139,11 @@ QModelIndex* QAbstractProxyModel_Sibling(const QAbstractProxyModel* self, int ro return new QModelIndex(self->sibling(static_cast(row), static_cast(column), *idx)); } -QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -127,7 +157,7 @@ bool QAbstractProxyModel_DropMimeData(QAbstractProxyModel* self, QMimeData* data return self->dropMimeData(data, static_cast(action), static_cast(row), static_cast(column), *parent); } -struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self) { +struct miqt_array QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -141,9 +171,9 @@ struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -157,6 +187,29 @@ int QAbstractProxyModel_SupportedDropActions(const QAbstractProxyModel* self) { return static_cast(_ret); } +struct miqt_map QAbstractProxyModel_RoleNames(const QAbstractProxyModel* self) { + QHash _ret = self->roleNames(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + struct miqt_string* _varr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + QByteArray _hashval_qb = _itr->second; + struct miqt_string _hashval_ms; + _hashval_ms.len = _hashval_qb.length(); + _hashval_ms.data = static_cast(malloc(_hashval_ms.len)); + memcpy(_hashval_ms.data, _hashval_qb.data(), _hashval_ms.len); + _varr[_ctr] = _hashval_ms; + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + struct miqt_string QAbstractProxyModel_Tr2(const char* s, const char* c) { QString _ret = QAbstractProxyModel::tr(s, c); // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory diff --git a/qt6/gen_qabstractproxymodel.go b/qt6/gen_qabstractproxymodel.go index 6f40bc7a..1e5a6a2e 100644 --- a/qt6/gen_qabstractproxymodel.go +++ b/qt6/gen_qabstractproxymodel.go @@ -106,6 +106,24 @@ func (this *QAbstractProxyModel) HeaderData(section int, orientation Orientation return _goptr } +func (this *QAbstractProxyModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QAbstractProxyModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QAbstractProxyModel) Flags(index *QModelIndex) ItemFlag { return (ItemFlag)(C.QAbstractProxyModel_Flags(this.h, index.cPointer())) } @@ -114,6 +132,25 @@ func (this *QAbstractProxyModel) SetData(index *QModelIndex, value *QVariant) bo return (bool)(C.QAbstractProxyModel_SetData(this.h, index.cPointer(), value.cPointer())) } +func (this *QAbstractProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QAbstractProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QAbstractProxyModel) SetHeaderData(section int, orientation Orientation, value *QVariant) bool { return (bool)(C.QAbstractProxyModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } @@ -160,14 +197,12 @@ func (this *QAbstractProxyModel) Sibling(row int, column int, idx *QModelIndex) } func (this *QAbstractProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QAbstractProxyModel_MimeData(this.h, indexes_ma))) } @@ -180,7 +215,7 @@ func (this *QAbstractProxyModel) DropMimeData(data *QMimeData, action DropAction } func (this *QAbstractProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QAbstractProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QAbstractProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -189,7 +224,6 @@ func (this *QAbstractProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -201,6 +235,23 @@ func (this *QAbstractProxyModel) SupportedDropActions() DropAction { return (DropAction)(C.QAbstractProxyModel_SupportedDropActions(this.h)) } +func (this *QAbstractProxyModel) RoleNames() map[int][]byte { + var _mm C.struct_miqt_map = C.QAbstractProxyModel_RoleNames(this.h) + _ret := make(map[int][]byte, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + var _hashval_bytearray C.struct_miqt_string = _Values[i] + _hashval_ret := C.GoBytes(unsafe.Pointer(_hashval_bytearray.data), C.int(int64(_hashval_bytearray.len))) + C.free(unsafe.Pointer(_hashval_bytearray.data)) + _entry_Value := _hashval_ret + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func QAbstractProxyModel_Tr2(s string, c string) string { s_Cstring := C.CString(s) defer C.free(unsafe.Pointer(s_Cstring)) diff --git a/qt6/gen_qabstractproxymodel.h b/qt6/gen_qabstractproxymodel.h index 24f1cee5..8c2d3ae7 100644 --- a/qt6/gen_qabstractproxymodel.h +++ b/qt6/gen_qabstractproxymodel.h @@ -16,6 +16,7 @@ extern "C" { #ifdef __cplusplus class QAbstractItemModel; class QAbstractProxyModel; +class QByteArray; class QMetaObject; class QMimeData; class QModelIndex; @@ -24,6 +25,7 @@ class QVariant; #else typedef struct QAbstractItemModel QAbstractItemModel; typedef struct QAbstractProxyModel QAbstractProxyModel; +typedef struct QByteArray QByteArray; typedef struct QMetaObject QMetaObject; typedef struct QMimeData QMimeData; typedef struct QModelIndex QModelIndex; @@ -42,8 +44,10 @@ bool QAbstractProxyModel_Submit(QAbstractProxyModel* self); void QAbstractProxyModel_Revert(QAbstractProxyModel* self); QVariant* QAbstractProxyModel_Data(const QAbstractProxyModel* self, QModelIndex* proxyIndex); QVariant* QAbstractProxyModel_HeaderData(const QAbstractProxyModel* self, int section, int orientation); +struct miqt_map QAbstractProxyModel_ItemData(const QAbstractProxyModel* self, QModelIndex* index); int QAbstractProxyModel_Flags(const QAbstractProxyModel* self, QModelIndex* index); bool QAbstractProxyModel_SetData(QAbstractProxyModel* self, QModelIndex* index, QVariant* value); +bool QAbstractProxyModel_SetItemData(QAbstractProxyModel* self, QModelIndex* index, struct miqt_map roles); bool QAbstractProxyModel_SetHeaderData(QAbstractProxyModel* self, int section, int orientation, QVariant* value); bool QAbstractProxyModel_ClearItemData(QAbstractProxyModel* self, QModelIndex* index); QModelIndex* QAbstractProxyModel_Buddy(const QAbstractProxyModel* self, QModelIndex* index); @@ -53,12 +57,13 @@ void QAbstractProxyModel_Sort(QAbstractProxyModel* self, int column); QSize* QAbstractProxyModel_Span(const QAbstractProxyModel* self, QModelIndex* index); bool QAbstractProxyModel_HasChildren(const QAbstractProxyModel* self); QModelIndex* QAbstractProxyModel_Sibling(const QAbstractProxyModel* self, int row, int column, QModelIndex* idx); -QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +QMimeData* QAbstractProxyModel_MimeData(const QAbstractProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QAbstractProxyModel_CanDropMimeData(const QAbstractProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QAbstractProxyModel_DropMimeData(QAbstractProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); -struct miqt_array* QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self); +struct miqt_array QAbstractProxyModel_MimeTypes(const QAbstractProxyModel* self); int QAbstractProxyModel_SupportedDragActions(const QAbstractProxyModel* self); int QAbstractProxyModel_SupportedDropActions(const QAbstractProxyModel* self); +struct miqt_map QAbstractProxyModel_RoleNames(const QAbstractProxyModel* self); struct miqt_string QAbstractProxyModel_Tr2(const char* s, const char* c); struct miqt_string QAbstractProxyModel_Tr3(const char* s, const char* c, int n); QVariant* QAbstractProxyModel_Data2(const QAbstractProxyModel* self, QModelIndex* proxyIndex, int role); diff --git a/qt6/gen_qabstractscrollarea.cpp b/qt6/gen_qabstractscrollarea.cpp index 962a8105..3105ffba 100644 --- a/qt6/gen_qabstractscrollarea.cpp +++ b/qt6/gen_qabstractscrollarea.cpp @@ -84,16 +84,16 @@ void QAbstractScrollArea_AddScrollBarWidget(QAbstractScrollArea* self, QWidget* self->addScrollBarWidget(widget, static_cast(alignment)); } -struct miqt_array* QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment) { +struct miqt_array QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment) { QWidgetList _ret = self->scrollBarWidgets(static_cast(alignment)); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qabstractscrollarea.go b/qt6/gen_qabstractscrollarea.go index c9c53437..55481c62 100644 --- a/qt6/gen_qabstractscrollarea.go +++ b/qt6/gen_qabstractscrollarea.go @@ -127,13 +127,12 @@ func (this *QAbstractScrollArea) AddScrollBarWidget(widget *QWidget, alignment A } func (this *QAbstractScrollArea) ScrollBarWidgets(alignment AlignmentFlag) []*QWidget { - var _ma *C.struct_miqt_array = C.QAbstractScrollArea_ScrollBarWidgets(this.h, (C.int)(alignment)) + var _ma C.struct_miqt_array = C.QAbstractScrollArea_ScrollBarWidgets(this.h, (C.int)(alignment)) _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qabstractscrollarea.h b/qt6/gen_qabstractscrollarea.h index 3329bc9b..d730a80c 100644 --- a/qt6/gen_qabstractscrollarea.h +++ b/qt6/gen_qabstractscrollarea.h @@ -43,7 +43,7 @@ void QAbstractScrollArea_SetHorizontalScrollBar(QAbstractScrollArea* self, QScro QWidget* QAbstractScrollArea_CornerWidget(const QAbstractScrollArea* self); void QAbstractScrollArea_SetCornerWidget(QAbstractScrollArea* self, QWidget* widget); void QAbstractScrollArea_AddScrollBarWidget(QAbstractScrollArea* self, QWidget* widget, int alignment); -struct miqt_array* QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment); +struct miqt_array QAbstractScrollArea_ScrollBarWidgets(QAbstractScrollArea* self, int alignment); QWidget* QAbstractScrollArea_Viewport(const QAbstractScrollArea* self); void QAbstractScrollArea_SetViewport(QAbstractScrollArea* self, QWidget* widget); QSize* QAbstractScrollArea_MaximumViewportSize(const QAbstractScrollArea* self); diff --git a/qt6/gen_qaccessible.cpp b/qt6/gen_qaccessible.cpp index 85831e8e..dda58de2 100644 --- a/qt6/gen_qaccessible.cpp +++ b/qt6/gen_qaccessible.cpp @@ -306,29 +306,29 @@ bool QAccessibleTableCellInterface_IsSelected(const QAccessibleTableCellInterfac return self->isSelected(); } -struct miqt_array* QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self) { +struct miqt_array QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self) { QList _ret = self->columnHeaderCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self) { +struct miqt_array QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self) { QList _ret = self->rowHeaderCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -376,16 +376,16 @@ int QAccessibleTableInterface_SelectedCellCount(const QAccessibleTableInterface* return self->selectedCellCount(); } -struct miqt_array* QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self) { QList _ret = self->selectedCells(); // Convert QList<> from C++ memory to manually-managed C memory QAccessibleInterface** _arr = static_cast(malloc(sizeof(QAccessibleInterface*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -427,29 +427,29 @@ int QAccessibleTableInterface_RowCount(const QAccessibleTableInterface* self) { return self->rowCount(); } -struct miqt_array* QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self) { QList _ret = self->selectedColumns(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self) { +struct miqt_array QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self) { QList _ret = self->selectedRows(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -496,7 +496,7 @@ struct miqt_string QAccessibleActionInterface_Tr(const char* sourceText) { return _ms; } -struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self) { +struct miqt_array QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self) { QStringList _ret = self->actionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -510,9 +510,9 @@ struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -545,7 +545,7 @@ void QAccessibleActionInterface_DoAction(QAccessibleActionInterface* self, struc self->doAction(actionName_QString); } -struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName) { +struct miqt_array QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName) { QString actionName_QString = QString::fromUtf8(actionName.data, actionName.len); QStringList _ret = self->keyBindingsForAction(actionName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -560,9 +560,9 @@ struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccess memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qaccessible.go b/qt6/gen_qaccessible.go index 79ede701..49263d54 100644 --- a/qt6/gen_qaccessible.go +++ b/qt6/gen_qaccessible.go @@ -485,24 +485,22 @@ func (this *QAccessibleTableCellInterface) IsSelected() bool { } func (this *QAccessibleTableCellInterface) ColumnHeaderCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableCellInterface_ColumnHeaderCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableCellInterface_ColumnHeaderCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAccessibleTableCellInterface) RowHeaderCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableCellInterface_RowHeaderCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableCellInterface_RowHeaderCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -590,13 +588,12 @@ func (this *QAccessibleTableInterface) SelectedCellCount() int { } func (this *QAccessibleTableInterface) SelectedCells() []*QAccessibleInterface { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedCells(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedCells(this.h) _ret := make([]*QAccessibleInterface, int(_ma.len)) _outCast := (*[0xffff]*C.QAccessibleInterface)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAccessibleInterface(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -631,24 +628,22 @@ func (this *QAccessibleTableInterface) RowCount() int { } func (this *QAccessibleTableInterface) SelectedColumns() []int { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedColumns(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedColumns(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QAccessibleTableInterface) SelectedRows() []int { - var _ma *C.struct_miqt_array = C.QAccessibleTableInterface_SelectedRows(this.h) + var _ma C.struct_miqt_array = C.QAccessibleTableInterface_SelectedRows(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -733,7 +728,7 @@ func QAccessibleActionInterface_Tr(sourceText string) string { } func (this *QAccessibleActionInterface) ActionNames() []string { - var _ma *C.struct_miqt_array = C.QAccessibleActionInterface_ActionNames(this.h) + var _ma C.struct_miqt_array = C.QAccessibleActionInterface_ActionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -742,7 +737,6 @@ func (this *QAccessibleActionInterface) ActionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -781,7 +775,7 @@ func (this *QAccessibleActionInterface) KeyBindingsForAction(actionName string) actionName_ms.data = C.CString(actionName) actionName_ms.len = C.size_t(len(actionName)) defer C.free(unsafe.Pointer(actionName_ms.data)) - var _ma *C.struct_miqt_array = C.QAccessibleActionInterface_KeyBindingsForAction(this.h, actionName_ms) + var _ma C.struct_miqt_array = C.QAccessibleActionInterface_KeyBindingsForAction(this.h, actionName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -790,7 +784,6 @@ func (this *QAccessibleActionInterface) KeyBindingsForAction(actionName string) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qaccessible.h b/qt6/gen_qaccessible.h index 194b5c21..ca518eb7 100644 --- a/qt6/gen_qaccessible.h +++ b/qt6/gen_qaccessible.h @@ -134,8 +134,8 @@ void QAccessibleValueInterface_OperatorAssign(QAccessibleValueInterface* self, Q void QAccessibleValueInterface_Delete(QAccessibleValueInterface* self); bool QAccessibleTableCellInterface_IsSelected(const QAccessibleTableCellInterface* self); -struct miqt_array* QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self); -struct miqt_array* QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self); +struct miqt_array QAccessibleTableCellInterface_ColumnHeaderCells(const QAccessibleTableCellInterface* self); +struct miqt_array QAccessibleTableCellInterface_RowHeaderCells(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_ColumnIndex(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_RowIndex(const QAccessibleTableCellInterface* self); int QAccessibleTableCellInterface_ColumnExtent(const QAccessibleTableCellInterface* self); @@ -148,15 +148,15 @@ QAccessibleInterface* QAccessibleTableInterface_Caption(const QAccessibleTableIn QAccessibleInterface* QAccessibleTableInterface_Summary(const QAccessibleTableInterface* self); QAccessibleInterface* QAccessibleTableInterface_CellAt(const QAccessibleTableInterface* self, int row, int column); int QAccessibleTableInterface_SelectedCellCount(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedCells(const QAccessibleTableInterface* self); struct miqt_string QAccessibleTableInterface_ColumnDescription(const QAccessibleTableInterface* self, int column); struct miqt_string QAccessibleTableInterface_RowDescription(const QAccessibleTableInterface* self, int row); int QAccessibleTableInterface_SelectedColumnCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_SelectedRowCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_ColumnCount(const QAccessibleTableInterface* self); int QAccessibleTableInterface_RowCount(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self); -struct miqt_array* QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedColumns(const QAccessibleTableInterface* self); +struct miqt_array QAccessibleTableInterface_SelectedRows(const QAccessibleTableInterface* self); bool QAccessibleTableInterface_IsColumnSelected(const QAccessibleTableInterface* self, int column); bool QAccessibleTableInterface_IsRowSelected(const QAccessibleTableInterface* self, int row); bool QAccessibleTableInterface_SelectRow(QAccessibleTableInterface* self, int row); @@ -167,11 +167,11 @@ void QAccessibleTableInterface_ModelChange(QAccessibleTableInterface* self, QAcc void QAccessibleTableInterface_Delete(QAccessibleTableInterface* self); struct miqt_string QAccessibleActionInterface_Tr(const char* sourceText); -struct miqt_array* QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self); +struct miqt_array QAccessibleActionInterface_ActionNames(const QAccessibleActionInterface* self); struct miqt_string QAccessibleActionInterface_LocalizedActionName(const QAccessibleActionInterface* self, struct miqt_string name); struct miqt_string QAccessibleActionInterface_LocalizedActionDescription(const QAccessibleActionInterface* self, struct miqt_string name); void QAccessibleActionInterface_DoAction(QAccessibleActionInterface* self, struct miqt_string actionName); -struct miqt_array* QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName); +struct miqt_array QAccessibleActionInterface_KeyBindingsForAction(const QAccessibleActionInterface* self, struct miqt_string actionName); struct miqt_string QAccessibleActionInterface_PressAction(); struct miqt_string QAccessibleActionInterface_IncreaseAction(); struct miqt_string QAccessibleActionInterface_DecreaseAction(); diff --git a/qt6/gen_qaccessiblewidget.cpp b/qt6/gen_qaccessiblewidget.cpp index 6f24396b..3714d335 100644 --- a/qt6/gen_qaccessiblewidget.cpp +++ b/qt6/gen_qaccessiblewidget.cpp @@ -90,7 +90,7 @@ void* QAccessibleWidget_InterfaceCast(QAccessibleWidget* self, int t) { return self->interface_cast(static_cast(t)); } -struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self) { +struct miqt_array QAccessibleWidget_ActionNames(const QAccessibleWidget* self) { QStringList _ret = self->actionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -104,9 +104,9 @@ struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -115,7 +115,7 @@ void QAccessibleWidget_DoAction(QAccessibleWidget* self, struct miqt_string acti self->doAction(actionName_QString); } -struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName) { +struct miqt_array QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName) { QString actionName_QString = QString::fromUtf8(actionName.data, actionName.len); QStringList _ret = self->keyBindingsForAction(actionName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -130,9 +130,9 @@ struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidge memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qaccessiblewidget.go b/qt6/gen_qaccessiblewidget.go index e11685b8..1b6ad9c2 100644 --- a/qt6/gen_qaccessiblewidget.go +++ b/qt6/gen_qaccessiblewidget.go @@ -137,7 +137,7 @@ func (this *QAccessibleWidget) InterfaceCast(t QAccessible__InterfaceType) unsaf } func (this *QAccessibleWidget) ActionNames() []string { - var _ma *C.struct_miqt_array = C.QAccessibleWidget_ActionNames(this.h) + var _ma C.struct_miqt_array = C.QAccessibleWidget_ActionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -146,7 +146,6 @@ func (this *QAccessibleWidget) ActionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -163,7 +162,7 @@ func (this *QAccessibleWidget) KeyBindingsForAction(actionName string) []string actionName_ms.data = C.CString(actionName) actionName_ms.len = C.size_t(len(actionName)) defer C.free(unsafe.Pointer(actionName_ms.data)) - var _ma *C.struct_miqt_array = C.QAccessibleWidget_KeyBindingsForAction(this.h, actionName_ms) + var _ma C.struct_miqt_array = C.QAccessibleWidget_KeyBindingsForAction(this.h, actionName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,6 +171,5 @@ func (this *QAccessibleWidget) KeyBindingsForAction(actionName string) []string C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qaccessiblewidget.h b/qt6/gen_qaccessiblewidget.h index bb1fbc73..f6b7b643 100644 --- a/qt6/gen_qaccessiblewidget.h +++ b/qt6/gen_qaccessiblewidget.h @@ -52,9 +52,9 @@ QAccessible__State* QAccessibleWidget_State(const QAccessibleWidget* self); QColor* QAccessibleWidget_ForegroundColor(const QAccessibleWidget* self); QColor* QAccessibleWidget_BackgroundColor(const QAccessibleWidget* self); void* QAccessibleWidget_InterfaceCast(QAccessibleWidget* self, int t); -struct miqt_array* QAccessibleWidget_ActionNames(const QAccessibleWidget* self); +struct miqt_array QAccessibleWidget_ActionNames(const QAccessibleWidget* self); void QAccessibleWidget_DoAction(QAccessibleWidget* self, struct miqt_string actionName); -struct miqt_array* QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName); +struct miqt_array QAccessibleWidget_KeyBindingsForAction(const QAccessibleWidget* self, struct miqt_string actionName); #ifdef __cplusplus } /* extern C */ diff --git a/qt6/gen_qaction.cpp b/qt6/gen_qaction.cpp index 80a0cd49..2148c7da 100644 --- a/qt6/gen_qaction.cpp +++ b/qt6/gen_qaction.cpp @@ -61,16 +61,16 @@ struct miqt_string QAction_Tr(const char* s) { return _ms; } -struct miqt_array* QAction_AssociatedObjects(const QAction* self) { +struct miqt_array QAction_AssociatedObjects(const QAction* self) { QList _ret = self->associatedObjects(); // Convert QList<> from C++ memory to manually-managed C memory QObject** _arr = static_cast(malloc(sizeof(QObject*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -195,11 +195,11 @@ QKeySequence* QAction_Shortcut(const QAction* self) { return new QKeySequence(self->shortcut()); } -void QAction_SetShortcuts(QAction* self, struct miqt_array* /* of QKeySequence* */ shortcuts) { +void QAction_SetShortcuts(QAction* self, struct miqt_array /* of QKeySequence* */ shortcuts) { QList shortcuts_QList; - shortcuts_QList.reserve(shortcuts->len); - QKeySequence** shortcuts_arr = static_cast(shortcuts->data); - for(size_t i = 0; i < shortcuts->len; ++i) { + shortcuts_QList.reserve(shortcuts.len); + QKeySequence** shortcuts_arr = static_cast(shortcuts.data); + for(size_t i = 0; i < shortcuts.len; ++i) { shortcuts_QList.push_back(*(shortcuts_arr[i])); } self->setShortcuts(shortcuts_QList); @@ -209,16 +209,16 @@ void QAction_SetShortcutsWithShortcuts(QAction* self, int shortcuts) { self->setShortcuts(static_cast(shortcuts)); } -struct miqt_array* QAction_Shortcuts(const QAction* self) { +struct miqt_array QAction_Shortcuts(const QAction* self) { QList _ret = self->shortcuts(); // Convert QList<> from C++ memory to manually-managed C memory QKeySequence** _arr = static_cast(malloc(sizeof(QKeySequence*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qaction.go b/qt6/gen_qaction.go index f343dd6e..12656536 100644 --- a/qt6/gen_qaction.go +++ b/qt6/gen_qaction.go @@ -143,13 +143,12 @@ func QAction_Tr(s string) string { } func (this *QAction) AssociatedObjects() []*QObject { - var _ma *C.struct_miqt_array = C.QAction_AssociatedObjects(this.h) + var _ma C.struct_miqt_array = C.QAction_AssociatedObjects(this.h) _ret := make([]*QObject, int(_ma.len)) _outCast := (*[0xffff]*C.QObject)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQObject(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -275,14 +274,12 @@ func (this *QAction) Shortcut() *QKeySequence { } func (this *QAction) SetShortcuts(shortcuts []QKeySequence) { - // For the C ABI, malloc a C array of raw pointers shortcuts_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(shortcuts)))) defer C.free(unsafe.Pointer(shortcuts_CArray)) for i := range shortcuts { shortcuts_CArray[i] = shortcuts[i].cPointer() } - shortcuts_ma := &C.struct_miqt_array{len: C.size_t(len(shortcuts)), data: unsafe.Pointer(shortcuts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(shortcuts_ma)) + shortcuts_ma := C.struct_miqt_array{len: C.size_t(len(shortcuts)), data: unsafe.Pointer(shortcuts_CArray)} C.QAction_SetShortcuts(this.h, shortcuts_ma) } @@ -291,7 +288,7 @@ func (this *QAction) SetShortcutsWithShortcuts(shortcuts QKeySequence__StandardK } func (this *QAction) Shortcuts() []QKeySequence { - var _ma *C.struct_miqt_array = C.QAction_Shortcuts(this.h) + var _ma C.struct_miqt_array = C.QAction_Shortcuts(this.h) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -300,7 +297,6 @@ func (this *QAction) Shortcuts() []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qaction.h b/qt6/gen_qaction.h index c70b59ce..3e40cc8f 100644 --- a/qt6/gen_qaction.h +++ b/qt6/gen_qaction.h @@ -42,7 +42,7 @@ QAction* QAction_new6(QIcon* icon, struct miqt_string text, QObject* parent); QMetaObject* QAction_MetaObject(const QAction* self); void* QAction_Metacast(QAction* self, const char* param1); struct miqt_string QAction_Tr(const char* s); -struct miqt_array* QAction_AssociatedObjects(const QAction* self); +struct miqt_array QAction_AssociatedObjects(const QAction* self); void QAction_SetActionGroup(QAction* self, QActionGroup* group); QActionGroup* QAction_ActionGroup(const QAction* self); void QAction_SetIcon(QAction* self, QIcon* icon); @@ -63,9 +63,9 @@ void QAction_SetSeparator(QAction* self, bool b); bool QAction_IsSeparator(const QAction* self); void QAction_SetShortcut(QAction* self, QKeySequence* shortcut); QKeySequence* QAction_Shortcut(const QAction* self); -void QAction_SetShortcuts(QAction* self, struct miqt_array* /* of QKeySequence* */ shortcuts); +void QAction_SetShortcuts(QAction* self, struct miqt_array /* of QKeySequence* */ shortcuts); void QAction_SetShortcutsWithShortcuts(QAction* self, int shortcuts); -struct miqt_array* QAction_Shortcuts(const QAction* self); +struct miqt_array QAction_Shortcuts(const QAction* self); void QAction_SetShortcutContext(QAction* self, int context); int QAction_ShortcutContext(const QAction* self); void QAction_SetAutoRepeat(QAction* self, bool autoRepeat); diff --git a/qt6/gen_qactiongroup.cpp b/qt6/gen_qactiongroup.cpp index b3ad2a97..8e82f402 100644 --- a/qt6/gen_qactiongroup.cpp +++ b/qt6/gen_qactiongroup.cpp @@ -52,16 +52,16 @@ void QActionGroup_RemoveAction(QActionGroup* self, QAction* a) { self->removeAction(a); } -struct miqt_array* QActionGroup_Actions(const QActionGroup* self) { +struct miqt_array QActionGroup_Actions(const QActionGroup* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qactiongroup.go b/qt6/gen_qactiongroup.go index 5ecaf509..08475bee 100644 --- a/qt6/gen_qactiongroup.go +++ b/qt6/gen_qactiongroup.go @@ -102,13 +102,12 @@ func (this *QActionGroup) RemoveAction(a *QAction) { } func (this *QActionGroup) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QActionGroup_Actions(this.h) + var _ma C.struct_miqt_array = C.QActionGroup_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qactiongroup.h b/qt6/gen_qactiongroup.h index c8cb7e68..2d07da05 100644 --- a/qt6/gen_qactiongroup.h +++ b/qt6/gen_qactiongroup.h @@ -35,7 +35,7 @@ QAction* QActionGroup_AddAction(QActionGroup* self, QAction* a); QAction* QActionGroup_AddActionWithText(QActionGroup* self, struct miqt_string text); QAction* QActionGroup_AddAction2(QActionGroup* self, QIcon* icon, struct miqt_string text); void QActionGroup_RemoveAction(QActionGroup* self, QAction* a); -struct miqt_array* QActionGroup_Actions(const QActionGroup* self); +struct miqt_array QActionGroup_Actions(const QActionGroup* self); QAction* QActionGroup_CheckedAction(const QActionGroup* self); bool QActionGroup_IsExclusive(const QActionGroup* self); bool QActionGroup_IsEnabled(const QActionGroup* self); diff --git a/qt6/gen_qapplication.cpp b/qt6/gen_qapplication.cpp index f842d766..262f4ab0 100644 --- a/qt6/gen_qapplication.cpp +++ b/qt6/gen_qapplication.cpp @@ -88,29 +88,29 @@ QFontMetrics* QApplication_FontMetrics() { return new QFontMetrics(QApplication::fontMetrics()); } -struct miqt_array* QApplication_AllWidgets() { +struct miqt_array QApplication_AllWidgets() { QWidgetList _ret = QApplication::allWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QApplication_TopLevelWidgets() { +struct miqt_array QApplication_TopLevelWidgets() { QWidgetList _ret = QApplication::topLevelWidgets(); // Convert QList<> from C++ memory to manually-managed C memory QWidget** _arr = static_cast(malloc(sizeof(QWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qapplication.go b/qt6/gen_qapplication.go index 4d134f74..47f435a2 100644 --- a/qt6/gen_qapplication.go +++ b/qt6/gen_qapplication.go @@ -160,24 +160,22 @@ func QApplication_FontMetrics() *QFontMetrics { } func QApplication_AllWidgets() []*QWidget { - var _ma *C.struct_miqt_array = C.QApplication_AllWidgets() + var _ma C.struct_miqt_array = C.QApplication_AllWidgets() _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QApplication_TopLevelWidgets() []*QWidget { - var _ma *C.struct_miqt_array = C.QApplication_TopLevelWidgets() + var _ma C.struct_miqt_array = C.QApplication_TopLevelWidgets() _ret := make([]*QWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qapplication.h b/qt6/gen_qapplication.h index 63f98d99..df718680 100644 --- a/qt6/gen_qapplication.h +++ b/qt6/gen_qapplication.h @@ -53,8 +53,8 @@ QFont* QApplication_FontWithQWidget(QWidget* param1); QFont* QApplication_FontWithClassName(const char* className); void QApplication_SetFont(QFont* param1); QFontMetrics* QApplication_FontMetrics(); -struct miqt_array* QApplication_AllWidgets(); -struct miqt_array* QApplication_TopLevelWidgets(); +struct miqt_array QApplication_AllWidgets(); +struct miqt_array QApplication_TopLevelWidgets(); QWidget* QApplication_ActivePopupWidget(); QWidget* QApplication_ActiveModalWidget(); QWidget* QApplication_FocusWidget(); diff --git a/qt6/gen_qbuttongroup.cpp b/qt6/gen_qbuttongroup.cpp index f9413982..67966416 100644 --- a/qt6/gen_qbuttongroup.cpp +++ b/qt6/gen_qbuttongroup.cpp @@ -53,16 +53,16 @@ void QButtonGroup_RemoveButton(QButtonGroup* self, QAbstractButton* param1) { self->removeButton(param1); } -struct miqt_array* QButtonGroup_Buttons(const QButtonGroup* self) { +struct miqt_array QButtonGroup_Buttons(const QButtonGroup* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qbuttongroup.go b/qt6/gen_qbuttongroup.go index 7175995b..0a78e35e 100644 --- a/qt6/gen_qbuttongroup.go +++ b/qt6/gen_qbuttongroup.go @@ -92,13 +92,12 @@ func (this *QButtonGroup) RemoveButton(param1 *QAbstractButton) { } func (this *QButtonGroup) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QButtonGroup_Buttons(this.h) + var _ma C.struct_miqt_array = C.QButtonGroup_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qbuttongroup.h b/qt6/gen_qbuttongroup.h index a69dc03b..6598e08e 100644 --- a/qt6/gen_qbuttongroup.h +++ b/qt6/gen_qbuttongroup.h @@ -34,7 +34,7 @@ void QButtonGroup_SetExclusive(QButtonGroup* self, bool exclusive); bool QButtonGroup_Exclusive(const QButtonGroup* self); void QButtonGroup_AddButton(QButtonGroup* self, QAbstractButton* param1); void QButtonGroup_RemoveButton(QButtonGroup* self, QAbstractButton* param1); -struct miqt_array* QButtonGroup_Buttons(const QButtonGroup* self); +struct miqt_array QButtonGroup_Buttons(const QButtonGroup* self); QAbstractButton* QButtonGroup_CheckedButton(const QButtonGroup* self); QAbstractButton* QButtonGroup_Button(const QButtonGroup* self, int id); void QButtonGroup_SetId(QButtonGroup* self, QAbstractButton* button, int id); diff --git a/qt6/gen_qcalendar.cpp b/qt6/gen_qcalendar.cpp index 27aba365..8c6b8274 100644 --- a/qt6/gen_qcalendar.cpp +++ b/qt6/gen_qcalendar.cpp @@ -159,7 +159,7 @@ struct miqt_string QCalendar_StandaloneWeekDayName(const QCalendar* self, QLocal return _ms; } -struct miqt_array* QCalendar_AvailableCalendars() { +struct miqt_array QCalendar_AvailableCalendars() { QStringList _ret = QCalendar::availableCalendars(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -173,9 +173,9 @@ struct miqt_array* QCalendar_AvailableCalendars() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcalendar.go b/qt6/gen_qcalendar.go index b6ec280a..d9eb116e 100644 --- a/qt6/gen_qcalendar.go +++ b/qt6/gen_qcalendar.go @@ -205,7 +205,7 @@ func (this *QCalendar) StandaloneWeekDayName(locale *QLocale, day int) string { } func QCalendar_AvailableCalendars() []string { - var _ma *C.struct_miqt_array = C.QCalendar_AvailableCalendars() + var _ma C.struct_miqt_array = C.QCalendar_AvailableCalendars() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -214,7 +214,6 @@ func QCalendar_AvailableCalendars() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcalendar.h b/qt6/gen_qcalendar.h index f7bc5b23..017084cf 100644 --- a/qt6/gen_qcalendar.h +++ b/qt6/gen_qcalendar.h @@ -65,7 +65,7 @@ struct miqt_string QCalendar_MonthName(const QCalendar* self, QLocale* locale, i struct miqt_string QCalendar_StandaloneMonthName(const QCalendar* self, QLocale* locale, int month); struct miqt_string QCalendar_WeekDayName(const QCalendar* self, QLocale* locale, int day); struct miqt_string QCalendar_StandaloneWeekDayName(const QCalendar* self, QLocale* locale, int day); -struct miqt_array* QCalendar_AvailableCalendars(); +struct miqt_array QCalendar_AvailableCalendars(); int QCalendar_DaysInMonth2(const QCalendar* self, int month, int year); struct miqt_string QCalendar_MonthName3(const QCalendar* self, QLocale* locale, int month, int year); struct miqt_string QCalendar_MonthName4(const QCalendar* self, QLocale* locale, int month, int year, int format); diff --git a/qt6/gen_qcalendarwidget.cpp b/qt6/gen_qcalendarwidget.cpp index 70722935..cf8d6213 100644 --- a/qt6/gen_qcalendarwidget.cpp +++ b/qt6/gen_qcalendarwidget.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -143,6 +144,24 @@ void QCalendarWidget_SetWeekdayTextFormat(QCalendarWidget* self, int dayOfWeek, self->setWeekdayTextFormat(static_cast(dayOfWeek), *format); } +struct miqt_map QCalendarWidget_DateTextFormat(const QCalendarWidget* self) { + QMap _ret = self->dateTextFormat(); + // Convert QMap<> from C++ memory to manually-managed C memory + QDate** _karr = static_cast(malloc(sizeof(QDate*) * _ret.size())); + QTextCharFormat** _varr = static_cast(malloc(sizeof(QTextCharFormat*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = new QDate(_itr->first); + _varr[_ctr] = new QTextCharFormat(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QTextCharFormat* QCalendarWidget_DateTextFormatWithDate(const QCalendarWidget* self, QDate* date) { return new QTextCharFormat(self->dateTextFormat(*date)); } diff --git a/qt6/gen_qcalendarwidget.go b/qt6/gen_qcalendarwidget.go index 9ebcc0ab..9aff4a21 100644 --- a/qt6/gen_qcalendarwidget.go +++ b/qt6/gen_qcalendarwidget.go @@ -222,6 +222,27 @@ func (this *QCalendarWidget) SetWeekdayTextFormat(dayOfWeek DayOfWeek, format *Q C.QCalendarWidget_SetWeekdayTextFormat(this.h, (C.int)(dayOfWeek), format.cPointer()) } +func (this *QCalendarWidget) DateTextFormat() map[QDate]QTextCharFormat { + var _mm C.struct_miqt_map = C.QCalendarWidget_DateTextFormat(this.h) + _ret := make(map[QDate]QTextCharFormat, int(_mm.len)) + _Keys := (*[0xffff]*C.QDate)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QTextCharFormat)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _mapkey_ret := _Keys[i] + _mapkey_goptr := newQDate(_mapkey_ret) + _mapkey_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Key := *_mapkey_goptr + + _mapval_ret := _Values[i] + _mapval_goptr := newQTextCharFormat(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QCalendarWidget) DateTextFormatWithDate(date QDate) *QTextCharFormat { _ret := C.QCalendarWidget_DateTextFormatWithDate(this.h, date.cPointer()) _goptr := newQTextCharFormat(_ret) diff --git a/qt6/gen_qcalendarwidget.h b/qt6/gen_qcalendarwidget.h index 57984a2f..a36699cc 100644 --- a/qt6/gen_qcalendarwidget.h +++ b/qt6/gen_qcalendarwidget.h @@ -61,6 +61,7 @@ QTextCharFormat* QCalendarWidget_HeaderTextFormat(const QCalendarWidget* self); void QCalendarWidget_SetHeaderTextFormat(QCalendarWidget* self, QTextCharFormat* format); QTextCharFormat* QCalendarWidget_WeekdayTextFormat(const QCalendarWidget* self, int dayOfWeek); void QCalendarWidget_SetWeekdayTextFormat(QCalendarWidget* self, int dayOfWeek, QTextCharFormat* format); +struct miqt_map QCalendarWidget_DateTextFormat(const QCalendarWidget* self); QTextCharFormat* QCalendarWidget_DateTextFormatWithDate(const QCalendarWidget* self, QDate* date); void QCalendarWidget_SetDateTextFormat(QCalendarWidget* self, QDate* date, QTextCharFormat* format); bool QCalendarWidget_IsDateEditEnabled(const QCalendarWidget* self); diff --git a/qt6/gen_qcborarray.cpp b/qt6/gen_qcborarray.cpp index 56ffc67e..571cefae 100644 --- a/qt6/gen_qcborarray.cpp +++ b/qt6/gen_qcborarray.cpp @@ -222,11 +222,11 @@ QCborArray* QCborArray_OperatorShiftLeft(QCborArray* self, QCborValue* v) { return &_ret; } -QCborArray* QCborArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list) { +QCborArray* QCborArray_FromStringList(struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } diff --git a/qt6/gen_qcborarray.go b/qt6/gen_qcborarray.go index 2b646005..4b75b987 100644 --- a/qt6/gen_qcborarray.go +++ b/qt6/gen_qcborarray.go @@ -329,7 +329,6 @@ func (this *QCborArray) OperatorShiftLeft(v *QCborValue) *QCborArray { } func QCborArray_FromStringList(list []string) *QCborArray { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -339,8 +338,7 @@ func QCborArray_FromStringList(list []string) *QCborArray { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} _ret := C.QCborArray_FromStringList(list_ma) _goptr := newQCborArray(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt6/gen_qcborarray.h b/qt6/gen_qcborarray.h index 521f80a3..ed1b00f6 100644 --- a/qt6/gen_qcborarray.h +++ b/qt6/gen_qcborarray.h @@ -90,7 +90,7 @@ bool QCborArray_Empty(const QCborArray* self); QCborArray* QCborArray_OperatorPlus(const QCborArray* self, QCborValue* v); QCborArray* QCborArray_OperatorPlusAssign(QCborArray* self, QCborValue* v); QCborArray* QCborArray_OperatorShiftLeft(QCborArray* self, QCborValue* v); -QCborArray* QCborArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list); +QCborArray* QCborArray_FromStringList(struct miqt_array /* of struct miqt_string */ list); QCborArray* QCborArray_FromJsonArray(QJsonArray* array); QJsonArray* QCborArray_ToJsonArray(const QCborArray* self); void QCborArray_Delete(QCborArray* self); diff --git a/qt6/gen_qcbormap.cpp b/qt6/gen_qcbormap.cpp index 703e7520..77cae178 100644 --- a/qt6/gen_qcbormap.cpp +++ b/qt6/gen_qcbormap.cpp @@ -6,9 +6,11 @@ #include #include #include +#include #include #include #include +#include #include #include "gen_qcbormap.h" #include "_cgo_export.h" @@ -46,16 +48,16 @@ void QCborMap_Clear(QCborMap* self) { self->clear(); } -struct miqt_array* QCborMap_Keys(const QCborMap* self) { +struct miqt_array QCborMap_Keys(const QCborMap* self) { QList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory QCborValue** _arr = static_cast(malloc(sizeof(QCborValue*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QCborValue(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -257,10 +259,83 @@ QCborMap__Iterator* QCborMap_Insert4(QCborMap* self, QCborValue* key, QCborValue return new QCborMap::Iterator(self->insert(*key, *value_)); } +QCborMap* QCborMap_FromVariantMap(struct miqt_map mapVal) { + QVariantMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QCborMap(QCborMap::fromVariantMap(mapVal_QMap)); +} + +QCborMap* QCborMap_FromVariantHash(struct miqt_map hash) { + QVariantHash hash_QMap; + hash_QMap.reserve(hash.len); + struct miqt_string* hash_karr = static_cast(hash.keys); + QVariant** hash_varr = static_cast(hash.values); + for(size_t i = 0; i < hash.len; ++i) { + QString hash_karr_i_QString = QString::fromUtf8(hash_karr[i].data, hash_karr[i].len); + hash_QMap[hash_karr_i_QString] = *(hash_varr[i]); + } + return new QCborMap(QCborMap::fromVariantHash(hash_QMap)); +} + QCborMap* QCborMap_FromJsonObject(QJsonObject* o) { return new QCborMap(QCborMap::fromJsonObject(*o)); } +struct miqt_map QCborMap_ToVariantMap(const QCborMap* self) { + QVariantMap _ret = self->toVariantMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_map QCborMap_ToVariantHash(const QCborMap* self) { + QVariantHash _ret = self->toVariantHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QJsonObject* QCborMap_ToJsonObject(const QCborMap* self) { return new QJsonObject(self->toJsonObject()); } diff --git a/qt6/gen_qcbormap.go b/qt6/gen_qcbormap.go index f9d27219..1a6fe998 100644 --- a/qt6/gen_qcbormap.go +++ b/qt6/gen_qcbormap.go @@ -82,7 +82,7 @@ func (this *QCborMap) Clear() { } func (this *QCborMap) Keys() []QCborValue { - var _ma *C.struct_miqt_array = C.QCborMap_Keys(this.h) + var _ma C.struct_miqt_array = C.QCborMap_Keys(this.h) _ret := make([]QCborValue, int(_ma.len)) _outCast := (*[0xffff]*C.QCborValue)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -91,7 +91,6 @@ func (this *QCborMap) Keys() []QCborValue { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -431,6 +430,58 @@ func (this *QCborMap) Insert4(key *QCborValue, value_ *QCborValue) *QCborMap__It return _goptr } +func QCborMap_FromVariantMap(mapVal map[string]QVariant) *QCborMap { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QCborMap_FromVariantMap(mapVal_mm) + _goptr := newQCborMap(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func QCborMap_FromVariantHash(hash map[string]QVariant) *QCborMap { + hash_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(hash)))) + defer C.free(unsafe.Pointer(hash_Keys_CArray)) + hash_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(hash)))) + defer C.free(unsafe.Pointer(hash_Values_CArray)) + hash_ctr := 0 + for hash_k, hash_v := range hash { + hash_k_ms := C.struct_miqt_string{} + hash_k_ms.data = C.CString(hash_k) + hash_k_ms.len = C.size_t(len(hash_k)) + defer C.free(unsafe.Pointer(hash_k_ms.data)) + hash_Keys_CArray[hash_ctr] = hash_k_ms + hash_Values_CArray[hash_ctr] = hash_v.cPointer() + hash_ctr++ + } + hash_mm := C.struct_miqt_map{ + len: C.size_t(len(hash)), + keys: unsafe.Pointer(hash_Keys_CArray), + values: unsafe.Pointer(hash_Values_CArray), + } + _ret := C.QCborMap_FromVariantHash(hash_mm) + _goptr := newQCborMap(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + func QCborMap_FromJsonObject(o *QJsonObject) *QCborMap { _ret := C.QCborMap_FromJsonObject(o.cPointer()) _goptr := newQCborMap(_ret) @@ -438,6 +489,46 @@ func QCborMap_FromJsonObject(o *QJsonObject) *QCborMap { return _goptr } +func (this *QCborMap) ToVariantMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QCborMap_ToVariantMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QCborMap) ToVariantHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QCborMap_ToVariantHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QCborMap) ToJsonObject() *QJsonObject { _ret := C.QCborMap_ToJsonObject(this.h) _goptr := newQJsonObject(_ret) diff --git a/qt6/gen_qcbormap.h b/qt6/gen_qcbormap.h index ddf96a8c..85aa486a 100644 --- a/qt6/gen_qcbormap.h +++ b/qt6/gen_qcbormap.h @@ -29,6 +29,7 @@ class QCborValue; class QCborValueConstRef; class QCborValueRef; class QJsonObject; +class QVariant; #else typedef struct QCborMap QCborMap; typedef struct QCborMap__ConstIterator QCborMap__ConstIterator; @@ -37,6 +38,7 @@ typedef struct QCborValue QCborValue; typedef struct QCborValueConstRef QCborValueConstRef; typedef struct QCborValueRef QCborValueRef; typedef struct QJsonObject QJsonObject; +typedef struct QVariant QVariant; #endif QCborMap* QCborMap_new(); @@ -47,7 +49,7 @@ QCborValue* QCborMap_ToCborValue(const QCborMap* self); ptrdiff_t QCborMap_Size(const QCborMap* self); bool QCborMap_IsEmpty(const QCborMap* self); void QCborMap_Clear(QCborMap* self); -struct miqt_array* QCborMap_Keys(const QCborMap* self); +struct miqt_array QCborMap_Keys(const QCborMap* self); QCborValue* QCborMap_Value(const QCborMap* self, long long key); QCborValue* QCborMap_Value2(const QCborMap* self, struct miqt_string key); QCborValue* QCborMap_Value3(const QCborMap* self, QCborValue* key); @@ -95,7 +97,11 @@ QCborMap__ConstIterator* QCborMap_Find7(const QCborMap* self, QCborValue* key); QCborMap__Iterator* QCborMap_Insert(QCborMap* self, long long key, QCborValue* value_); QCborMap__Iterator* QCborMap_Insert3(QCborMap* self, struct miqt_string key, QCborValue* value_); QCborMap__Iterator* QCborMap_Insert4(QCborMap* self, QCborValue* key, QCborValue* value_); +QCborMap* QCborMap_FromVariantMap(struct miqt_map mapVal); +QCborMap* QCborMap_FromVariantHash(struct miqt_map hash); QCborMap* QCborMap_FromJsonObject(QJsonObject* o); +struct miqt_map QCborMap_ToVariantMap(const QCborMap* self); +struct miqt_map QCborMap_ToVariantHash(const QCborMap* self); QJsonObject* QCborMap_ToJsonObject(const QCborMap* self); void QCborMap_Delete(QCborMap* self); diff --git a/qt6/gen_qcolor.cpp b/qt6/gen_qcolor.cpp index 844d694e..77df7ea1 100644 --- a/qt6/gen_qcolor.cpp +++ b/qt6/gen_qcolor.cpp @@ -86,7 +86,7 @@ void QColor_SetNamedColor(QColor* self, struct miqt_string name) { self->setNamedColor(name_QString); } -struct miqt_array* QColor_ColorNames() { +struct miqt_array QColor_ColorNames() { QStringList _ret = QColor::colorNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -100,9 +100,9 @@ struct miqt_array* QColor_ColorNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcolor.go b/qt6/gen_qcolor.go index 87eb0eca..af66b639 100644 --- a/qt6/gen_qcolor.go +++ b/qt6/gen_qcolor.go @@ -169,7 +169,7 @@ func (this *QColor) SetNamedColor(name string) { } func QColor_ColorNames() []string { - var _ma *C.struct_miqt_array = C.QColor_ColorNames() + var _ma C.struct_miqt_array = C.QColor_ColorNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -178,7 +178,6 @@ func QColor_ColorNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcolor.h b/qt6/gen_qcolor.h index e4d8e557..31d865e9 100644 --- a/qt6/gen_qcolor.h +++ b/qt6/gen_qcolor.h @@ -40,7 +40,7 @@ void QColor_OperatorAssign(QColor* self, int color); bool QColor_IsValid(const QColor* self); struct miqt_string QColor_Name(const QColor* self); void QColor_SetNamedColor(QColor* self, struct miqt_string name); -struct miqt_array* QColor_ColorNames(); +struct miqt_array QColor_ColorNames(); int QColor_Spec(const QColor* self); int QColor_Alpha(const QColor* self); void QColor_SetAlpha(QColor* self, int alpha); diff --git a/qt6/gen_qcolormap.cpp b/qt6/gen_qcolormap.cpp index edd15a39..0349ab45 100644 --- a/qt6/gen_qcolormap.cpp +++ b/qt6/gen_qcolormap.cpp @@ -47,16 +47,16 @@ QColor* QColormap_ColorAt(const QColormap* self, unsigned int pixel) { return new QColor(self->colorAt(static_cast(pixel))); } -struct miqt_array* QColormap_Colormap(const QColormap* self) { +struct miqt_array QColormap_Colormap(const QColormap* self) { const QList _ret = self->colormap(); // Convert QList<> from C++ memory to manually-managed C memory QColor** _arr = static_cast(malloc(sizeof(QColor*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QColor(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcolormap.go b/qt6/gen_qcolormap.go index d9a09f12..71d7f152 100644 --- a/qt6/gen_qcolormap.go +++ b/qt6/gen_qcolormap.go @@ -99,7 +99,7 @@ func (this *QColormap) ColorAt(pixel uint) *QColor { } func (this *QColormap) Colormap() []QColor { - var _ma *C.struct_miqt_array = C.QColormap_Colormap(this.h) + var _ma C.struct_miqt_array = C.QColormap_Colormap(this.h) _ret := make([]QColor, int(_ma.len)) _outCast := (*[0xffff]*C.QColor)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -108,7 +108,6 @@ func (this *QColormap) Colormap() []QColor { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcolormap.h b/qt6/gen_qcolormap.h index f04e5257..980e81d9 100644 --- a/qt6/gen_qcolormap.h +++ b/qt6/gen_qcolormap.h @@ -31,7 +31,7 @@ int QColormap_Depth(const QColormap* self); int QColormap_Size(const QColormap* self); unsigned int QColormap_Pixel(const QColormap* self, QColor* color); QColor* QColormap_ColorAt(const QColormap* self, unsigned int pixel); -struct miqt_array* QColormap_Colormap(const QColormap* self); +struct miqt_array QColormap_Colormap(const QColormap* self); QColormap* QColormap_Instance1(int screen); void QColormap_Delete(QColormap* self); diff --git a/qt6/gen_qcolorspace.cpp b/qt6/gen_qcolorspace.cpp index f73c22d8..3134341b 100644 --- a/qt6/gen_qcolorspace.cpp +++ b/qt6/gen_qcolorspace.cpp @@ -26,11 +26,11 @@ QColorSpace* QColorSpace_new4(int primaries, float gamma) { return new QColorSpace(static_cast(primaries), static_cast(gamma)); } -QColorSpace* QColorSpace_new5(int primaries, struct miqt_array* /* of uint16_t */ transferFunctionTable) { +QColorSpace* QColorSpace_new5(int primaries, struct miqt_array /* of uint16_t */ transferFunctionTable) { QList transferFunctionTable_QList; - transferFunctionTable_QList.reserve(transferFunctionTable->len); - uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable->data); - for(size_t i = 0; i < transferFunctionTable->len; ++i) { + transferFunctionTable_QList.reserve(transferFunctionTable.len); + uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable.data); + for(size_t i = 0; i < transferFunctionTable.len; ++i) { transferFunctionTable_QList.push_back(static_cast(transferFunctionTable_arr[i])); } return new QColorSpace(static_cast(primaries), transferFunctionTable_QList); @@ -40,33 +40,33 @@ QColorSpace* QColorSpace_new6(QPointF* whitePoint, QPointF* redPoint, QPointF* g return new QColorSpace(*whitePoint, *redPoint, *greenPoint, *bluePoint, static_cast(transferFunction)); } -QColorSpace* QColorSpace_new7(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array* /* of uint16_t */ transferFunctionTable) { +QColorSpace* QColorSpace_new7(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array /* of uint16_t */ transferFunctionTable) { QList transferFunctionTable_QList; - transferFunctionTable_QList.reserve(transferFunctionTable->len); - uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable->data); - for(size_t i = 0; i < transferFunctionTable->len; ++i) { + transferFunctionTable_QList.reserve(transferFunctionTable.len); + uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable.data); + for(size_t i = 0; i < transferFunctionTable.len; ++i) { transferFunctionTable_QList.push_back(static_cast(transferFunctionTable_arr[i])); } return new QColorSpace(*whitePoint, *redPoint, *greenPoint, *bluePoint, transferFunctionTable_QList); } -QColorSpace* QColorSpace_new8(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable) { +QColorSpace* QColorSpace_new8(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable) { QList redTransferFunctionTable_QList; - redTransferFunctionTable_QList.reserve(redTransferFunctionTable->len); - uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable->data); - for(size_t i = 0; i < redTransferFunctionTable->len; ++i) { + redTransferFunctionTable_QList.reserve(redTransferFunctionTable.len); + uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable.data); + for(size_t i = 0; i < redTransferFunctionTable.len; ++i) { redTransferFunctionTable_QList.push_back(static_cast(redTransferFunctionTable_arr[i])); } QList greenTransferFunctionTable_QList; - greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable->len); - uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable->data); - for(size_t i = 0; i < greenTransferFunctionTable->len; ++i) { + greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable.len); + uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable.data); + for(size_t i = 0; i < greenTransferFunctionTable.len; ++i) { greenTransferFunctionTable_QList.push_back(static_cast(greenTransferFunctionTable_arr[i])); } QList blueTransferFunctionTable_QList; - blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable->len); - uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable->data); - for(size_t i = 0; i < blueTransferFunctionTable->len; ++i) { + blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable.len); + uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable.data); + for(size_t i = 0; i < blueTransferFunctionTable.len; ++i) { blueTransferFunctionTable_QList.push_back(static_cast(blueTransferFunctionTable_arr[i])); } return new QColorSpace(*whitePoint, *redPoint, *greenPoint, *bluePoint, redTransferFunctionTable_QList, greenTransferFunctionTable_QList, blueTransferFunctionTable_QList); @@ -126,33 +126,33 @@ void QColorSpace_SetTransferFunction(QColorSpace* self, int transferFunction) { self->setTransferFunction(static_cast(transferFunction)); } -void QColorSpace_SetTransferFunctionWithTransferFunctionTable(QColorSpace* self, struct miqt_array* /* of uint16_t */ transferFunctionTable) { +void QColorSpace_SetTransferFunctionWithTransferFunctionTable(QColorSpace* self, struct miqt_array /* of uint16_t */ transferFunctionTable) { QList transferFunctionTable_QList; - transferFunctionTable_QList.reserve(transferFunctionTable->len); - uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable->data); - for(size_t i = 0; i < transferFunctionTable->len; ++i) { + transferFunctionTable_QList.reserve(transferFunctionTable.len); + uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable.data); + for(size_t i = 0; i < transferFunctionTable.len; ++i) { transferFunctionTable_QList.push_back(static_cast(transferFunctionTable_arr[i])); } self->setTransferFunction(transferFunctionTable_QList); } -void QColorSpace_SetTransferFunctions(QColorSpace* self, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable) { +void QColorSpace_SetTransferFunctions(QColorSpace* self, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable) { QList redTransferFunctionTable_QList; - redTransferFunctionTable_QList.reserve(redTransferFunctionTable->len); - uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable->data); - for(size_t i = 0; i < redTransferFunctionTable->len; ++i) { + redTransferFunctionTable_QList.reserve(redTransferFunctionTable.len); + uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable.data); + for(size_t i = 0; i < redTransferFunctionTable.len; ++i) { redTransferFunctionTable_QList.push_back(static_cast(redTransferFunctionTable_arr[i])); } QList greenTransferFunctionTable_QList; - greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable->len); - uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable->data); - for(size_t i = 0; i < greenTransferFunctionTable->len; ++i) { + greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable.len); + uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable.data); + for(size_t i = 0; i < greenTransferFunctionTable.len; ++i) { greenTransferFunctionTable_QList.push_back(static_cast(greenTransferFunctionTable_arr[i])); } QList blueTransferFunctionTable_QList; - blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable->len); - uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable->data); - for(size_t i = 0; i < blueTransferFunctionTable->len; ++i) { + blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable.len); + uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable.data); + for(size_t i = 0; i < blueTransferFunctionTable.len; ++i) { blueTransferFunctionTable_QList.push_back(static_cast(blueTransferFunctionTable_arr[i])); } self->setTransferFunctions(redTransferFunctionTable_QList, greenTransferFunctionTable_QList, blueTransferFunctionTable_QList); @@ -162,33 +162,33 @@ QColorSpace* QColorSpace_WithTransferFunction(const QColorSpace* self, int trans return new QColorSpace(self->withTransferFunction(static_cast(transferFunction))); } -QColorSpace* QColorSpace_WithTransferFunctionWithTransferFunctionTable(const QColorSpace* self, struct miqt_array* /* of uint16_t */ transferFunctionTable) { +QColorSpace* QColorSpace_WithTransferFunctionWithTransferFunctionTable(const QColorSpace* self, struct miqt_array /* of uint16_t */ transferFunctionTable) { QList transferFunctionTable_QList; - transferFunctionTable_QList.reserve(transferFunctionTable->len); - uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable->data); - for(size_t i = 0; i < transferFunctionTable->len; ++i) { + transferFunctionTable_QList.reserve(transferFunctionTable.len); + uint16_t* transferFunctionTable_arr = static_cast(transferFunctionTable.data); + for(size_t i = 0; i < transferFunctionTable.len; ++i) { transferFunctionTable_QList.push_back(static_cast(transferFunctionTable_arr[i])); } return new QColorSpace(self->withTransferFunction(transferFunctionTable_QList)); } -QColorSpace* QColorSpace_WithTransferFunctions(const QColorSpace* self, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable) { +QColorSpace* QColorSpace_WithTransferFunctions(const QColorSpace* self, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable) { QList redTransferFunctionTable_QList; - redTransferFunctionTable_QList.reserve(redTransferFunctionTable->len); - uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable->data); - for(size_t i = 0; i < redTransferFunctionTable->len; ++i) { + redTransferFunctionTable_QList.reserve(redTransferFunctionTable.len); + uint16_t* redTransferFunctionTable_arr = static_cast(redTransferFunctionTable.data); + for(size_t i = 0; i < redTransferFunctionTable.len; ++i) { redTransferFunctionTable_QList.push_back(static_cast(redTransferFunctionTable_arr[i])); } QList greenTransferFunctionTable_QList; - greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable->len); - uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable->data); - for(size_t i = 0; i < greenTransferFunctionTable->len; ++i) { + greenTransferFunctionTable_QList.reserve(greenTransferFunctionTable.len); + uint16_t* greenTransferFunctionTable_arr = static_cast(greenTransferFunctionTable.data); + for(size_t i = 0; i < greenTransferFunctionTable.len; ++i) { greenTransferFunctionTable_QList.push_back(static_cast(greenTransferFunctionTable_arr[i])); } QList blueTransferFunctionTable_QList; - blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable->len); - uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable->data); - for(size_t i = 0; i < blueTransferFunctionTable->len; ++i) { + blueTransferFunctionTable_QList.reserve(blueTransferFunctionTable.len); + uint16_t* blueTransferFunctionTable_arr = static_cast(blueTransferFunctionTable.data); + for(size_t i = 0; i < blueTransferFunctionTable.len; ++i) { blueTransferFunctionTable_QList.push_back(static_cast(blueTransferFunctionTable_arr[i])); } return new QColorSpace(self->withTransferFunctions(redTransferFunctionTable_QList, greenTransferFunctionTable_QList, blueTransferFunctionTable_QList)); diff --git a/qt6/gen_qcolorspace.go b/qt6/gen_qcolorspace.go index cc6cd600..8432f8b7 100644 --- a/qt6/gen_qcolorspace.go +++ b/qt6/gen_qcolorspace.go @@ -98,14 +98,12 @@ func NewQColorSpace4(primaries QColorSpace__Primaries, gamma float32) *QColorSpa // NewQColorSpace5 constructs a new QColorSpace object. func NewQColorSpace5(primaries QColorSpace__Primaries, transferFunctionTable []uint16) *QColorSpace { - // For the C ABI, malloc a C array of raw pointers transferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(transferFunctionTable)))) defer C.free(unsafe.Pointer(transferFunctionTable_CArray)) for i := range transferFunctionTable { transferFunctionTable_CArray[i] = (C.uint16_t)(transferFunctionTable[i]) } - transferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transferFunctionTable_ma)) + transferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} ret := C.QColorSpace_new5((C.int)(primaries), transferFunctionTable_ma) return newQColorSpace(ret) } @@ -118,44 +116,36 @@ func NewQColorSpace6(whitePoint *QPointF, redPoint *QPointF, greenPoint *QPointF // NewQColorSpace7 constructs a new QColorSpace object. func NewQColorSpace7(whitePoint *QPointF, redPoint *QPointF, greenPoint *QPointF, bluePoint *QPointF, transferFunctionTable []uint16) *QColorSpace { - // For the C ABI, malloc a C array of raw pointers transferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(transferFunctionTable)))) defer C.free(unsafe.Pointer(transferFunctionTable_CArray)) for i := range transferFunctionTable { transferFunctionTable_CArray[i] = (C.uint16_t)(transferFunctionTable[i]) } - transferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transferFunctionTable_ma)) + transferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} ret := C.QColorSpace_new7(whitePoint.cPointer(), redPoint.cPointer(), greenPoint.cPointer(), bluePoint.cPointer(), transferFunctionTable_ma) return newQColorSpace(ret) } // NewQColorSpace8 constructs a new QColorSpace object. func NewQColorSpace8(whitePoint *QPointF, redPoint *QPointF, greenPoint *QPointF, bluePoint *QPointF, redTransferFunctionTable []uint16, greenTransferFunctionTable []uint16, blueTransferFunctionTable []uint16) *QColorSpace { - // For the C ABI, malloc a C array of raw pointers redTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(redTransferFunctionTable)))) defer C.free(unsafe.Pointer(redTransferFunctionTable_CArray)) for i := range redTransferFunctionTable { redTransferFunctionTable_CArray[i] = (C.uint16_t)(redTransferFunctionTable[i]) } - redTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(redTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + redTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} greenTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(greenTransferFunctionTable)))) defer C.free(unsafe.Pointer(greenTransferFunctionTable_CArray)) for i := range greenTransferFunctionTable { greenTransferFunctionTable_CArray[i] = (C.uint16_t)(greenTransferFunctionTable[i]) } - greenTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(greenTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + greenTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} blueTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(blueTransferFunctionTable)))) defer C.free(unsafe.Pointer(blueTransferFunctionTable_CArray)) for i := range blueTransferFunctionTable { blueTransferFunctionTable_CArray[i] = (C.uint16_t)(blueTransferFunctionTable[i]) } - blueTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(blueTransferFunctionTable_ma)) + blueTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} ret := C.QColorSpace_new8(whitePoint.cPointer(), redPoint.cPointer(), greenPoint.cPointer(), bluePoint.cPointer(), redTransferFunctionTable_ma, greenTransferFunctionTable_ma, blueTransferFunctionTable_ma) return newQColorSpace(ret) } @@ -218,42 +208,34 @@ func (this *QColorSpace) SetTransferFunction(transferFunction QColorSpace__Trans } func (this *QColorSpace) SetTransferFunctionWithTransferFunctionTable(transferFunctionTable []uint16) { - // For the C ABI, malloc a C array of raw pointers transferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(transferFunctionTable)))) defer C.free(unsafe.Pointer(transferFunctionTable_CArray)) for i := range transferFunctionTable { transferFunctionTable_CArray[i] = (C.uint16_t)(transferFunctionTable[i]) } - transferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transferFunctionTable_ma)) + transferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} C.QColorSpace_SetTransferFunctionWithTransferFunctionTable(this.h, transferFunctionTable_ma) } func (this *QColorSpace) SetTransferFunctions(redTransferFunctionTable []uint16, greenTransferFunctionTable []uint16, blueTransferFunctionTable []uint16) { - // For the C ABI, malloc a C array of raw pointers redTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(redTransferFunctionTable)))) defer C.free(unsafe.Pointer(redTransferFunctionTable_CArray)) for i := range redTransferFunctionTable { redTransferFunctionTable_CArray[i] = (C.uint16_t)(redTransferFunctionTable[i]) } - redTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(redTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + redTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} greenTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(greenTransferFunctionTable)))) defer C.free(unsafe.Pointer(greenTransferFunctionTable_CArray)) for i := range greenTransferFunctionTable { greenTransferFunctionTable_CArray[i] = (C.uint16_t)(greenTransferFunctionTable[i]) } - greenTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(greenTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + greenTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} blueTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(blueTransferFunctionTable)))) defer C.free(unsafe.Pointer(blueTransferFunctionTable_CArray)) for i := range blueTransferFunctionTable { blueTransferFunctionTable_CArray[i] = (C.uint16_t)(blueTransferFunctionTable[i]) } - blueTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(blueTransferFunctionTable_ma)) + blueTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} C.QColorSpace_SetTransferFunctions(this.h, redTransferFunctionTable_ma, greenTransferFunctionTable_ma, blueTransferFunctionTable_ma) } @@ -265,14 +247,12 @@ func (this *QColorSpace) WithTransferFunction(transferFunction QColorSpace__Tran } func (this *QColorSpace) WithTransferFunctionWithTransferFunctionTable(transferFunctionTable []uint16) *QColorSpace { - // For the C ABI, malloc a C array of raw pointers transferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(transferFunctionTable)))) defer C.free(unsafe.Pointer(transferFunctionTable_CArray)) for i := range transferFunctionTable { transferFunctionTable_CArray[i] = (C.uint16_t)(transferFunctionTable[i]) } - transferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transferFunctionTable_ma)) + transferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(transferFunctionTable)), data: unsafe.Pointer(transferFunctionTable_CArray)} _ret := C.QColorSpace_WithTransferFunctionWithTransferFunctionTable(this.h, transferFunctionTable_ma) _goptr := newQColorSpace(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer @@ -280,30 +260,24 @@ func (this *QColorSpace) WithTransferFunctionWithTransferFunctionTable(transferF } func (this *QColorSpace) WithTransferFunctions(redTransferFunctionTable []uint16, greenTransferFunctionTable []uint16, blueTransferFunctionTable []uint16) *QColorSpace { - // For the C ABI, malloc a C array of raw pointers redTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(redTransferFunctionTable)))) defer C.free(unsafe.Pointer(redTransferFunctionTable_CArray)) for i := range redTransferFunctionTable { redTransferFunctionTable_CArray[i] = (C.uint16_t)(redTransferFunctionTable[i]) } - redTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(redTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + redTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(redTransferFunctionTable)), data: unsafe.Pointer(redTransferFunctionTable_CArray)} greenTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(greenTransferFunctionTable)))) defer C.free(unsafe.Pointer(greenTransferFunctionTable_CArray)) for i := range greenTransferFunctionTable { greenTransferFunctionTable_CArray[i] = (C.uint16_t)(greenTransferFunctionTable[i]) } - greenTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(greenTransferFunctionTable_ma)) - // For the C ABI, malloc a C array of raw pointers + greenTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(greenTransferFunctionTable)), data: unsafe.Pointer(greenTransferFunctionTable_CArray)} blueTransferFunctionTable_CArray := (*[0xffff]C.uint16_t)(C.malloc(C.size_t(8 * len(blueTransferFunctionTable)))) defer C.free(unsafe.Pointer(blueTransferFunctionTable_CArray)) for i := range blueTransferFunctionTable { blueTransferFunctionTable_CArray[i] = (C.uint16_t)(blueTransferFunctionTable[i]) } - blueTransferFunctionTable_ma := &C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(blueTransferFunctionTable_ma)) + blueTransferFunctionTable_ma := C.struct_miqt_array{len: C.size_t(len(blueTransferFunctionTable)), data: unsafe.Pointer(blueTransferFunctionTable_CArray)} _ret := C.QColorSpace_WithTransferFunctions(this.h, redTransferFunctionTable_ma, greenTransferFunctionTable_ma, blueTransferFunctionTable_ma) _goptr := newQColorSpace(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt6/gen_qcolorspace.h b/qt6/gen_qcolorspace.h index f60d42d8..78943f43 100644 --- a/qt6/gen_qcolorspace.h +++ b/qt6/gen_qcolorspace.h @@ -29,10 +29,10 @@ QColorSpace* QColorSpace_new(); QColorSpace* QColorSpace_new2(int namedColorSpace); QColorSpace* QColorSpace_new3(int primaries, int transferFunction); QColorSpace* QColorSpace_new4(int primaries, float gamma); -QColorSpace* QColorSpace_new5(int primaries, struct miqt_array* /* of uint16_t */ transferFunctionTable); +QColorSpace* QColorSpace_new5(int primaries, struct miqt_array /* of uint16_t */ transferFunctionTable); QColorSpace* QColorSpace_new6(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, int transferFunction); -QColorSpace* QColorSpace_new7(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array* /* of uint16_t */ transferFunctionTable); -QColorSpace* QColorSpace_new8(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable); +QColorSpace* QColorSpace_new7(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array /* of uint16_t */ transferFunctionTable); +QColorSpace* QColorSpace_new8(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable); QColorSpace* QColorSpace_new9(QColorSpace* colorSpace); QColorSpace* QColorSpace_new10(int primaries, int transferFunction, float gamma); QColorSpace* QColorSpace_new11(QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint, int transferFunction, float gamma); @@ -44,11 +44,11 @@ float QColorSpace_Gamma(const QColorSpace* self); struct miqt_string QColorSpace_Description(const QColorSpace* self); void QColorSpace_SetDescription(QColorSpace* self, struct miqt_string description); void QColorSpace_SetTransferFunction(QColorSpace* self, int transferFunction); -void QColorSpace_SetTransferFunctionWithTransferFunctionTable(QColorSpace* self, struct miqt_array* /* of uint16_t */ transferFunctionTable); -void QColorSpace_SetTransferFunctions(QColorSpace* self, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable); +void QColorSpace_SetTransferFunctionWithTransferFunctionTable(QColorSpace* self, struct miqt_array /* of uint16_t */ transferFunctionTable); +void QColorSpace_SetTransferFunctions(QColorSpace* self, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable); QColorSpace* QColorSpace_WithTransferFunction(const QColorSpace* self, int transferFunction); -QColorSpace* QColorSpace_WithTransferFunctionWithTransferFunctionTable(const QColorSpace* self, struct miqt_array* /* of uint16_t */ transferFunctionTable); -QColorSpace* QColorSpace_WithTransferFunctions(const QColorSpace* self, struct miqt_array* /* of uint16_t */ redTransferFunctionTable, struct miqt_array* /* of uint16_t */ greenTransferFunctionTable, struct miqt_array* /* of uint16_t */ blueTransferFunctionTable); +QColorSpace* QColorSpace_WithTransferFunctionWithTransferFunctionTable(const QColorSpace* self, struct miqt_array /* of uint16_t */ transferFunctionTable); +QColorSpace* QColorSpace_WithTransferFunctions(const QColorSpace* self, struct miqt_array /* of uint16_t */ redTransferFunctionTable, struct miqt_array /* of uint16_t */ greenTransferFunctionTable, struct miqt_array /* of uint16_t */ blueTransferFunctionTable); void QColorSpace_SetPrimaries(QColorSpace* self, int primariesId); void QColorSpace_SetPrimaries2(QColorSpace* self, QPointF* whitePoint, QPointF* redPoint, QPointF* greenPoint, QPointF* bluePoint); void QColorSpace_Detach(QColorSpace* self); diff --git a/qt6/gen_qcolumnview.cpp b/qt6/gen_qcolumnview.cpp index 4f6767a9..fec62aab 100644 --- a/qt6/gen_qcolumnview.cpp +++ b/qt6/gen_qcolumnview.cpp @@ -103,26 +103,26 @@ void QColumnView_SetPreviewWidget(QColumnView* self, QWidget* widget) { self->setPreviewWidget(widget); } -void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array* /* of int */ list) { +void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array /* of int */ list) { QList list_QList; - list_QList.reserve(list->len); - int* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + int* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(static_cast(list_arr[i])); } self->setColumnWidths(list_QList); } -struct miqt_array* QColumnView_ColumnWidths(const QColumnView* self) { +struct miqt_array QColumnView_ColumnWidths(const QColumnView* self) { QList _ret = self->columnWidths(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcolumnview.go b/qt6/gen_qcolumnview.go index 4eff4676..e6542969 100644 --- a/qt6/gen_qcolumnview.go +++ b/qt6/gen_qcolumnview.go @@ -153,25 +153,22 @@ func (this *QColumnView) SetPreviewWidget(widget *QWidget) { } func (this *QColumnView) SetColumnWidths(list []int) { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = (C.int)(list[i]) } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QColumnView_SetColumnWidths(this.h, list_ma) } func (this *QColumnView) ColumnWidths() []int { - var _ma *C.struct_miqt_array = C.QColumnView_ColumnWidths(this.h) + var _ma C.struct_miqt_array = C.QColumnView_ColumnWidths(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcolumnview.h b/qt6/gen_qcolumnview.h index 6dd58a53..7d280496 100644 --- a/qt6/gen_qcolumnview.h +++ b/qt6/gen_qcolumnview.h @@ -54,8 +54,8 @@ void QColumnView_SetResizeGripsVisible(QColumnView* self, bool visible); bool QColumnView_ResizeGripsVisible(const QColumnView* self); QWidget* QColumnView_PreviewWidget(const QColumnView* self); void QColumnView_SetPreviewWidget(QColumnView* self, QWidget* widget); -void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array* /* of int */ list); -struct miqt_array* QColumnView_ColumnWidths(const QColumnView* self); +void QColumnView_SetColumnWidths(QColumnView* self, struct miqt_array /* of int */ list); +struct miqt_array QColumnView_ColumnWidths(const QColumnView* self); struct miqt_string QColumnView_Tr2(const char* s, const char* c); struct miqt_string QColumnView_Tr3(const char* s, const char* c, int n); void QColumnView_ScrollTo2(QColumnView* self, QModelIndex* index, int hint); diff --git a/qt6/gen_qcombobox.cpp b/qt6/gen_qcombobox.cpp index 4829a0ec..f36af8a2 100644 --- a/qt6/gen_qcombobox.cpp +++ b/qt6/gen_qcombobox.cpp @@ -254,11 +254,11 @@ void QComboBox_AddItem2(QComboBox* self, QIcon* icon, struct miqt_string text) { self->addItem(*icon, text_QString); } -void QComboBox_AddItems(QComboBox* self, struct miqt_array* /* of struct miqt_string */ texts) { +void QComboBox_AddItems(QComboBox* self, struct miqt_array /* of struct miqt_string */ texts) { QStringList texts_QList; - texts_QList.reserve(texts->len); - struct miqt_string* texts_arr = static_cast(texts->data); - for(size_t i = 0; i < texts->len; ++i) { + texts_QList.reserve(texts.len); + struct miqt_string* texts_arr = static_cast(texts.data); + for(size_t i = 0; i < texts.len; ++i) { QString texts_arr_i_QString = QString::fromUtf8(texts_arr[i].data, texts_arr[i].len); texts_QList.push_back(texts_arr_i_QString); } @@ -275,11 +275,11 @@ void QComboBox_InsertItem2(QComboBox* self, int index, QIcon* icon, struct miqt_ self->insertItem(static_cast(index), *icon, text_QString); } -void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array* /* of struct miqt_string */ texts) { +void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array /* of struct miqt_string */ texts) { QStringList texts_QList; - texts_QList.reserve(texts->len); - struct miqt_string* texts_arr = static_cast(texts->data); - for(size_t i = 0; i < texts->len; ++i) { + texts_QList.reserve(texts.len); + struct miqt_string* texts_arr = static_cast(texts.data); + for(size_t i = 0; i < texts.len; ++i) { QString texts_arr_i_QString = QString::fromUtf8(texts_arr[i].data, texts_arr[i].len); texts_QList.push_back(texts_arr_i_QString); } diff --git a/qt6/gen_qcombobox.go b/qt6/gen_qcombobox.go index a5c6e736..47cb8fa4 100644 --- a/qt6/gen_qcombobox.go +++ b/qt6/gen_qcombobox.go @@ -316,7 +316,6 @@ func (this *QComboBox) AddItem2(icon *QIcon, text string) { } func (this *QComboBox) AddItems(texts []string) { - // For the C ABI, malloc a C array of structs texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts)))) defer C.free(unsafe.Pointer(texts_CArray)) for i := range texts { @@ -326,8 +325,7 @@ func (this *QComboBox) AddItems(texts []string) { defer C.free(unsafe.Pointer(texts_i_ms.data)) texts_CArray[i] = texts_i_ms } - texts_ma := &C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(texts_ma)) + texts_ma := C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} C.QComboBox_AddItems(this.h, texts_ma) } @@ -348,7 +346,6 @@ func (this *QComboBox) InsertItem2(index int, icon *QIcon, text string) { } func (this *QComboBox) InsertItems(index int, texts []string) { - // For the C ABI, malloc a C array of structs texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts)))) defer C.free(unsafe.Pointer(texts_CArray)) for i := range texts { @@ -358,8 +355,7 @@ func (this *QComboBox) InsertItems(index int, texts []string) { defer C.free(unsafe.Pointer(texts_i_ms.data)) texts_CArray[i] = texts_i_ms } - texts_ma := &C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(texts_ma)) + texts_ma := C.struct_miqt_array{len: C.size_t(len(texts)), data: unsafe.Pointer(texts_CArray)} C.QComboBox_InsertItems(this.h, (C.int)(index), texts_ma) } diff --git a/qt6/gen_qcombobox.h b/qt6/gen_qcombobox.h index 62f298ed..ba6f5155 100644 --- a/qt6/gen_qcombobox.h +++ b/qt6/gen_qcombobox.h @@ -95,10 +95,10 @@ QIcon* QComboBox_ItemIcon(const QComboBox* self, int index); QVariant* QComboBox_ItemData(const QComboBox* self, int index); void QComboBox_AddItem(QComboBox* self, struct miqt_string text); void QComboBox_AddItem2(QComboBox* self, QIcon* icon, struct miqt_string text); -void QComboBox_AddItems(QComboBox* self, struct miqt_array* /* of struct miqt_string */ texts); +void QComboBox_AddItems(QComboBox* self, struct miqt_array /* of struct miqt_string */ texts); void QComboBox_InsertItem(QComboBox* self, int index, struct miqt_string text); void QComboBox_InsertItem2(QComboBox* self, int index, QIcon* icon, struct miqt_string text); -void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array* /* of struct miqt_string */ texts); +void QComboBox_InsertItems(QComboBox* self, int index, struct miqt_array /* of struct miqt_string */ texts); void QComboBox_InsertSeparator(QComboBox* self, int index); void QComboBox_RemoveItem(QComboBox* self, int index); void QComboBox_SetItemText(QComboBox* self, int index, struct miqt_string text); diff --git a/qt6/gen_qcommandlineoption.cpp b/qt6/gen_qcommandlineoption.cpp index 811a8b52..dc02a091 100644 --- a/qt6/gen_qcommandlineoption.cpp +++ b/qt6/gen_qcommandlineoption.cpp @@ -12,11 +12,11 @@ QCommandLineOption* QCommandLineOption_new(struct miqt_string name) { return new QCommandLineOption(name_QString); } -QCommandLineOption* QCommandLineOption_new2(struct miqt_array* /* of struct miqt_string */ names) { +QCommandLineOption* QCommandLineOption_new2(struct miqt_array /* of struct miqt_string */ names) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -29,11 +29,11 @@ QCommandLineOption* QCommandLineOption_new3(struct miqt_string name, struct miqt return new QCommandLineOption(name_QString, description_QString); } -QCommandLineOption* QCommandLineOption_new4(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description) { +QCommandLineOption* QCommandLineOption_new4(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -60,11 +60,11 @@ QCommandLineOption* QCommandLineOption_new7(struct miqt_string name, struct miqt return new QCommandLineOption(name_QString, description_QString, valueName_QString, defaultValue_QString); } -QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName) { +QCommandLineOption* QCommandLineOption_new8(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -73,11 +73,11 @@ QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt return new QCommandLineOption(names_QList, description_QString, valueName_QString); } -QCommandLineOption* QCommandLineOption_new9(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue) { +QCommandLineOption* QCommandLineOption_new9(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } @@ -95,7 +95,7 @@ void QCommandLineOption_Swap(QCommandLineOption* self, QCommandLineOption* other self->swap(*other); } -struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self) { +struct miqt_array QCommandLineOption_Names(const QCommandLineOption* self) { QStringList _ret = self->names(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -109,9 +109,9 @@ struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -152,18 +152,18 @@ void QCommandLineOption_SetDefaultValue(QCommandLineOption* self, struct miqt_st self->setDefaultValue(defaultValue_QString); } -void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array* /* of struct miqt_string */ defaultValues) { +void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array /* of struct miqt_string */ defaultValues) { QStringList defaultValues_QList; - defaultValues_QList.reserve(defaultValues->len); - struct miqt_string* defaultValues_arr = static_cast(defaultValues->data); - for(size_t i = 0; i < defaultValues->len; ++i) { + defaultValues_QList.reserve(defaultValues.len); + struct miqt_string* defaultValues_arr = static_cast(defaultValues.data); + for(size_t i = 0; i < defaultValues.len; ++i) { QString defaultValues_arr_i_QString = QString::fromUtf8(defaultValues_arr[i].data, defaultValues_arr[i].len); defaultValues_QList.push_back(defaultValues_arr_i_QString); } self->setDefaultValues(defaultValues_QList); } -struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* self) { +struct miqt_array QCommandLineOption_DefaultValues(const QCommandLineOption* self) { QStringList _ret = self->defaultValues(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -177,9 +177,9 @@ struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* se memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcommandlineoption.go b/qt6/gen_qcommandlineoption.go index 0bcd990b..a11c89b2 100644 --- a/qt6/gen_qcommandlineoption.go +++ b/qt6/gen_qcommandlineoption.go @@ -61,7 +61,6 @@ func NewQCommandLineOption(name string) *QCommandLineOption { // NewQCommandLineOption2 constructs a new QCommandLineOption object. func NewQCommandLineOption2(names []string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -71,8 +70,7 @@ func NewQCommandLineOption2(names []string) *QCommandLineOption { defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} ret := C.QCommandLineOption_new2(names_ma) return newQCommandLineOption(ret) } @@ -93,7 +91,6 @@ func NewQCommandLineOption3(name string, description string) *QCommandLineOption // NewQCommandLineOption4 constructs a new QCommandLineOption object. func NewQCommandLineOption4(names []string, description string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -103,8 +100,7 @@ func NewQCommandLineOption4(names []string, description string) *QCommandLineOpt defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -161,7 +157,6 @@ func NewQCommandLineOption7(name string, description string, valueName string, d // NewQCommandLineOption8 constructs a new QCommandLineOption object. func NewQCommandLineOption8(names []string, description string, valueName string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -171,8 +166,7 @@ func NewQCommandLineOption8(names []string, description string, valueName string defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -187,7 +181,6 @@ func NewQCommandLineOption8(names []string, description string, valueName string // NewQCommandLineOption9 constructs a new QCommandLineOption object. func NewQCommandLineOption9(names []string, description string, valueName string, defaultValue string) *QCommandLineOption { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -197,8 +190,7 @@ func NewQCommandLineOption9(names []string, description string, valueName string defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} description_ms := C.struct_miqt_string{} description_ms.data = C.CString(description) description_ms.len = C.size_t(len(description)) @@ -224,7 +216,7 @@ func (this *QCommandLineOption) Swap(other *QCommandLineOption) { } func (this *QCommandLineOption) Names() []string { - var _ma *C.struct_miqt_array = C.QCommandLineOption_Names(this.h) + var _ma C.struct_miqt_array = C.QCommandLineOption_Names(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -233,7 +225,6 @@ func (this *QCommandLineOption) Names() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -276,7 +267,6 @@ func (this *QCommandLineOption) SetDefaultValue(defaultValue string) { } func (this *QCommandLineOption) SetDefaultValues(defaultValues []string) { - // For the C ABI, malloc a C array of structs defaultValues_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(defaultValues)))) defer C.free(unsafe.Pointer(defaultValues_CArray)) for i := range defaultValues { @@ -286,13 +276,12 @@ func (this *QCommandLineOption) SetDefaultValues(defaultValues []string) { defer C.free(unsafe.Pointer(defaultValues_i_ms.data)) defaultValues_CArray[i] = defaultValues_i_ms } - defaultValues_ma := &C.struct_miqt_array{len: C.size_t(len(defaultValues)), data: unsafe.Pointer(defaultValues_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(defaultValues_ma)) + defaultValues_ma := C.struct_miqt_array{len: C.size_t(len(defaultValues)), data: unsafe.Pointer(defaultValues_CArray)} C.QCommandLineOption_SetDefaultValues(this.h, defaultValues_ma) } func (this *QCommandLineOption) DefaultValues() []string { - var _ma *C.struct_miqt_array = C.QCommandLineOption_DefaultValues(this.h) + var _ma C.struct_miqt_array = C.QCommandLineOption_DefaultValues(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -301,7 +290,6 @@ func (this *QCommandLineOption) DefaultValues() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcommandlineoption.h b/qt6/gen_qcommandlineoption.h index da4aaa75..0d5f90f0 100644 --- a/qt6/gen_qcommandlineoption.h +++ b/qt6/gen_qcommandlineoption.h @@ -20,24 +20,24 @@ typedef struct QCommandLineOption QCommandLineOption; #endif QCommandLineOption* QCommandLineOption_new(struct miqt_string name); -QCommandLineOption* QCommandLineOption_new2(struct miqt_array* /* of struct miqt_string */ names); +QCommandLineOption* QCommandLineOption_new2(struct miqt_array /* of struct miqt_string */ names); QCommandLineOption* QCommandLineOption_new3(struct miqt_string name, struct miqt_string description); -QCommandLineOption* QCommandLineOption_new4(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description); +QCommandLineOption* QCommandLineOption_new4(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description); QCommandLineOption* QCommandLineOption_new5(QCommandLineOption* other); QCommandLineOption* QCommandLineOption_new6(struct miqt_string name, struct miqt_string description, struct miqt_string valueName); QCommandLineOption* QCommandLineOption_new7(struct miqt_string name, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); -QCommandLineOption* QCommandLineOption_new8(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName); -QCommandLineOption* QCommandLineOption_new9(struct miqt_array* /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); +QCommandLineOption* QCommandLineOption_new8(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName); +QCommandLineOption* QCommandLineOption_new9(struct miqt_array /* of struct miqt_string */ names, struct miqt_string description, struct miqt_string valueName, struct miqt_string defaultValue); void QCommandLineOption_OperatorAssign(QCommandLineOption* self, QCommandLineOption* other); void QCommandLineOption_Swap(QCommandLineOption* self, QCommandLineOption* other); -struct miqt_array* QCommandLineOption_Names(const QCommandLineOption* self); +struct miqt_array QCommandLineOption_Names(const QCommandLineOption* self); void QCommandLineOption_SetValueName(QCommandLineOption* self, struct miqt_string name); struct miqt_string QCommandLineOption_ValueName(const QCommandLineOption* self); void QCommandLineOption_SetDescription(QCommandLineOption* self, struct miqt_string description); struct miqt_string QCommandLineOption_Description(const QCommandLineOption* self); void QCommandLineOption_SetDefaultValue(QCommandLineOption* self, struct miqt_string defaultValue); -void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array* /* of struct miqt_string */ defaultValues); -struct miqt_array* QCommandLineOption_DefaultValues(const QCommandLineOption* self); +void QCommandLineOption_SetDefaultValues(QCommandLineOption* self, struct miqt_array /* of struct miqt_string */ defaultValues); +struct miqt_array QCommandLineOption_DefaultValues(const QCommandLineOption* self); int QCommandLineOption_Flags(const QCommandLineOption* self); void QCommandLineOption_SetFlags(QCommandLineOption* self, int aflags); void QCommandLineOption_Delete(QCommandLineOption* self); diff --git a/qt6/gen_qcommandlineparser.cpp b/qt6/gen_qcommandlineparser.cpp index 0938e33b..2ac88797 100644 --- a/qt6/gen_qcommandlineparser.cpp +++ b/qt6/gen_qcommandlineparser.cpp @@ -36,11 +36,11 @@ bool QCommandLineParser_AddOption(QCommandLineParser* self, QCommandLineOption* return self->addOption(*commandLineOption); } -bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array* /* of QCommandLineOption* */ options) { +bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array /* of QCommandLineOption* */ options) { QList options_QList; - options_QList.reserve(options->len); - QCommandLineOption** options_arr = static_cast(options->data); - for(size_t i = 0; i < options->len; ++i) { + options_QList.reserve(options.len); + QCommandLineOption** options_arr = static_cast(options.data); + for(size_t i = 0; i < options.len; ++i) { options_QList.push_back(*(options_arr[i])); } return self->addOptions(options_QList); @@ -80,11 +80,11 @@ void QCommandLineParser_ClearPositionalArguments(QCommandLineParser* self) { self->clearPositionalArguments(); } -void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments) { +void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -95,11 +95,11 @@ void QCommandLineParser_ProcessWithApp(QCommandLineParser* self, QCoreApplicatio self->process(*app); } -bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments) { +bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -134,7 +134,7 @@ struct miqt_string QCommandLineParser_Value(const QCommandLineParser* self, stru return _ms; } -struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name) { +struct miqt_array QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name) { QString name_QString = QString::fromUtf8(name.data, name.len); QStringList _ret = self->values(name_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -149,9 +149,9 @@ struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, str memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -170,7 +170,7 @@ struct miqt_string QCommandLineParser_ValueWithOption(const QCommandLineParser* return _ms; } -struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option) { +struct miqt_array QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option) { QStringList _ret = self->values(*option); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -184,13 +184,13 @@ struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_PositionalArguments(const QCommandLineParser* self) { QStringList _ret = self->positionalArguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -204,13 +204,13 @@ struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLinePars memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_OptionNames(const QCommandLineParser* self) { QStringList _ret = self->optionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -224,13 +224,13 @@ struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self) { +struct miqt_array QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self) { QStringList _ret = self->unknownOptionNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -244,9 +244,9 @@ struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParse memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcommandlineparser.go b/qt6/gen_qcommandlineparser.go index d50a2db7..eecd7178 100644 --- a/qt6/gen_qcommandlineparser.go +++ b/qt6/gen_qcommandlineparser.go @@ -84,14 +84,12 @@ func (this *QCommandLineParser) AddOption(commandLineOption *QCommandLineOption) } func (this *QCommandLineParser) AddOptions(options []QCommandLineOption) bool { - // For the C ABI, malloc a C array of raw pointers options_CArray := (*[0xffff]*C.QCommandLineOption)(C.malloc(C.size_t(8 * len(options)))) defer C.free(unsafe.Pointer(options_CArray)) for i := range options { options_CArray[i] = options[i].cPointer() } - options_ma := &C.struct_miqt_array{len: C.size_t(len(options)), data: unsafe.Pointer(options_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(options_ma)) + options_ma := C.struct_miqt_array{len: C.size_t(len(options)), data: unsafe.Pointer(options_CArray)} return (bool)(C.QCommandLineParser_AddOptions(this.h, options_ma)) } @@ -141,7 +139,6 @@ func (this *QCommandLineParser) ClearPositionalArguments() { } func (this *QCommandLineParser) Process(arguments []string) { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -151,8 +148,7 @@ func (this *QCommandLineParser) Process(arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QCommandLineParser_Process(this.h, arguments_ma) } @@ -161,7 +157,6 @@ func (this *QCommandLineParser) ProcessWithApp(app *QCoreApplication) { } func (this *QCommandLineParser) Parse(arguments []string) bool { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -171,8 +166,7 @@ func (this *QCommandLineParser) Parse(arguments []string) bool { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (bool)(C.QCommandLineParser_Parse(this.h, arguments_ma)) } @@ -207,7 +201,7 @@ func (this *QCommandLineParser) Values(name string) []string { name_ms.data = C.CString(name) name_ms.len = C.size_t(len(name)) defer C.free(unsafe.Pointer(name_ms.data)) - var _ma *C.struct_miqt_array = C.QCommandLineParser_Values(this.h, name_ms) + var _ma C.struct_miqt_array = C.QCommandLineParser_Values(this.h, name_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -216,7 +210,6 @@ func (this *QCommandLineParser) Values(name string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -232,7 +225,7 @@ func (this *QCommandLineParser) ValueWithOption(option *QCommandLineOption) stri } func (this *QCommandLineParser) ValuesWithOption(option *QCommandLineOption) []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_ValuesWithOption(this.h, option.cPointer()) + var _ma C.struct_miqt_array = C.QCommandLineParser_ValuesWithOption(this.h, option.cPointer()) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -241,12 +234,11 @@ func (this *QCommandLineParser) ValuesWithOption(option *QCommandLineOption) []s C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) PositionalArguments() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_PositionalArguments(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_PositionalArguments(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -255,12 +247,11 @@ func (this *QCommandLineParser) PositionalArguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) OptionNames() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_OptionNames(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_OptionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -269,12 +260,11 @@ func (this *QCommandLineParser) OptionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QCommandLineParser) UnknownOptionNames() []string { - var _ma *C.struct_miqt_array = C.QCommandLineParser_UnknownOptionNames(this.h) + var _ma C.struct_miqt_array = C.QCommandLineParser_UnknownOptionNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -283,7 +273,6 @@ func (this *QCommandLineParser) UnknownOptionNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcommandlineparser.h b/qt6/gen_qcommandlineparser.h index 0bcb49f8..f1055caf 100644 --- a/qt6/gen_qcommandlineparser.h +++ b/qt6/gen_qcommandlineparser.h @@ -28,26 +28,26 @@ struct miqt_string QCommandLineParser_Tr(const char* sourceText); void QCommandLineParser_SetSingleDashWordOptionMode(QCommandLineParser* self, int parsingMode); void QCommandLineParser_SetOptionsAfterPositionalArgumentsMode(QCommandLineParser* self, int mode); bool QCommandLineParser_AddOption(QCommandLineParser* self, QCommandLineOption* commandLineOption); -bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array* /* of QCommandLineOption* */ options); +bool QCommandLineParser_AddOptions(QCommandLineParser* self, struct miqt_array /* of QCommandLineOption* */ options); QCommandLineOption* QCommandLineParser_AddVersionOption(QCommandLineParser* self); QCommandLineOption* QCommandLineParser_AddHelpOption(QCommandLineParser* self); void QCommandLineParser_SetApplicationDescription(QCommandLineParser* self, struct miqt_string description); struct miqt_string QCommandLineParser_ApplicationDescription(const QCommandLineParser* self); void QCommandLineParser_AddPositionalArgument(QCommandLineParser* self, struct miqt_string name, struct miqt_string description); void QCommandLineParser_ClearPositionalArguments(QCommandLineParser* self); -void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments); +void QCommandLineParser_Process(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments); void QCommandLineParser_ProcessWithApp(QCommandLineParser* self, QCoreApplication* app); -bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array* /* of struct miqt_string */ arguments); +bool QCommandLineParser_Parse(QCommandLineParser* self, struct miqt_array /* of struct miqt_string */ arguments); struct miqt_string QCommandLineParser_ErrorText(const QCommandLineParser* self); bool QCommandLineParser_IsSet(const QCommandLineParser* self, struct miqt_string name); struct miqt_string QCommandLineParser_Value(const QCommandLineParser* self, struct miqt_string name); -struct miqt_array* QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name); +struct miqt_array QCommandLineParser_Values(const QCommandLineParser* self, struct miqt_string name); bool QCommandLineParser_IsSetWithOption(const QCommandLineParser* self, QCommandLineOption* option); struct miqt_string QCommandLineParser_ValueWithOption(const QCommandLineParser* self, QCommandLineOption* option); -struct miqt_array* QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option); -struct miqt_array* QCommandLineParser_PositionalArguments(const QCommandLineParser* self); -struct miqt_array* QCommandLineParser_OptionNames(const QCommandLineParser* self); -struct miqt_array* QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_ValuesWithOption(const QCommandLineParser* self, QCommandLineOption* option); +struct miqt_array QCommandLineParser_PositionalArguments(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_OptionNames(const QCommandLineParser* self); +struct miqt_array QCommandLineParser_UnknownOptionNames(const QCommandLineParser* self); void QCommandLineParser_ShowVersion(QCommandLineParser* self); void QCommandLineParser_ShowHelp(QCommandLineParser* self); struct miqt_string QCommandLineParser_HelpText(const QCommandLineParser* self); diff --git a/qt6/gen_qcompleter.cpp b/qt6/gen_qcompleter.cpp index 29189046..609b8f61 100644 --- a/qt6/gen_qcompleter.cpp +++ b/qt6/gen_qcompleter.cpp @@ -22,11 +22,11 @@ QCompleter* QCompleter_new2(QAbstractItemModel* model) { return new QCompleter(model); } -QCompleter* QCompleter_new3(struct miqt_array* /* of struct miqt_string */ completions) { +QCompleter* QCompleter_new3(struct miqt_array /* of struct miqt_string */ completions) { QStringList completions_QList; - completions_QList.reserve(completions->len); - struct miqt_string* completions_arr = static_cast(completions->data); - for(size_t i = 0; i < completions->len; ++i) { + completions_QList.reserve(completions.len); + struct miqt_string* completions_arr = static_cast(completions.data); + for(size_t i = 0; i < completions.len; ++i) { QString completions_arr_i_QString = QString::fromUtf8(completions_arr[i].data, completions_arr[i].len); completions_QList.push_back(completions_arr_i_QString); } @@ -41,11 +41,11 @@ QCompleter* QCompleter_new5(QAbstractItemModel* model, QObject* parent) { return new QCompleter(model, parent); } -QCompleter* QCompleter_new6(struct miqt_array* /* of struct miqt_string */ completions, QObject* parent) { +QCompleter* QCompleter_new6(struct miqt_array /* of struct miqt_string */ completions, QObject* parent) { QStringList completions_QList; - completions_QList.reserve(completions->len); - struct miqt_string* completions_arr = static_cast(completions->data); - for(size_t i = 0; i < completions->len; ++i) { + completions_QList.reserve(completions.len); + struct miqt_string* completions_arr = static_cast(completions.data); + for(size_t i = 0; i < completions.len; ++i) { QString completions_arr_i_QString = QString::fromUtf8(completions_arr[i].data, completions_arr[i].len); completions_QList.push_back(completions_arr_i_QString); } @@ -225,7 +225,7 @@ struct miqt_string QCompleter_PathFromIndex(const QCompleter* self, QModelIndex* return _ms; } -struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_string path) { +struct miqt_array QCompleter_SplitPath(const QCompleter* self, struct miqt_string path) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList _ret = self->splitPath(path_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -240,9 +240,9 @@ struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_stri memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcompleter.go b/qt6/gen_qcompleter.go index 3a394b38..0e997e6b 100644 --- a/qt6/gen_qcompleter.go +++ b/qt6/gen_qcompleter.go @@ -74,7 +74,6 @@ func NewQCompleter2(model *QAbstractItemModel) *QCompleter { // NewQCompleter3 constructs a new QCompleter object. func NewQCompleter3(completions []string) *QCompleter { - // For the C ABI, malloc a C array of structs completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions)))) defer C.free(unsafe.Pointer(completions_CArray)) for i := range completions { @@ -84,8 +83,7 @@ func NewQCompleter3(completions []string) *QCompleter { defer C.free(unsafe.Pointer(completions_i_ms.data)) completions_CArray[i] = completions_i_ms } - completions_ma := &C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(completions_ma)) + completions_ma := C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} ret := C.QCompleter_new3(completions_ma) return newQCompleter(ret) } @@ -104,7 +102,6 @@ func NewQCompleter5(model *QAbstractItemModel, parent *QObject) *QCompleter { // NewQCompleter6 constructs a new QCompleter object. func NewQCompleter6(completions []string, parent *QObject) *QCompleter { - // For the C ABI, malloc a C array of structs completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions)))) defer C.free(unsafe.Pointer(completions_CArray)) for i := range completions { @@ -114,8 +111,7 @@ func NewQCompleter6(completions []string, parent *QObject) *QCompleter { defer C.free(unsafe.Pointer(completions_i_ms.data)) completions_CArray[i] = completions_i_ms } - completions_ma := &C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(completions_ma)) + completions_ma := C.struct_miqt_array{len: C.size_t(len(completions)), data: unsafe.Pointer(completions_CArray)} ret := C.QCompleter_new6(completions_ma, parent.cPointer()) return newQCompleter(ret) } @@ -288,7 +284,7 @@ func (this *QCompleter) SplitPath(path string) []string { path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - var _ma *C.struct_miqt_array = C.QCompleter_SplitPath(this.h, path_ms) + var _ma C.struct_miqt_array = C.QCompleter_SplitPath(this.h, path_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -297,7 +293,6 @@ func (this *QCompleter) SplitPath(path string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcompleter.h b/qt6/gen_qcompleter.h index 70703474..03b43835 100644 --- a/qt6/gen_qcompleter.h +++ b/qt6/gen_qcompleter.h @@ -35,10 +35,10 @@ typedef struct QWidget QWidget; QCompleter* QCompleter_new(); QCompleter* QCompleter_new2(QAbstractItemModel* model); -QCompleter* QCompleter_new3(struct miqt_array* /* of struct miqt_string */ completions); +QCompleter* QCompleter_new3(struct miqt_array /* of struct miqt_string */ completions); QCompleter* QCompleter_new4(QObject* parent); QCompleter* QCompleter_new5(QAbstractItemModel* model, QObject* parent); -QCompleter* QCompleter_new6(struct miqt_array* /* of struct miqt_string */ completions, QObject* parent); +QCompleter* QCompleter_new6(struct miqt_array /* of struct miqt_string */ completions, QObject* parent); QMetaObject* QCompleter_MetaObject(const QCompleter* self); void* QCompleter_Metacast(QCompleter* self, const char* param1); struct miqt_string QCompleter_Tr(const char* s); @@ -74,7 +74,7 @@ void QCompleter_SetCompletionPrefix(QCompleter* self, struct miqt_string prefix) void QCompleter_Complete(QCompleter* self); void QCompleter_SetWrapAround(QCompleter* self, bool wrap); struct miqt_string QCompleter_PathFromIndex(const QCompleter* self, QModelIndex* index); -struct miqt_array* QCompleter_SplitPath(const QCompleter* self, struct miqt_string path); +struct miqt_array QCompleter_SplitPath(const QCompleter* self, struct miqt_string path); void QCompleter_Activated(QCompleter* self, struct miqt_string text); void QCompleter_connect_Activated(QCompleter* self, intptr_t slot); void QCompleter_ActivatedWithIndex(QCompleter* self, QModelIndex* index); diff --git a/qt6/gen_qconcatenatetablesproxymodel.cpp b/qt6/gen_qconcatenatetablesproxymodel.cpp index 4118ced3..b0ba4085 100644 --- a/qt6/gen_qconcatenatetablesproxymodel.cpp +++ b/qt6/gen_qconcatenatetablesproxymodel.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -41,16 +42,16 @@ struct miqt_string QConcatenateTablesProxyModel_Tr(const char* s) { return _ms; } -struct miqt_array* QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self) { +struct miqt_array QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self) { QList _ret = self->sourceModels(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractItemModel** _arr = static_cast(malloc(sizeof(QAbstractItemModel*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -78,6 +79,34 @@ bool QConcatenateTablesProxyModel_SetData(QConcatenateTablesProxyModel* self, QM return self->setData(*index, *value); } +struct miqt_map QConcatenateTablesProxyModel_ItemData(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex) { + QMap _ret = self->itemData(*proxyIndex); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QConcatenateTablesProxyModel_SetItemData(QConcatenateTablesProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + int QConcatenateTablesProxyModel_Flags(const QConcatenateTablesProxyModel* self, QModelIndex* index) { Qt::ItemFlags _ret = self->flags(*index); return static_cast(_ret); @@ -103,7 +132,7 @@ int QConcatenateTablesProxyModel_ColumnCount(const QConcatenateTablesProxyModel* return self->columnCount(); } -struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self) { +struct miqt_array QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -117,17 +146,17 @@ struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTabl memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); diff --git a/qt6/gen_qconcatenatetablesproxymodel.go b/qt6/gen_qconcatenatetablesproxymodel.go index c521dafe..c3261ebc 100644 --- a/qt6/gen_qconcatenatetablesproxymodel.go +++ b/qt6/gen_qconcatenatetablesproxymodel.go @@ -75,13 +75,12 @@ func QConcatenateTablesProxyModel_Tr(s string) string { } func (this *QConcatenateTablesProxyModel) SourceModels() []*QAbstractItemModel { - var _ma *C.struct_miqt_array = C.QConcatenateTablesProxyModel_SourceModels(this.h) + var _ma C.struct_miqt_array = C.QConcatenateTablesProxyModel_SourceModels(this.h) _ret := make([]*QAbstractItemModel, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractItemModel)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractItemModel(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -118,6 +117,43 @@ func (this *QConcatenateTablesProxyModel) SetData(index *QModelIndex, value *QVa return (bool)(C.QConcatenateTablesProxyModel_SetData(this.h, index.cPointer(), value.cPointer())) } +func (this *QConcatenateTablesProxyModel) ItemData(proxyIndex *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QConcatenateTablesProxyModel_ItemData(this.h, proxyIndex.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QConcatenateTablesProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QConcatenateTablesProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QConcatenateTablesProxyModel) Flags(index *QModelIndex) ItemFlag { return (ItemFlag)(C.QConcatenateTablesProxyModel_Flags(this.h, index.cPointer())) } @@ -152,7 +188,7 @@ func (this *QConcatenateTablesProxyModel) ColumnCount() int { } func (this *QConcatenateTablesProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QConcatenateTablesProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QConcatenateTablesProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -161,19 +197,16 @@ func (this *QConcatenateTablesProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QConcatenateTablesProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QConcatenateTablesProxyModel_MimeData(this.h, indexes_ma))) } diff --git a/qt6/gen_qconcatenatetablesproxymodel.h b/qt6/gen_qconcatenatetablesproxymodel.h index 76b294d7..78fdd66d 100644 --- a/qt6/gen_qconcatenatetablesproxymodel.h +++ b/qt6/gen_qconcatenatetablesproxymodel.h @@ -38,21 +38,23 @@ QConcatenateTablesProxyModel* QConcatenateTablesProxyModel_new2(QObject* parent) QMetaObject* QConcatenateTablesProxyModel_MetaObject(const QConcatenateTablesProxyModel* self); void* QConcatenateTablesProxyModel_Metacast(QConcatenateTablesProxyModel* self, const char* param1); struct miqt_string QConcatenateTablesProxyModel_Tr(const char* s); -struct miqt_array* QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self); +struct miqt_array QConcatenateTablesProxyModel_SourceModels(const QConcatenateTablesProxyModel* self); void QConcatenateTablesProxyModel_AddSourceModel(QConcatenateTablesProxyModel* self, QAbstractItemModel* sourceModel); void QConcatenateTablesProxyModel_RemoveSourceModel(QConcatenateTablesProxyModel* self, QAbstractItemModel* sourceModel); QModelIndex* QConcatenateTablesProxyModel_MapFromSource(const QConcatenateTablesProxyModel* self, QModelIndex* sourceIndex); QModelIndex* QConcatenateTablesProxyModel_MapToSource(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex); QVariant* QConcatenateTablesProxyModel_Data(const QConcatenateTablesProxyModel* self, QModelIndex* index); bool QConcatenateTablesProxyModel_SetData(QConcatenateTablesProxyModel* self, QModelIndex* index, QVariant* value); +struct miqt_map QConcatenateTablesProxyModel_ItemData(const QConcatenateTablesProxyModel* self, QModelIndex* proxyIndex); +bool QConcatenateTablesProxyModel_SetItemData(QConcatenateTablesProxyModel* self, QModelIndex* index, struct miqt_map roles); int QConcatenateTablesProxyModel_Flags(const QConcatenateTablesProxyModel* self, QModelIndex* index); QModelIndex* QConcatenateTablesProxyModel_Index(const QConcatenateTablesProxyModel* self, int row, int column); QModelIndex* QConcatenateTablesProxyModel_Parent(const QConcatenateTablesProxyModel* self, QModelIndex* index); int QConcatenateTablesProxyModel_RowCount(const QConcatenateTablesProxyModel* self); QVariant* QConcatenateTablesProxyModel_HeaderData(const QConcatenateTablesProxyModel* self, int section, int orientation); int QConcatenateTablesProxyModel_ColumnCount(const QConcatenateTablesProxyModel* self); -struct miqt_array* QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self); -QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QConcatenateTablesProxyModel_MimeTypes(const QConcatenateTablesProxyModel* self); +QMimeData* QConcatenateTablesProxyModel_MimeData(const QConcatenateTablesProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QConcatenateTablesProxyModel_CanDropMimeData(const QConcatenateTablesProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QConcatenateTablesProxyModel_DropMimeData(QConcatenateTablesProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); QSize* QConcatenateTablesProxyModel_Span(const QConcatenateTablesProxyModel* self, QModelIndex* index); diff --git a/qt6/gen_qcoreapplication.cpp b/qt6/gen_qcoreapplication.cpp index 42efe244..11abfc85 100644 --- a/qt6/gen_qcoreapplication.cpp +++ b/qt6/gen_qcoreapplication.cpp @@ -40,7 +40,7 @@ struct miqt_string QCoreApplication_Tr(const char* s) { return _ms; } -struct miqt_array* QCoreApplication_Arguments() { +struct miqt_array QCoreApplication_Arguments() { QStringList _ret = QCoreApplication::arguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -54,9 +54,9 @@ struct miqt_array* QCoreApplication_Arguments() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -219,18 +219,18 @@ long long QCoreApplication_ApplicationPid() { return static_cast(_ret); } -void QCoreApplication_SetLibraryPaths(struct miqt_array* /* of struct miqt_string */ libraryPaths) { +void QCoreApplication_SetLibraryPaths(struct miqt_array /* of struct miqt_string */ libraryPaths) { QStringList libraryPaths_QList; - libraryPaths_QList.reserve(libraryPaths->len); - struct miqt_string* libraryPaths_arr = static_cast(libraryPaths->data); - for(size_t i = 0; i < libraryPaths->len; ++i) { + libraryPaths_QList.reserve(libraryPaths.len); + struct miqt_string* libraryPaths_arr = static_cast(libraryPaths.data); + for(size_t i = 0; i < libraryPaths.len; ++i) { QString libraryPaths_arr_i_QString = QString::fromUtf8(libraryPaths_arr[i].data, libraryPaths_arr[i].len); libraryPaths_QList.push_back(libraryPaths_arr_i_QString); } QCoreApplication::setLibraryPaths(libraryPaths_QList); } -struct miqt_array* QCoreApplication_LibraryPaths() { +struct miqt_array QCoreApplication_LibraryPaths() { QStringList _ret = QCoreApplication::libraryPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -244,9 +244,9 @@ struct miqt_array* QCoreApplication_LibraryPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qcoreapplication.go b/qt6/gen_qcoreapplication.go index a0ea43a3..d66cfea2 100644 --- a/qt6/gen_qcoreapplication.go +++ b/qt6/gen_qcoreapplication.go @@ -96,7 +96,7 @@ func QCoreApplication_Tr(s string) string { } func QCoreApplication_Arguments() []string { - var _ma *C.struct_miqt_array = C.QCoreApplication_Arguments() + var _ma C.struct_miqt_array = C.QCoreApplication_Arguments() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -105,7 +105,6 @@ func QCoreApplication_Arguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -256,7 +255,6 @@ func QCoreApplication_ApplicationPid() int64 { } func QCoreApplication_SetLibraryPaths(libraryPaths []string) { - // For the C ABI, malloc a C array of structs libraryPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(libraryPaths)))) defer C.free(unsafe.Pointer(libraryPaths_CArray)) for i := range libraryPaths { @@ -266,13 +264,12 @@ func QCoreApplication_SetLibraryPaths(libraryPaths []string) { defer C.free(unsafe.Pointer(libraryPaths_i_ms.data)) libraryPaths_CArray[i] = libraryPaths_i_ms } - libraryPaths_ma := &C.struct_miqt_array{len: C.size_t(len(libraryPaths)), data: unsafe.Pointer(libraryPaths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(libraryPaths_ma)) + libraryPaths_ma := C.struct_miqt_array{len: C.size_t(len(libraryPaths)), data: unsafe.Pointer(libraryPaths_CArray)} C.QCoreApplication_SetLibraryPaths(libraryPaths_ma) } func QCoreApplication_LibraryPaths() []string { - var _ma *C.struct_miqt_array = C.QCoreApplication_LibraryPaths() + var _ma C.struct_miqt_array = C.QCoreApplication_LibraryPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -281,7 +278,6 @@ func QCoreApplication_LibraryPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qcoreapplication.h b/qt6/gen_qcoreapplication.h index 74f1c22b..08d1efb2 100644 --- a/qt6/gen_qcoreapplication.h +++ b/qt6/gen_qcoreapplication.h @@ -36,7 +36,7 @@ QCoreApplication* QCoreApplication_new2(int* argc, char** argv, int param3); QMetaObject* QCoreApplication_MetaObject(const QCoreApplication* self); void* QCoreApplication_Metacast(QCoreApplication* self, const char* param1); struct miqt_string QCoreApplication_Tr(const char* s); -struct miqt_array* QCoreApplication_Arguments(); +struct miqt_array QCoreApplication_Arguments(); void QCoreApplication_SetAttribute(int attribute); bool QCoreApplication_TestAttribute(int attribute); void QCoreApplication_SetOrganizationDomain(struct miqt_string orgDomain); @@ -65,8 +65,8 @@ bool QCoreApplication_ClosingDown(); struct miqt_string QCoreApplication_ApplicationDirPath(); struct miqt_string QCoreApplication_ApplicationFilePath(); long long QCoreApplication_ApplicationPid(); -void QCoreApplication_SetLibraryPaths(struct miqt_array* /* of struct miqt_string */ libraryPaths); -struct miqt_array* QCoreApplication_LibraryPaths(); +void QCoreApplication_SetLibraryPaths(struct miqt_array /* of struct miqt_string */ libraryPaths); +struct miqt_array QCoreApplication_LibraryPaths(); void QCoreApplication_AddLibraryPath(struct miqt_string param1); void QCoreApplication_RemoveLibraryPath(struct miqt_string param1); bool QCoreApplication_InstallTranslator(QTranslator* messageFile); diff --git a/qt6/gen_qdialogbuttonbox.cpp b/qt6/gen_qdialogbuttonbox.cpp index d2c42e7e..ea546722 100644 --- a/qt6/gen_qdialogbuttonbox.cpp +++ b/qt6/gen_qdialogbuttonbox.cpp @@ -92,16 +92,16 @@ void QDialogButtonBox_Clear(QDialogButtonBox* self) { self->clear(); } -struct miqt_array* QDialogButtonBox_Buttons(const QDialogButtonBox* self) { +struct miqt_array QDialogButtonBox_Buttons(const QDialogButtonBox* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qdialogbuttonbox.go b/qt6/gen_qdialogbuttonbox.go index 6952ee32..ebbc8fc1 100644 --- a/qt6/gen_qdialogbuttonbox.go +++ b/qt6/gen_qdialogbuttonbox.go @@ -196,13 +196,12 @@ func (this *QDialogButtonBox) Clear() { } func (this *QDialogButtonBox) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QDialogButtonBox_Buttons(this.h) + var _ma C.struct_miqt_array = C.QDialogButtonBox_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qdialogbuttonbox.h b/qt6/gen_qdialogbuttonbox.h index c699741f..72cada6d 100644 --- a/qt6/gen_qdialogbuttonbox.h +++ b/qt6/gen_qdialogbuttonbox.h @@ -45,7 +45,7 @@ QPushButton* QDialogButtonBox_AddButton2(QDialogButtonBox* self, struct miqt_str QPushButton* QDialogButtonBox_AddButtonWithButton(QDialogButtonBox* self, int button); void QDialogButtonBox_RemoveButton(QDialogButtonBox* self, QAbstractButton* button); void QDialogButtonBox_Clear(QDialogButtonBox* self); -struct miqt_array* QDialogButtonBox_Buttons(const QDialogButtonBox* self); +struct miqt_array QDialogButtonBox_Buttons(const QDialogButtonBox* self); int QDialogButtonBox_ButtonRole(const QDialogButtonBox* self, QAbstractButton* button); void QDialogButtonBox_SetStandardButtons(QDialogButtonBox* self, int buttons); int QDialogButtonBox_StandardButtons(const QDialogButtonBox* self); diff --git a/qt6/gen_qdir.cpp b/qt6/gen_qdir.cpp index cea92b23..e266a57b 100644 --- a/qt6/gen_qdir.cpp +++ b/qt6/gen_qdir.cpp @@ -86,12 +86,12 @@ struct miqt_string QDir_CanonicalPath(const QDir* self) { return _ms; } -void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array* /* of struct miqt_string */ searchPaths) { +void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array /* of struct miqt_string */ searchPaths) { QString prefix_QString = QString::fromUtf8(prefix.data, prefix.len); QStringList searchPaths_QList; - searchPaths_QList.reserve(searchPaths->len); - struct miqt_string* searchPaths_arr = static_cast(searchPaths->data); - for(size_t i = 0; i < searchPaths->len; ++i) { + searchPaths_QList.reserve(searchPaths.len); + struct miqt_string* searchPaths_arr = static_cast(searchPaths.data); + for(size_t i = 0; i < searchPaths.len; ++i) { QString searchPaths_arr_i_QString = QString::fromUtf8(searchPaths_arr[i].data, searchPaths_arr[i].len); searchPaths_QList.push_back(searchPaths_arr_i_QString); } @@ -104,7 +104,7 @@ void QDir_AddSearchPath(struct miqt_string prefix, struct miqt_string path) { QDir::addSearchPath(prefix_QString, path_QString); } -struct miqt_array* QDir_SearchPaths(struct miqt_string prefix) { +struct miqt_array QDir_SearchPaths(struct miqt_string prefix) { QString prefix_QString = QString::fromUtf8(prefix.data, prefix.len); QStringList _ret = QDir::searchPaths(prefix_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -119,9 +119,9 @@ struct miqt_array* QDir_SearchPaths(struct miqt_string prefix) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -205,7 +205,7 @@ bool QDir_CdUp(QDir* self) { return self->cdUp(); } -struct miqt_array* QDir_NameFilters(const QDir* self) { +struct miqt_array QDir_NameFilters(const QDir* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -219,17 +219,17 @@ struct miqt_array* QDir_NameFilters(const QDir* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QDir_SetNameFilters(QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +void QDir_SetNameFilters(QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -274,7 +274,7 @@ struct miqt_string QDir_OperatorSubscript(const QDir* self, int param1) { return _ms; } -struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter) { +struct miqt_array QDir_NameFiltersFromString(struct miqt_string nameFilter) { QString nameFilter_QString = QString::fromUtf8(nameFilter.data, nameFilter.len); QStringList _ret = QDir::nameFiltersFromString(nameFilter_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -289,13 +289,13 @@ struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList(const QDir* self) { +struct miqt_array QDir_EntryList(const QDir* self) { QStringList _ret = self->entryList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -309,17 +309,17 @@ struct miqt_array* QDir_EntryList(const QDir* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +struct miqt_array QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -336,30 +336,30 @@ struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_a memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList(const QDir* self) { +struct miqt_array QDir_EntryInfoList(const QDir* self) { QFileInfoList _ret = self->entryInfoList(); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters) { +struct miqt_array QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -369,9 +369,9 @@ struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct mi for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -462,16 +462,16 @@ bool QDir_ExistsWithName(const QDir* self, struct miqt_string name) { return self->exists(name_QString); } -struct miqt_array* QDir_Drives() { +struct miqt_array QDir_Drives() { QFileInfoList _ret = QDir::drives(); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -548,11 +548,11 @@ struct miqt_string QDir_TempPath() { return _ms; } -bool QDir_Match(struct miqt_array* /* of struct miqt_string */ filters, struct miqt_string fileName) { +bool QDir_Match(struct miqt_array /* of struct miqt_string */ filters, struct miqt_string fileName) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } @@ -586,7 +586,7 @@ bool QDir_IsEmpty1(const QDir* self, int filters) { return self->isEmpty(static_cast(filters)); } -struct miqt_array* QDir_EntryList1(const QDir* self, int filters) { +struct miqt_array QDir_EntryList1(const QDir* self, int filters) { QStringList _ret = self->entryList(static_cast(filters)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -600,13 +600,13 @@ struct miqt_array* QDir_EntryList1(const QDir* self, int filters) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort) { +struct miqt_array QDir_EntryList2(const QDir* self, int filters, int sort) { QStringList _ret = self->entryList(static_cast(filters), static_cast(sort)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -620,17 +620,17 @@ struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +struct miqt_array QDir_EntryList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -647,17 +647,17 @@ struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of s memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort) { +struct miqt_array QDir_EntryList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -674,43 +674,43 @@ struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList1(const QDir* self, int filters) { +struct miqt_array QDir_EntryInfoList1(const QDir* self, int filters) { QFileInfoList _ret = self->entryInfoList(static_cast(filters)); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList2(const QDir* self, int filters, int sort) { +struct miqt_array QDir_EntryInfoList2(const QDir* self, int filters, int sort) { QFileInfoList _ret = self->entryInfoList(static_cast(filters), static_cast(sort)); // Convert QList<> from C++ memory to manually-managed C memory QFileInfo** _arr = static_cast(malloc(sizeof(QFileInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +struct miqt_array QDir_EntryInfoList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -720,17 +720,17 @@ struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort) { +struct miqt_array QDir_EntryInfoList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort) { QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -740,9 +740,9 @@ struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* o for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QFileInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qdir.go b/qt6/gen_qdir.go index a9383071..60d8be19 100644 --- a/qt6/gen_qdir.go +++ b/qt6/gen_qdir.go @@ -190,7 +190,6 @@ func QDir_SetSearchPaths(prefix string, searchPaths []string) { prefix_ms.data = C.CString(prefix) prefix_ms.len = C.size_t(len(prefix)) defer C.free(unsafe.Pointer(prefix_ms.data)) - // For the C ABI, malloc a C array of structs searchPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(searchPaths)))) defer C.free(unsafe.Pointer(searchPaths_CArray)) for i := range searchPaths { @@ -200,8 +199,7 @@ func QDir_SetSearchPaths(prefix string, searchPaths []string) { defer C.free(unsafe.Pointer(searchPaths_i_ms.data)) searchPaths_CArray[i] = searchPaths_i_ms } - searchPaths_ma := &C.struct_miqt_array{len: C.size_t(len(searchPaths)), data: unsafe.Pointer(searchPaths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(searchPaths_ma)) + searchPaths_ma := C.struct_miqt_array{len: C.size_t(len(searchPaths)), data: unsafe.Pointer(searchPaths_CArray)} C.QDir_SetSearchPaths(prefix_ms, searchPaths_ma) } @@ -222,7 +220,7 @@ func QDir_SearchPaths(prefix string) []string { prefix_ms.data = C.CString(prefix) prefix_ms.len = C.size_t(len(prefix)) defer C.free(unsafe.Pointer(prefix_ms.data)) - var _ma *C.struct_miqt_array = C.QDir_SearchPaths(prefix_ms) + var _ma C.struct_miqt_array = C.QDir_SearchPaths(prefix_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -231,7 +229,6 @@ func QDir_SearchPaths(prefix string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -310,7 +307,7 @@ func (this *QDir) CdUp() bool { } func (this *QDir) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QDir_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QDir_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -319,12 +316,10 @@ func (this *QDir) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) SetNameFilters(nameFilters []string) { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -334,8 +329,7 @@ func (this *QDir) SetNameFilters(nameFilters []string) { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} C.QDir_SetNameFilters(this.h, nameFilters_ma) } @@ -375,7 +369,7 @@ func QDir_NameFiltersFromString(nameFilter string) []string { nameFilter_ms.data = C.CString(nameFilter) nameFilter_ms.len = C.size_t(len(nameFilter)) defer C.free(unsafe.Pointer(nameFilter_ms.data)) - var _ma *C.struct_miqt_array = C.QDir_NameFiltersFromString(nameFilter_ms) + var _ma C.struct_miqt_array = C.QDir_NameFiltersFromString(nameFilter_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -384,12 +378,11 @@ func QDir_NameFiltersFromString(nameFilter string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList() []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList(this.h) + var _ma C.struct_miqt_array = C.QDir_EntryList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -398,12 +391,10 @@ func (this *QDir) EntryList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -413,9 +404,8 @@ func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryListWithNameFilters(this.h, nameFilters_ma) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryListWithNameFilters(this.h, nameFilters_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -424,12 +414,11 @@ func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList() []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList(this.h) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList(this.h) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -438,12 +427,10 @@ func (this *QDir) EntryInfoList() []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -453,9 +440,8 @@ func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoListWithNameFilters(this.h, nameFilters_ma) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoListWithNameFilters(this.h, nameFilters_ma) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -464,7 +450,6 @@ func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -589,7 +574,7 @@ func (this *QDir) ExistsWithName(name string) bool { } func QDir_Drives() []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_Drives() + var _ma C.struct_miqt_array = C.QDir_Drives() _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -598,7 +583,6 @@ func QDir_Drives() []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -681,7 +665,6 @@ func QDir_TempPath() string { } func QDir_Match(filters []string, fileName string) bool { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -691,8 +674,7 @@ func QDir_Match(filters []string, fileName string) bool { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} fileName_ms := C.struct_miqt_string{} fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) @@ -732,7 +714,7 @@ func (this *QDir) IsEmpty1(filters QDir__Filter) bool { } func (this *QDir) EntryList1(filters QDir__Filter) []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList1(this.h, (C.int)(filters)) + var _ma C.struct_miqt_array = C.QDir_EntryList1(this.h, (C.int)(filters)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -741,12 +723,11 @@ func (this *QDir) EntryList1(filters QDir__Filter) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList2(filters QDir__Filter, sort QDir__SortFlag) []string { - var _ma *C.struct_miqt_array = C.QDir_EntryList2(this.h, (C.int)(filters), (C.int)(sort)) + var _ma C.struct_miqt_array = C.QDir_EntryList2(this.h, (C.int)(filters), (C.int)(sort)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -755,12 +736,10 @@ func (this *QDir) EntryList2(filters QDir__Filter, sort QDir__SortFlag) []string C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -770,9 +749,8 @@ func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []stri defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryList22(this.h, nameFilters_ma, (C.int)(filters)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryList22(this.h, nameFilters_ma, (C.int)(filters)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -781,12 +759,10 @@ func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []stri C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []string { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -796,9 +772,8 @@ func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QD defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -807,12 +782,11 @@ func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QD C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList1(filters QDir__Filter) []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList1(this.h, (C.int)(filters)) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList1(this.h, (C.int)(filters)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -821,12 +795,11 @@ func (this *QDir) EntryInfoList1(filters QDir__Filter) []QFileInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList2(filters QDir__Filter, sort QDir__SortFlag) []QFileInfo { - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList2(this.h, (C.int)(filters), (C.int)(sort)) + var _ma C.struct_miqt_array = C.QDir_EntryInfoList2(this.h, (C.int)(filters), (C.int)(sort)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -835,12 +808,10 @@ func (this *QDir) EntryInfoList2(filters QDir__Filter, sort QDir__SortFlag) []QF _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -850,9 +821,8 @@ func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) [] defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList22(this.h, nameFilters_ma, (C.int)(filters)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoList22(this.h, nameFilters_ma, (C.int)(filters)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -861,12 +831,10 @@ func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) [] _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []QFileInfo { - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -876,9 +844,8 @@ func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sor defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) - var _ma *C.struct_miqt_array = C.QDir_EntryInfoList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} + var _ma C.struct_miqt_array = C.QDir_EntryInfoList3(this.h, nameFilters_ma, (C.int)(filters), (C.int)(sort)) _ret := make([]QFileInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QFileInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -887,7 +854,6 @@ func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sor _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qdir.h b/qt6/gen_qdir.h index 48121362..9b561f4f 100644 --- a/qt6/gen_qdir.h +++ b/qt6/gen_qdir.h @@ -35,9 +35,9 @@ void QDir_SetPath(QDir* self, struct miqt_string path); struct miqt_string QDir_Path(const QDir* self); struct miqt_string QDir_AbsolutePath(const QDir* self); struct miqt_string QDir_CanonicalPath(const QDir* self); -void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array* /* of struct miqt_string */ searchPaths); +void QDir_SetSearchPaths(struct miqt_string prefix, struct miqt_array /* of struct miqt_string */ searchPaths); void QDir_AddSearchPath(struct miqt_string prefix, struct miqt_string path); -struct miqt_array* QDir_SearchPaths(struct miqt_string prefix); +struct miqt_array QDir_SearchPaths(struct miqt_string prefix); struct miqt_string QDir_DirName(const QDir* self); struct miqt_string QDir_FilePath(const QDir* self, struct miqt_string fileName); struct miqt_string QDir_AbsoluteFilePath(const QDir* self, struct miqt_string fileName); @@ -46,8 +46,8 @@ struct miqt_string QDir_ToNativeSeparators(struct miqt_string pathName); struct miqt_string QDir_FromNativeSeparators(struct miqt_string pathName); bool QDir_Cd(QDir* self, struct miqt_string dirName); bool QDir_CdUp(QDir* self); -struct miqt_array* QDir_NameFilters(const QDir* self); -void QDir_SetNameFilters(QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_NameFilters(const QDir* self); +void QDir_SetNameFilters(QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); int QDir_Filter(const QDir* self); void QDir_SetFilter(QDir* self, int filter); int QDir_Sorting(const QDir* self); @@ -55,11 +55,11 @@ void QDir_SetSorting(QDir* self, int sort); unsigned int QDir_Count(const QDir* self); bool QDir_IsEmpty(const QDir* self); struct miqt_string QDir_OperatorSubscript(const QDir* self, int param1); -struct miqt_array* QDir_NameFiltersFromString(struct miqt_string nameFilter); -struct miqt_array* QDir_EntryList(const QDir* self); -struct miqt_array* QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); -struct miqt_array* QDir_EntryInfoList(const QDir* self); -struct miqt_array* QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_NameFiltersFromString(struct miqt_string nameFilter); +struct miqt_array QDir_EntryList(const QDir* self); +struct miqt_array QDir_EntryListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); +struct miqt_array QDir_EntryInfoList(const QDir* self); +struct miqt_array QDir_EntryInfoListWithNameFilters(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters); bool QDir_Mkdir(const QDir* self, struct miqt_string dirName); bool QDir_Mkdir2(const QDir* self, struct miqt_string dirName, int permissions); bool QDir_Rmdir(const QDir* self, struct miqt_string dirName); @@ -79,7 +79,7 @@ bool QDir_OperatorNotEqual(const QDir* self, QDir* dir); bool QDir_Remove(QDir* self, struct miqt_string fileName); bool QDir_Rename(QDir* self, struct miqt_string oldName, struct miqt_string newName); bool QDir_ExistsWithName(const QDir* self, struct miqt_string name); -struct miqt_array* QDir_Drives(); +struct miqt_array QDir_Drives(); QChar* QDir_ListSeparator(); QChar* QDir_Separator(); bool QDir_SetCurrent(struct miqt_string path); @@ -91,19 +91,19 @@ QDir* QDir_Root(); struct miqt_string QDir_RootPath(); QDir* QDir_Temp(); struct miqt_string QDir_TempPath(); -bool QDir_Match(struct miqt_array* /* of struct miqt_string */ filters, struct miqt_string fileName); +bool QDir_Match(struct miqt_array /* of struct miqt_string */ filters, struct miqt_string fileName); bool QDir_Match2(struct miqt_string filter, struct miqt_string fileName); struct miqt_string QDir_CleanPath(struct miqt_string path); void QDir_Refresh(const QDir* self); bool QDir_IsEmpty1(const QDir* self, int filters); -struct miqt_array* QDir_EntryList1(const QDir* self, int filters); -struct miqt_array* QDir_EntryList2(const QDir* self, int filters, int sort); -struct miqt_array* QDir_EntryList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -struct miqt_array* QDir_EntryList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort); -struct miqt_array* QDir_EntryInfoList1(const QDir* self, int filters); -struct miqt_array* QDir_EntryInfoList2(const QDir* self, int filters, int sort); -struct miqt_array* QDir_EntryInfoList22(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -struct miqt_array* QDir_EntryInfoList3(const QDir* self, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int sort); +struct miqt_array QDir_EntryList1(const QDir* self, int filters); +struct miqt_array QDir_EntryList2(const QDir* self, int filters, int sort); +struct miqt_array QDir_EntryList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +struct miqt_array QDir_EntryList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort); +struct miqt_array QDir_EntryInfoList1(const QDir* self, int filters); +struct miqt_array QDir_EntryInfoList2(const QDir* self, int filters, int sort); +struct miqt_array QDir_EntryInfoList22(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +struct miqt_array QDir_EntryInfoList3(const QDir* self, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int sort); void QDir_Delete(QDir* self); #ifdef __cplusplus diff --git a/qt6/gen_qdiriterator.cpp b/qt6/gen_qdiriterator.cpp index e6d4115b..4c0e65f5 100644 --- a/qt6/gen_qdiriterator.cpp +++ b/qt6/gen_qdiriterator.cpp @@ -23,12 +23,12 @@ QDirIterator* QDirIterator_new3(struct miqt_string path, int filter) { return new QDirIterator(path_QString, static_cast(filter)); } -QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters) { +QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } @@ -49,24 +49,24 @@ QDirIterator* QDirIterator_new7(struct miqt_string path, int filter, int flags) return new QDirIterator(path_QString, static_cast(filter), static_cast(flags)); } -QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters) { +QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } return new QDirIterator(path_QString, nameFilters_QList, static_cast(filters)); } -QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int flags) { +QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int flags) { QString path_QString = QString::fromUtf8(path.data, path.len); QStringList nameFilters_QList; - nameFilters_QList.reserve(nameFilters->len); - struct miqt_string* nameFilters_arr = static_cast(nameFilters->data); - for(size_t i = 0; i < nameFilters->len; ++i) { + nameFilters_QList.reserve(nameFilters.len); + struct miqt_string* nameFilters_arr = static_cast(nameFilters.data); + for(size_t i = 0; i < nameFilters.len; ++i) { QString nameFilters_arr_i_QString = QString::fromUtf8(nameFilters_arr[i].data, nameFilters_arr[i].len); nameFilters_QList.push_back(nameFilters_arr_i_QString); } diff --git a/qt6/gen_qdiriterator.go b/qt6/gen_qdiriterator.go index cbaaf308..95e9a97d 100644 --- a/qt6/gen_qdiriterator.go +++ b/qt6/gen_qdiriterator.go @@ -82,7 +82,6 @@ func NewQDirIterator4(path string, nameFilters []string) *QDirIterator { path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -92,8 +91,7 @@ func NewQDirIterator4(path string, nameFilters []string) *QDirIterator { defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new4(path_ms, nameFilters_ma) return newQDirIterator(ret) } @@ -130,7 +128,6 @@ func NewQDirIterator8(path string, nameFilters []string, filters QDir__Filter) * path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -140,8 +137,7 @@ func NewQDirIterator8(path string, nameFilters []string, filters QDir__Filter) * defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new8(path_ms, nameFilters_ma, (C.int)(filters)) return newQDirIterator(ret) } @@ -152,7 +148,6 @@ func NewQDirIterator9(path string, nameFilters []string, filters QDir__Filter, f path_ms.data = C.CString(path) path_ms.len = C.size_t(len(path)) defer C.free(unsafe.Pointer(path_ms.data)) - // For the C ABI, malloc a C array of structs nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters)))) defer C.free(unsafe.Pointer(nameFilters_CArray)) for i := range nameFilters { @@ -162,8 +157,7 @@ func NewQDirIterator9(path string, nameFilters []string, filters QDir__Filter, f defer C.free(unsafe.Pointer(nameFilters_i_ms.data)) nameFilters_CArray[i] = nameFilters_i_ms } - nameFilters_ma := &C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(nameFilters_ma)) + nameFilters_ma := C.struct_miqt_array{len: C.size_t(len(nameFilters)), data: unsafe.Pointer(nameFilters_CArray)} ret := C.QDirIterator_new9(path_ms, nameFilters_ma, (C.int)(filters), (C.int)(flags)) return newQDirIterator(ret) } diff --git a/qt6/gen_qdiriterator.h b/qt6/gen_qdiriterator.h index 34527605..54406088 100644 --- a/qt6/gen_qdiriterator.h +++ b/qt6/gen_qdiriterator.h @@ -26,12 +26,12 @@ typedef struct QFileInfo QFileInfo; QDirIterator* QDirIterator_new(QDir* dir); QDirIterator* QDirIterator_new2(struct miqt_string path); QDirIterator* QDirIterator_new3(struct miqt_string path, int filter); -QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters); +QDirIterator* QDirIterator_new4(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters); QDirIterator* QDirIterator_new5(QDir* dir, int flags); QDirIterator* QDirIterator_new6(struct miqt_string path, int flags); QDirIterator* QDirIterator_new7(struct miqt_string path, int filter, int flags); -QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters); -QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array* /* of struct miqt_string */ nameFilters, int filters, int flags); +QDirIterator* QDirIterator_new8(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters); +QDirIterator* QDirIterator_new9(struct miqt_string path, struct miqt_array /* of struct miqt_string */ nameFilters, int filters, int flags); struct miqt_string QDirIterator_Next(QDirIterator* self); QFileInfo* QDirIterator_NextFileInfo(QDirIterator* self); bool QDirIterator_HasNext(const QDirIterator* self); diff --git a/qt6/gen_qeasingcurve.cpp b/qt6/gen_qeasingcurve.cpp index 04b2d691..b9892fe4 100644 --- a/qt6/gen_qeasingcurve.cpp +++ b/qt6/gen_qeasingcurve.cpp @@ -68,16 +68,16 @@ void QEasingCurve_AddTCBSegment(QEasingCurve* self, QPointF* nextPoint, double t self->addTCBSegment(*nextPoint, static_cast(t), static_cast(c), static_cast(b)); } -struct miqt_array* QEasingCurve_ToCubicSpline(const QEasingCurve* self) { +struct miqt_array QEasingCurve_ToCubicSpline(const QEasingCurve* self) { QList _ret = self->toCubicSpline(); // Convert QList<> from C++ memory to manually-managed C memory QPointF** _arr = static_cast(malloc(sizeof(QPointF*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qeasingcurve.go b/qt6/gen_qeasingcurve.go index c3e61aa6..b6dd5f73 100644 --- a/qt6/gen_qeasingcurve.go +++ b/qt6/gen_qeasingcurve.go @@ -163,7 +163,7 @@ func (this *QEasingCurve) AddTCBSegment(nextPoint *QPointF, t float64, c float64 } func (this *QEasingCurve) ToCubicSpline() []QPointF { - var _ma *C.struct_miqt_array = C.QEasingCurve_ToCubicSpline(this.h) + var _ma C.struct_miqt_array = C.QEasingCurve_ToCubicSpline(this.h) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,7 +172,6 @@ func (this *QEasingCurve) ToCubicSpline() []QPointF { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qeasingcurve.h b/qt6/gen_qeasingcurve.h index 72694465..b70f923a 100644 --- a/qt6/gen_qeasingcurve.h +++ b/qt6/gen_qeasingcurve.h @@ -36,7 +36,7 @@ double QEasingCurve_Overshoot(const QEasingCurve* self); void QEasingCurve_SetOvershoot(QEasingCurve* self, double overshoot); void QEasingCurve_AddCubicBezierSegment(QEasingCurve* self, QPointF* c1, QPointF* c2, QPointF* endPoint); void QEasingCurve_AddTCBSegment(QEasingCurve* self, QPointF* nextPoint, double t, double c, double b); -struct miqt_array* QEasingCurve_ToCubicSpline(const QEasingCurve* self); +struct miqt_array QEasingCurve_ToCubicSpline(const QEasingCurve* self); int QEasingCurve_Type(const QEasingCurve* self); void QEasingCurve_SetType(QEasingCurve* self, int typeVal); double QEasingCurve_ValueForProgress(const QEasingCurve* self, double progress); diff --git a/qt6/gen_qevent.cpp b/qt6/gen_qevent.cpp index 87c40eee..c6d49045 100644 --- a/qt6/gen_qevent.cpp +++ b/qt6/gen_qevent.cpp @@ -116,11 +116,11 @@ QPointerEvent* QPointerEvent_new2(int typeVal, QPointingDevice* dev, int modifie return new QPointerEvent(static_cast(typeVal), dev, static_cast(modifiers)); } -QPointerEvent* QPointerEvent_new3(int typeVal, QPointingDevice* dev, int modifiers, struct miqt_array* /* of QEventPoint* */ points) { +QPointerEvent* QPointerEvent_new3(int typeVal, QPointingDevice* dev, int modifiers, struct miqt_array /* of QEventPoint* */ points) { QList points_QList; - points_QList.reserve(points->len); - QEventPoint** points_arr = static_cast(points->data); - for(size_t i = 0; i < points->len; ++i) { + points_QList.reserve(points.len); + QEventPoint** points_arr = static_cast(points.data); + for(size_t i = 0; i < points.len; ++i) { points_QList.push_back(*(points_arr[i])); } return new QPointerEvent(static_cast(typeVal), dev, static_cast(modifiers), points_QList); @@ -154,16 +154,16 @@ QEventPoint* QPointerEvent_Point(QPointerEvent* self, ptrdiff_t i) { return &_ret; } -struct miqt_array* QPointerEvent_Points(const QPointerEvent* self) { +struct miqt_array QPointerEvent_Points(const QPointerEvent* self) { const QList& _ret = self->points(); // Convert QList<> from C++ memory to manually-managed C memory QEventPoint** _arr = static_cast(malloc(sizeof(QEventPoint*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QEventPoint(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1015,12 +1015,12 @@ QInputMethodEvent* QInputMethodEvent_new() { return new QInputMethodEvent(); } -QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array* /* of QInputMethodEvent__Attribute* */ attributes) { +QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array /* of QInputMethodEvent__Attribute* */ attributes) { QString preeditText_QString = QString::fromUtf8(preeditText.data, preeditText.len); QList attributes_QList; - attributes_QList.reserve(attributes->len); - QInputMethodEvent__Attribute** attributes_arr = static_cast(attributes->data); - for(size_t i = 0; i < attributes->len; ++i) { + attributes_QList.reserve(attributes.len); + QInputMethodEvent__Attribute** attributes_arr = static_cast(attributes.data); + for(size_t i = 0; i < attributes.len; ++i) { attributes_QList.push_back(*(attributes_arr[i])); } return new QInputMethodEvent(preeditText_QString, attributes_QList); @@ -1035,16 +1035,16 @@ void QInputMethodEvent_SetCommitString(QInputMethodEvent* self, struct miqt_stri self->setCommitString(commitString_QString); } -struct miqt_array* QInputMethodEvent_Attributes(const QInputMethodEvent* self) { +struct miqt_array QInputMethodEvent_Attributes(const QInputMethodEvent* self) { const QList& _ret = self->attributes(); // Convert QList<> from C++ memory to manually-managed C memory QInputMethodEvent__Attribute** _arr = static_cast(malloc(sizeof(QInputMethodEvent__Attribute*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QInputMethodEvent::Attribute(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1491,21 +1491,21 @@ QTouchEvent* QTouchEvent_new4(int eventType, QPointingDevice* device, int modifi return new QTouchEvent(static_cast(eventType), device, static_cast(modifiers)); } -QTouchEvent* QTouchEvent_new5(int eventType, QPointingDevice* device, int modifiers, struct miqt_array* /* of QEventPoint* */ touchPoints) { +QTouchEvent* QTouchEvent_new5(int eventType, QPointingDevice* device, int modifiers, struct miqt_array /* of QEventPoint* */ touchPoints) { QList touchPoints_QList; - touchPoints_QList.reserve(touchPoints->len); - QEventPoint** touchPoints_arr = static_cast(touchPoints->data); - for(size_t i = 0; i < touchPoints->len; ++i) { + touchPoints_QList.reserve(touchPoints.len); + QEventPoint** touchPoints_arr = static_cast(touchPoints.data); + for(size_t i = 0; i < touchPoints.len; ++i) { touchPoints_QList.push_back(*(touchPoints_arr[i])); } return new QTouchEvent(static_cast(eventType), device, static_cast(modifiers), touchPoints_QList); } -QTouchEvent* QTouchEvent_new6(int eventType, QPointingDevice* device, int modifiers, uint8_t touchPointStates, struct miqt_array* /* of QEventPoint* */ touchPoints) { +QTouchEvent* QTouchEvent_new6(int eventType, QPointingDevice* device, int modifiers, uint8_t touchPointStates, struct miqt_array /* of QEventPoint* */ touchPoints) { QList touchPoints_QList; - touchPoints_QList.reserve(touchPoints->len); - QEventPoint** touchPoints_arr = static_cast(touchPoints->data); - for(size_t i = 0; i < touchPoints->len; ++i) { + touchPoints_QList.reserve(touchPoints.len); + QEventPoint** touchPoints_arr = static_cast(touchPoints.data); + for(size_t i = 0; i < touchPoints.len; ++i) { touchPoints_QList.push_back(*(touchPoints_arr[i])); } return new QTouchEvent(static_cast(eventType), device, static_cast(modifiers), static_cast(touchPointStates), touchPoints_QList); @@ -1524,16 +1524,16 @@ uint8_t QTouchEvent_TouchPointStates(const QTouchEvent* self) { return static_cast(_ret); } -struct miqt_array* QTouchEvent_TouchPoints(const QTouchEvent* self) { +struct miqt_array QTouchEvent_TouchPoints(const QTouchEvent* self) { const QList& _ret = self->touchPoints(); // Convert QList<> from C++ memory to manually-managed C memory QEventPoint** _arr = static_cast(malloc(sizeof(QEventPoint*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QEventPoint(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qevent.go b/qt6/gen_qevent.go index 90acfa45..98dc1998 100644 --- a/qt6/gen_qevent.go +++ b/qt6/gen_qevent.go @@ -180,14 +180,12 @@ func NewQPointerEvent2(typeVal QEvent__Type, dev *QPointingDevice, modifiers Key // NewQPointerEvent3 constructs a new QPointerEvent object. func NewQPointerEvent3(typeVal QEvent__Type, dev *QPointingDevice, modifiers KeyboardModifier, points []QEventPoint) *QPointerEvent { - // For the C ABI, malloc a C array of raw pointers points_CArray := (*[0xffff]*C.QEventPoint)(C.malloc(C.size_t(8 * len(points)))) defer C.free(unsafe.Pointer(points_CArray)) for i := range points { points_CArray[i] = points[i].cPointer() } - points_ma := &C.struct_miqt_array{len: C.size_t(len(points)), data: unsafe.Pointer(points_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(points_ma)) + points_ma := C.struct_miqt_array{len: C.size_t(len(points)), data: unsafe.Pointer(points_CArray)} ret := C.QPointerEvent_new3((C.int)(typeVal), dev.cPointer(), (C.int)(modifiers), points_ma) return newQPointerEvent(ret) } @@ -217,7 +215,7 @@ func (this *QPointerEvent) Point(i int64) *QEventPoint { } func (this *QPointerEvent) Points() []QEventPoint { - var _ma *C.struct_miqt_array = C.QPointerEvent_Points(this.h) + var _ma C.struct_miqt_array = C.QPointerEvent_Points(this.h) _ret := make([]QEventPoint, int(_ma.len)) _outCast := (*[0xffff]*C.QEventPoint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -226,7 +224,6 @@ func (this *QPointerEvent) Points() []QEventPoint { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -2045,14 +2042,12 @@ func NewQInputMethodEvent2(preeditText string, attributes []QInputMethodEvent__A preeditText_ms.data = C.CString(preeditText) preeditText_ms.len = C.size_t(len(preeditText)) defer C.free(unsafe.Pointer(preeditText_ms.data)) - // For the C ABI, malloc a C array of raw pointers attributes_CArray := (*[0xffff]*C.QInputMethodEvent__Attribute)(C.malloc(C.size_t(8 * len(attributes)))) defer C.free(unsafe.Pointer(attributes_CArray)) for i := range attributes { attributes_CArray[i] = attributes[i].cPointer() } - attributes_ma := &C.struct_miqt_array{len: C.size_t(len(attributes)), data: unsafe.Pointer(attributes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(attributes_ma)) + attributes_ma := C.struct_miqt_array{len: C.size_t(len(attributes)), data: unsafe.Pointer(attributes_CArray)} ret := C.QInputMethodEvent_new2(preeditText_ms, attributes_ma) return newQInputMethodEvent(ret) } @@ -2070,7 +2065,7 @@ func (this *QInputMethodEvent) SetCommitString(commitString string) { } func (this *QInputMethodEvent) Attributes() []QInputMethodEvent__Attribute { - var _ma *C.struct_miqt_array = C.QInputMethodEvent_Attributes(this.h) + var _ma C.struct_miqt_array = C.QInputMethodEvent_Attributes(this.h) _ret := make([]QInputMethodEvent__Attribute, int(_ma.len)) _outCast := (*[0xffff]*C.QInputMethodEvent__Attribute)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -2079,7 +2074,6 @@ func (this *QInputMethodEvent) Attributes() []QInputMethodEvent__Attribute { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -3132,28 +3126,24 @@ func NewQTouchEvent4(eventType QEvent__Type, device *QPointingDevice, modifiers // NewQTouchEvent5 constructs a new QTouchEvent object. func NewQTouchEvent5(eventType QEvent__Type, device *QPointingDevice, modifiers KeyboardModifier, touchPoints []QEventPoint) *QTouchEvent { - // For the C ABI, malloc a C array of raw pointers touchPoints_CArray := (*[0xffff]*C.QEventPoint)(C.malloc(C.size_t(8 * len(touchPoints)))) defer C.free(unsafe.Pointer(touchPoints_CArray)) for i := range touchPoints { touchPoints_CArray[i] = touchPoints[i].cPointer() } - touchPoints_ma := &C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(touchPoints_ma)) + touchPoints_ma := C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} ret := C.QTouchEvent_new5((C.int)(eventType), device.cPointer(), (C.int)(modifiers), touchPoints_ma) return newQTouchEvent(ret) } // NewQTouchEvent6 constructs a new QTouchEvent object. func NewQTouchEvent6(eventType QEvent__Type, device *QPointingDevice, modifiers KeyboardModifier, touchPointStates QEventPoint__State, touchPoints []QEventPoint) *QTouchEvent { - // For the C ABI, malloc a C array of raw pointers touchPoints_CArray := (*[0xffff]*C.QEventPoint)(C.malloc(C.size_t(8 * len(touchPoints)))) defer C.free(unsafe.Pointer(touchPoints_CArray)) for i := range touchPoints { touchPoints_CArray[i] = touchPoints[i].cPointer() } - touchPoints_ma := &C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(touchPoints_ma)) + touchPoints_ma := C.struct_miqt_array{len: C.size_t(len(touchPoints)), data: unsafe.Pointer(touchPoints_CArray)} ret := C.QTouchEvent_new6((C.int)(eventType), device.cPointer(), (C.int)(modifiers), (C.uint8_t)(touchPointStates), touchPoints_ma) return newQTouchEvent(ret) } @@ -3171,7 +3161,7 @@ func (this *QTouchEvent) TouchPointStates() QEventPoint__State { } func (this *QTouchEvent) TouchPoints() []QEventPoint { - var _ma *C.struct_miqt_array = C.QTouchEvent_TouchPoints(this.h) + var _ma C.struct_miqt_array = C.QTouchEvent_TouchPoints(this.h) _ret := make([]QEventPoint, int(_ma.len)) _outCast := (*[0xffff]*C.QEventPoint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -3180,7 +3170,6 @@ func (this *QTouchEvent) TouchPoints() []QEventPoint { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qevent.h b/qt6/gen_qevent.h index 621aa4a4..b08933f5 100644 --- a/qt6/gen_qevent.h +++ b/qt6/gen_qevent.h @@ -154,14 +154,14 @@ void QInputEvent_Delete(QInputEvent* self); QPointerEvent* QPointerEvent_new(int typeVal, QPointingDevice* dev); QPointerEvent* QPointerEvent_new2(int typeVal, QPointingDevice* dev, int modifiers); -QPointerEvent* QPointerEvent_new3(int typeVal, QPointingDevice* dev, int modifiers, struct miqt_array* /* of QEventPoint* */ points); +QPointerEvent* QPointerEvent_new3(int typeVal, QPointingDevice* dev, int modifiers, struct miqt_array /* of QEventPoint* */ points); QPointerEvent* QPointerEvent_Clone(const QPointerEvent* self); QPointingDevice* QPointerEvent_PointingDevice(const QPointerEvent* self); int QPointerEvent_PointerType(const QPointerEvent* self); void QPointerEvent_SetTimestamp(QPointerEvent* self, unsigned long long timestamp); ptrdiff_t QPointerEvent_PointCount(const QPointerEvent* self); QEventPoint* QPointerEvent_Point(QPointerEvent* self, ptrdiff_t i); -struct miqt_array* QPointerEvent_Points(const QPointerEvent* self); +struct miqt_array QPointerEvent_Points(const QPointerEvent* self); QEventPoint* QPointerEvent_PointById(QPointerEvent* self, int id); bool QPointerEvent_AllPointsGrabbed(const QPointerEvent* self); bool QPointerEvent_IsBeginEvent(const QPointerEvent* self); @@ -380,10 +380,10 @@ int QContextMenuEvent_Reason(const QContextMenuEvent* self); void QContextMenuEvent_Delete(QContextMenuEvent* self); QInputMethodEvent* QInputMethodEvent_new(); -QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array* /* of QInputMethodEvent__Attribute* */ attributes); +QInputMethodEvent* QInputMethodEvent_new2(struct miqt_string preeditText, struct miqt_array /* of QInputMethodEvent__Attribute* */ attributes); QInputMethodEvent* QInputMethodEvent_Clone(const QInputMethodEvent* self); void QInputMethodEvent_SetCommitString(QInputMethodEvent* self, struct miqt_string commitString); -struct miqt_array* QInputMethodEvent_Attributes(const QInputMethodEvent* self); +struct miqt_array QInputMethodEvent_Attributes(const QInputMethodEvent* self); struct miqt_string QInputMethodEvent_PreeditString(const QInputMethodEvent* self); struct miqt_string QInputMethodEvent_CommitString(const QInputMethodEvent* self); int QInputMethodEvent_ReplacementStart(const QInputMethodEvent* self); @@ -495,12 +495,12 @@ QTouchEvent* QTouchEvent_new(int eventType); QTouchEvent* QTouchEvent_new2(int eventType, QPointingDevice* device, int modifiers, uint8_t touchPointStates); QTouchEvent* QTouchEvent_new3(int eventType, QPointingDevice* device); QTouchEvent* QTouchEvent_new4(int eventType, QPointingDevice* device, int modifiers); -QTouchEvent* QTouchEvent_new5(int eventType, QPointingDevice* device, int modifiers, struct miqt_array* /* of QEventPoint* */ touchPoints); -QTouchEvent* QTouchEvent_new6(int eventType, QPointingDevice* device, int modifiers, uint8_t touchPointStates, struct miqt_array* /* of QEventPoint* */ touchPoints); +QTouchEvent* QTouchEvent_new5(int eventType, QPointingDevice* device, int modifiers, struct miqt_array /* of QEventPoint* */ touchPoints); +QTouchEvent* QTouchEvent_new6(int eventType, QPointingDevice* device, int modifiers, uint8_t touchPointStates, struct miqt_array /* of QEventPoint* */ touchPoints); QTouchEvent* QTouchEvent_Clone(const QTouchEvent* self); QObject* QTouchEvent_Target(const QTouchEvent* self); uint8_t QTouchEvent_TouchPointStates(const QTouchEvent* self); -struct miqt_array* QTouchEvent_TouchPoints(const QTouchEvent* self); +struct miqt_array QTouchEvent_TouchPoints(const QTouchEvent* self); bool QTouchEvent_IsBeginEvent(const QTouchEvent* self); bool QTouchEvent_IsUpdateEvent(const QTouchEvent* self); bool QTouchEvent_IsEndEvent(const QTouchEvent* self); diff --git a/qt6/gen_qfactoryinterface.cpp b/qt6/gen_qfactoryinterface.cpp index 7c3eafaa..dec46a8f 100644 --- a/qt6/gen_qfactoryinterface.cpp +++ b/qt6/gen_qfactoryinterface.cpp @@ -7,7 +7,7 @@ #include "gen_qfactoryinterface.h" #include "_cgo_export.h" -struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self) { +struct miqt_array QFactoryInterface_Keys(const QFactoryInterface* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -21,9 +21,9 @@ struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfactoryinterface.go b/qt6/gen_qfactoryinterface.go index 703c00b8..91d5fe37 100644 --- a/qt6/gen_qfactoryinterface.go +++ b/qt6/gen_qfactoryinterface.go @@ -43,7 +43,7 @@ func UnsafeNewQFactoryInterface(h unsafe.Pointer) *QFactoryInterface { } func (this *QFactoryInterface) Keys() []string { - var _ma *C.struct_miqt_array = C.QFactoryInterface_Keys(this.h) + var _ma C.struct_miqt_array = C.QFactoryInterface_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func (this *QFactoryInterface) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfactoryinterface.h b/qt6/gen_qfactoryinterface.h index ae93f479..e9f4546f 100644 --- a/qt6/gen_qfactoryinterface.h +++ b/qt6/gen_qfactoryinterface.h @@ -19,7 +19,7 @@ class QFactoryInterface; typedef struct QFactoryInterface QFactoryInterface; #endif -struct miqt_array* QFactoryInterface_Keys(const QFactoryInterface* self); +struct miqt_array QFactoryInterface_Keys(const QFactoryInterface* self); void QFactoryInterface_Delete(QFactoryInterface* self); #ifdef __cplusplus diff --git a/qt6/gen_qfiledialog.cpp b/qt6/gen_qfiledialog.cpp index 1553b8cd..f5152244 100644 --- a/qt6/gen_qfiledialog.cpp +++ b/qt6/gen_qfiledialog.cpp @@ -90,7 +90,7 @@ void QFileDialog_SelectFile(QFileDialog* self, struct miqt_string filename) { self->selectFile(filename_QString); } -struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self) { +struct miqt_array QFileDialog_SelectedFiles(const QFileDialog* self) { QStringList _ret = self->selectedFiles(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -104,9 +104,9 @@ struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -114,16 +114,16 @@ void QFileDialog_SelectUrl(QFileDialog* self, QUrl* url) { self->selectUrl(*url); } -struct miqt_array* QFileDialog_SelectedUrls(const QFileDialog* self) { +struct miqt_array QFileDialog_SelectedUrls(const QFileDialog* self) { QList _ret = self->selectedUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -132,18 +132,18 @@ void QFileDialog_SetNameFilter(QFileDialog* self, struct miqt_string filter) { self->setNameFilter(filter_QString); } -void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setNameFilters(filters_QList); } -struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self) { +struct miqt_array QFileDialog_NameFilters(const QFileDialog* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -157,9 +157,9 @@ struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -190,18 +190,18 @@ struct miqt_string QFileDialog_SelectedNameFilter(const QFileDialog* self) { return _ms; } -void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setMimeTypeFilters(filters_QList); } -struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self) { +struct miqt_array QFileDialog_MimeTypeFilters(const QFileDialog* self) { QStringList _ret = self->mimeTypeFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -215,9 +215,9 @@ struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -262,26 +262,26 @@ int QFileDialog_AcceptMode(const QFileDialog* self) { return static_cast(_ret); } -void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls) { +void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->setSidebarUrls(urls_QList); } -struct miqt_array* QFileDialog_SidebarUrls(const QFileDialog* self) { +struct miqt_array QFileDialog_SidebarUrls(const QFileDialog* self) { QList _ret = self->sidebarUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -315,18 +315,18 @@ struct miqt_string QFileDialog_DefaultSuffix(const QFileDialog* self) { return _ms; } -void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ paths) { +void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } self->setHistory(paths_QList); } -struct miqt_array* QFileDialog_History(const QFileDialog* self) { +struct miqt_array QFileDialog_History(const QFileDialog* self) { QStringList _ret = self->history(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -340,9 +340,9 @@ struct miqt_array* QFileDialog_History(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -378,18 +378,18 @@ struct miqt_string QFileDialog_LabelText(const QFileDialog* self, int label) { return _ms; } -void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ schemes) { +void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array /* of struct miqt_string */ schemes) { QStringList schemes_QList; - schemes_QList.reserve(schemes->len); - struct miqt_string* schemes_arr = static_cast(schemes->data); - for(size_t i = 0; i < schemes->len; ++i) { + schemes_QList.reserve(schemes.len); + struct miqt_string* schemes_arr = static_cast(schemes.data); + for(size_t i = 0; i < schemes.len; ++i) { QString schemes_arr_i_QString = QString::fromUtf8(schemes_arr[i].data, schemes_arr[i].len); schemes_QList.push_back(schemes_arr_i_QString); } self->setSupportedSchemes(schemes_QList); } -struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self) { +struct miqt_array QFileDialog_SupportedSchemes(const QFileDialog* self) { QStringList _ret = self->supportedSchemes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -403,9 +403,9 @@ struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -457,11 +457,11 @@ void QFileDialog_connect_FileSelected(QFileDialog* self, intptr_t slot) { }); } -void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ files) { +void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -483,10 +483,10 @@ void QFileDialog_connect_FilesSelected(QFileDialog* self, intptr_t slot) { memcpy(files_lv_ms.data, files_lv_b.data(), files_lv_ms.len); files_arr[i] = files_lv_ms; } - struct miqt_array* files_out = static_cast(malloc(sizeof(struct miqt_array))); - files_out->len = files_ret.length(); - files_out->data = static_cast(files_arr); - struct miqt_array* sigval1 = files_out; + struct miqt_array files_out; + files_out.len = files_ret.length(); + files_out.data = static_cast(files_arr); + struct miqt_array sigval1 = files_out; miqt_exec_callback_QFileDialog_FilesSelected(slot, sigval1); }); } @@ -542,11 +542,11 @@ void QFileDialog_connect_UrlSelected(QFileDialog* self, intptr_t slot) { }); } -void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls) { +void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->urlsSelected(urls_QList); @@ -560,10 +560,10 @@ void QFileDialog_connect_UrlsSelected(QFileDialog* self, intptr_t slot) { for (size_t i = 0, e = urls_ret.length(); i < e; ++i) { urls_arr[i] = new QUrl(urls_ret[i]); } - struct miqt_array* urls_out = static_cast(malloc(sizeof(struct miqt_array))); - urls_out->len = urls_ret.length(); - urls_out->data = static_cast(urls_arr); - struct miqt_array* sigval1 = urls_out; + struct miqt_array urls_out; + urls_out.len = urls_ret.length(); + urls_out.data = static_cast(urls_arr); + struct miqt_array sigval1 = urls_out; miqt_exec_callback_QFileDialog_UrlsSelected(slot, sigval1); }); } @@ -658,7 +658,7 @@ QUrl* QFileDialog_GetExistingDirectoryUrl() { return new QUrl(QFileDialog::getExistingDirectoryUrl()); } -struct miqt_array* QFileDialog_GetOpenFileNames() { +struct miqt_array QFileDialog_GetOpenFileNames() { QStringList _ret = QFileDialog::getOpenFileNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -672,22 +672,22 @@ struct miqt_array* QFileDialog_GetOpenFileNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls() { +struct miqt_array QFileDialog_GetOpenFileUrls() { QList _ret = QFileDialog::getOpenFileUrls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -931,19 +931,19 @@ QUrl* QFileDialog_GetExistingDirectoryUrl4(QWidget* parent, struct miqt_string c return new QUrl(QFileDialog::getExistingDirectoryUrl(parent, caption_QString, *dir, static_cast(options))); } -QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array* /* of struct miqt_string */ supportedSchemes) { +QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array /* of struct miqt_string */ supportedSchemes) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QStringList supportedSchemes_QList; - supportedSchemes_QList.reserve(supportedSchemes->len); - struct miqt_string* supportedSchemes_arr = static_cast(supportedSchemes->data); - for(size_t i = 0; i < supportedSchemes->len; ++i) { + supportedSchemes_QList.reserve(supportedSchemes.len); + struct miqt_string* supportedSchemes_arr = static_cast(supportedSchemes.data); + for(size_t i = 0; i < supportedSchemes.len; ++i) { QString supportedSchemes_arr_i_QString = QString::fromUtf8(supportedSchemes_arr[i].data, supportedSchemes_arr[i].len); supportedSchemes_QList.push_back(supportedSchemes_arr_i_QString); } return new QUrl(QFileDialog::getExistingDirectoryUrl(parent, caption_QString, *dir, static_cast(options), supportedSchemes_QList)); } -struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent) { +struct miqt_array QFileDialog_GetOpenFileNames1(QWidget* parent) { QStringList _ret = QFileDialog::getOpenFileNames(parent); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -957,13 +957,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption) { +struct miqt_array QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QStringList _ret = QFileDialog::getOpenFileNames(parent, caption_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -978,13 +978,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir) { +struct miqt_array QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString dir_QString = QString::fromUtf8(dir.data, dir.len); QStringList _ret = QFileDialog::getOpenFileNames(parent, caption_QString, dir_QString); @@ -1000,13 +1000,13 @@ struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter) { +struct miqt_array QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString dir_QString = QString::fromUtf8(dir.data, dir.len); QString filter_QString = QString::fromUtf8(filter.data, filter.len); @@ -1023,26 +1023,26 @@ struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_st memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls1(QWidget* parent) { +struct miqt_array QFileDialog_GetOpenFileUrls1(QWidget* parent) { QList _ret = QFileDialog::getOpenFileUrls(parent); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption) { +struct miqt_array QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -1050,13 +1050,13 @@ struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir) { +struct miqt_array QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString, *dir); // Convert QList<> from C++ memory to manually-managed C memory @@ -1064,13 +1064,13 @@ struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter) { +struct miqt_array QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter) { QString caption_QString = QString::fromUtf8(caption.data, caption.len); QString filter_QString = QString::fromUtf8(filter.data, filter.len); QList _ret = QFileDialog::getOpenFileUrls(parent, caption_QString, *dir, filter_QString); @@ -1079,9 +1079,9 @@ struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfiledialog.go b/qt6/gen_qfiledialog.go index ecf18200..54cd9122 100644 --- a/qt6/gen_qfiledialog.go +++ b/qt6/gen_qfiledialog.go @@ -207,7 +207,7 @@ func (this *QFileDialog) SelectFile(filename string) { } func (this *QFileDialog) SelectedFiles() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_SelectedFiles(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SelectedFiles(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -216,7 +216,6 @@ func (this *QFileDialog) SelectedFiles() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -225,7 +224,7 @@ func (this *QFileDialog) SelectUrl(url *QUrl) { } func (this *QFileDialog) SelectedUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_SelectedUrls(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SelectedUrls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -234,7 +233,6 @@ func (this *QFileDialog) SelectedUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -247,7 +245,6 @@ func (this *QFileDialog) SetNameFilter(filter string) { } func (this *QFileDialog) SetNameFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -257,13 +254,12 @@ func (this *QFileDialog) SetNameFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileDialog_SetNameFilters(this.h, filters_ma) } func (this *QFileDialog) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -272,7 +268,6 @@ func (this *QFileDialog) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -299,7 +294,6 @@ func (this *QFileDialog) SelectedNameFilter() string { } func (this *QFileDialog) SetMimeTypeFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -309,13 +303,12 @@ func (this *QFileDialog) SetMimeTypeFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileDialog_SetMimeTypeFilters(this.h, filters_ma) } func (this *QFileDialog) MimeTypeFilters() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_MimeTypeFilters(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_MimeTypeFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -324,7 +317,6 @@ func (this *QFileDialog) MimeTypeFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -369,19 +361,17 @@ func (this *QFileDialog) AcceptMode() QFileDialog__AcceptMode { } func (this *QFileDialog) SetSidebarUrls(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QFileDialog_SetSidebarUrls(this.h, urls_ma) } func (this *QFileDialog) SidebarUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_SidebarUrls(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SidebarUrls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -390,7 +380,6 @@ func (this *QFileDialog) SidebarUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -424,7 +413,6 @@ func (this *QFileDialog) DefaultSuffix() string { } func (this *QFileDialog) SetHistory(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -434,13 +422,12 @@ func (this *QFileDialog) SetHistory(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QFileDialog_SetHistory(this.h, paths_ma) } func (this *QFileDialog) History() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_History(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_History(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -449,7 +436,6 @@ func (this *QFileDialog) History() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -485,7 +471,6 @@ func (this *QFileDialog) LabelText(label QFileDialog__DialogLabel) string { } func (this *QFileDialog) SetSupportedSchemes(schemes []string) { - // For the C ABI, malloc a C array of structs schemes_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(schemes)))) defer C.free(unsafe.Pointer(schemes_CArray)) for i := range schemes { @@ -495,13 +480,12 @@ func (this *QFileDialog) SetSupportedSchemes(schemes []string) { defer C.free(unsafe.Pointer(schemes_i_ms.data)) schemes_CArray[i] = schemes_i_ms } - schemes_ma := &C.struct_miqt_array{len: C.size_t(len(schemes)), data: unsafe.Pointer(schemes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(schemes_ma)) + schemes_ma := C.struct_miqt_array{len: C.size_t(len(schemes)), data: unsafe.Pointer(schemes_CArray)} C.QFileDialog_SetSupportedSchemes(this.h, schemes_ma) } func (this *QFileDialog) SupportedSchemes() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_SupportedSchemes(this.h) + var _ma C.struct_miqt_array = C.QFileDialog_SupportedSchemes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -510,7 +494,6 @@ func (this *QFileDialog) SupportedSchemes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -570,7 +553,6 @@ func miqt_exec_callback_QFileDialog_FileSelected(cb C.intptr_t, file C.struct_mi } func (this *QFileDialog) FilesSelected(files []string) { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -580,8 +562,7 @@ func (this *QFileDialog) FilesSelected(files []string) { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} C.QFileDialog_FilesSelected(this.h, files_ma) } func (this *QFileDialog) OnFilesSelected(slot func(files []string)) { @@ -589,14 +570,14 @@ func (this *QFileDialog) OnFilesSelected(slot func(files []string)) { } //export miqt_exec_callback_QFileDialog_FilesSelected -func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files *C.struct_miqt_array) { +func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(files []string)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var files_ma *C.struct_miqt_array = files + var files_ma C.struct_miqt_array = files files_ret := make([]string, int(files_ma.len)) files_outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(files_ma.data)) // hey ya for i := 0; i < int(files_ma.len); i++ { @@ -605,7 +586,6 @@ func miqt_exec_callback_QFileDialog_FilesSelected(cb C.intptr_t, files *C.struct C.free(unsafe.Pointer(files_lv_ms.data)) files_ret[i] = files_lv_ret } - C.free(unsafe.Pointer(files_ma)) slotval1 := files_ret gofunc(slotval1) @@ -686,14 +666,12 @@ func miqt_exec_callback_QFileDialog_UrlSelected(cb C.intptr_t, url *C.QUrl) { } func (this *QFileDialog) UrlsSelected(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QFileDialog_UrlsSelected(this.h, urls_ma) } func (this *QFileDialog) OnUrlsSelected(slot func(urls []QUrl)) { @@ -701,14 +679,14 @@ func (this *QFileDialog) OnUrlsSelected(slot func(urls []QUrl)) { } //export miqt_exec_callback_QFileDialog_UrlsSelected -func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls *C.struct_miqt_array) { +func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(urls []QUrl)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var urls_ma *C.struct_miqt_array = urls + var urls_ma C.struct_miqt_array = urls urls_ret := make([]QUrl, int(urls_ma.len)) urls_outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(urls_ma.data)) // hey ya for i := 0; i < int(urls_ma.len); i++ { @@ -717,7 +695,6 @@ func miqt_exec_callback_QFileDialog_UrlsSelected(cb C.intptr_t, urls *C.struct_m urls_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer urls_ret[i] = *urls_lv_goptr } - C.free(unsafe.Pointer(urls_ma)) slotval1 := urls_ret gofunc(slotval1) @@ -833,7 +810,7 @@ func QFileDialog_GetExistingDirectoryUrl() *QUrl { } func QFileDialog_GetOpenFileNames() []string { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames() + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -842,12 +819,11 @@ func QFileDialog_GetOpenFileNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFileDialog_GetOpenFileUrls() []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls() + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls() _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -856,7 +832,6 @@ func QFileDialog_GetOpenFileUrls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1182,7 +1157,6 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - // For the C ABI, malloc a C array of structs supportedSchemes_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(supportedSchemes)))) defer C.free(unsafe.Pointer(supportedSchemes_CArray)) for i := range supportedSchemes { @@ -1192,8 +1166,7 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * defer C.free(unsafe.Pointer(supportedSchemes_i_ms.data)) supportedSchemes_CArray[i] = supportedSchemes_i_ms } - supportedSchemes_ma := &C.struct_miqt_array{len: C.size_t(len(supportedSchemes)), data: unsafe.Pointer(supportedSchemes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(supportedSchemes_ma)) + supportedSchemes_ma := C.struct_miqt_array{len: C.size_t(len(supportedSchemes)), data: unsafe.Pointer(supportedSchemes_CArray)} _ret := C.QFileDialog_GetExistingDirectoryUrl5(parent.cPointer(), caption_ms, dir.cPointer(), (C.int)(options), supportedSchemes_ma) _goptr := newQUrl(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer @@ -1201,7 +1174,7 @@ func QFileDialog_GetExistingDirectoryUrl5(parent *QWidget, caption string, dir * } func QFileDialog_GetOpenFileNames1(parent *QWidget) []string { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames1(parent.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames1(parent.cPointer()) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1210,7 +1183,6 @@ func QFileDialog_GetOpenFileNames1(parent *QWidget) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1219,7 +1191,7 @@ func QFileDialog_GetOpenFileNames2(parent *QWidget, caption string) []string { caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames2(parent.cPointer(), caption_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames2(parent.cPointer(), caption_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1228,7 +1200,6 @@ func QFileDialog_GetOpenFileNames2(parent *QWidget, caption string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1241,7 +1212,7 @@ func QFileDialog_GetOpenFileNames3(parent *QWidget, caption string, dir string) dir_ms.data = C.CString(dir) dir_ms.len = C.size_t(len(dir)) defer C.free(unsafe.Pointer(dir_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames3(parent.cPointer(), caption_ms, dir_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames3(parent.cPointer(), caption_ms, dir_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1250,7 +1221,6 @@ func QFileDialog_GetOpenFileNames3(parent *QWidget, caption string, dir string) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1267,7 +1237,7 @@ func QFileDialog_GetOpenFileNames4(parent *QWidget, caption string, dir string, filter_ms.data = C.CString(filter) filter_ms.len = C.size_t(len(filter)) defer C.free(unsafe.Pointer(filter_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileNames4(parent.cPointer(), caption_ms, dir_ms, filter_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileNames4(parent.cPointer(), caption_ms, dir_ms, filter_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1276,12 +1246,11 @@ func QFileDialog_GetOpenFileNames4(parent *QWidget, caption string, dir string, C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFileDialog_GetOpenFileUrls1(parent *QWidget) []QUrl { - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls1(parent.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls1(parent.cPointer()) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1290,7 +1259,6 @@ func QFileDialog_GetOpenFileUrls1(parent *QWidget) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1299,7 +1267,7 @@ func QFileDialog_GetOpenFileUrls2(parent *QWidget, caption string) []QUrl { caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls2(parent.cPointer(), caption_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls2(parent.cPointer(), caption_ms) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1308,7 +1276,6 @@ func QFileDialog_GetOpenFileUrls2(parent *QWidget, caption string) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1317,7 +1284,7 @@ func QFileDialog_GetOpenFileUrls3(parent *QWidget, caption string, dir *QUrl) [] caption_ms.data = C.CString(caption) caption_ms.len = C.size_t(len(caption)) defer C.free(unsafe.Pointer(caption_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls3(parent.cPointer(), caption_ms, dir.cPointer()) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls3(parent.cPointer(), caption_ms, dir.cPointer()) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1326,7 +1293,6 @@ func QFileDialog_GetOpenFileUrls3(parent *QWidget, caption string, dir *QUrl) [] _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1339,7 +1305,7 @@ func QFileDialog_GetOpenFileUrls4(parent *QWidget, caption string, dir *QUrl, fi filter_ms.data = C.CString(filter) filter_ms.len = C.size_t(len(filter)) defer C.free(unsafe.Pointer(filter_ms.data)) - var _ma *C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls4(parent.cPointer(), caption_ms, dir.cPointer(), filter_ms) + var _ma C.struct_miqt_array = C.QFileDialog_GetOpenFileUrls4(parent.cPointer(), caption_ms, dir.cPointer(), filter_ms) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1348,7 +1314,6 @@ func QFileDialog_GetOpenFileUrls4(parent *QWidget, caption string, dir *QUrl, fi _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfiledialog.h b/qt6/gen_qfiledialog.h index 8a18a89f..2e5c1207 100644 --- a/qt6/gen_qfiledialog.h +++ b/qt6/gen_qfiledialog.h @@ -50,17 +50,17 @@ QDir* QFileDialog_Directory(const QFileDialog* self); void QFileDialog_SetDirectoryUrl(QFileDialog* self, QUrl* directory); QUrl* QFileDialog_DirectoryUrl(const QFileDialog* self); void QFileDialog_SelectFile(QFileDialog* self, struct miqt_string filename); -struct miqt_array* QFileDialog_SelectedFiles(const QFileDialog* self); +struct miqt_array QFileDialog_SelectedFiles(const QFileDialog* self); void QFileDialog_SelectUrl(QFileDialog* self, QUrl* url); -struct miqt_array* QFileDialog_SelectedUrls(const QFileDialog* self); +struct miqt_array QFileDialog_SelectedUrls(const QFileDialog* self); void QFileDialog_SetNameFilter(QFileDialog* self, struct miqt_string filter); -void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileDialog_NameFilters(const QFileDialog* self); +void QFileDialog_SetNameFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileDialog_NameFilters(const QFileDialog* self); void QFileDialog_SelectNameFilter(QFileDialog* self, struct miqt_string filter); struct miqt_string QFileDialog_SelectedMimeTypeFilter(const QFileDialog* self); struct miqt_string QFileDialog_SelectedNameFilter(const QFileDialog* self); -void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileDialog_MimeTypeFilters(const QFileDialog* self); +void QFileDialog_SetMimeTypeFilters(QFileDialog* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileDialog_MimeTypeFilters(const QFileDialog* self); void QFileDialog_SelectMimeTypeFilter(QFileDialog* self, struct miqt_string filter); int QFileDialog_Filter(const QFileDialog* self); void QFileDialog_SetFilter(QFileDialog* self, int filters); @@ -70,22 +70,22 @@ void QFileDialog_SetFileMode(QFileDialog* self, int mode); int QFileDialog_FileMode(const QFileDialog* self); void QFileDialog_SetAcceptMode(QFileDialog* self, int mode); int QFileDialog_AcceptMode(const QFileDialog* self); -void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls); -struct miqt_array* QFileDialog_SidebarUrls(const QFileDialog* self); +void QFileDialog_SetSidebarUrls(QFileDialog* self, struct miqt_array /* of QUrl* */ urls); +struct miqt_array QFileDialog_SidebarUrls(const QFileDialog* self); struct miqt_string QFileDialog_SaveState(const QFileDialog* self); bool QFileDialog_RestoreState(QFileDialog* self, struct miqt_string state); void QFileDialog_SetDefaultSuffix(QFileDialog* self, struct miqt_string suffix); struct miqt_string QFileDialog_DefaultSuffix(const QFileDialog* self); -void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ paths); -struct miqt_array* QFileDialog_History(const QFileDialog* self); +void QFileDialog_SetHistory(QFileDialog* self, struct miqt_array /* of struct miqt_string */ paths); +struct miqt_array QFileDialog_History(const QFileDialog* self); void QFileDialog_SetItemDelegate(QFileDialog* self, QAbstractItemDelegate* delegate); QAbstractItemDelegate* QFileDialog_ItemDelegate(const QFileDialog* self); void QFileDialog_SetIconProvider(QFileDialog* self, QAbstractFileIconProvider* provider); QAbstractFileIconProvider* QFileDialog_IconProvider(const QFileDialog* self); void QFileDialog_SetLabelText(QFileDialog* self, int label, struct miqt_string text); struct miqt_string QFileDialog_LabelText(const QFileDialog* self, int label); -void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ schemes); -struct miqt_array* QFileDialog_SupportedSchemes(const QFileDialog* self); +void QFileDialog_SetSupportedSchemes(QFileDialog* self, struct miqt_array /* of struct miqt_string */ schemes); +struct miqt_array QFileDialog_SupportedSchemes(const QFileDialog* self); void QFileDialog_SetProxyModel(QFileDialog* self, QAbstractProxyModel* model); QAbstractProxyModel* QFileDialog_ProxyModel(const QFileDialog* self); void QFileDialog_SetOption(QFileDialog* self, int option); @@ -95,7 +95,7 @@ int QFileDialog_Options(const QFileDialog* self); void QFileDialog_SetVisible(QFileDialog* self, bool visible); void QFileDialog_FileSelected(QFileDialog* self, struct miqt_string file); void QFileDialog_connect_FileSelected(QFileDialog* self, intptr_t slot); -void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array* /* of struct miqt_string */ files); +void QFileDialog_FilesSelected(QFileDialog* self, struct miqt_array /* of struct miqt_string */ files); void QFileDialog_connect_FilesSelected(QFileDialog* self, intptr_t slot); void QFileDialog_CurrentChanged(QFileDialog* self, struct miqt_string path); void QFileDialog_connect_CurrentChanged(QFileDialog* self, intptr_t slot); @@ -103,7 +103,7 @@ void QFileDialog_DirectoryEntered(QFileDialog* self, struct miqt_string director void QFileDialog_connect_DirectoryEntered(QFileDialog* self, intptr_t slot); void QFileDialog_UrlSelected(QFileDialog* self, QUrl* url); void QFileDialog_connect_UrlSelected(QFileDialog* self, intptr_t slot); -void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array* /* of QUrl* */ urls); +void QFileDialog_UrlsSelected(QFileDialog* self, struct miqt_array /* of QUrl* */ urls); void QFileDialog_connect_UrlsSelected(QFileDialog* self, intptr_t slot); void QFileDialog_CurrentUrlChanged(QFileDialog* self, QUrl* url); void QFileDialog_connect_CurrentUrlChanged(QFileDialog* self, intptr_t slot); @@ -117,8 +117,8 @@ struct miqt_string QFileDialog_GetSaveFileName(); QUrl* QFileDialog_GetSaveFileUrl(); struct miqt_string QFileDialog_GetExistingDirectory(); QUrl* QFileDialog_GetExistingDirectoryUrl(); -struct miqt_array* QFileDialog_GetOpenFileNames(); -struct miqt_array* QFileDialog_GetOpenFileUrls(); +struct miqt_array QFileDialog_GetOpenFileNames(); +struct miqt_array QFileDialog_GetOpenFileUrls(); void QFileDialog_SaveFileContent(struct miqt_string fileContent, struct miqt_string fileNameHint); struct miqt_string QFileDialog_Tr2(const char* s, const char* c); struct miqt_string QFileDialog_Tr3(const char* s, const char* c, int n); @@ -147,15 +147,15 @@ QUrl* QFileDialog_GetExistingDirectoryUrl1(QWidget* parent); QUrl* QFileDialog_GetExistingDirectoryUrl2(QWidget* parent, struct miqt_string caption); QUrl* QFileDialog_GetExistingDirectoryUrl3(QWidget* parent, struct miqt_string caption, QUrl* dir); QUrl* QFileDialog_GetExistingDirectoryUrl4(QWidget* parent, struct miqt_string caption, QUrl* dir, int options); -QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array* /* of struct miqt_string */ supportedSchemes); -struct miqt_array* QFileDialog_GetOpenFileNames1(QWidget* parent); -struct miqt_array* QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption); -struct miqt_array* QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir); -struct miqt_array* QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter); -struct miqt_array* QFileDialog_GetOpenFileUrls1(QWidget* parent); -struct miqt_array* QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption); -struct miqt_array* QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir); -struct miqt_array* QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter); +QUrl* QFileDialog_GetExistingDirectoryUrl5(QWidget* parent, struct miqt_string caption, QUrl* dir, int options, struct miqt_array /* of struct miqt_string */ supportedSchemes); +struct miqt_array QFileDialog_GetOpenFileNames1(QWidget* parent); +struct miqt_array QFileDialog_GetOpenFileNames2(QWidget* parent, struct miqt_string caption); +struct miqt_array QFileDialog_GetOpenFileNames3(QWidget* parent, struct miqt_string caption, struct miqt_string dir); +struct miqt_array QFileDialog_GetOpenFileNames4(QWidget* parent, struct miqt_string caption, struct miqt_string dir, struct miqt_string filter); +struct miqt_array QFileDialog_GetOpenFileUrls1(QWidget* parent); +struct miqt_array QFileDialog_GetOpenFileUrls2(QWidget* parent, struct miqt_string caption); +struct miqt_array QFileDialog_GetOpenFileUrls3(QWidget* parent, struct miqt_string caption, QUrl* dir); +struct miqt_array QFileDialog_GetOpenFileUrls4(QWidget* parent, struct miqt_string caption, QUrl* dir, struct miqt_string filter); void QFileDialog_Delete(QFileDialog* self); #ifdef __cplusplus diff --git a/qt6/gen_qfileselector.cpp b/qt6/gen_qfileselector.cpp index 9b8a5141..f699772c 100644 --- a/qt6/gen_qfileselector.cpp +++ b/qt6/gen_qfileselector.cpp @@ -53,7 +53,7 @@ QUrl* QFileSelector_SelectWithFilePath(const QFileSelector* self, QUrl* filePath return new QUrl(self->select(*filePath)); } -struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self) { +struct miqt_array QFileSelector_ExtraSelectors(const QFileSelector* self) { QStringList _ret = self->extraSelectors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -67,24 +67,24 @@ struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array* /* of struct miqt_string */ list) { +void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } self->setExtraSelectors(list_QList); } -struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self) { +struct miqt_array QFileSelector_AllSelectors(const QFileSelector* self) { QStringList _ret = self->allSelectors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -98,9 +98,9 @@ struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfileselector.go b/qt6/gen_qfileselector.go index 8811d8b3..78f60d87 100644 --- a/qt6/gen_qfileselector.go +++ b/qt6/gen_qfileselector.go @@ -93,7 +93,7 @@ func (this *QFileSelector) SelectWithFilePath(filePath *QUrl) *QUrl { } func (this *QFileSelector) ExtraSelectors() []string { - var _ma *C.struct_miqt_array = C.QFileSelector_ExtraSelectors(this.h) + var _ma C.struct_miqt_array = C.QFileSelector_ExtraSelectors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -102,12 +102,10 @@ func (this *QFileSelector) ExtraSelectors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSelector) SetExtraSelectors(list []string) { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -117,13 +115,12 @@ func (this *QFileSelector) SetExtraSelectors(list []string) { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QFileSelector_SetExtraSelectors(this.h, list_ma) } func (this *QFileSelector) AllSelectors() []string { - var _ma *C.struct_miqt_array = C.QFileSelector_AllSelectors(this.h) + var _ma C.struct_miqt_array = C.QFileSelector_AllSelectors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -132,7 +129,6 @@ func (this *QFileSelector) AllSelectors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfileselector.h b/qt6/gen_qfileselector.h index fc9f4018..bc46b0ee 100644 --- a/qt6/gen_qfileselector.h +++ b/qt6/gen_qfileselector.h @@ -32,9 +32,9 @@ void* QFileSelector_Metacast(QFileSelector* self, const char* param1); struct miqt_string QFileSelector_Tr(const char* s); struct miqt_string QFileSelector_Select(const QFileSelector* self, struct miqt_string filePath); QUrl* QFileSelector_SelectWithFilePath(const QFileSelector* self, QUrl* filePath); -struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self); -void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array* /* of struct miqt_string */ list); -struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self); +struct miqt_array QFileSelector_ExtraSelectors(const QFileSelector* self); +void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array /* of struct miqt_string */ list); +struct miqt_array QFileSelector_AllSelectors(const QFileSelector* self); struct miqt_string QFileSelector_Tr2(const char* s, const char* c); struct miqt_string QFileSelector_Tr3(const char* s, const char* c, int n); void QFileSelector_Delete(QFileSelector* self); diff --git a/qt6/gen_qfilesystemmodel.cpp b/qt6/gen_qfilesystemmodel.cpp index 298e98e6..7f1035f6 100644 --- a/qt6/gen_qfilesystemmodel.cpp +++ b/qt6/gen_qfilesystemmodel.cpp @@ -1,10 +1,12 @@ #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -181,7 +183,7 @@ void QFileSystemModel_Sort(QFileSystemModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self) { +struct miqt_array QFileSystemModel_MimeTypes(const QFileSystemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -195,17 +197,17 @@ struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -220,6 +222,29 @@ int QFileSystemModel_SupportedDropActions(const QFileSystemModel* self) { return static_cast(_ret); } +struct miqt_map QFileSystemModel_RoleNames(const QFileSystemModel* self) { + QHash _ret = self->roleNames(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + struct miqt_string* _varr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + QByteArray _hashval_qb = _itr->second; + struct miqt_string _hashval_ms; + _hashval_ms.len = _hashval_qb.length(); + _hashval_ms.data = static_cast(malloc(_hashval_ms.len)); + memcpy(_hashval_ms.data, _hashval_qb.data(), _hashval_ms.len); + _varr[_ctr] = _hashval_ms; + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QModelIndex* QFileSystemModel_SetRootPath(QFileSystemModel* self, struct miqt_string path) { QString path_QString = QString::fromUtf8(path.data, path.len); return new QModelIndex(self->setRootPath(path_QString)); @@ -281,18 +306,18 @@ bool QFileSystemModel_NameFilterDisables(const QFileSystemModel* self) { return self->nameFilterDisables(); } -void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array* /* of struct miqt_string */ filters) { +void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array /* of struct miqt_string */ filters) { QStringList filters_QList; - filters_QList.reserve(filters->len); - struct miqt_string* filters_arr = static_cast(filters->data); - for(size_t i = 0; i < filters->len; ++i) { + filters_QList.reserve(filters.len); + struct miqt_string* filters_arr = static_cast(filters.data); + for(size_t i = 0; i < filters.len; ++i) { QString filters_arr_i_QString = QString::fromUtf8(filters_arr[i].data, filters_arr[i].len); filters_QList.push_back(filters_arr_i_QString); } self->setNameFilters(filters_QList); } -struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self) { +struct miqt_array QFileSystemModel_NameFilters(const QFileSystemModel* self) { QStringList _ret = self->nameFilters(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -306,9 +331,9 @@ struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfilesystemmodel.go b/qt6/gen_qfilesystemmodel.go index 6435bfb5..5c11079a 100644 --- a/qt6/gen_qfilesystemmodel.go +++ b/qt6/gen_qfilesystemmodel.go @@ -275,7 +275,7 @@ func (this *QFileSystemModel) Sort(column int) { } func (this *QFileSystemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QFileSystemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QFileSystemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -284,19 +284,16 @@ func (this *QFileSystemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QFileSystemModel_MimeData(this.h, indexes_ma))) } @@ -308,6 +305,23 @@ func (this *QFileSystemModel) SupportedDropActions() DropAction { return (DropAction)(C.QFileSystemModel_SupportedDropActions(this.h)) } +func (this *QFileSystemModel) RoleNames() map[int][]byte { + var _mm C.struct_miqt_map = C.QFileSystemModel_RoleNames(this.h) + _ret := make(map[int][]byte, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + var _hashval_bytearray C.struct_miqt_string = _Values[i] + _hashval_ret := C.GoBytes(unsafe.Pointer(_hashval_bytearray.data), C.int(int64(_hashval_bytearray.len))) + C.free(unsafe.Pointer(_hashval_bytearray.data)) + _entry_Value := _hashval_ret + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QFileSystemModel) SetRootPath(path string) *QModelIndex { path_ms := C.struct_miqt_string{} path_ms.data = C.CString(path) @@ -374,7 +388,6 @@ func (this *QFileSystemModel) NameFilterDisables() bool { } func (this *QFileSystemModel) SetNameFilters(filters []string) { - // For the C ABI, malloc a C array of structs filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters)))) defer C.free(unsafe.Pointer(filters_CArray)) for i := range filters { @@ -384,13 +397,12 @@ func (this *QFileSystemModel) SetNameFilters(filters []string) { defer C.free(unsafe.Pointer(filters_i_ms.data)) filters_CArray[i] = filters_i_ms } - filters_ma := &C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(filters_ma)) + filters_ma := C.struct_miqt_array{len: C.size_t(len(filters)), data: unsafe.Pointer(filters_CArray)} C.QFileSystemModel_SetNameFilters(this.h, filters_ma) } func (this *QFileSystemModel) NameFilters() []string { - var _ma *C.struct_miqt_array = C.QFileSystemModel_NameFilters(this.h) + var _ma C.struct_miqt_array = C.QFileSystemModel_NameFilters(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -399,7 +411,6 @@ func (this *QFileSystemModel) NameFilters() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfilesystemmodel.h b/qt6/gen_qfilesystemmodel.h index 2570a00d..bffbf536 100644 --- a/qt6/gen_qfilesystemmodel.h +++ b/qt6/gen_qfilesystemmodel.h @@ -15,6 +15,7 @@ extern "C" { #ifdef __cplusplus class QAbstractFileIconProvider; +class QByteArray; class QDateTime; class QDir; class QFileInfo; @@ -27,6 +28,7 @@ class QObject; class QVariant; #else typedef struct QAbstractFileIconProvider QAbstractFileIconProvider; +typedef struct QByteArray QByteArray; typedef struct QDateTime QDateTime; typedef struct QDir QDir; typedef struct QFileInfo QFileInfo; @@ -65,10 +67,11 @@ bool QFileSystemModel_SetData(QFileSystemModel* self, QModelIndex* index, QVaria QVariant* QFileSystemModel_HeaderData(const QFileSystemModel* self, int section, int orientation); int QFileSystemModel_Flags(const QFileSystemModel* self, QModelIndex* index); void QFileSystemModel_Sort(QFileSystemModel* self, int column); -struct miqt_array* QFileSystemModel_MimeTypes(const QFileSystemModel* self); -QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QFileSystemModel_MimeTypes(const QFileSystemModel* self); +QMimeData* QFileSystemModel_MimeData(const QFileSystemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QFileSystemModel_DropMimeData(QFileSystemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); int QFileSystemModel_SupportedDropActions(const QFileSystemModel* self); +struct miqt_map QFileSystemModel_RoleNames(const QFileSystemModel* self); QModelIndex* QFileSystemModel_SetRootPath(QFileSystemModel* self, struct miqt_string path); struct miqt_string QFileSystemModel_RootPath(const QFileSystemModel* self); QDir* QFileSystemModel_RootDirectory(const QFileSystemModel* self); @@ -82,8 +85,8 @@ void QFileSystemModel_SetReadOnly(QFileSystemModel* self, bool enable); bool QFileSystemModel_IsReadOnly(const QFileSystemModel* self); void QFileSystemModel_SetNameFilterDisables(QFileSystemModel* self, bool enable); bool QFileSystemModel_NameFilterDisables(const QFileSystemModel* self); -void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array* /* of struct miqt_string */ filters); -struct miqt_array* QFileSystemModel_NameFilters(const QFileSystemModel* self); +void QFileSystemModel_SetNameFilters(QFileSystemModel* self, struct miqt_array /* of struct miqt_string */ filters); +struct miqt_array QFileSystemModel_NameFilters(const QFileSystemModel* self); void QFileSystemModel_SetOption(QFileSystemModel* self, int option); bool QFileSystemModel_TestOption(const QFileSystemModel* self, int option); void QFileSystemModel_SetOptions(QFileSystemModel* self, int options); diff --git a/qt6/gen_qfilesystemwatcher.cpp b/qt6/gen_qfilesystemwatcher.cpp index c257f00e..761d47cd 100644 --- a/qt6/gen_qfilesystemwatcher.cpp +++ b/qt6/gen_qfilesystemwatcher.cpp @@ -13,11 +13,11 @@ QFileSystemWatcher* QFileSystemWatcher_new() { return new QFileSystemWatcher(); } -QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array* /* of struct miqt_string */ paths) { +QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -28,11 +28,11 @@ QFileSystemWatcher* QFileSystemWatcher_new3(QObject* parent) { return new QFileSystemWatcher(parent); } -QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array* /* of struct miqt_string */ paths, QObject* parent) { +QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array /* of struct miqt_string */ paths, QObject* parent) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -63,11 +63,11 @@ bool QFileSystemWatcher_AddPath(QFileSystemWatcher* self, struct miqt_string fil return self->addPath(file_QString); } -struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files) { +struct miqt_array QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -84,9 +84,9 @@ struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -95,11 +95,11 @@ bool QFileSystemWatcher_RemovePath(QFileSystemWatcher* self, struct miqt_string return self->removePath(file_QString); } -struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files) { +struct miqt_array QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files) { QStringList files_QList; - files_QList.reserve(files->len); - struct miqt_string* files_arr = static_cast(files->data); - for(size_t i = 0; i < files->len; ++i) { + files_QList.reserve(files.len); + struct miqt_string* files_arr = static_cast(files.data); + for(size_t i = 0; i < files.len; ++i) { QString files_arr_i_QString = QString::fromUtf8(files_arr[i].data, files_arr[i].len); files_QList.push_back(files_arr_i_QString); } @@ -116,13 +116,13 @@ struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, stru memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self) { +struct miqt_array QFileSystemWatcher_Files(const QFileSystemWatcher* self) { QStringList _ret = self->files(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -136,13 +136,13 @@ struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self) { +struct miqt_array QFileSystemWatcher_Directories(const QFileSystemWatcher* self) { QStringList _ret = self->directories(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -156,9 +156,9 @@ struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfilesystemwatcher.go b/qt6/gen_qfilesystemwatcher.go index 2cdd6c19..b7381c80 100644 --- a/qt6/gen_qfilesystemwatcher.go +++ b/qt6/gen_qfilesystemwatcher.go @@ -51,7 +51,6 @@ func NewQFileSystemWatcher() *QFileSystemWatcher { // NewQFileSystemWatcher2 constructs a new QFileSystemWatcher object. func NewQFileSystemWatcher2(paths []string) *QFileSystemWatcher { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -61,8 +60,7 @@ func NewQFileSystemWatcher2(paths []string) *QFileSystemWatcher { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} ret := C.QFileSystemWatcher_new2(paths_ma) return newQFileSystemWatcher(ret) } @@ -75,7 +73,6 @@ func NewQFileSystemWatcher3(parent *QObject) *QFileSystemWatcher { // NewQFileSystemWatcher4 constructs a new QFileSystemWatcher object. func NewQFileSystemWatcher4(paths []string, parent *QObject) *QFileSystemWatcher { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -85,8 +82,7 @@ func NewQFileSystemWatcher4(paths []string, parent *QObject) *QFileSystemWatcher defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} ret := C.QFileSystemWatcher_new4(paths_ma, parent.cPointer()) return newQFileSystemWatcher(ret) } @@ -119,7 +115,6 @@ func (this *QFileSystemWatcher) AddPath(file string) bool { } func (this *QFileSystemWatcher) AddPaths(files []string) []string { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -129,9 +124,8 @@ func (this *QFileSystemWatcher) AddPaths(files []string) []string { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_AddPaths(this.h, files_ma) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} + var _ma C.struct_miqt_array = C.QFileSystemWatcher_AddPaths(this.h, files_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -140,7 +134,6 @@ func (this *QFileSystemWatcher) AddPaths(files []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -153,7 +146,6 @@ func (this *QFileSystemWatcher) RemovePath(file string) bool { } func (this *QFileSystemWatcher) RemovePaths(files []string) []string { - // For the C ABI, malloc a C array of structs files_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(files)))) defer C.free(unsafe.Pointer(files_CArray)) for i := range files { @@ -163,9 +155,8 @@ func (this *QFileSystemWatcher) RemovePaths(files []string) []string { defer C.free(unsafe.Pointer(files_i_ms.data)) files_CArray[i] = files_i_ms } - files_ma := &C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(files_ma)) - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_RemovePaths(this.h, files_ma) + files_ma := C.struct_miqt_array{len: C.size_t(len(files)), data: unsafe.Pointer(files_CArray)} + var _ma C.struct_miqt_array = C.QFileSystemWatcher_RemovePaths(this.h, files_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -174,12 +165,11 @@ func (this *QFileSystemWatcher) RemovePaths(files []string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemWatcher) Files() []string { - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_Files(this.h) + var _ma C.struct_miqt_array = C.QFileSystemWatcher_Files(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -188,12 +178,11 @@ func (this *QFileSystemWatcher) Files() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFileSystemWatcher) Directories() []string { - var _ma *C.struct_miqt_array = C.QFileSystemWatcher_Directories(this.h) + var _ma C.struct_miqt_array = C.QFileSystemWatcher_Directories(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -202,7 +191,6 @@ func (this *QFileSystemWatcher) Directories() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfilesystemwatcher.h b/qt6/gen_qfilesystemwatcher.h index c031b3c5..9defd829 100644 --- a/qt6/gen_qfilesystemwatcher.h +++ b/qt6/gen_qfilesystemwatcher.h @@ -24,18 +24,18 @@ typedef struct QObject QObject; #endif QFileSystemWatcher* QFileSystemWatcher_new(); -QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array* /* of struct miqt_string */ paths); +QFileSystemWatcher* QFileSystemWatcher_new2(struct miqt_array /* of struct miqt_string */ paths); QFileSystemWatcher* QFileSystemWatcher_new3(QObject* parent); -QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array* /* of struct miqt_string */ paths, QObject* parent); +QFileSystemWatcher* QFileSystemWatcher_new4(struct miqt_array /* of struct miqt_string */ paths, QObject* parent); QMetaObject* QFileSystemWatcher_MetaObject(const QFileSystemWatcher* self); void* QFileSystemWatcher_Metacast(QFileSystemWatcher* self, const char* param1); struct miqt_string QFileSystemWatcher_Tr(const char* s); bool QFileSystemWatcher_AddPath(QFileSystemWatcher* self, struct miqt_string file); -struct miqt_array* QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files); +struct miqt_array QFileSystemWatcher_AddPaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files); bool QFileSystemWatcher_RemovePath(QFileSystemWatcher* self, struct miqt_string file); -struct miqt_array* QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array* /* of struct miqt_string */ files); -struct miqt_array* QFileSystemWatcher_Files(const QFileSystemWatcher* self); -struct miqt_array* QFileSystemWatcher_Directories(const QFileSystemWatcher* self); +struct miqt_array QFileSystemWatcher_RemovePaths(QFileSystemWatcher* self, struct miqt_array /* of struct miqt_string */ files); +struct miqt_array QFileSystemWatcher_Files(const QFileSystemWatcher* self); +struct miqt_array QFileSystemWatcher_Directories(const QFileSystemWatcher* self); struct miqt_string QFileSystemWatcher_Tr2(const char* s, const char* c); struct miqt_string QFileSystemWatcher_Tr3(const char* s, const char* c, int n); void QFileSystemWatcher_Delete(QFileSystemWatcher* self); diff --git a/qt6/gen_qfont.cpp b/qt6/gen_qfont.cpp index 5b82884e..a92a189a 100644 --- a/qt6/gen_qfont.cpp +++ b/qt6/gen_qfont.cpp @@ -17,11 +17,11 @@ QFont* QFont_new2(struct miqt_string family) { return new QFont(family_QString); } -QFont* QFont_new3(struct miqt_array* /* of struct miqt_string */ families) { +QFont* QFont_new3(struct miqt_array /* of struct miqt_string */ families) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -51,33 +51,33 @@ QFont* QFont_new8(struct miqt_string family, int pointSize, int weight, bool ita return new QFont(family_QString, static_cast(pointSize), static_cast(weight), italic); } -QFont* QFont_new9(struct miqt_array* /* of struct miqt_string */ families, int pointSize) { +QFont* QFont_new9(struct miqt_array /* of struct miqt_string */ families, int pointSize) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } return new QFont(families_QList, static_cast(pointSize)); } -QFont* QFont_new10(struct miqt_array* /* of struct miqt_string */ families, int pointSize, int weight) { +QFont* QFont_new10(struct miqt_array /* of struct miqt_string */ families, int pointSize, int weight) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } return new QFont(families_QList, static_cast(pointSize), static_cast(weight)); } -QFont* QFont_new11(struct miqt_array* /* of struct miqt_string */ families, int pointSize, int weight, bool italic) { +QFont* QFont_new11(struct miqt_array /* of struct miqt_string */ families, int pointSize, int weight, bool italic) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -104,7 +104,7 @@ void QFont_SetFamily(QFont* self, struct miqt_string family) { self->setFamily(family_QString); } -struct miqt_array* QFont_Families(const QFont* self) { +struct miqt_array QFont_Families(const QFont* self) { QStringList _ret = self->families(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -118,17 +118,17 @@ struct miqt_array* QFont_Families(const QFont* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QFont_SetFamilies(QFont* self, struct miqt_array* /* of struct miqt_string */ families) { +void QFont_SetFamilies(QFont* self, struct miqt_array /* of struct miqt_string */ families) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -380,7 +380,7 @@ struct miqt_string QFont_Substitute(struct miqt_string param1) { return _ms; } -struct miqt_array* QFont_Substitutes(struct miqt_string param1) { +struct miqt_array QFont_Substitutes(struct miqt_string param1) { QString param1_QString = QString::fromUtf8(param1.data, param1.len); QStringList _ret = QFont::substitutes(param1_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -395,13 +395,13 @@ struct miqt_array* QFont_Substitutes(struct miqt_string param1) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFont_Substitutions() { +struct miqt_array QFont_Substitutions() { QStringList _ret = QFont::substitutions(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -415,9 +415,9 @@ struct miqt_array* QFont_Substitutions() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -427,12 +427,12 @@ void QFont_InsertSubstitution(struct miqt_string param1, struct miqt_string para QFont::insertSubstitution(param1_QString, param2_QString); } -void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array* /* of struct miqt_string */ param2) { +void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array /* of struct miqt_string */ param2) { QString param1_QString = QString::fromUtf8(param1.data, param1.len); QStringList param2_QList; - param2_QList.reserve(param2->len); - struct miqt_string* param2_arr = static_cast(param2->data); - for(size_t i = 0; i < param2->len; ++i) { + param2_QList.reserve(param2.len); + struct miqt_string* param2_arr = static_cast(param2.data); + for(size_t i = 0; i < param2.len; ++i) { QString param2_arr_i_QString = QString::fromUtf8(param2_arr[i].data, param2_arr[i].len); param2_QList.push_back(param2_arr_i_QString); } diff --git a/qt6/gen_qfont.go b/qt6/gen_qfont.go index 46f68bc4..47416bcb 100644 --- a/qt6/gen_qfont.go +++ b/qt6/gen_qfont.go @@ -183,7 +183,6 @@ func NewQFont2(family string) *QFont { // NewQFont3 constructs a new QFont object. func NewQFont3(families []string) *QFont { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -193,8 +192,7 @@ func NewQFont3(families []string) *QFont { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} ret := C.QFont_new3(families_ma) return newQFont(ret) } @@ -243,7 +241,6 @@ func NewQFont8(family string, pointSize int, weight int, italic bool) *QFont { // NewQFont9 constructs a new QFont object. func NewQFont9(families []string, pointSize int) *QFont { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -253,15 +250,13 @@ func NewQFont9(families []string, pointSize int) *QFont { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} ret := C.QFont_new9(families_ma, (C.int)(pointSize)) return newQFont(ret) } // NewQFont10 constructs a new QFont object. func NewQFont10(families []string, pointSize int, weight int) *QFont { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -271,15 +266,13 @@ func NewQFont10(families []string, pointSize int, weight int) *QFont { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} ret := C.QFont_new10(families_ma, (C.int)(pointSize), (C.int)(weight)) return newQFont(ret) } // NewQFont11 constructs a new QFont object. func NewQFont11(families []string, pointSize int, weight int, italic bool) *QFont { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -289,8 +282,7 @@ func NewQFont11(families []string, pointSize int, weight int, italic bool) *QFon defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} ret := C.QFont_new11(families_ma, (C.int)(pointSize), (C.int)(weight), (C.bool)(italic)) return newQFont(ret) } @@ -315,7 +307,7 @@ func (this *QFont) SetFamily(family string) { } func (this *QFont) Families() []string { - var _ma *C.struct_miqt_array = C.QFont_Families(this.h) + var _ma C.struct_miqt_array = C.QFont_Families(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -324,12 +316,10 @@ func (this *QFont) Families() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QFont) SetFamilies(families []string) { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -339,8 +329,7 @@ func (this *QFont) SetFamilies(families []string) { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} C.QFont_SetFamilies(this.h, families_ma) } @@ -577,7 +566,7 @@ func QFont_Substitutes(param1 string) []string { param1_ms.data = C.CString(param1) param1_ms.len = C.size_t(len(param1)) defer C.free(unsafe.Pointer(param1_ms.data)) - var _ma *C.struct_miqt_array = C.QFont_Substitutes(param1_ms) + var _ma C.struct_miqt_array = C.QFont_Substitutes(param1_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -586,12 +575,11 @@ func QFont_Substitutes(param1 string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QFont_Substitutions() []string { - var _ma *C.struct_miqt_array = C.QFont_Substitutions() + var _ma C.struct_miqt_array = C.QFont_Substitutions() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -600,7 +588,6 @@ func QFont_Substitutions() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -621,7 +608,6 @@ func QFont_InsertSubstitutions(param1 string, param2 []string) { param1_ms.data = C.CString(param1) param1_ms.len = C.size_t(len(param1)) defer C.free(unsafe.Pointer(param1_ms.data)) - // For the C ABI, malloc a C array of structs param2_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(param2)))) defer C.free(unsafe.Pointer(param2_CArray)) for i := range param2 { @@ -631,8 +617,7 @@ func QFont_InsertSubstitutions(param1 string, param2 []string) { defer C.free(unsafe.Pointer(param2_i_ms.data)) param2_CArray[i] = param2_i_ms } - param2_ma := &C.struct_miqt_array{len: C.size_t(len(param2)), data: unsafe.Pointer(param2_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(param2_ma)) + param2_ma := C.struct_miqt_array{len: C.size_t(len(param2)), data: unsafe.Pointer(param2_CArray)} C.QFont_InsertSubstitutions(param1_ms, param2_ma) } diff --git a/qt6/gen_qfont.h b/qt6/gen_qfont.h index 00b1b603..365d7618 100644 --- a/qt6/gen_qfont.h +++ b/qt6/gen_qfont.h @@ -23,20 +23,20 @@ typedef struct QPaintDevice QPaintDevice; QFont* QFont_new(); QFont* QFont_new2(struct miqt_string family); -QFont* QFont_new3(struct miqt_array* /* of struct miqt_string */ families); +QFont* QFont_new3(struct miqt_array /* of struct miqt_string */ families); QFont* QFont_new4(QFont* font, QPaintDevice* pd); QFont* QFont_new5(QFont* font); QFont* QFont_new6(struct miqt_string family, int pointSize); QFont* QFont_new7(struct miqt_string family, int pointSize, int weight); QFont* QFont_new8(struct miqt_string family, int pointSize, int weight, bool italic); -QFont* QFont_new9(struct miqt_array* /* of struct miqt_string */ families, int pointSize); -QFont* QFont_new10(struct miqt_array* /* of struct miqt_string */ families, int pointSize, int weight); -QFont* QFont_new11(struct miqt_array* /* of struct miqt_string */ families, int pointSize, int weight, bool italic); +QFont* QFont_new9(struct miqt_array /* of struct miqt_string */ families, int pointSize); +QFont* QFont_new10(struct miqt_array /* of struct miqt_string */ families, int pointSize, int weight); +QFont* QFont_new11(struct miqt_array /* of struct miqt_string */ families, int pointSize, int weight, bool italic); void QFont_Swap(QFont* self, QFont* other); struct miqt_string QFont_Family(const QFont* self); void QFont_SetFamily(QFont* self, struct miqt_string family); -struct miqt_array* QFont_Families(const QFont* self); -void QFont_SetFamilies(QFont* self, struct miqt_array* /* of struct miqt_string */ families); +struct miqt_array QFont_Families(const QFont* self); +void QFont_SetFamilies(QFont* self, struct miqt_array /* of struct miqt_string */ families); struct miqt_string QFont_StyleName(const QFont* self); void QFont_SetStyleName(QFont* self, struct miqt_string styleName); int QFont_PointSize(const QFont* self); @@ -88,10 +88,10 @@ struct miqt_string QFont_Key(const QFont* self); struct miqt_string QFont_ToString(const QFont* self); bool QFont_FromString(QFont* self, struct miqt_string param1); struct miqt_string QFont_Substitute(struct miqt_string param1); -struct miqt_array* QFont_Substitutes(struct miqt_string param1); -struct miqt_array* QFont_Substitutions(); +struct miqt_array QFont_Substitutes(struct miqt_string param1); +struct miqt_array QFont_Substitutions(); void QFont_InsertSubstitution(struct miqt_string param1, struct miqt_string param2); -void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array* /* of struct miqt_string */ param2); +void QFont_InsertSubstitutions(struct miqt_string param1, struct miqt_array /* of struct miqt_string */ param2); void QFont_RemoveSubstitutions(struct miqt_string param1); void QFont_Initialize(); void QFont_Cleanup(); diff --git a/qt6/gen_qfontdatabase.cpp b/qt6/gen_qfontdatabase.cpp index efffb1c8..fda37612 100644 --- a/qt6/gen_qfontdatabase.cpp +++ b/qt6/gen_qfontdatabase.cpp @@ -14,20 +14,20 @@ QFontDatabase* QFontDatabase_new() { return new QFontDatabase(); } -struct miqt_array* QFontDatabase_StandardSizes() { +struct miqt_array QFontDatabase_StandardSizes() { QList _ret = QFontDatabase::standardSizes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_WritingSystems() { +struct miqt_array QFontDatabase_WritingSystems() { QList _ret = QFontDatabase::writingSystems(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -35,13 +35,13 @@ struct miqt_array* QFontDatabase_WritingSystems() { QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_WritingSystemsWithFamily(struct miqt_string family) { +struct miqt_array QFontDatabase_WritingSystemsWithFamily(struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QList _ret = QFontDatabase::writingSystems(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -50,13 +50,13 @@ struct miqt_array* QFontDatabase_WritingSystemsWithFamily(struct miqt_string fam QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_Families() { +struct miqt_array QFontDatabase_Families() { QStringList _ret = QFontDatabase::families(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -70,13 +70,13 @@ struct miqt_array* QFontDatabase_Families() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_Styles(struct miqt_string family) { +struct miqt_array QFontDatabase_Styles(struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QStringList _ret = QFontDatabase::styles(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -91,13 +91,13 @@ struct miqt_array* QFontDatabase_Styles(struct miqt_string family) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_PointSizes(struct miqt_string family) { +struct miqt_array QFontDatabase_PointSizes(struct miqt_string family) { QString family_QString = QString::fromUtf8(family.data, family.len); QList _ret = QFontDatabase::pointSizes(family_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -105,13 +105,13 @@ struct miqt_array* QFontDatabase_PointSizes(struct miqt_string family) { for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_SmoothSizes(struct miqt_string family, struct miqt_string style) { +struct miqt_array QFontDatabase_SmoothSizes(struct miqt_string family, struct miqt_string style) { QString family_QString = QString::fromUtf8(family.data, family.len); QString style_QString = QString::fromUtf8(style.data, style.len); QList _ret = QFontDatabase::smoothSizes(family_QString, style_QString); @@ -120,9 +120,9 @@ struct miqt_array* QFontDatabase_SmoothSizes(struct miqt_string family, struct m for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -234,7 +234,7 @@ int QFontDatabase_AddApplicationFontFromData(struct miqt_string fontData) { return QFontDatabase::addApplicationFontFromData(fontData_QByteArray); } -struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id) { +struct miqt_array QFontDatabase_ApplicationFontFamilies(int id) { QStringList _ret = QFontDatabase::applicationFontFamilies(static_cast(id)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -248,9 +248,9 @@ struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -266,7 +266,7 @@ QFont* QFontDatabase_SystemFont(int typeVal) { return new QFont(QFontDatabase::systemFont(static_cast(typeVal))); } -struct miqt_array* QFontDatabase_Families1(int writingSystem) { +struct miqt_array QFontDatabase_Families1(int writingSystem) { QStringList _ret = QFontDatabase::families(static_cast(writingSystem)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -280,13 +280,13 @@ struct miqt_array* QFontDatabase_Families1(int writingSystem) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QFontDatabase_PointSizes2(struct miqt_string family, struct miqt_string style) { +struct miqt_array QFontDatabase_PointSizes2(struct miqt_string family, struct miqt_string style) { QString family_QString = QString::fromUtf8(family.data, family.len); QString style_QString = QString::fromUtf8(style.data, style.len); QList _ret = QFontDatabase::pointSizes(family_QString, style_QString); @@ -295,9 +295,9 @@ struct miqt_array* QFontDatabase_PointSizes2(struct miqt_string family, struct m for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qfontdatabase.go b/qt6/gen_qfontdatabase.go index 2549f9f7..2a58b8ba 100644 --- a/qt6/gen_qfontdatabase.go +++ b/qt6/gen_qfontdatabase.go @@ -99,24 +99,22 @@ func NewQFontDatabase() *QFontDatabase { } func QFontDatabase_StandardSizes() []int { - var _ma *C.struct_miqt_array = C.QFontDatabase_StandardSizes() + var _ma C.struct_miqt_array = C.QFontDatabase_StandardSizes() _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func QFontDatabase_WritingSystems() []QFontDatabase__WritingSystem { - var _ma *C.struct_miqt_array = C.QFontDatabase_WritingSystems() + var _ma C.struct_miqt_array = C.QFontDatabase_WritingSystems() _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -125,18 +123,17 @@ func QFontDatabase_WritingSystemsWithFamily(family string) []QFontDatabase__Writ family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_WritingSystemsWithFamily(family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_WritingSystemsWithFamily(family_ms) _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func QFontDatabase_Families() []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_Families() + var _ma C.struct_miqt_array = C.QFontDatabase_Families() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -145,7 +142,6 @@ func QFontDatabase_Families() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -154,7 +150,7 @@ func QFontDatabase_Styles(family string) []string { family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_Styles(family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_Styles(family_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -163,7 +159,6 @@ func QFontDatabase_Styles(family string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -172,13 +167,12 @@ func QFontDatabase_PointSizes(family string) []int { family_ms.data = C.CString(family) family_ms.len = C.size_t(len(family)) defer C.free(unsafe.Pointer(family_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_PointSizes(family_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_PointSizes(family_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -191,13 +185,12 @@ func QFontDatabase_SmoothSizes(family string, style string) []int { style_ms.data = C.CString(style) style_ms.len = C.size_t(len(style)) defer C.free(unsafe.Pointer(style_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_SmoothSizes(family_ms, style_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_SmoothSizes(family_ms, style_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -344,7 +337,7 @@ func QFontDatabase_AddApplicationFontFromData(fontData []byte) int { } func QFontDatabase_ApplicationFontFamilies(id int) []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_ApplicationFontFamilies((C.int)(id)) + var _ma C.struct_miqt_array = C.QFontDatabase_ApplicationFontFamilies((C.int)(id)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -353,7 +346,6 @@ func QFontDatabase_ApplicationFontFamilies(id int) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -373,7 +365,7 @@ func QFontDatabase_SystemFont(typeVal QFontDatabase__SystemFont) *QFont { } func QFontDatabase_Families1(writingSystem QFontDatabase__WritingSystem) []string { - var _ma *C.struct_miqt_array = C.QFontDatabase_Families1((C.int)(writingSystem)) + var _ma C.struct_miqt_array = C.QFontDatabase_Families1((C.int)(writingSystem)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -382,7 +374,6 @@ func QFontDatabase_Families1(writingSystem QFontDatabase__WritingSystem) []strin C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -395,13 +386,12 @@ func QFontDatabase_PointSizes2(family string, style string) []int { style_ms.data = C.CString(style) style_ms.len = C.size_t(len(style)) defer C.free(unsafe.Pointer(style_ms.data)) - var _ma *C.struct_miqt_array = C.QFontDatabase_PointSizes2(family_ms, style_ms) + var _ma C.struct_miqt_array = C.QFontDatabase_PointSizes2(family_ms, style_ms) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qfontdatabase.h b/qt6/gen_qfontdatabase.h index 74e46414..a5b79abc 100644 --- a/qt6/gen_qfontdatabase.h +++ b/qt6/gen_qfontdatabase.h @@ -26,13 +26,13 @@ typedef struct QFontInfo QFontInfo; #endif QFontDatabase* QFontDatabase_new(); -struct miqt_array* QFontDatabase_StandardSizes(); -struct miqt_array* QFontDatabase_WritingSystems(); -struct miqt_array* QFontDatabase_WritingSystemsWithFamily(struct miqt_string family); -struct miqt_array* QFontDatabase_Families(); -struct miqt_array* QFontDatabase_Styles(struct miqt_string family); -struct miqt_array* QFontDatabase_PointSizes(struct miqt_string family); -struct miqt_array* QFontDatabase_SmoothSizes(struct miqt_string family, struct miqt_string style); +struct miqt_array QFontDatabase_StandardSizes(); +struct miqt_array QFontDatabase_WritingSystems(); +struct miqt_array QFontDatabase_WritingSystemsWithFamily(struct miqt_string family); +struct miqt_array QFontDatabase_Families(); +struct miqt_array QFontDatabase_Styles(struct miqt_string family); +struct miqt_array QFontDatabase_PointSizes(struct miqt_string family); +struct miqt_array QFontDatabase_SmoothSizes(struct miqt_string family, struct miqt_string style); struct miqt_string QFontDatabase_StyleString(QFont* font); struct miqt_string QFontDatabase_StyleStringWithFontInfo(QFontInfo* fontInfo); QFont* QFontDatabase_Font(struct miqt_string family, struct miqt_string style, int pointSize); @@ -49,12 +49,12 @@ struct miqt_string QFontDatabase_WritingSystemName(int writingSystem); struct miqt_string QFontDatabase_WritingSystemSample(int writingSystem); int QFontDatabase_AddApplicationFont(struct miqt_string fileName); int QFontDatabase_AddApplicationFontFromData(struct miqt_string fontData); -struct miqt_array* QFontDatabase_ApplicationFontFamilies(int id); +struct miqt_array QFontDatabase_ApplicationFontFamilies(int id); bool QFontDatabase_RemoveApplicationFont(int id); bool QFontDatabase_RemoveAllApplicationFonts(); QFont* QFontDatabase_SystemFont(int typeVal); -struct miqt_array* QFontDatabase_Families1(int writingSystem); -struct miqt_array* QFontDatabase_PointSizes2(struct miqt_string family, struct miqt_string style); +struct miqt_array QFontDatabase_Families1(int writingSystem); +struct miqt_array QFontDatabase_PointSizes2(struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsBitmapScalable2(struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsSmoothlyScalable2(struct miqt_string family, struct miqt_string style); bool QFontDatabase_IsScalable2(struct miqt_string family, struct miqt_string style); diff --git a/qt6/gen_qgenericpluginfactory.cpp b/qt6/gen_qgenericpluginfactory.cpp index b88a0629..4292d5b1 100644 --- a/qt6/gen_qgenericpluginfactory.cpp +++ b/qt6/gen_qgenericpluginfactory.cpp @@ -8,7 +8,7 @@ #include "gen_qgenericpluginfactory.h" #include "_cgo_export.h" -struct miqt_array* QGenericPluginFactory_Keys() { +struct miqt_array QGenericPluginFactory_Keys() { QStringList _ret = QGenericPluginFactory::keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -22,9 +22,9 @@ struct miqt_array* QGenericPluginFactory_Keys() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgenericpluginfactory.go b/qt6/gen_qgenericpluginfactory.go index b4dc765e..caa7f9af 100644 --- a/qt6/gen_qgenericpluginfactory.go +++ b/qt6/gen_qgenericpluginfactory.go @@ -43,7 +43,7 @@ func UnsafeNewQGenericPluginFactory(h unsafe.Pointer) *QGenericPluginFactory { } func QGenericPluginFactory_Keys() []string { - var _ma *C.struct_miqt_array = C.QGenericPluginFactory_Keys() + var _ma C.struct_miqt_array = C.QGenericPluginFactory_Keys() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func QGenericPluginFactory_Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgenericpluginfactory.h b/qt6/gen_qgenericpluginfactory.h index 365e737a..f7974818 100644 --- a/qt6/gen_qgenericpluginfactory.h +++ b/qt6/gen_qgenericpluginfactory.h @@ -21,7 +21,7 @@ typedef struct QGenericPluginFactory QGenericPluginFactory; typedef struct QObject QObject; #endif -struct miqt_array* QGenericPluginFactory_Keys(); +struct miqt_array QGenericPluginFactory_Keys(); QObject* QGenericPluginFactory_Create(struct miqt_string param1, struct miqt_string param2); void QGenericPluginFactory_Delete(QGenericPluginFactory* self); diff --git a/qt6/gen_qgesture.cpp b/qt6/gen_qgesture.cpp index 9710226c..a8b78fc0 100644 --- a/qt6/gen_qgesture.cpp +++ b/qt6/gen_qgesture.cpp @@ -538,11 +538,11 @@ void QTapAndHoldGesture_Delete(QTapAndHoldGesture* self) { delete self; } -QGestureEvent* QGestureEvent_new(struct miqt_array* /* of QGesture* */ gestures) { +QGestureEvent* QGestureEvent_new(struct miqt_array /* of QGesture* */ gestures) { QList gestures_QList; - gestures_QList.reserve(gestures->len); - QGesture** gestures_arr = static_cast(gestures->data); - for(size_t i = 0; i < gestures->len; ++i) { + gestures_QList.reserve(gestures.len); + QGesture** gestures_arr = static_cast(gestures.data); + for(size_t i = 0; i < gestures.len; ++i) { gestures_QList.push_back(gestures_arr[i]); } return new QGestureEvent(gestures_QList); @@ -552,16 +552,16 @@ QGestureEvent* QGestureEvent_new2(QGestureEvent* param1) { return new QGestureEvent(*param1); } -struct miqt_array* QGestureEvent_Gestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_Gestures(const QGestureEvent* self) { QList _ret = self->gestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -569,29 +569,29 @@ QGesture* QGestureEvent_Gesture(const QGestureEvent* self, int typeVal) { return self->gesture(static_cast(typeVal)); } -struct miqt_array* QGestureEvent_ActiveGestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_ActiveGestures(const QGestureEvent* self) { QList _ret = self->activeGestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGestureEvent_CanceledGestures(const QGestureEvent* self) { +struct miqt_array QGestureEvent_CanceledGestures(const QGestureEvent* self) { QList _ret = self->canceledGestures(); // Convert QList<> from C++ memory to manually-managed C memory QGesture** _arr = static_cast(malloc(sizeof(QGesture*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgesture.go b/qt6/gen_qgesture.go index c57517e3..8022917d 100644 --- a/qt6/gen_qgesture.go +++ b/qt6/gen_qgesture.go @@ -867,14 +867,12 @@ func UnsafeNewQGestureEvent(h unsafe.Pointer) *QGestureEvent { // NewQGestureEvent constructs a new QGestureEvent object. func NewQGestureEvent(gestures []*QGesture) *QGestureEvent { - // For the C ABI, malloc a C array of raw pointers gestures_CArray := (*[0xffff]*C.QGesture)(C.malloc(C.size_t(8 * len(gestures)))) defer C.free(unsafe.Pointer(gestures_CArray)) for i := range gestures { gestures_CArray[i] = gestures[i].cPointer() } - gestures_ma := &C.struct_miqt_array{len: C.size_t(len(gestures)), data: unsafe.Pointer(gestures_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(gestures_ma)) + gestures_ma := C.struct_miqt_array{len: C.size_t(len(gestures)), data: unsafe.Pointer(gestures_CArray)} ret := C.QGestureEvent_new(gestures_ma) return newQGestureEvent(ret) } @@ -886,13 +884,12 @@ func NewQGestureEvent2(param1 *QGestureEvent) *QGestureEvent { } func (this *QGestureEvent) Gestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_Gestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_Gestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -901,24 +898,22 @@ func (this *QGestureEvent) Gesture(typeVal GestureType) *QGesture { } func (this *QGestureEvent) ActiveGestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_ActiveGestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_ActiveGestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGestureEvent) CanceledGestures() []*QGesture { - var _ma *C.struct_miqt_array = C.QGestureEvent_CanceledGestures(this.h) + var _ma C.struct_miqt_array = C.QGestureEvent_CanceledGestures(this.h) _ret := make([]*QGesture, int(_ma.len)) _outCast := (*[0xffff]*C.QGesture)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGesture(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgesture.h b/qt6/gen_qgesture.h index 1a15f41e..2616ab7f 100644 --- a/qt6/gen_qgesture.h +++ b/qt6/gen_qgesture.h @@ -140,12 +140,12 @@ struct miqt_string QTapAndHoldGesture_Tr2(const char* s, const char* c); struct miqt_string QTapAndHoldGesture_Tr3(const char* s, const char* c, int n); void QTapAndHoldGesture_Delete(QTapAndHoldGesture* self); -QGestureEvent* QGestureEvent_new(struct miqt_array* /* of QGesture* */ gestures); +QGestureEvent* QGestureEvent_new(struct miqt_array /* of QGesture* */ gestures); QGestureEvent* QGestureEvent_new2(QGestureEvent* param1); -struct miqt_array* QGestureEvent_Gestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_Gestures(const QGestureEvent* self); QGesture* QGestureEvent_Gesture(const QGestureEvent* self, int typeVal); -struct miqt_array* QGestureEvent_ActiveGestures(const QGestureEvent* self); -struct miqt_array* QGestureEvent_CanceledGestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_ActiveGestures(const QGestureEvent* self); +struct miqt_array QGestureEvent_CanceledGestures(const QGestureEvent* self); void QGestureEvent_SetAccepted(QGestureEvent* self, QGesture* param1, bool param2); void QGestureEvent_Accept(QGestureEvent* self, QGesture* param1); void QGestureEvent_Ignore(QGestureEvent* self, QGesture* param1); diff --git a/qt6/gen_qglyphrun.cpp b/qt6/gen_qglyphrun.cpp index 466a320e..3311ab70 100644 --- a/qt6/gen_qglyphrun.cpp +++ b/qt6/gen_qglyphrun.cpp @@ -35,47 +35,47 @@ void QGlyphRun_SetRawData(QGlyphRun* self, const unsigned int* glyphIndexArray, self->setRawData(static_cast(glyphIndexArray), glyphPositionArray, static_cast(size)); } -struct miqt_array* QGlyphRun_GlyphIndexes(const QGlyphRun* self) { +struct miqt_array QGlyphRun_GlyphIndexes(const QGlyphRun* self) { QList _ret = self->glyphIndexes(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array* /* of unsigned int */ glyphIndexes) { +void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array /* of unsigned int */ glyphIndexes) { QList glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } self->setGlyphIndexes(glyphIndexes_QList); } -struct miqt_array* QGlyphRun_Positions(const QGlyphRun* self) { +struct miqt_array QGlyphRun_Positions(const QGlyphRun* self) { QList _ret = self->positions(); // Convert QList<> from C++ memory to manually-managed C memory QPointF** _arr = static_cast(malloc(sizeof(QPointF*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array* /* of QPointF* */ positions) { +void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array /* of QPointF* */ positions) { QList positions_QList; - positions_QList.reserve(positions->len); - QPointF** positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + QPointF** positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(*(positions_arr[i])); } self->setPositions(positions_QList); diff --git a/qt6/gen_qglyphrun.go b/qt6/gen_qglyphrun.go index 9e6458c8..6dc1ad91 100644 --- a/qt6/gen_qglyphrun.go +++ b/qt6/gen_qglyphrun.go @@ -88,30 +88,27 @@ func (this *QGlyphRun) SetRawData(glyphIndexArray *uint, glyphPositionArray *QPo } func (this *QGlyphRun) GlyphIndexes() []uint { - var _ma *C.struct_miqt_array = C.QGlyphRun_GlyphIndexes(this.h) + var _ma C.struct_miqt_array = C.QGlyphRun_GlyphIndexes(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGlyphRun) SetGlyphIndexes(glyphIndexes []uint) { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} C.QGlyphRun_SetGlyphIndexes(this.h, glyphIndexes_ma) } func (this *QGlyphRun) Positions() []QPointF { - var _ma *C.struct_miqt_array = C.QGlyphRun_Positions(this.h) + var _ma C.struct_miqt_array = C.QGlyphRun_Positions(this.h) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -120,19 +117,16 @@ func (this *QGlyphRun) Positions() []QPointF { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGlyphRun) SetPositions(positions []QPointF) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]*C.QPointF)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = positions[i].cPointer() } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QGlyphRun_SetPositions(this.h, positions_ma) } diff --git a/qt6/gen_qglyphrun.h b/qt6/gen_qglyphrun.h index 49ae89b7..88ba5bcd 100644 --- a/qt6/gen_qglyphrun.h +++ b/qt6/gen_qglyphrun.h @@ -32,10 +32,10 @@ void QGlyphRun_Swap(QGlyphRun* self, QGlyphRun* other); QRawFont* QGlyphRun_RawFont(const QGlyphRun* self); void QGlyphRun_SetRawFont(QGlyphRun* self, QRawFont* rawFont); void QGlyphRun_SetRawData(QGlyphRun* self, const unsigned int* glyphIndexArray, QPointF* glyphPositionArray, int size); -struct miqt_array* QGlyphRun_GlyphIndexes(const QGlyphRun* self); -void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array* /* of unsigned int */ glyphIndexes); -struct miqt_array* QGlyphRun_Positions(const QGlyphRun* self); -void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array* /* of QPointF* */ positions); +struct miqt_array QGlyphRun_GlyphIndexes(const QGlyphRun* self); +void QGlyphRun_SetGlyphIndexes(QGlyphRun* self, struct miqt_array /* of unsigned int */ glyphIndexes); +struct miqt_array QGlyphRun_Positions(const QGlyphRun* self); +void QGlyphRun_SetPositions(QGlyphRun* self, struct miqt_array /* of QPointF* */ positions); void QGlyphRun_Clear(QGlyphRun* self); bool QGlyphRun_OperatorEqual(const QGlyphRun* self, QGlyphRun* other); bool QGlyphRun_OperatorNotEqual(const QGlyphRun* self, QGlyphRun* other); diff --git a/qt6/gen_qgraphicsitem.cpp b/qt6/gen_qgraphicsitem.cpp index e378b2ec..18dfe6fd 100644 --- a/qt6/gen_qgraphicsitem.cpp +++ b/qt6/gen_qgraphicsitem.cpp @@ -78,16 +78,16 @@ void QGraphicsItem_SetParentItem(QGraphicsItem* self, QGraphicsItem* parent) { self->setParentItem(parent); } -struct miqt_array* QGraphicsItem_ChildItems(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_ChildItems(const QGraphicsItem* self) { QList _ret = self->childItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -433,24 +433,24 @@ double QGraphicsItem_Scale(const QGraphicsItem* self) { return static_cast(_ret); } -struct miqt_array* QGraphicsItem_Transformations(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_Transformations(const QGraphicsItem* self) { QList _ret = self->transformations(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsTransform** _arr = static_cast(malloc(sizeof(QGraphicsTransform*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array* /* of QGraphicsTransform* */ transformations) { +void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array /* of QGraphicsTransform* */ transformations) { QList transformations_QList; - transformations_QList.reserve(transformations->len); - QGraphicsTransform** transformations_arr = static_cast(transformations->data); - for(size_t i = 0; i < transformations->len; ++i) { + transformations_QList.reserve(transformations.len); + QGraphicsTransform** transformations_arr = static_cast(transformations.data); + for(size_t i = 0; i < transformations.len; ++i) { transformations_QList.push_back(transformations_arr[i]); } self->setTransformations(transformations_QList); @@ -521,16 +521,16 @@ bool QGraphicsItem_CollidesWithPath(const QGraphicsItem* self, QPainterPath* pat return self->collidesWithPath(*path); } -struct miqt_array* QGraphicsItem_CollidingItems(const QGraphicsItem* self) { +struct miqt_array QGraphicsItem_CollidingItems(const QGraphicsItem* self) { QList _ret = self->collidingItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -788,16 +788,16 @@ bool QGraphicsItem_CollidesWithPath2(const QGraphicsItem* self, QPainterPath* pa return self->collidesWithPath(*path, static_cast(mode)); } -struct miqt_array* QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode) { +struct miqt_array QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode) { QList _ret = self->collidingItems(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgraphicsitem.go b/qt6/gen_qgraphicsitem.go index 2265161c..68b82b61 100644 --- a/qt6/gen_qgraphicsitem.go +++ b/qt6/gen_qgraphicsitem.go @@ -228,13 +228,12 @@ func (this *QGraphicsItem) SetParentItem(parent *QGraphicsItem) { } func (this *QGraphicsItem) ChildItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_ChildItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_ChildItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -591,25 +590,22 @@ func (this *QGraphicsItem) Scale() float64 { } func (this *QGraphicsItem) Transformations() []*QGraphicsTransform { - var _ma *C.struct_miqt_array = C.QGraphicsItem_Transformations(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_Transformations(this.h) _ret := make([]*QGraphicsTransform, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsTransform)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsTransform(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsItem) SetTransformations(transformations []*QGraphicsTransform) { - // For the C ABI, malloc a C array of raw pointers transformations_CArray := (*[0xffff]*C.QGraphicsTransform)(C.malloc(C.size_t(8 * len(transformations)))) defer C.free(unsafe.Pointer(transformations_CArray)) for i := range transformations { transformations_CArray[i] = transformations[i].cPointer() } - transformations_ma := &C.struct_miqt_array{len: C.size_t(len(transformations)), data: unsafe.Pointer(transformations_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(transformations_ma)) + transformations_ma := C.struct_miqt_array{len: C.size_t(len(transformations)), data: unsafe.Pointer(transformations_CArray)} C.QGraphicsItem_SetTransformations(this.h, transformations_ma) } @@ -696,13 +692,12 @@ func (this *QGraphicsItem) CollidesWithPath(path *QPainterPath) bool { } func (this *QGraphicsItem) CollidingItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_CollidingItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsItem_CollidingItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1061,13 +1056,12 @@ func (this *QGraphicsItem) CollidesWithPath2(path *QPainterPath, mode ItemSelect } func (this *QGraphicsItem) CollidingItems1(mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsItem_CollidingItems1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsItem_CollidingItems1(this.h, (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgraphicsitem.h b/qt6/gen_qgraphicsitem.h index 0578b73b..65c6432b 100644 --- a/qt6/gen_qgraphicsitem.h +++ b/qt6/gen_qgraphicsitem.h @@ -98,7 +98,7 @@ QGraphicsWidget* QGraphicsItem_TopLevelWidget(const QGraphicsItem* self); QGraphicsWidget* QGraphicsItem_Window(const QGraphicsItem* self); QGraphicsItem* QGraphicsItem_Panel(const QGraphicsItem* self); void QGraphicsItem_SetParentItem(QGraphicsItem* self, QGraphicsItem* parent); -struct miqt_array* QGraphicsItem_ChildItems(const QGraphicsItem* self); +struct miqt_array QGraphicsItem_ChildItems(const QGraphicsItem* self); bool QGraphicsItem_IsWidget(const QGraphicsItem* self); bool QGraphicsItem_IsWindow(const QGraphicsItem* self); bool QGraphicsItem_IsPanel(const QGraphicsItem* self); @@ -180,8 +180,8 @@ void QGraphicsItem_SetRotation(QGraphicsItem* self, double angle); double QGraphicsItem_Rotation(const QGraphicsItem* self); void QGraphicsItem_SetScale(QGraphicsItem* self, double scale); double QGraphicsItem_Scale(const QGraphicsItem* self); -struct miqt_array* QGraphicsItem_Transformations(const QGraphicsItem* self); -void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array* /* of QGraphicsTransform* */ transformations); +struct miqt_array QGraphicsItem_Transformations(const QGraphicsItem* self); +void QGraphicsItem_SetTransformations(QGraphicsItem* self, struct miqt_array /* of QGraphicsTransform* */ transformations); QPointF* QGraphicsItem_TransformOriginPoint(const QGraphicsItem* self); void QGraphicsItem_SetTransformOriginPoint(QGraphicsItem* self, QPointF* origin); void QGraphicsItem_SetTransformOriginPoint2(QGraphicsItem* self, double ax, double ay); @@ -198,7 +198,7 @@ QPainterPath* QGraphicsItem_ClipPath(const QGraphicsItem* self); bool QGraphicsItem_Contains(const QGraphicsItem* self, QPointF* point); bool QGraphicsItem_CollidesWithItem(const QGraphicsItem* self, QGraphicsItem* other); bool QGraphicsItem_CollidesWithPath(const QGraphicsItem* self, QPainterPath* path); -struct miqt_array* QGraphicsItem_CollidingItems(const QGraphicsItem* self); +struct miqt_array QGraphicsItem_CollidingItems(const QGraphicsItem* self); bool QGraphicsItem_IsObscured(const QGraphicsItem* self); bool QGraphicsItem_IsObscured2(const QGraphicsItem* self, double x, double y, double w, double h); bool QGraphicsItem_IsObscuredBy(const QGraphicsItem* self, QGraphicsItem* item); @@ -262,7 +262,7 @@ QTransform* QGraphicsItem_ItemTransform2(const QGraphicsItem* self, QGraphicsIte void QGraphicsItem_SetTransform2(QGraphicsItem* self, QTransform* matrix, bool combine); bool QGraphicsItem_CollidesWithItem2(const QGraphicsItem* self, QGraphicsItem* other, int mode); bool QGraphicsItem_CollidesWithPath2(const QGraphicsItem* self, QPainterPath* path, int mode); -struct miqt_array* QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode); +struct miqt_array QGraphicsItem_CollidingItems1(const QGraphicsItem* self, int mode); bool QGraphicsItem_IsObscured1(const QGraphicsItem* self, QRectF* rect); void QGraphicsItem_Paint3(QGraphicsItem* self, QPainter* painter, QStyleOptionGraphicsItem* option, QWidget* widget); void QGraphicsItem_Update1(QGraphicsItem* self, QRectF* rect); diff --git a/qt6/gen_qgraphicsscene.cpp b/qt6/gen_qgraphicsscene.cpp index 610dd9c3..950e3e87 100644 --- a/qt6/gen_qgraphicsscene.cpp +++ b/qt6/gen_qgraphicsscene.cpp @@ -126,81 +126,81 @@ QRectF* QGraphicsScene_ItemsBoundingRect(const QGraphicsScene* self) { return new QRectF(self->itemsBoundingRect()); } -struct miqt_array* QGraphicsScene_Items(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_Items(const QGraphicsScene* self) { QList _ret = self->items(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos) { +struct miqt_array QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos) { QList _ret = self->items(*pos); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect) { +struct miqt_array QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect) { QList _ret = self->items(*rect); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path) { +struct miqt_array QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path) { QList _ret = self->items(*path); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order) { +struct miqt_array QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item) { +struct miqt_array QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item) { QList _ret = self->collidingItems(item); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -212,16 +212,16 @@ QGraphicsItem* QGraphicsScene_ItemAt2(const QGraphicsScene* self, double x, doub return self->itemAt(static_cast(x), static_cast(y), *deviceTransform); } -struct miqt_array* QGraphicsScene_SelectedItems(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_SelectedItems(const QGraphicsScene* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -237,11 +237,11 @@ void QGraphicsScene_SetSelectionAreaWithPath(QGraphicsScene* self, QPainterPath* self->setSelectionArea(*path); } -QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array* /* of QGraphicsItem* */ items) { +QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array /* of QGraphicsItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QGraphicsItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QGraphicsItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } return self->createItemGroup(items_QList); @@ -357,16 +357,16 @@ QVariant* QGraphicsScene_InputMethodQuery(const QGraphicsScene* self, int query) return new QVariant(self->inputMethodQuery(static_cast(query))); } -struct miqt_array* QGraphicsScene_Views(const QGraphicsScene* self) { +struct miqt_array QGraphicsScene_Views(const QGraphicsScene* self) { QList _ret = self->views(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsView** _arr = static_cast(malloc(sizeof(QGraphicsView*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -463,11 +463,11 @@ void QGraphicsScene_Clear(QGraphicsScene* self) { self->clear(); } -void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array* /* of QRectF* */ region) { +void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array /* of QRectF* */ region) { QList region_QList; - region_QList.reserve(region->len); - QRectF** region_arr = static_cast(region->data); - for(size_t i = 0; i < region->len; ++i) { + region_QList.reserve(region.len); + QRectF** region_arr = static_cast(region.data); + for(size_t i = 0; i < region.len; ++i) { region_QList.push_back(*(region_arr[i])); } self->changed(region_QList); @@ -481,10 +481,10 @@ void QGraphicsScene_connect_Changed(QGraphicsScene* self, intptr_t slot) { for (size_t i = 0, e = region_ret.length(); i < e; ++i) { region_arr[i] = new QRectF(region_ret[i]); } - struct miqt_array* region_out = static_cast(malloc(sizeof(struct miqt_array))); - region_out->len = region_ret.length(); - region_out->data = static_cast(region_arr); - struct miqt_array* sigval1 = region_out; + struct miqt_array region_out; + region_out.len = region_ret.length(); + region_out.data = static_cast(region_arr); + struct miqt_array sigval1 = region_out; miqt_exec_callback_QGraphicsScene_Changed(slot, sigval1); }); } @@ -560,159 +560,159 @@ void QGraphicsScene_Render4(QGraphicsScene* self, QPainter* painter, QRectF* tar self->render(painter, *target, *source, static_cast(aspectRatioMode)); } -struct miqt_array* QGraphicsScene_Items1(const QGraphicsScene* self, int order) { +struct miqt_array QGraphicsScene_Items1(const QGraphicsScene* self, int order) { QList _ret = self->items(static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode) { +struct miqt_array QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode) { QList _ret = self->items(*pos, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order) { +struct miqt_array QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order) { QList _ret = self->items(*pos, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*pos, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode) { +struct miqt_array QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode) { QList _ret = self->items(*rect, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order) { +struct miqt_array QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order) { QList _ret = self->items(*rect, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*rect, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode) { +struct miqt_array QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode) { QList _ret = self->items(*path, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order) { +struct miqt_array QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order) { QList _ret = self->items(*path, static_cast(mode), static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(*path, static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform) { +struct miqt_array QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode), static_cast(order), *deviceTransform); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode) { +struct miqt_array QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode) { QList _ret = self->collidingItems(item, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgraphicsscene.go b/qt6/gen_qgraphicsscene.go index 6173be95..053b3d95 100644 --- a/qt6/gen_qgraphicsscene.go +++ b/qt6/gen_qgraphicsscene.go @@ -166,68 +166,62 @@ func (this *QGraphicsScene) ItemsBoundingRect() *QRectF { } func (this *QGraphicsScene) Items() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithPos(pos *QPointF) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithPos(this.h, pos.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithPos(this.h, pos.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithRect(rect *QRectF) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithRect(this.h, rect.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithRect(this.h, rect.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) ItemsWithPath(path *QPainterPath) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_ItemsWithPath(this.h, path.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_ItemsWithPath(this.h, path.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items2(x float64, y float64, w float64, h float64, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items2(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items2(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) CollidingItems(item *QGraphicsItem) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_CollidingItems(this.h, item.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_CollidingItems(this.h, item.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -240,13 +234,12 @@ func (this *QGraphicsScene) ItemAt2(x float64, y float64, deviceTransform *QTran } func (this *QGraphicsScene) SelectedItems() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_SelectedItems(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -266,14 +259,12 @@ func (this *QGraphicsScene) SetSelectionAreaWithPath(path *QPainterPath) { } func (this *QGraphicsScene) CreateItemGroup(items []*QGraphicsItem) *QGraphicsItemGroup { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QGraphicsItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} return UnsafeNewQGraphicsItemGroup(unsafe.Pointer(C.QGraphicsScene_CreateItemGroup(this.h, items_ma))) } @@ -403,13 +394,12 @@ func (this *QGraphicsScene) InputMethodQuery(query InputMethodQuery) *QVariant { } func (this *QGraphicsScene) Views() []*QGraphicsView { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Views(this.h) + var _ma C.struct_miqt_array = C.QGraphicsScene_Views(this.h) _ret := make([]*QGraphicsView, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsView)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsView(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -512,14 +502,12 @@ func (this *QGraphicsScene) Clear() { } func (this *QGraphicsScene) Changed(region []QRectF) { - // For the C ABI, malloc a C array of raw pointers region_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(region)))) defer C.free(unsafe.Pointer(region_CArray)) for i := range region { region_CArray[i] = region[i].cPointer() } - region_ma := &C.struct_miqt_array{len: C.size_t(len(region)), data: unsafe.Pointer(region_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(region_ma)) + region_ma := C.struct_miqt_array{len: C.size_t(len(region)), data: unsafe.Pointer(region_CArray)} C.QGraphicsScene_Changed(this.h, region_ma) } func (this *QGraphicsScene) OnChanged(slot func(region []QRectF)) { @@ -527,14 +515,14 @@ func (this *QGraphicsScene) OnChanged(slot func(region []QRectF)) { } //export miqt_exec_callback_QGraphicsScene_Changed -func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region *C.struct_miqt_array) { +func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(region []QRectF)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var region_ma *C.struct_miqt_array = region + var region_ma C.struct_miqt_array = region region_ret := make([]QRectF, int(region_ma.len)) region_outCast := (*[0xffff]*C.QRectF)(unsafe.Pointer(region_ma.data)) // hey ya for i := 0; i < int(region_ma.len); i++ { @@ -543,7 +531,6 @@ func miqt_exec_callback_QGraphicsScene_Changed(cb C.intptr_t, region *C.struct_m region_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer region_ret[i] = *region_lv_goptr } - C.free(unsafe.Pointer(region_ma)) slotval1 := region_ret gofunc(slotval1) @@ -643,134 +630,122 @@ func (this *QGraphicsScene) Render4(painter *QPainter, target *QRectF, source *Q } func (this *QGraphicsScene) Items1(order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items1(this.h, (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items1(this.h, (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items22(pos *QPointF, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items22(this.h, pos.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items22(this.h, pos.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items3(pos *QPointF, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items3(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items3(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items4(pos *QPointF, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items4(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items4(this.h, pos.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items23(rect *QRectF, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items23(this.h, rect.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items23(this.h, rect.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items32(rect *QRectF, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items32(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items32(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items42(rect *QRectF, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items42(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items42(this.h, rect.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items25(path *QPainterPath, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items25(this.h, path.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items25(this.h, path.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items34(path *QPainterPath, mode ItemSelectionMode, order SortOrder) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items34(this.h, path.cPointer(), (C.int)(mode), (C.int)(order)) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items34(this.h, path.cPointer(), (C.int)(mode), (C.int)(order)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items44(path *QPainterPath, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items44(this.h, path.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items44(this.h, path.cPointer(), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) Items7(x float64, y float64, w float64, h float64, mode ItemSelectionMode, order SortOrder, deviceTransform *QTransform) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_Items7(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsScene_Items7(this.h, (C.double)(x), (C.double)(y), (C.double)(w), (C.double)(h), (C.int)(mode), (C.int)(order), deviceTransform.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsScene) CollidingItems2(item *QGraphicsItem, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsScene_CollidingItems2(this.h, item.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsScene_CollidingItems2(this.h, item.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgraphicsscene.h b/qt6/gen_qgraphicsscene.h index 401d0c65..4908f016 100644 --- a/qt6/gen_qgraphicsscene.h +++ b/qt6/gen_qgraphicsscene.h @@ -97,19 +97,19 @@ void QGraphicsScene_SetItemIndexMethod(QGraphicsScene* self, int method); int QGraphicsScene_BspTreeDepth(const QGraphicsScene* self); void QGraphicsScene_SetBspTreeDepth(QGraphicsScene* self, int depth); QRectF* QGraphicsScene_ItemsBoundingRect(const QGraphicsScene* self); -struct miqt_array* QGraphicsScene_Items(const QGraphicsScene* self); -struct miqt_array* QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos); -struct miqt_array* QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect); -struct miqt_array* QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path); -struct miqt_array* QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order); -struct miqt_array* QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item); +struct miqt_array QGraphicsScene_Items(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_ItemsWithPos(const QGraphicsScene* self, QPointF* pos); +struct miqt_array QGraphicsScene_ItemsWithRect(const QGraphicsScene* self, QRectF* rect); +struct miqt_array QGraphicsScene_ItemsWithPath(const QGraphicsScene* self, QPainterPath* path); +struct miqt_array QGraphicsScene_Items2(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order); +struct miqt_array QGraphicsScene_CollidingItems(const QGraphicsScene* self, QGraphicsItem* item); QGraphicsItem* QGraphicsScene_ItemAt(const QGraphicsScene* self, QPointF* pos, QTransform* deviceTransform); QGraphicsItem* QGraphicsScene_ItemAt2(const QGraphicsScene* self, double x, double y, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_SelectedItems(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_SelectedItems(const QGraphicsScene* self); QPainterPath* QGraphicsScene_SelectionArea(const QGraphicsScene* self); void QGraphicsScene_SetSelectionArea(QGraphicsScene* self, QPainterPath* path, QTransform* deviceTransform); void QGraphicsScene_SetSelectionAreaWithPath(QGraphicsScene* self, QPainterPath* path); -QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array* /* of QGraphicsItem* */ items); +QGraphicsItemGroup* QGraphicsScene_CreateItemGroup(QGraphicsScene* self, struct miqt_array /* of QGraphicsItem* */ items); void QGraphicsScene_DestroyItemGroup(QGraphicsScene* self, QGraphicsItemGroup* group); void QGraphicsScene_AddItem(QGraphicsScene* self, QGraphicsItem* item); QGraphicsEllipseItem* QGraphicsScene_AddEllipse(QGraphicsScene* self, QRectF* rect); @@ -137,7 +137,7 @@ void QGraphicsScene_SetBackgroundBrush(QGraphicsScene* self, QBrush* brush); QBrush* QGraphicsScene_ForegroundBrush(const QGraphicsScene* self); void QGraphicsScene_SetForegroundBrush(QGraphicsScene* self, QBrush* brush); QVariant* QGraphicsScene_InputMethodQuery(const QGraphicsScene* self, int query); -struct miqt_array* QGraphicsScene_Views(const QGraphicsScene* self); +struct miqt_array QGraphicsScene_Views(const QGraphicsScene* self); void QGraphicsScene_Update(QGraphicsScene* self, double x, double y, double w, double h); void QGraphicsScene_Invalidate(QGraphicsScene* self, double x, double y, double w, double h); QStyle* QGraphicsScene_Style(const QGraphicsScene* self); @@ -161,7 +161,7 @@ void QGraphicsScene_Invalidate2(QGraphicsScene* self); void QGraphicsScene_Advance(QGraphicsScene* self); void QGraphicsScene_ClearSelection(QGraphicsScene* self); void QGraphicsScene_Clear(QGraphicsScene* self); -void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array* /* of QRectF* */ region); +void QGraphicsScene_Changed(QGraphicsScene* self, struct miqt_array /* of QRectF* */ region); void QGraphicsScene_connect_Changed(QGraphicsScene* self, intptr_t slot); void QGraphicsScene_SceneRectChanged(QGraphicsScene* self, QRectF* rect); void QGraphicsScene_connect_SceneRectChanged(QGraphicsScene* self, intptr_t slot); @@ -174,18 +174,18 @@ struct miqt_string QGraphicsScene_Tr3(const char* s, const char* c, int n); void QGraphicsScene_Render2(QGraphicsScene* self, QPainter* painter, QRectF* target); void QGraphicsScene_Render3(QGraphicsScene* self, QPainter* painter, QRectF* target, QRectF* source); void QGraphicsScene_Render4(QGraphicsScene* self, QPainter* painter, QRectF* target, QRectF* source, int aspectRatioMode); -struct miqt_array* QGraphicsScene_Items1(const QGraphicsScene* self, int order); -struct miqt_array* QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode); -struct miqt_array* QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order); -struct miqt_array* QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode); -struct miqt_array* QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order); -struct miqt_array* QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode); -struct miqt_array* QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order); -struct miqt_array* QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform); -struct miqt_array* QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode); +struct miqt_array QGraphicsScene_Items1(const QGraphicsScene* self, int order); +struct miqt_array QGraphicsScene_Items22(const QGraphicsScene* self, QPointF* pos, int mode); +struct miqt_array QGraphicsScene_Items3(const QGraphicsScene* self, QPointF* pos, int mode, int order); +struct miqt_array QGraphicsScene_Items4(const QGraphicsScene* self, QPointF* pos, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items23(const QGraphicsScene* self, QRectF* rect, int mode); +struct miqt_array QGraphicsScene_Items32(const QGraphicsScene* self, QRectF* rect, int mode, int order); +struct miqt_array QGraphicsScene_Items42(const QGraphicsScene* self, QRectF* rect, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items25(const QGraphicsScene* self, QPainterPath* path, int mode); +struct miqt_array QGraphicsScene_Items34(const QGraphicsScene* self, QPainterPath* path, int mode, int order); +struct miqt_array QGraphicsScene_Items44(const QGraphicsScene* self, QPainterPath* path, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_Items7(const QGraphicsScene* self, double x, double y, double w, double h, int mode, int order, QTransform* deviceTransform); +struct miqt_array QGraphicsScene_CollidingItems2(const QGraphicsScene* self, QGraphicsItem* item, int mode); void QGraphicsScene_SetSelectionArea2(QGraphicsScene* self, QPainterPath* path, int selectionOperation); void QGraphicsScene_SetSelectionArea3(QGraphicsScene* self, QPainterPath* path, int selectionOperation, int mode); void QGraphicsScene_SetSelectionArea4(QGraphicsScene* self, QPainterPath* path, int selectionOperation, int mode, QTransform* deviceTransform); diff --git a/qt6/gen_qgraphicsview.cpp b/qt6/gen_qgraphicsview.cpp index a501a407..6cb54810 100644 --- a/qt6/gen_qgraphicsview.cpp +++ b/qt6/gen_qgraphicsview.cpp @@ -261,81 +261,81 @@ void QGraphicsView_Render(QGraphicsView* self, QPainter* painter) { self->render(painter); } -struct miqt_array* QGraphicsView_Items(const QGraphicsView* self) { +struct miqt_array QGraphicsView_Items(const QGraphicsView* self) { QList _ret = self->items(); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos) { +struct miqt_array QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos) { QList _ret = self->items(*pos); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items2(const QGraphicsView* self, int x, int y) { +struct miqt_array QGraphicsView_Items2(const QGraphicsView* self, int x, int y) { QList _ret = self->items(static_cast(x), static_cast(y)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect) { +struct miqt_array QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect) { QList _ret = self->items(*rect); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h) { +struct miqt_array QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path) { +struct miqt_array QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path) { QList _ret = self->items(*path); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -391,11 +391,11 @@ void QGraphicsView_SetForegroundBrush(QGraphicsView* self, QBrush* brush) { self->setForegroundBrush(*brush); } -void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array* /* of QRectF* */ rects) { +void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array /* of QRectF* */ rects) { QList rects_QList; - rects_QList.reserve(rects->len); - QRectF** rects_arr = static_cast(rects->data); - for(size_t i = 0; i < rects->len; ++i) { + rects_QList.reserve(rects.len); + QRectF** rects_arr = static_cast(rects.data); + for(size_t i = 0; i < rects.len; ++i) { rects_QList.push_back(*(rects_arr[i])); } self->updateScene(rects_QList); @@ -504,42 +504,42 @@ void QGraphicsView_Render4(QGraphicsView* self, QPainter* painter, QRectF* targe self->render(painter, *target, *source, static_cast(aspectRatioMode)); } -struct miqt_array* QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode) { +struct miqt_array QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode) { QList _ret = self->items(*rect, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode) { +struct miqt_array QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode) { QList _ret = self->items(static_cast(x), static_cast(y), static_cast(w), static_cast(h), static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode) { +struct miqt_array QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode) { QList _ret = self->items(*path, static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QGraphicsItem** _arr = static_cast(malloc(sizeof(QGraphicsItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgraphicsview.go b/qt6/gen_qgraphicsview.go index 491b908f..3f6305ce 100644 --- a/qt6/gen_qgraphicsview.go +++ b/qt6/gen_qgraphicsview.go @@ -340,68 +340,62 @@ func (this *QGraphicsView) Render(painter *QPainter) { } func (this *QGraphicsView) Items() []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items(this.h) + var _ma C.struct_miqt_array = C.QGraphicsView_Items(this.h) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithPos(pos *QPoint) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithPos(this.h, pos.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithPos(this.h, pos.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items2(x int, y int) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items2(this.h, (C.int)(x), (C.int)(y)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items2(this.h, (C.int)(x), (C.int)(y)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithRect(rect *QRect) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithRect(this.h, rect.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithRect(this.h, rect.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items3(x int, y int, w int, h int) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items3(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items3(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) ItemsWithPath(path *QPainterPath) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_ItemsWithPath(this.h, path.cPointer()) + var _ma C.struct_miqt_array = C.QGraphicsView_ItemsWithPath(this.h, path.cPointer()) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -485,14 +479,12 @@ func (this *QGraphicsView) SetForegroundBrush(brush *QBrush) { } func (this *QGraphicsView) UpdateScene(rects []QRectF) { - // For the C ABI, malloc a C array of raw pointers rects_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(rects)))) defer C.free(unsafe.Pointer(rects_CArray)) for i := range rects { rects_CArray[i] = rects[i].cPointer() } - rects_ma := &C.struct_miqt_array{len: C.size_t(len(rects)), data: unsafe.Pointer(rects_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rects_ma)) + rects_ma := C.struct_miqt_array{len: C.size_t(len(rects)), data: unsafe.Pointer(rects_CArray)} C.QGraphicsView_UpdateScene(this.h, rects_ma) } @@ -620,35 +612,32 @@ func (this *QGraphicsView) Render4(painter *QPainter, target *QRectF, source *QR } func (this *QGraphicsView) Items22(rect *QRect, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items22(this.h, rect.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items22(this.h, rect.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items5(x int, y int, w int, h int, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items5(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items5(this.h, (C.int)(x), (C.int)(y), (C.int)(w), (C.int)(h), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QGraphicsView) Items24(path *QPainterPath, mode ItemSelectionMode) []*QGraphicsItem { - var _ma *C.struct_miqt_array = C.QGraphicsView_Items24(this.h, path.cPointer(), (C.int)(mode)) + var _ma C.struct_miqt_array = C.QGraphicsView_Items24(this.h, path.cPointer(), (C.int)(mode)) _ret := make([]*QGraphicsItem, int(_ma.len)) _outCast := (*[0xffff]*C.QGraphicsItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQGraphicsItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgraphicsview.h b/qt6/gen_qgraphicsview.h index 6d7543e3..e8367890 100644 --- a/qt6/gen_qgraphicsview.h +++ b/qt6/gen_qgraphicsview.h @@ -103,12 +103,12 @@ void QGraphicsView_FitInView(QGraphicsView* self, QRectF* rect); void QGraphicsView_FitInView2(QGraphicsView* self, double x, double y, double w, double h); void QGraphicsView_FitInViewWithItem(QGraphicsView* self, QGraphicsItem* item); void QGraphicsView_Render(QGraphicsView* self, QPainter* painter); -struct miqt_array* QGraphicsView_Items(const QGraphicsView* self); -struct miqt_array* QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos); -struct miqt_array* QGraphicsView_Items2(const QGraphicsView* self, int x, int y); -struct miqt_array* QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect); -struct miqt_array* QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h); -struct miqt_array* QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path); +struct miqt_array QGraphicsView_Items(const QGraphicsView* self); +struct miqt_array QGraphicsView_ItemsWithPos(const QGraphicsView* self, QPoint* pos); +struct miqt_array QGraphicsView_Items2(const QGraphicsView* self, int x, int y); +struct miqt_array QGraphicsView_ItemsWithRect(const QGraphicsView* self, QRect* rect); +struct miqt_array QGraphicsView_Items3(const QGraphicsView* self, int x, int y, int w, int h); +struct miqt_array QGraphicsView_ItemsWithPath(const QGraphicsView* self, QPainterPath* path); QGraphicsItem* QGraphicsView_ItemAt(const QGraphicsView* self, QPoint* pos); QGraphicsItem* QGraphicsView_ItemAt2(const QGraphicsView* self, int x, int y); QPointF* QGraphicsView_MapToScene(const QGraphicsView* self, QPoint* point); @@ -122,7 +122,7 @@ QBrush* QGraphicsView_BackgroundBrush(const QGraphicsView* self); void QGraphicsView_SetBackgroundBrush(QGraphicsView* self, QBrush* brush); QBrush* QGraphicsView_ForegroundBrush(const QGraphicsView* self); void QGraphicsView_SetForegroundBrush(QGraphicsView* self, QBrush* brush); -void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array* /* of QRectF* */ rects); +void QGraphicsView_UpdateScene(QGraphicsView* self, struct miqt_array /* of QRectF* */ rects); void QGraphicsView_InvalidateScene(QGraphicsView* self); void QGraphicsView_UpdateSceneRect(QGraphicsView* self, QRectF* rect); void QGraphicsView_RubberBandChanged(QGraphicsView* self, QRect* viewportRect, QPointF* fromScenePoint, QPointF* toScenePoint); @@ -144,9 +144,9 @@ void QGraphicsView_FitInView23(QGraphicsView* self, QGraphicsItem* item, int asp void QGraphicsView_Render2(QGraphicsView* self, QPainter* painter, QRectF* target); void QGraphicsView_Render3(QGraphicsView* self, QPainter* painter, QRectF* target, QRect* source); void QGraphicsView_Render4(QGraphicsView* self, QPainter* painter, QRectF* target, QRect* source, int aspectRatioMode); -struct miqt_array* QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode); -struct miqt_array* QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode); -struct miqt_array* QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode); +struct miqt_array QGraphicsView_Items22(const QGraphicsView* self, QRect* rect, int mode); +struct miqt_array QGraphicsView_Items5(const QGraphicsView* self, int x, int y, int w, int h, int mode); +struct miqt_array QGraphicsView_Items24(const QGraphicsView* self, QPainterPath* path, int mode); void QGraphicsView_InvalidateScene1(QGraphicsView* self, QRectF* rect); void QGraphicsView_InvalidateScene2(QGraphicsView* self, QRectF* rect, int layers); void QGraphicsView_Delete(QGraphicsView* self); diff --git a/qt6/gen_qgraphicswidget.cpp b/qt6/gen_qgraphicswidget.cpp index 6126499c..75c4f335 100644 --- a/qt6/gen_qgraphicswidget.cpp +++ b/qt6/gen_qgraphicswidget.cpp @@ -241,21 +241,21 @@ void QGraphicsWidget_AddAction(QGraphicsWidget* self, QAction* action) { self->addAction(action); } -void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array* /* of QAction* */ actions) { +void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->addActions(actions_QList); } -void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions) { +void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->insertActions(before, actions_QList); @@ -269,16 +269,16 @@ void QGraphicsWidget_RemoveAction(QGraphicsWidget* self, QAction* action) { self->removeAction(action); } -struct miqt_array* QGraphicsWidget_Actions(const QGraphicsWidget* self) { +struct miqt_array QGraphicsWidget_Actions(const QGraphicsWidget* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qgraphicswidget.go b/qt6/gen_qgraphicswidget.go index 960a3ea4..00435cf0 100644 --- a/qt6/gen_qgraphicswidget.go +++ b/qt6/gen_qgraphicswidget.go @@ -290,26 +290,22 @@ func (this *QGraphicsWidget) AddAction(action *QAction) { } func (this *QGraphicsWidget) AddActions(actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QGraphicsWidget_AddActions(this.h, actions_ma) } func (this *QGraphicsWidget) InsertActions(before *QAction, actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QGraphicsWidget_InsertActions(this.h, before.cPointer(), actions_ma) } @@ -322,13 +318,12 @@ func (this *QGraphicsWidget) RemoveAction(action *QAction) { } func (this *QGraphicsWidget) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QGraphicsWidget_Actions(this.h) + var _ma C.struct_miqt_array = C.QGraphicsWidget_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qgraphicswidget.h b/qt6/gen_qgraphicswidget.h index c51999cc..2cff4349 100644 --- a/qt6/gen_qgraphicswidget.h +++ b/qt6/gen_qgraphicswidget.h @@ -99,11 +99,11 @@ void QGraphicsWidget_ReleaseShortcut(QGraphicsWidget* self, int id); void QGraphicsWidget_SetShortcutEnabled(QGraphicsWidget* self, int id); void QGraphicsWidget_SetShortcutAutoRepeat(QGraphicsWidget* self, int id); void QGraphicsWidget_AddAction(QGraphicsWidget* self, QAction* action); -void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array* /* of QAction* */ actions); -void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions); +void QGraphicsWidget_AddActions(QGraphicsWidget* self, struct miqt_array /* of QAction* */ actions); +void QGraphicsWidget_InsertActions(QGraphicsWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions); void QGraphicsWidget_InsertAction(QGraphicsWidget* self, QAction* before, QAction* action); void QGraphicsWidget_RemoveAction(QGraphicsWidget* self, QAction* action); -struct miqt_array* QGraphicsWidget_Actions(const QGraphicsWidget* self); +struct miqt_array QGraphicsWidget_Actions(const QGraphicsWidget* self); void QGraphicsWidget_SetAttribute(QGraphicsWidget* self, int attribute); bool QGraphicsWidget_TestAttribute(const QGraphicsWidget* self, int attribute); int QGraphicsWidget_Type(const QGraphicsWidget* self); diff --git a/qt6/gen_qguiapplication.cpp b/qt6/gen_qguiapplication.cpp index 020aa388..c129f5b2 100644 --- a/qt6/gen_qguiapplication.cpp +++ b/qt6/gen_qguiapplication.cpp @@ -80,29 +80,29 @@ struct miqt_string QGuiApplication_DesktopFileName() { return _ms; } -struct miqt_array* QGuiApplication_AllWindows() { +struct miqt_array QGuiApplication_AllWindows() { QWindowList _ret = QGuiApplication::allWindows(); // Convert QList<> from C++ memory to manually-managed C memory QWindow** _arr = static_cast(malloc(sizeof(QWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QGuiApplication_TopLevelWindows() { +struct miqt_array QGuiApplication_TopLevelWindows() { QWindowList _ret = QGuiApplication::topLevelWindows(); // Convert QList<> from C++ memory to manually-managed C memory QWindow** _arr = static_cast(malloc(sizeof(QWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -145,16 +145,16 @@ QScreen* QGuiApplication_PrimaryScreen() { return QGuiApplication::primaryScreen(); } -struct miqt_array* QGuiApplication_Screens() { +struct miqt_array QGuiApplication_Screens() { QList _ret = QGuiApplication::screens(); // Convert QList<> from C++ memory to manually-managed C memory QScreen** _arr = static_cast(malloc(sizeof(QScreen*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qguiapplication.go b/qt6/gen_qguiapplication.go index 9471b73f..737cf43d 100644 --- a/qt6/gen_qguiapplication.go +++ b/qt6/gen_qguiapplication.go @@ -120,24 +120,22 @@ func QGuiApplication_DesktopFileName() string { } func QGuiApplication_AllWindows() []*QWindow { - var _ma *C.struct_miqt_array = C.QGuiApplication_AllWindows() + var _ma C.struct_miqt_array = C.QGuiApplication_AllWindows() _ret := make([]*QWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QGuiApplication_TopLevelWindows() []*QWindow { - var _ma *C.struct_miqt_array = C.QGuiApplication_TopLevelWindows() + var _ma C.struct_miqt_array = C.QGuiApplication_TopLevelWindows() _ret := make([]*QWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -180,13 +178,12 @@ func QGuiApplication_PrimaryScreen() *QScreen { } func QGuiApplication_Screens() []*QScreen { - var _ma *C.struct_miqt_array = C.QGuiApplication_Screens() + var _ma C.struct_miqt_array = C.QGuiApplication_Screens() _ret := make([]*QScreen, int(_ma.len)) _outCast := (*[0xffff]*C.QScreen)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScreen(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qguiapplication.h b/qt6/gen_qguiapplication.h index 11d7b88a..a8716c14 100644 --- a/qt6/gen_qguiapplication.h +++ b/qt6/gen_qguiapplication.h @@ -56,8 +56,8 @@ void QGuiApplication_SetApplicationDisplayName(struct miqt_string name); struct miqt_string QGuiApplication_ApplicationDisplayName(); void QGuiApplication_SetDesktopFileName(struct miqt_string name); struct miqt_string QGuiApplication_DesktopFileName(); -struct miqt_array* QGuiApplication_AllWindows(); -struct miqt_array* QGuiApplication_TopLevelWindows(); +struct miqt_array QGuiApplication_AllWindows(); +struct miqt_array QGuiApplication_TopLevelWindows(); QWindow* QGuiApplication_TopLevelAt(QPoint* pos); void QGuiApplication_SetWindowIcon(QIcon* icon); QIcon* QGuiApplication_WindowIcon(); @@ -66,7 +66,7 @@ QWindow* QGuiApplication_ModalWindow(); QWindow* QGuiApplication_FocusWindow(); QObject* QGuiApplication_FocusObject(); QScreen* QGuiApplication_PrimaryScreen(); -struct miqt_array* QGuiApplication_Screens(); +struct miqt_array QGuiApplication_Screens(); QScreen* QGuiApplication_ScreenAt(QPoint* point); double QGuiApplication_DevicePixelRatio(const QGuiApplication* self); QCursor* QGuiApplication_OverrideCursor(); diff --git a/qt6/gen_qhash.cpp b/qt6/gen_qhash.cpp deleted file mode 100644 index 6d8fe376..00000000 --- a/qt6/gen_qhash.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#define WORKAROUND_INNER_CLASS_DEFINITION_QHashPrivate__SpanConstants -#include -#include "gen_qhash.h" -#include "_cgo_export.h" - -QHashDummyValue* QHashDummyValue_new() { - return new QHashDummyValue(); -} - -QHashDummyValue* QHashDummyValue_new2(QHashDummyValue* param1) { - return new QHashDummyValue(*param1); -} - -bool QHashDummyValue_OperatorEqual(const QHashDummyValue* self, QHashDummyValue* param1) { - return self->operator==(*param1); -} - -void QHashDummyValue_Delete(QHashDummyValue* self) { - delete self; -} - -void QHashPrivate__SpanConstants_Delete(QHashPrivate__SpanConstants* self) { - delete self; -} - diff --git a/qt6/gen_qhash.go b/qt6/gen_qhash.go deleted file mode 100644 index 98cdc13f..00000000 --- a/qt6/gen_qhash.go +++ /dev/null @@ -1,116 +0,0 @@ -package qt6 - -/* - -#include "gen_qhash.h" -#include - -*/ -import "C" - -import ( - "runtime" - "unsafe" -) - -type QHashDummyValue struct { - h *C.QHashDummyValue -} - -func (this *QHashDummyValue) cPointer() *C.QHashDummyValue { - if this == nil { - return nil - } - return this.h -} - -func (this *QHashDummyValue) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQHashDummyValue(h *C.QHashDummyValue) *QHashDummyValue { - if h == nil { - return nil - } - return &QHashDummyValue{h: h} -} - -func UnsafeNewQHashDummyValue(h unsafe.Pointer) *QHashDummyValue { - return newQHashDummyValue((*C.QHashDummyValue)(h)) -} - -// NewQHashDummyValue constructs a new QHashDummyValue object. -func NewQHashDummyValue() *QHashDummyValue { - ret := C.QHashDummyValue_new() - return newQHashDummyValue(ret) -} - -// NewQHashDummyValue2 constructs a new QHashDummyValue object. -func NewQHashDummyValue2(param1 *QHashDummyValue) *QHashDummyValue { - ret := C.QHashDummyValue_new2(param1.cPointer()) - return newQHashDummyValue(ret) -} - -func (this *QHashDummyValue) OperatorEqual(param1 *QHashDummyValue) bool { - return (bool)(C.QHashDummyValue_OperatorEqual(this.h, param1.cPointer())) -} - -// Delete this object from C++ memory. -func (this *QHashDummyValue) Delete() { - C.QHashDummyValue_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QHashDummyValue) GoGC() { - runtime.SetFinalizer(this, func(this *QHashDummyValue) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} - -type QHashPrivate__SpanConstants struct { - h *C.QHashPrivate__SpanConstants -} - -func (this *QHashPrivate__SpanConstants) cPointer() *C.QHashPrivate__SpanConstants { - if this == nil { - return nil - } - return this.h -} - -func (this *QHashPrivate__SpanConstants) UnsafePointer() unsafe.Pointer { - if this == nil { - return nil - } - return unsafe.Pointer(this.h) -} - -func newQHashPrivate__SpanConstants(h *C.QHashPrivate__SpanConstants) *QHashPrivate__SpanConstants { - if h == nil { - return nil - } - return &QHashPrivate__SpanConstants{h: h} -} - -func UnsafeNewQHashPrivate__SpanConstants(h unsafe.Pointer) *QHashPrivate__SpanConstants { - return newQHashPrivate__SpanConstants((*C.QHashPrivate__SpanConstants)(h)) -} - -// Delete this object from C++ memory. -func (this *QHashPrivate__SpanConstants) Delete() { - C.QHashPrivate__SpanConstants_Delete(this.h) -} - -// GoGC adds a Go Finalizer to this pointer, so that it will be deleted -// from C++ memory once it is unreachable from Go memory. -func (this *QHashPrivate__SpanConstants) GoGC() { - runtime.SetFinalizer(this, func(this *QHashPrivate__SpanConstants) { - this.Delete() - runtime.KeepAlive(this.h) - }) -} diff --git a/qt6/gen_qhash.h b/qt6/gen_qhash.h deleted file mode 100644 index abacb57c..00000000 --- a/qt6/gen_qhash.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef GEN_QHASH_H -#define GEN_QHASH_H - -#include -#include -#include - -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -#include "../libmiqt/libmiqt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -class QHashDummyValue; -#if defined(WORKAROUND_INNER_CLASS_DEFINITION_QHashPrivate__SpanConstants) -typedef QHashPrivate::SpanConstants QHashPrivate__SpanConstants; -#else -class QHashPrivate__SpanConstants; -#endif -#else -typedef struct QHashDummyValue QHashDummyValue; -typedef struct QHashPrivate__SpanConstants QHashPrivate__SpanConstants; -#endif - -QHashDummyValue* QHashDummyValue_new(); -QHashDummyValue* QHashDummyValue_new2(QHashDummyValue* param1); -bool QHashDummyValue_OperatorEqual(const QHashDummyValue* self, QHashDummyValue* param1); -void QHashDummyValue_Delete(QHashDummyValue* self); - -void QHashPrivate__SpanConstants_Delete(QHashPrivate__SpanConstants* self); - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif diff --git a/qt6/gen_qicon.cpp b/qt6/gen_qicon.cpp index b2598c0e..6761ef80 100644 --- a/qt6/gen_qicon.cpp +++ b/qt6/gen_qicon.cpp @@ -115,16 +115,16 @@ void QIcon_AddFile(QIcon* self, struct miqt_string fileName) { self->addFile(fileName_QString); } -struct miqt_array* QIcon_AvailableSizes(const QIcon* self) { +struct miqt_array QIcon_AvailableSizes(const QIcon* self) { QList _ret = self->availableSizes(); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -151,7 +151,7 @@ bool QIcon_HasThemeIcon(struct miqt_string name) { return QIcon::hasThemeIcon(name_QString); } -struct miqt_array* QIcon_ThemeSearchPaths() { +struct miqt_array QIcon_ThemeSearchPaths() { QStringList _ret = QIcon::themeSearchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -165,24 +165,24 @@ struct miqt_array* QIcon_ThemeSearchPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QIcon_SetThemeSearchPaths(struct miqt_array* /* of struct miqt_string */ searchpath) { +void QIcon_SetThemeSearchPaths(struct miqt_array /* of struct miqt_string */ searchpath) { QStringList searchpath_QList; - searchpath_QList.reserve(searchpath->len); - struct miqt_string* searchpath_arr = static_cast(searchpath->data); - for(size_t i = 0; i < searchpath->len; ++i) { + searchpath_QList.reserve(searchpath.len); + struct miqt_string* searchpath_arr = static_cast(searchpath.data); + for(size_t i = 0; i < searchpath.len; ++i) { QString searchpath_arr_i_QString = QString::fromUtf8(searchpath_arr[i].data, searchpath_arr[i].len); searchpath_QList.push_back(searchpath_arr_i_QString); } QIcon::setThemeSearchPaths(searchpath_QList); } -struct miqt_array* QIcon_FallbackSearchPaths() { +struct miqt_array QIcon_FallbackSearchPaths() { QStringList _ret = QIcon::fallbackSearchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -196,17 +196,17 @@ struct miqt_array* QIcon_FallbackSearchPaths() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QIcon_SetFallbackSearchPaths(struct miqt_array* /* of struct miqt_string */ paths) { +void QIcon_SetFallbackSearchPaths(struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } @@ -348,29 +348,29 @@ void QIcon_AddFile4(QIcon* self, struct miqt_string fileName, QSize* size, int m self->addFile(fileName_QString, *size, static_cast(mode), static_cast(state)); } -struct miqt_array* QIcon_AvailableSizes1(const QIcon* self, int mode) { +struct miqt_array QIcon_AvailableSizes1(const QIcon* self, int mode) { QList _ret = self->availableSizes(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIcon_AvailableSizes2(const QIcon* self, int mode, int state) { +struct miqt_array QIcon_AvailableSizes2(const QIcon* self, int mode, int state) { QList _ret = self->availableSizes(static_cast(mode), static_cast(state)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qicon.go b/qt6/gen_qicon.go index c906a0ab..23d3bb8a 100644 --- a/qt6/gen_qicon.go +++ b/qt6/gen_qicon.go @@ -193,7 +193,7 @@ func (this *QIcon) AddFile(fileName string) { } func (this *QIcon) AvailableSizes() []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes(this.h) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes(this.h) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -202,7 +202,6 @@ func (this *QIcon) AvailableSizes() []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -245,7 +244,7 @@ func QIcon_HasThemeIcon(name string) bool { } func QIcon_ThemeSearchPaths() []string { - var _ma *C.struct_miqt_array = C.QIcon_ThemeSearchPaths() + var _ma C.struct_miqt_array = C.QIcon_ThemeSearchPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -254,12 +253,10 @@ func QIcon_ThemeSearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QIcon_SetThemeSearchPaths(searchpath []string) { - // For the C ABI, malloc a C array of structs searchpath_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(searchpath)))) defer C.free(unsafe.Pointer(searchpath_CArray)) for i := range searchpath { @@ -269,13 +266,12 @@ func QIcon_SetThemeSearchPaths(searchpath []string) { defer C.free(unsafe.Pointer(searchpath_i_ms.data)) searchpath_CArray[i] = searchpath_i_ms } - searchpath_ma := &C.struct_miqt_array{len: C.size_t(len(searchpath)), data: unsafe.Pointer(searchpath_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(searchpath_ma)) + searchpath_ma := C.struct_miqt_array{len: C.size_t(len(searchpath)), data: unsafe.Pointer(searchpath_CArray)} C.QIcon_SetThemeSearchPaths(searchpath_ma) } func QIcon_FallbackSearchPaths() []string { - var _ma *C.struct_miqt_array = C.QIcon_FallbackSearchPaths() + var _ma C.struct_miqt_array = C.QIcon_FallbackSearchPaths() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -284,12 +280,10 @@ func QIcon_FallbackSearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QIcon_SetFallbackSearchPaths(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -299,8 +293,7 @@ func QIcon_SetFallbackSearchPaths(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QIcon_SetFallbackSearchPaths(paths_ma) } @@ -489,7 +482,7 @@ func (this *QIcon) AddFile4(fileName string, size *QSize, mode QIcon__Mode, stat } func (this *QIcon) AvailableSizes1(mode QIcon__Mode) []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes1(this.h, (C.int)(mode)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -498,12 +491,11 @@ func (this *QIcon) AvailableSizes1(mode QIcon__Mode) []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIcon) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize { - var _ma *C.struct_miqt_array = C.QIcon_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) + var _ma C.struct_miqt_array = C.QIcon_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -512,7 +504,6 @@ func (this *QIcon) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qicon.h b/qt6/gen_qicon.h index c9b7947d..c53d8c15 100644 --- a/qt6/gen_qicon.h +++ b/qt6/gen_qicon.h @@ -54,16 +54,16 @@ void QIcon_Detach(QIcon* self); long long QIcon_CacheKey(const QIcon* self); void QIcon_AddPixmap(QIcon* self, QPixmap* pixmap); void QIcon_AddFile(QIcon* self, struct miqt_string fileName); -struct miqt_array* QIcon_AvailableSizes(const QIcon* self); +struct miqt_array QIcon_AvailableSizes(const QIcon* self); void QIcon_SetIsMask(QIcon* self, bool isMask); bool QIcon_IsMask(const QIcon* self); QIcon* QIcon_FromTheme(struct miqt_string name); QIcon* QIcon_FromTheme2(struct miqt_string name, QIcon* fallback); bool QIcon_HasThemeIcon(struct miqt_string name); -struct miqt_array* QIcon_ThemeSearchPaths(); -void QIcon_SetThemeSearchPaths(struct miqt_array* /* of struct miqt_string */ searchpath); -struct miqt_array* QIcon_FallbackSearchPaths(); -void QIcon_SetFallbackSearchPaths(struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QIcon_ThemeSearchPaths(); +void QIcon_SetThemeSearchPaths(struct miqt_array /* of struct miqt_string */ searchpath); +struct miqt_array QIcon_FallbackSearchPaths(); +void QIcon_SetFallbackSearchPaths(struct miqt_array /* of struct miqt_string */ paths); struct miqt_string QIcon_ThemeName(); void QIcon_SetThemeName(struct miqt_string path); struct miqt_string QIcon_FallbackThemeName(); @@ -93,8 +93,8 @@ void QIcon_AddPixmap3(QIcon* self, QPixmap* pixmap, int mode, int state); void QIcon_AddFile2(QIcon* self, struct miqt_string fileName, QSize* size); void QIcon_AddFile3(QIcon* self, struct miqt_string fileName, QSize* size, int mode); void QIcon_AddFile4(QIcon* self, struct miqt_string fileName, QSize* size, int mode, int state); -struct miqt_array* QIcon_AvailableSizes1(const QIcon* self, int mode); -struct miqt_array* QIcon_AvailableSizes2(const QIcon* self, int mode, int state); +struct miqt_array QIcon_AvailableSizes1(const QIcon* self, int mode); +struct miqt_array QIcon_AvailableSizes2(const QIcon* self, int mode, int state); void QIcon_Delete(QIcon* self); #ifdef __cplusplus diff --git a/qt6/gen_qiconengine.cpp b/qt6/gen_qiconengine.cpp index ca7809fd..805229c3 100644 --- a/qt6/gen_qiconengine.cpp +++ b/qt6/gen_qiconengine.cpp @@ -57,16 +57,16 @@ bool QIconEngine_Write(const QIconEngine* self, QDataStream* out) { return self->write(*out); } -struct miqt_array* QIconEngine_AvailableSizes(QIconEngine* self) { +struct miqt_array QIconEngine_AvailableSizes(QIconEngine* self) { QList _ret = self->availableSizes(); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -93,29 +93,29 @@ void QIconEngine_VirtualHook(QIconEngine* self, int id, void* data) { self->virtual_hook(static_cast(id), data); } -struct miqt_array* QIconEngine_AvailableSizes1(QIconEngine* self, int mode) { +struct miqt_array QIconEngine_AvailableSizes1(QIconEngine* self, int mode) { QList _ret = self->availableSizes(static_cast(mode)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIconEngine_AvailableSizes2(QIconEngine* self, int mode, int state) { +struct miqt_array QIconEngine_AvailableSizes2(QIconEngine* self, int mode, int state) { QList _ret = self->availableSizes(static_cast(mode), static_cast(state)); // Convert QList<> from C++ memory to manually-managed C memory QSize** _arr = static_cast(malloc(sizeof(QSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qiconengine.go b/qt6/gen_qiconengine.go index 017fa086..c7974681 100644 --- a/qt6/gen_qiconengine.go +++ b/qt6/gen_qiconengine.go @@ -99,7 +99,7 @@ func (this *QIconEngine) Write(out *QDataStream) bool { } func (this *QIconEngine) AvailableSizes() []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes(this.h) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes(this.h) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -108,7 +108,6 @@ func (this *QIconEngine) AvailableSizes() []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -135,7 +134,7 @@ func (this *QIconEngine) VirtualHook(id int, data unsafe.Pointer) { } func (this *QIconEngine) AvailableSizes1(mode QIcon__Mode) []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes1(this.h, (C.int)(mode)) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes1(this.h, (C.int)(mode)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -144,12 +143,11 @@ func (this *QIconEngine) AvailableSizes1(mode QIcon__Mode) []QSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIconEngine) AvailableSizes2(mode QIcon__Mode, state QIcon__State) []QSize { - var _ma *C.struct_miqt_array = C.QIconEngine_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) + var _ma C.struct_miqt_array = C.QIconEngine_AvailableSizes2(this.h, (C.int)(mode), (C.int)(state)) _ret := make([]QSize, int(_ma.len)) _outCast := (*[0xffff]*C.QSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -158,7 +156,6 @@ func (this *QIconEngine) AvailableSizes2(mode QIcon__Mode, state QIcon__State) [ _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qiconengine.h b/qt6/gen_qiconengine.h index eee096a0..b68bf90a 100644 --- a/qt6/gen_qiconengine.h +++ b/qt6/gen_qiconengine.h @@ -44,13 +44,13 @@ struct miqt_string QIconEngine_Key(const QIconEngine* self); QIconEngine* QIconEngine_Clone(const QIconEngine* self); bool QIconEngine_Read(QIconEngine* self, QDataStream* in); bool QIconEngine_Write(const QIconEngine* self, QDataStream* out); -struct miqt_array* QIconEngine_AvailableSizes(QIconEngine* self); +struct miqt_array QIconEngine_AvailableSizes(QIconEngine* self); struct miqt_string QIconEngine_IconName(QIconEngine* self); bool QIconEngine_IsNull(QIconEngine* self); QPixmap* QIconEngine_ScaledPixmap(QIconEngine* self, QSize* size, int mode, int state, double scale); void QIconEngine_VirtualHook(QIconEngine* self, int id, void* data); -struct miqt_array* QIconEngine_AvailableSizes1(QIconEngine* self, int mode); -struct miqt_array* QIconEngine_AvailableSizes2(QIconEngine* self, int mode, int state); +struct miqt_array QIconEngine_AvailableSizes1(QIconEngine* self, int mode); +struct miqt_array QIconEngine_AvailableSizes2(QIconEngine* self, int mode, int state); void QIconEngine_Delete(QIconEngine* self); QIconEngine__ScaledPixmapArgument* QIconEngine__ScaledPixmapArgument_new(QIconEngine__ScaledPixmapArgument* param1); diff --git a/qt6/gen_qidentityproxymodel.cpp b/qt6/gen_qidentityproxymodel.cpp index 954f27ca..1fc6c5c8 100644 --- a/qt6/gen_qidentityproxymodel.cpp +++ b/qt6/gen_qidentityproxymodel.cpp @@ -76,16 +76,16 @@ QModelIndex* QIdentityProxyModel_Sibling(const QIdentityProxyModel* self, int ro return new QModelIndex(self->sibling(static_cast(row), static_cast(column), *idx)); } -struct miqt_array* QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -155,29 +155,29 @@ QVariant* QIdentityProxyModel_HeaderData3(const QIdentityProxyModel* self, int s return new QVariant(self->headerData(static_cast(section), static_cast(orientation), static_cast(role))); } -struct miqt_array* QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qidentityproxymodel.go b/qt6/gen_qidentityproxymodel.go index 012d04e0..b97c8e6b 100644 --- a/qt6/gen_qidentityproxymodel.go +++ b/qt6/gen_qidentityproxymodel.go @@ -129,7 +129,7 @@ func (this *QIdentityProxyModel) Sibling(row int, column int, idx *QModelIndex) } func (this *QIdentityProxyModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -138,7 +138,6 @@ func (this *QIdentityProxyModel) Match(start *QModelIndex, role int, value *QVar _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -215,7 +214,7 @@ func (this *QIdentityProxyModel) HeaderData3(section int, orientation Orientatio } func (this *QIdentityProxyModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -224,12 +223,11 @@ func (this *QIdentityProxyModel) Match4(start *QModelIndex, role int, value *QVa _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QIdentityProxyModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QIdentityProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QIdentityProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -238,7 +236,6 @@ func (this *QIdentityProxyModel) Match5(start *QModelIndex, role int, value *QVa _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qidentityproxymodel.h b/qt6/gen_qidentityproxymodel.h index 6f56bd9c..9a7a340a 100644 --- a/qt6/gen_qidentityproxymodel.h +++ b/qt6/gen_qidentityproxymodel.h @@ -45,7 +45,7 @@ int QIdentityProxyModel_RowCount(const QIdentityProxyModel* self); QVariant* QIdentityProxyModel_HeaderData(const QIdentityProxyModel* self, int section, int orientation); bool QIdentityProxyModel_DropMimeData(QIdentityProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); QModelIndex* QIdentityProxyModel_Sibling(const QIdentityProxyModel* self, int row, int column, QModelIndex* idx); -struct miqt_array* QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QIdentityProxyModel_Match(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value); void QIdentityProxyModel_SetSourceModel(QIdentityProxyModel* self, QAbstractItemModel* sourceModel); bool QIdentityProxyModel_InsertColumns(QIdentityProxyModel* self, int column, int count); bool QIdentityProxyModel_InsertRows(QIdentityProxyModel* self, int row, int count); @@ -59,8 +59,8 @@ int QIdentityProxyModel_ColumnCount1(const QIdentityProxyModel* self, QModelInde QModelIndex* QIdentityProxyModel_Index3(const QIdentityProxyModel* self, int row, int column, QModelIndex* parent); int QIdentityProxyModel_RowCount1(const QIdentityProxyModel* self, QModelIndex* parent); QVariant* QIdentityProxyModel_HeaderData3(const QIdentityProxyModel* self, int section, int orientation, int role); -struct miqt_array* QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QIdentityProxyModel_Match4(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QIdentityProxyModel_Match5(const QIdentityProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); bool QIdentityProxyModel_InsertColumns3(QIdentityProxyModel* self, int column, int count, QModelIndex* parent); bool QIdentityProxyModel_InsertRows3(QIdentityProxyModel* self, int row, int count, QModelIndex* parent); bool QIdentityProxyModel_RemoveColumns3(QIdentityProxyModel* self, int column, int count, QModelIndex* parent); diff --git a/qt6/gen_qimage.cpp b/qt6/gen_qimage.cpp index c6d606e8..d646de4c 100644 --- a/qt6/gen_qimage.cpp +++ b/qt6/gen_qimage.cpp @@ -111,11 +111,11 @@ QImage* QImage_ConvertToFormat(const QImage* self, int f) { return new QImage(self->convertToFormat(static_cast(f))); } -QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable) { +QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable) { QList colorTable_QList; - colorTable_QList.reserve(colorTable->len); - unsigned int* colorTable_arr = static_cast(colorTable->data); - for(size_t i = 0; i < colorTable->len; ++i) { + colorTable_QList.reserve(colorTable.len); + unsigned int* colorTable_arr = static_cast(colorTable.data); + for(size_t i = 0; i < colorTable.len; ++i) { colorTable_QList.push_back(static_cast(colorTable_arr[i])); } return new QImage(self->convertToFormat(static_cast(f), colorTable_QList)); @@ -272,24 +272,24 @@ void QImage_SetPixelColor2(QImage* self, QPoint* pt, QColor* c) { self->setPixelColor(*pt, *c); } -struct miqt_array* QImage_ColorTable(const QImage* self) { +struct miqt_array QImage_ColorTable(const QImage* self) { QList _ret = self->colorTable(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QImage_SetColorTable(QImage* self, struct miqt_array* /* of unsigned int */ colors) { +void QImage_SetColorTable(QImage* self, struct miqt_array /* of unsigned int */ colors) { QList colors_QList; - colors_QList.reserve(colors->len); - unsigned int* colors_arr = static_cast(colors->data); - for(size_t i = 0; i < colors->len; ++i) { + colors_QList.reserve(colors.len); + unsigned int* colors_arr = static_cast(colors.data); + for(size_t i = 0; i < colors.len; ++i) { colors_QList.push_back(static_cast(colors_arr[i])); } self->setColorTable(colors_QList); @@ -485,7 +485,7 @@ void QImage_SetOffset(QImage* self, QPoint* offset) { self->setOffset(*offset); } -struct miqt_array* QImage_TextKeys(const QImage* self) { +struct miqt_array QImage_TextKeys(const QImage* self) { QStringList _ret = self->textKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -499,9 +499,9 @@ struct miqt_array* QImage_TextKeys(const QImage* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -543,11 +543,11 @@ QImage* QImage_ConvertToFormat22(const QImage* self, int f, int flags) { return new QImage(self->convertToFormat(static_cast(f), static_cast(flags))); } -QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable, int flags) { +QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable, int flags) { QList colorTable_QList; - colorTable_QList.reserve(colorTable->len); - unsigned int* colorTable_arr = static_cast(colorTable->data); - for(size_t i = 0; i < colorTable->len; ++i) { + colorTable_QList.reserve(colorTable.len); + unsigned int* colorTable_arr = static_cast(colorTable.data); + for(size_t i = 0; i < colorTable.len; ++i) { colorTable_QList.push_back(static_cast(colorTable_arr[i])); } return new QImage(self->convertToFormat(static_cast(f), colorTable_QList, static_cast(flags))); diff --git a/qt6/gen_qimage.go b/qt6/gen_qimage.go index e80cd617..a9155af5 100644 --- a/qt6/gen_qimage.go +++ b/qt6/gen_qimage.go @@ -220,14 +220,12 @@ func (this *QImage) ConvertToFormat(f QImage__Format) *QImage { } func (this *QImage) ConvertToFormat2(f QImage__Format, colorTable []uint) *QImage { - // For the C ABI, malloc a C array of raw pointers colorTable_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colorTable)))) defer C.free(unsafe.Pointer(colorTable_CArray)) for i := range colorTable { colorTable_CArray[i] = (C.uint)(colorTable[i]) } - colorTable_ma := &C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colorTable_ma)) + colorTable_ma := C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} _ret := C.QImage_ConvertToFormat2(this.h, (C.int)(f), colorTable_ma) _goptr := newQImage(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer @@ -390,25 +388,22 @@ func (this *QImage) SetPixelColor2(pt *QPoint, c *QColor) { } func (this *QImage) ColorTable() []uint { - var _ma *C.struct_miqt_array = C.QImage_ColorTable(this.h) + var _ma C.struct_miqt_array = C.QImage_ColorTable(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QImage) SetColorTable(colors []uint) { - // For the C ABI, malloc a C array of raw pointers colors_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colors)))) defer C.free(unsafe.Pointer(colors_CArray)) for i := range colors { colors_CArray[i] = (C.uint)(colors[i]) } - colors_ma := &C.struct_miqt_array{len: C.size_t(len(colors)), data: unsafe.Pointer(colors_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colors_ma)) + colors_ma := C.struct_miqt_array{len: C.size_t(len(colors)), data: unsafe.Pointer(colors_CArray)} C.QImage_SetColorTable(this.h, colors_ma) } @@ -670,7 +665,7 @@ func (this *QImage) SetOffset(offset *QPoint) { } func (this *QImage) TextKeys() []string { - var _ma *C.struct_miqt_array = C.QImage_TextKeys(this.h) + var _ma C.struct_miqt_array = C.QImage_TextKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -679,7 +674,6 @@ func (this *QImage) TextKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -735,14 +729,12 @@ func (this *QImage) ConvertToFormat22(f QImage__Format, flags ImageConversionFla } func (this *QImage) ConvertToFormat3(f QImage__Format, colorTable []uint, flags ImageConversionFlag) *QImage { - // For the C ABI, malloc a C array of raw pointers colorTable_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(colorTable)))) defer C.free(unsafe.Pointer(colorTable_CArray)) for i := range colorTable { colorTable_CArray[i] = (C.uint)(colorTable[i]) } - colorTable_ma := &C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(colorTable_ma)) + colorTable_ma := C.struct_miqt_array{len: C.size_t(len(colorTable)), data: unsafe.Pointer(colorTable_CArray)} _ret := C.QImage_ConvertToFormat3(this.h, (C.int)(f), colorTable_ma, (C.int)(flags)) _goptr := newQImage(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt6/gen_qimage.h b/qt6/gen_qimage.h index 3c945680..d510e8b0 100644 --- a/qt6/gen_qimage.h +++ b/qt6/gen_qimage.h @@ -67,7 +67,7 @@ QImage* QImage_Copy(const QImage* self); QImage* QImage_Copy2(const QImage* self, int x, int y, int w, int h); int QImage_Format(const QImage* self); QImage* QImage_ConvertToFormat(const QImage* self, int f); -QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable); +QImage* QImage_ConvertToFormat2(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable); bool QImage_ReinterpretAsFormat(QImage* self, int f); QImage* QImage_ConvertedTo(const QImage* self, int f); void QImage_ConvertTo(QImage* self, int f); @@ -103,8 +103,8 @@ QColor* QImage_PixelColor(const QImage* self, int x, int y); QColor* QImage_PixelColorWithPt(const QImage* self, QPoint* pt); void QImage_SetPixelColor(QImage* self, int x, int y, QColor* c); void QImage_SetPixelColor2(QImage* self, QPoint* pt, QColor* c); -struct miqt_array* QImage_ColorTable(const QImage* self); -void QImage_SetColorTable(QImage* self, struct miqt_array* /* of unsigned int */ colors); +struct miqt_array QImage_ColorTable(const QImage* self); +void QImage_SetColorTable(QImage* self, struct miqt_array /* of unsigned int */ colors); double QImage_DevicePixelRatio(const QImage* self); void QImage_SetDevicePixelRatio(QImage* self, double scaleFactor); QSizeF* QImage_DeviceIndependentSize(const QImage* self); @@ -151,7 +151,7 @@ void QImage_SetDotsPerMeterX(QImage* self, int dotsPerMeterX); void QImage_SetDotsPerMeterY(QImage* self, int dotsPerMeterY); QPoint* QImage_Offset(const QImage* self); void QImage_SetOffset(QImage* self, QPoint* offset); -struct miqt_array* QImage_TextKeys(const QImage* self); +struct miqt_array QImage_TextKeys(const QImage* self); struct miqt_string QImage_Text(const QImage* self); void QImage_SetText(QImage* self, struct miqt_string key, struct miqt_string value); QPixelFormat* QImage_PixelFormat(const QImage* self); @@ -159,7 +159,7 @@ QPixelFormat* QImage_ToPixelFormat(int format); int QImage_ToImageFormat(QPixelFormat* format); QImage* QImage_Copy1(const QImage* self, QRect* rect); QImage* QImage_ConvertToFormat22(const QImage* self, int f, int flags); -QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array* /* of unsigned int */ colorTable, int flags); +QImage* QImage_ConvertToFormat3(const QImage* self, int f, struct miqt_array /* of unsigned int */ colorTable, int flags); QImage* QImage_ConvertedTo2(const QImage* self, int f, int flags); void QImage_ConvertTo2(QImage* self, int f, int flags); QImage* QImage_CreateAlphaMask1(const QImage* self, int flags); diff --git a/qt6/gen_qimagereader.cpp b/qt6/gen_qimagereader.cpp index 9e7cd11d..37944d1f 100644 --- a/qt6/gen_qimagereader.cpp +++ b/qt6/gen_qimagereader.cpp @@ -111,7 +111,7 @@ int QImageReader_ImageFormat(const QImageReader* self) { return static_cast(_ret); } -struct miqt_array* QImageReader_TextKeys(const QImageReader* self) { +struct miqt_array QImageReader_TextKeys(const QImageReader* self) { QStringList _ret = self->textKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -125,9 +125,9 @@ struct miqt_array* QImageReader_TextKeys(const QImageReader* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -209,7 +209,7 @@ struct miqt_string QImageReader_SubType(const QImageReader* self) { return _ms; } -struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self) { +struct miqt_array QImageReader_SupportedSubTypes(const QImageReader* self) { QList _ret = self->supportedSubTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -221,9 +221,9 @@ struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -306,7 +306,7 @@ struct miqt_string QImageReader_ImageFormatWithDevice(QIODevice* device) { return _ms; } -struct miqt_array* QImageReader_SupportedImageFormats() { +struct miqt_array QImageReader_SupportedImageFormats() { QList _ret = QImageReader::supportedImageFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -318,13 +318,13 @@ struct miqt_array* QImageReader_SupportedImageFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageReader_SupportedMimeTypes() { +struct miqt_array QImageReader_SupportedMimeTypes() { QList _ret = QImageReader::supportedMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -336,13 +336,13 @@ struct miqt_array* QImageReader_SupportedMimeTypes() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType) { +struct miqt_array QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType) { QByteArray mimeType_QByteArray(mimeType.data, mimeType.len); QList _ret = QImageReader::imageFormatsForMimeType(mimeType_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -355,9 +355,9 @@ struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeT memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qimagereader.go b/qt6/gen_qimagereader.go index 179170ec..dc449a8f 100644 --- a/qt6/gen_qimagereader.go +++ b/qt6/gen_qimagereader.go @@ -170,7 +170,7 @@ func (this *QImageReader) ImageFormat() QImage__Format { } func (this *QImageReader) TextKeys() []string { - var _ma *C.struct_miqt_array = C.QImageReader_TextKeys(this.h) + var _ma C.struct_miqt_array = C.QImageReader_TextKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -179,7 +179,6 @@ func (this *QImageReader) TextKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -270,7 +269,7 @@ func (this *QImageReader) SubType() []byte { } func (this *QImageReader) SupportedSubTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedSubTypes(this.h) + var _ma C.struct_miqt_array = C.QImageReader_SupportedSubTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -279,7 +278,6 @@ func (this *QImageReader) SupportedSubTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -363,7 +361,7 @@ func QImageReader_ImageFormatWithDevice(device *QIODevice) []byte { } func QImageReader_SupportedImageFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedImageFormats() + var _ma C.struct_miqt_array = C.QImageReader_SupportedImageFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -372,12 +370,11 @@ func QImageReader_SupportedImageFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QImageReader_SupportedMimeTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageReader_SupportedMimeTypes() + var _ma C.struct_miqt_array = C.QImageReader_SupportedMimeTypes() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -386,7 +383,6 @@ func QImageReader_SupportedMimeTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -394,7 +390,7 @@ func QImageReader_ImageFormatsForMimeType(mimeType []byte) [][]byte { mimeType_alias := C.struct_miqt_string{} mimeType_alias.data = (*C.char)(unsafe.Pointer(&mimeType[0])) mimeType_alias.len = C.size_t(len(mimeType)) - var _ma *C.struct_miqt_array = C.QImageReader_ImageFormatsForMimeType(mimeType_alias) + var _ma C.struct_miqt_array = C.QImageReader_ImageFormatsForMimeType(mimeType_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -403,7 +399,6 @@ func QImageReader_ImageFormatsForMimeType(mimeType []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qimagereader.h b/qt6/gen_qimagereader.h index 47e1bdfb..d5fe3e91 100644 --- a/qt6/gen_qimagereader.h +++ b/qt6/gen_qimagereader.h @@ -49,7 +49,7 @@ void QImageReader_SetFileName(QImageReader* self, struct miqt_string fileName); struct miqt_string QImageReader_FileName(const QImageReader* self); QSize* QImageReader_Size(const QImageReader* self); int QImageReader_ImageFormat(const QImageReader* self); -struct miqt_array* QImageReader_TextKeys(const QImageReader* self); +struct miqt_array QImageReader_TextKeys(const QImageReader* self); struct miqt_string QImageReader_Text(const QImageReader* self, struct miqt_string key); void QImageReader_SetClipRect(QImageReader* self, QRect* rect); QRect* QImageReader_ClipRect(const QImageReader* self); @@ -66,7 +66,7 @@ int QImageReader_Transformation(const QImageReader* self); void QImageReader_SetAutoTransform(QImageReader* self, bool enabled); bool QImageReader_AutoTransform(const QImageReader* self); struct miqt_string QImageReader_SubType(const QImageReader* self); -struct miqt_array* QImageReader_SupportedSubTypes(const QImageReader* self); +struct miqt_array QImageReader_SupportedSubTypes(const QImageReader* self); bool QImageReader_CanRead(const QImageReader* self); QImage* QImageReader_Read(QImageReader* self); bool QImageReader_ReadWithImage(QImageReader* self, QImage* image); @@ -82,9 +82,9 @@ struct miqt_string QImageReader_ErrorString(const QImageReader* self); bool QImageReader_SupportsOption(const QImageReader* self, int option); struct miqt_string QImageReader_ImageFormatWithFileName(struct miqt_string fileName); struct miqt_string QImageReader_ImageFormatWithDevice(QIODevice* device); -struct miqt_array* QImageReader_SupportedImageFormats(); -struct miqt_array* QImageReader_SupportedMimeTypes(); -struct miqt_array* QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType); +struct miqt_array QImageReader_SupportedImageFormats(); +struct miqt_array QImageReader_SupportedMimeTypes(); +struct miqt_array QImageReader_ImageFormatsForMimeType(struct miqt_string mimeType); int QImageReader_AllocationLimit(); void QImageReader_SetAllocationLimit(int mbLimit); struct miqt_string QImageReader_Tr2(const char* sourceText, const char* disambiguation); diff --git a/qt6/gen_qimagewriter.cpp b/qt6/gen_qimagewriter.cpp index 0f6d2e0f..3905ba53 100644 --- a/qt6/gen_qimagewriter.cpp +++ b/qt6/gen_qimagewriter.cpp @@ -109,7 +109,7 @@ struct miqt_string QImageWriter_SubType(const QImageWriter* self) { return _ms; } -struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self) { +struct miqt_array QImageWriter_SupportedSubTypes(const QImageWriter* self) { QList _ret = self->supportedSubTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -121,9 +121,9 @@ struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -186,7 +186,7 @@ bool QImageWriter_SupportsOption(const QImageWriter* self, int option) { return self->supportsOption(static_cast(option)); } -struct miqt_array* QImageWriter_SupportedImageFormats() { +struct miqt_array QImageWriter_SupportedImageFormats() { QList _ret = QImageWriter::supportedImageFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -198,13 +198,13 @@ struct miqt_array* QImageWriter_SupportedImageFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageWriter_SupportedMimeTypes() { +struct miqt_array QImageWriter_SupportedMimeTypes() { QList _ret = QImageWriter::supportedMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -216,13 +216,13 @@ struct miqt_array* QImageWriter_SupportedMimeTypes() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType) { +struct miqt_array QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType) { QByteArray mimeType_QByteArray(mimeType.data, mimeType.len); QList _ret = QImageWriter::imageFormatsForMimeType(mimeType_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -235,9 +235,9 @@ struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeT memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qimagewriter.go b/qt6/gen_qimagewriter.go index 52e34313..d8e10dad 100644 --- a/qt6/gen_qimagewriter.go +++ b/qt6/gen_qimagewriter.go @@ -166,7 +166,7 @@ func (this *QImageWriter) SubType() []byte { } func (this *QImageWriter) SupportedSubTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedSubTypes(this.h) + var _ma C.struct_miqt_array = C.QImageWriter_SupportedSubTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -175,7 +175,6 @@ func (this *QImageWriter) SupportedSubTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -239,7 +238,7 @@ func (this *QImageWriter) SupportsOption(option QImageIOHandler__ImageOption) bo } func QImageWriter_SupportedImageFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedImageFormats() + var _ma C.struct_miqt_array = C.QImageWriter_SupportedImageFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -248,12 +247,11 @@ func QImageWriter_SupportedImageFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QImageWriter_SupportedMimeTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QImageWriter_SupportedMimeTypes() + var _ma C.struct_miqt_array = C.QImageWriter_SupportedMimeTypes() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -262,7 +260,6 @@ func QImageWriter_SupportedMimeTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -270,7 +267,7 @@ func QImageWriter_ImageFormatsForMimeType(mimeType []byte) [][]byte { mimeType_alias := C.struct_miqt_string{} mimeType_alias.data = (*C.char)(unsafe.Pointer(&mimeType[0])) mimeType_alias.len = C.size_t(len(mimeType)) - var _ma *C.struct_miqt_array = C.QImageWriter_ImageFormatsForMimeType(mimeType_alias) + var _ma C.struct_miqt_array = C.QImageWriter_ImageFormatsForMimeType(mimeType_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -279,7 +276,6 @@ func QImageWriter_ImageFormatsForMimeType(mimeType []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qimagewriter.h b/qt6/gen_qimagewriter.h index 726cf90a..df923c70 100644 --- a/qt6/gen_qimagewriter.h +++ b/qt6/gen_qimagewriter.h @@ -42,7 +42,7 @@ void QImageWriter_SetCompression(QImageWriter* self, int compression); int QImageWriter_Compression(const QImageWriter* self); void QImageWriter_SetSubType(QImageWriter* self, struct miqt_string typeVal); struct miqt_string QImageWriter_SubType(const QImageWriter* self); -struct miqt_array* QImageWriter_SupportedSubTypes(const QImageWriter* self); +struct miqt_array QImageWriter_SupportedSubTypes(const QImageWriter* self); void QImageWriter_SetOptimizedWrite(QImageWriter* self, bool optimize); bool QImageWriter_OptimizedWrite(const QImageWriter* self); void QImageWriter_SetProgressiveScanWrite(QImageWriter* self, bool progressive); @@ -55,9 +55,9 @@ bool QImageWriter_Write(QImageWriter* self, QImage* image); int QImageWriter_Error(const QImageWriter* self); struct miqt_string QImageWriter_ErrorString(const QImageWriter* self); bool QImageWriter_SupportsOption(const QImageWriter* self, int option); -struct miqt_array* QImageWriter_SupportedImageFormats(); -struct miqt_array* QImageWriter_SupportedMimeTypes(); -struct miqt_array* QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType); +struct miqt_array QImageWriter_SupportedImageFormats(); +struct miqt_array QImageWriter_SupportedMimeTypes(); +struct miqt_array QImageWriter_ImageFormatsForMimeType(struct miqt_string mimeType); struct miqt_string QImageWriter_Tr2(const char* sourceText, const char* disambiguation); struct miqt_string QImageWriter_Tr3(const char* sourceText, const char* disambiguation, int n); void QImageWriter_Delete(QImageWriter* self); diff --git a/qt6/gen_qinputdevice.cpp b/qt6/gen_qinputdevice.cpp index 8fd3aa0c..6f7b602d 100644 --- a/qt6/gen_qinputdevice.cpp +++ b/qt6/gen_qinputdevice.cpp @@ -99,7 +99,7 @@ QRect* QInputDevice_AvailableVirtualGeometry(const QInputDevice* self) { return new QRect(self->availableVirtualGeometry()); } -struct miqt_array* QInputDevice_SeatNames() { +struct miqt_array QInputDevice_SeatNames() { QStringList _ret = QInputDevice::seatNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -113,22 +113,22 @@ struct miqt_array* QInputDevice_SeatNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QInputDevice_Devices() { +struct miqt_array QInputDevice_Devices() { QList _ret = QInputDevice::devices(); // Convert QList<> from C++ memory to manually-managed C memory QInputDevice** _arr = static_cast(malloc(sizeof(QInputDevice*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = (QInputDevice*) _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qinputdevice.go b/qt6/gen_qinputdevice.go index 420aafd9..fcbe9248 100644 --- a/qt6/gen_qinputdevice.go +++ b/qt6/gen_qinputdevice.go @@ -186,7 +186,7 @@ func (this *QInputDevice) AvailableVirtualGeometry() *QRect { } func QInputDevice_SeatNames() []string { - var _ma *C.struct_miqt_array = C.QInputDevice_SeatNames() + var _ma C.struct_miqt_array = C.QInputDevice_SeatNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -195,18 +195,16 @@ func QInputDevice_SeatNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QInputDevice_Devices() []*QInputDevice { - var _ma *C.struct_miqt_array = C.QInputDevice_Devices() + var _ma C.struct_miqt_array = C.QInputDevice_Devices() _ret := make([]*QInputDevice, int(_ma.len)) _outCast := (*[0xffff]*C.QInputDevice)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQInputDevice(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qinputdevice.h b/qt6/gen_qinputdevice.h index d25f15b5..6e2e7be1 100644 --- a/qt6/gen_qinputdevice.h +++ b/qt6/gen_qinputdevice.h @@ -40,8 +40,8 @@ bool QInputDevice_HasCapability(const QInputDevice* self, int cap); long long QInputDevice_SystemId(const QInputDevice* self); struct miqt_string QInputDevice_SeatName(const QInputDevice* self); QRect* QInputDevice_AvailableVirtualGeometry(const QInputDevice* self); -struct miqt_array* QInputDevice_SeatNames(); -struct miqt_array* QInputDevice_Devices(); +struct miqt_array QInputDevice_SeatNames(); +struct miqt_array QInputDevice_Devices(); QInputDevice* QInputDevice_PrimaryKeyboard(); bool QInputDevice_OperatorEqual(const QInputDevice* self, QInputDevice* other); void QInputDevice_AvailableVirtualGeometryChanged(QInputDevice* self, QRect* area); diff --git a/qt6/gen_qinputdialog.cpp b/qt6/gen_qinputdialog.cpp index 54528c8f..4d540420 100644 --- a/qt6/gen_qinputdialog.cpp +++ b/qt6/gen_qinputdialog.cpp @@ -116,18 +116,18 @@ bool QInputDialog_IsComboBoxEditable(const QInputDialog* self) { return self->isComboBoxEditable(); } -void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array* /* of struct miqt_string */ items) { +void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array /* of struct miqt_string */ items) { QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } self->setComboBoxItems(items_QList); } -struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self) { +struct miqt_array QInputDialog_ComboBoxItems(const QInputDialog* self) { QStringList _ret = self->comboBoxItems(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -141,9 +141,9 @@ struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -289,13 +289,13 @@ struct miqt_string QInputDialog_GetMultiLineText(QWidget* parent, struct miqt_st return _ms; } -struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items) { +struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -566,13 +566,13 @@ struct miqt_string QInputDialog_GetMultiLineText7(QWidget* parent, struct miqt_s return _ms; } -struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current) { +struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -586,13 +586,13 @@ struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable) { +struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -606,13 +606,13 @@ struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok) { +struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -626,13 +626,13 @@ struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags) { +struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } @@ -646,13 +646,13 @@ struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string tit return _ms; } -struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints) { +struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints) { QString title_QString = QString::fromUtf8(title.data, title.len); QString label_QString = QString::fromUtf8(label.data, label.len); QStringList items_QList; - items_QList.reserve(items->len); - struct miqt_string* items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + struct miqt_string* items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { QString items_arr_i_QString = QString::fromUtf8(items_arr[i].data, items_arr[i].len); items_QList.push_back(items_arr_i_QString); } diff --git a/qt6/gen_qinputdialog.go b/qt6/gen_qinputdialog.go index e8bb3748..fb19af98 100644 --- a/qt6/gen_qinputdialog.go +++ b/qt6/gen_qinputdialog.go @@ -168,7 +168,6 @@ func (this *QInputDialog) IsComboBoxEditable() bool { } func (this *QInputDialog) SetComboBoxItems(items []string) { - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -178,13 +177,12 @@ func (this *QInputDialog) SetComboBoxItems(items []string) { defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QInputDialog_SetComboBoxItems(this.h, items_ma) } func (this *QInputDialog) ComboBoxItems() []string { - var _ma *C.struct_miqt_array = C.QInputDialog_ComboBoxItems(this.h) + var _ma C.struct_miqt_array = C.QInputDialog_ComboBoxItems(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -193,7 +191,6 @@ func (this *QInputDialog) ComboBoxItems() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -356,7 +353,6 @@ func QInputDialog_GetItem(parent *QWidget, title string, label string, items []s label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -366,8 +362,7 @@ func QInputDialog_GetItem(parent *QWidget, title string, label string, items []s defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem(parent.cPointer(), title_ms, label_ms, items_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -746,7 +741,6 @@ func QInputDialog_GetItem5(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -756,8 +750,7 @@ func QInputDialog_GetItem5(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem5(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -773,7 +766,6 @@ func QInputDialog_GetItem6(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -783,8 +775,7 @@ func QInputDialog_GetItem6(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem6(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -800,7 +791,6 @@ func QInputDialog_GetItem7(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -810,8 +800,7 @@ func QInputDialog_GetItem7(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem7(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok))) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -827,7 +816,6 @@ func QInputDialog_GetItem8(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -837,8 +825,7 @@ func QInputDialog_GetItem8(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem8(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok)), (C.int)(flags)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -854,7 +841,6 @@ func QInputDialog_GetItem9(parent *QWidget, title string, label string, items [] label_ms.data = C.CString(label) label_ms.len = C.size_t(len(label)) defer C.free(unsafe.Pointer(label_ms.data)) - // For the C ABI, malloc a C array of structs items_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { @@ -864,8 +850,7 @@ func QInputDialog_GetItem9(parent *QWidget, title string, label string, items [] defer C.free(unsafe.Pointer(items_i_ms.data)) items_CArray[i] = items_i_ms } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} var _ms C.struct_miqt_string = C.QInputDialog_GetItem9(parent.cPointer(), title_ms, label_ms, items_ma, (C.int)(current), (C.bool)(editable), (*C.bool)(unsafe.Pointer(ok)), (C.int)(flags), (C.int)(inputMethodHints)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt6/gen_qinputdialog.h b/qt6/gen_qinputdialog.h index de8b83f9..fe3fd6c5 100644 --- a/qt6/gen_qinputdialog.h +++ b/qt6/gen_qinputdialog.h @@ -45,8 +45,8 @@ void QInputDialog_SetTextEchoMode(QInputDialog* self, int mode); int QInputDialog_TextEchoMode(const QInputDialog* self); void QInputDialog_SetComboBoxEditable(QInputDialog* self, bool editable); bool QInputDialog_IsComboBoxEditable(const QInputDialog* self); -void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array* /* of struct miqt_string */ items); -struct miqt_array* QInputDialog_ComboBoxItems(const QInputDialog* self); +void QInputDialog_SetComboBoxItems(QInputDialog* self, struct miqt_array /* of struct miqt_string */ items); +struct miqt_array QInputDialog_ComboBoxItems(const QInputDialog* self); void QInputDialog_SetIntValue(QInputDialog* self, int value); int QInputDialog_IntValue(const QInputDialog* self); void QInputDialog_SetIntMinimum(QInputDialog* self, int min); @@ -74,7 +74,7 @@ QSize* QInputDialog_SizeHint(const QInputDialog* self); void QInputDialog_SetVisible(QInputDialog* self, bool visible); struct miqt_string QInputDialog_GetText(QWidget* parent, struct miqt_string title, struct miqt_string label); struct miqt_string QInputDialog_GetMultiLineText(QWidget* parent, struct miqt_string title, struct miqt_string label); -struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items); +struct miqt_string QInputDialog_GetItem(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items); int QInputDialog_GetInt(QWidget* parent, struct miqt_string title, struct miqt_string label); double QInputDialog_GetDouble(QWidget* parent, struct miqt_string title, struct miqt_string label); void QInputDialog_SetDoubleStep(QInputDialog* self, double step); @@ -104,11 +104,11 @@ struct miqt_string QInputDialog_GetMultiLineText4(QWidget* parent, struct miqt_s struct miqt_string QInputDialog_GetMultiLineText5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok); struct miqt_string QInputDialog_GetMultiLineText6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok, int flags); struct miqt_string QInputDialog_GetMultiLineText7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_string text, bool* ok, int flags, int inputMethodHints); -struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current); -struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable); -struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok); -struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags); -struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array* /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints); +struct miqt_string QInputDialog_GetItem5(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current); +struct miqt_string QInputDialog_GetItem6(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable); +struct miqt_string QInputDialog_GetItem7(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok); +struct miqt_string QInputDialog_GetItem8(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags); +struct miqt_string QInputDialog_GetItem9(QWidget* parent, struct miqt_string title, struct miqt_string label, struct miqt_array /* of struct miqt_string */ items, int current, bool editable, bool* ok, int flags, int inputMethodHints); int QInputDialog_GetInt4(QWidget* parent, struct miqt_string title, struct miqt_string label, int value); int QInputDialog_GetInt5(QWidget* parent, struct miqt_string title, struct miqt_string label, int value, int minValue); int QInputDialog_GetInt6(QWidget* parent, struct miqt_string title, struct miqt_string label, int value, int minValue, int maxValue); diff --git a/qt6/gen_qitemselectionmodel.cpp b/qt6/gen_qitemselectionmodel.cpp index c3b65db4..ac119d34 100644 --- a/qt6/gen_qitemselectionmodel.cpp +++ b/qt6/gen_qitemselectionmodel.cpp @@ -109,16 +109,16 @@ bool QItemSelectionRange_IsEmpty(const QItemSelectionRange* self) { return self->isEmpty(); } -struct miqt_array* QItemSelectionRange_Indexes(const QItemSelectionRange* self) { +struct miqt_array QItemSelectionRange_Indexes(const QItemSelectionRange* self) { QModelIndexList _ret = self->indexes(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -185,42 +185,42 @@ bool QItemSelectionModel_HasSelection(const QItemSelectionModel* self) { return self->hasSelection(); } -struct miqt_array* QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedIndexes(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedRows(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedRows(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedRows(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self) { +struct miqt_array QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self) { QModelIndexList _ret = self->selectedColumns(); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -357,29 +357,29 @@ bool QItemSelectionModel_ColumnIntersectsSelection2(const QItemSelectionModel* s return self->columnIntersectsSelection(static_cast(column), *parent); } -struct miqt_array* QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column) { +struct miqt_array QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column) { QModelIndexList _ret = self->selectedRows(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row) { +struct miqt_array QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row) { QModelIndexList _ret = self->selectedColumns(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qitemselectionmodel.go b/qt6/gen_qitemselectionmodel.go index 06cf3f2b..70c4d188 100644 --- a/qt6/gen_qitemselectionmodel.go +++ b/qt6/gen_qitemselectionmodel.go @@ -166,7 +166,7 @@ func (this *QItemSelectionRange) IsEmpty() bool { } func (this *QItemSelectionRange) Indexes() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionRange_Indexes(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionRange_Indexes(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -175,7 +175,6 @@ func (this *QItemSelectionRange) Indexes() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -292,7 +291,7 @@ func (this *QItemSelectionModel) HasSelection() bool { } func (this *QItemSelectionModel) SelectedIndexes() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedIndexes(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedIndexes(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -301,12 +300,11 @@ func (this *QItemSelectionModel) SelectedIndexes() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedRows() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedRows(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedRows(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -315,12 +313,11 @@ func (this *QItemSelectionModel) SelectedRows() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedColumns() []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns(this.h) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns(this.h) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -329,7 +326,6 @@ func (this *QItemSelectionModel) SelectedColumns() []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -491,7 +487,7 @@ func (this *QItemSelectionModel) ColumnIntersectsSelection2(column int, parent * } func (this *QItemSelectionModel) SelectedRows1(column int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedRows1(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedRows1(this.h, (C.int)(column)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -500,12 +496,11 @@ func (this *QItemSelectionModel) SelectedRows1(column int) []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QItemSelectionModel) SelectedColumns1(row int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns1(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QItemSelectionModel_SelectedColumns1(this.h, (C.int)(row)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -514,7 +509,6 @@ func (this *QItemSelectionModel) SelectedColumns1(row int) []QModelIndex { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qitemselectionmodel.h b/qt6/gen_qitemselectionmodel.h index 02b2b252..c5835754 100644 --- a/qt6/gen_qitemselectionmodel.h +++ b/qt6/gen_qitemselectionmodel.h @@ -54,7 +54,7 @@ bool QItemSelectionRange_OperatorEqual(const QItemSelectionRange* self, QItemSel bool QItemSelectionRange_OperatorNotEqual(const QItemSelectionRange* self, QItemSelectionRange* other); bool QItemSelectionRange_IsValid(const QItemSelectionRange* self); bool QItemSelectionRange_IsEmpty(const QItemSelectionRange* self); -struct miqt_array* QItemSelectionRange_Indexes(const QItemSelectionRange* self); +struct miqt_array QItemSelectionRange_Indexes(const QItemSelectionRange* self); void QItemSelectionRange_Delete(QItemSelectionRange* self); QItemSelectionModel* QItemSelectionModel_new(); @@ -70,9 +70,9 @@ bool QItemSelectionModel_IsColumnSelected(const QItemSelectionModel* self, int c bool QItemSelectionModel_RowIntersectsSelection(const QItemSelectionModel* self, int row); bool QItemSelectionModel_ColumnIntersectsSelection(const QItemSelectionModel* self, int column); bool QItemSelectionModel_HasSelection(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedRows(const QItemSelectionModel* self); -struct miqt_array* QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedIndexes(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedRows(const QItemSelectionModel* self); +struct miqt_array QItemSelectionModel_SelectedColumns(const QItemSelectionModel* self); QAbstractItemModel* QItemSelectionModel_Model(const QItemSelectionModel* self); QAbstractItemModel* QItemSelectionModel_Model2(QItemSelectionModel* self); void QItemSelectionModel_SetModel(QItemSelectionModel* self, QAbstractItemModel* model); @@ -96,8 +96,8 @@ bool QItemSelectionModel_IsRowSelected2(const QItemSelectionModel* self, int row bool QItemSelectionModel_IsColumnSelected2(const QItemSelectionModel* self, int column, QModelIndex* parent); bool QItemSelectionModel_RowIntersectsSelection2(const QItemSelectionModel* self, int row, QModelIndex* parent); bool QItemSelectionModel_ColumnIntersectsSelection2(const QItemSelectionModel* self, int column, QModelIndex* parent); -struct miqt_array* QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column); -struct miqt_array* QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row); +struct miqt_array QItemSelectionModel_SelectedRows1(const QItemSelectionModel* self, int column); +struct miqt_array QItemSelectionModel_SelectedColumns1(const QItemSelectionModel* self, int row); void QItemSelectionModel_Delete(QItemSelectionModel* self); #ifdef __cplusplus diff --git a/qt6/gen_qjsonarray.cpp b/qt6/gen_qjsonarray.cpp index b2a0bb70..b08ed31b 100644 --- a/qt6/gen_qjsonarray.cpp +++ b/qt6/gen_qjsonarray.cpp @@ -24,11 +24,11 @@ void QJsonArray_OperatorAssign(QJsonArray* self, QJsonArray* other) { self->operator=(*other); } -QJsonArray* QJsonArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list) { +QJsonArray* QJsonArray_FromStringList(struct miqt_array /* of struct miqt_string */ list) { QStringList list_QList; - list_QList.reserve(list->len); - struct miqt_string* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + struct miqt_string* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len); list_QList.push_back(list_arr_i_QString); } diff --git a/qt6/gen_qjsonarray.go b/qt6/gen_qjsonarray.go index 9079ad80..9fa30f5c 100644 --- a/qt6/gen_qjsonarray.go +++ b/qt6/gen_qjsonarray.go @@ -59,7 +59,6 @@ func (this *QJsonArray) OperatorAssign(other *QJsonArray) { } func QJsonArray_FromStringList(list []string) *QJsonArray { - // For the C ABI, malloc a C array of structs list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { @@ -69,8 +68,7 @@ func QJsonArray_FromStringList(list []string) *QJsonArray { defer C.free(unsafe.Pointer(list_i_ms.data)) list_CArray[i] = list_i_ms } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} _ret := C.QJsonArray_FromStringList(list_ma) _goptr := newQJsonArray(_ret) _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer diff --git a/qt6/gen_qjsonarray.h b/qt6/gen_qjsonarray.h index aad59d42..7716fead 100644 --- a/qt6/gen_qjsonarray.h +++ b/qt6/gen_qjsonarray.h @@ -40,7 +40,7 @@ typedef struct QJsonValueRef QJsonValueRef; QJsonArray* QJsonArray_new(); QJsonArray* QJsonArray_new2(QJsonArray* other); void QJsonArray_OperatorAssign(QJsonArray* self, QJsonArray* other); -QJsonArray* QJsonArray_FromStringList(struct miqt_array* /* of struct miqt_string */ list); +QJsonArray* QJsonArray_FromStringList(struct miqt_array /* of struct miqt_string */ list); ptrdiff_t QJsonArray_Size(const QJsonArray* self); ptrdiff_t QJsonArray_Count(const QJsonArray* self); bool QJsonArray_IsEmpty(const QJsonArray* self); diff --git a/qt6/gen_qjsonobject.cpp b/qt6/gen_qjsonobject.cpp index 7df5652f..5244a915 100644 --- a/qt6/gen_qjsonobject.cpp +++ b/qt6/gen_qjsonobject.cpp @@ -5,9 +5,11 @@ #include #include #include +#include #include #include #include +#include #include #include "gen_qjsonobject.h" #include "_cgo_export.h" @@ -28,7 +30,80 @@ void QJsonObject_Swap(QJsonObject* self, QJsonObject* other) { self->swap(*other); } -struct miqt_array* QJsonObject_Keys(const QJsonObject* self) { +QJsonObject* QJsonObject_FromVariantMap(struct miqt_map mapVal) { + QVariantMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QJsonObject(QJsonObject::fromVariantMap(mapVal_QMap)); +} + +struct miqt_map QJsonObject_ToVariantMap(const QJsonObject* self) { + QVariantMap _ret = self->toVariantMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +QJsonObject* QJsonObject_FromVariantHash(struct miqt_map mapVal) { + QVariantHash mapVal_QMap; + mapVal_QMap.reserve(mapVal.len); + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QJsonObject(QJsonObject::fromVariantHash(mapVal_QMap)); +} + +struct miqt_map QJsonObject_ToVariantHash(const QJsonObject* self) { + QVariantHash _ret = self->toVariantHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_array QJsonObject_Keys(const QJsonObject* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -42,9 +117,9 @@ struct miqt_array* QJsonObject_Keys(const QJsonObject* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qjsonobject.go b/qt6/gen_qjsonobject.go index 91e9f1c1..a66a10e0 100644 --- a/qt6/gen_qjsonobject.go +++ b/qt6/gen_qjsonobject.go @@ -62,8 +62,100 @@ func (this *QJsonObject) Swap(other *QJsonObject) { C.QJsonObject_Swap(this.h, other.cPointer()) } +func QJsonObject_FromVariantMap(mapVal map[string]QVariant) *QJsonObject { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QJsonObject_FromVariantMap(mapVal_mm) + _goptr := newQJsonObject(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func (this *QJsonObject) ToVariantMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QJsonObject_ToVariantMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func QJsonObject_FromVariantHash(mapVal map[string]QVariant) *QJsonObject { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + _ret := C.QJsonObject_FromVariantHash(mapVal_mm) + _goptr := newQJsonObject(_ret) + _goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + return _goptr +} + +func (this *QJsonObject) ToVariantHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QJsonObject_ToVariantHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QJsonObject) Keys() []string { - var _ma *C.struct_miqt_array = C.QJsonObject_Keys(this.h) + var _ma C.struct_miqt_array = C.QJsonObject_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -72,7 +164,6 @@ func (this *QJsonObject) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qjsonobject.h b/qt6/gen_qjsonobject.h index 48e6ef06..2b96e8b4 100644 --- a/qt6/gen_qjsonobject.h +++ b/qt6/gen_qjsonobject.h @@ -28,6 +28,7 @@ class QJsonObject__iterator; class QJsonValue; class QJsonValueConstRef; class QJsonValueRef; +class QVariant; #else typedef struct QJsonObject QJsonObject; typedef struct QJsonObject__const_iterator QJsonObject__const_iterator; @@ -35,13 +36,18 @@ typedef struct QJsonObject__iterator QJsonObject__iterator; typedef struct QJsonValue QJsonValue; typedef struct QJsonValueConstRef QJsonValueConstRef; typedef struct QJsonValueRef QJsonValueRef; +typedef struct QVariant QVariant; #endif QJsonObject* QJsonObject_new(); QJsonObject* QJsonObject_new2(QJsonObject* other); void QJsonObject_OperatorAssign(QJsonObject* self, QJsonObject* other); void QJsonObject_Swap(QJsonObject* self, QJsonObject* other); -struct miqt_array* QJsonObject_Keys(const QJsonObject* self); +QJsonObject* QJsonObject_FromVariantMap(struct miqt_map mapVal); +struct miqt_map QJsonObject_ToVariantMap(const QJsonObject* self); +QJsonObject* QJsonObject_FromVariantHash(struct miqt_map mapVal); +struct miqt_map QJsonObject_ToVariantHash(const QJsonObject* self); +struct miqt_array QJsonObject_Keys(const QJsonObject* self); ptrdiff_t QJsonObject_Size(const QJsonObject* self); ptrdiff_t QJsonObject_Count(const QJsonObject* self); ptrdiff_t QJsonObject_Length(const QJsonObject* self); diff --git a/qt6/gen_qkeysequence.cpp b/qt6/gen_qkeysequence.cpp index 95826c9b..c7ef86d1 100644 --- a/qt6/gen_qkeysequence.cpp +++ b/qt6/gen_qkeysequence.cpp @@ -86,7 +86,7 @@ QKeySequence* QKeySequence_FromString(struct miqt_string str) { return new QKeySequence(QKeySequence::fromString(str_QString)); } -struct miqt_array* QKeySequence_ListFromString(struct miqt_string str) { +struct miqt_array QKeySequence_ListFromString(struct miqt_string str) { QString str_QString = QString::fromUtf8(str.data, str.len); QList _ret = QKeySequence::listFromString(str_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -94,17 +94,17 @@ struct miqt_array* QKeySequence_ListFromString(struct miqt_string str) { for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QKeySequence_ListToString(struct miqt_array* /* of QKeySequence* */ list) { +struct miqt_string QKeySequence_ListToString(struct miqt_array /* of QKeySequence* */ list) { QList list_QList; - list_QList.reserve(list->len); - QKeySequence** list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + QKeySequence** list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(*(list_arr[i])); } QString _ret = QKeySequence::listToString(list_QList); @@ -127,16 +127,16 @@ QKeySequence* QKeySequence_Mnemonic(struct miqt_string text) { return new QKeySequence(QKeySequence::mnemonic(text_QString)); } -struct miqt_array* QKeySequence_KeyBindings(int key) { +struct miqt_array QKeySequence_KeyBindings(int key) { QList _ret = QKeySequence::keyBindings(static_cast(key)); // Convert QList<> from C++ memory to manually-managed C memory QKeySequence** _arr = static_cast(malloc(sizeof(QKeySequence*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -196,7 +196,7 @@ QKeySequence* QKeySequence_FromString2(struct miqt_string str, int format) { return new QKeySequence(QKeySequence::fromString(str_QString, static_cast(format))); } -struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int format) { +struct miqt_array QKeySequence_ListFromString2(struct miqt_string str, int format) { QString str_QString = QString::fromUtf8(str.data, str.len); QList _ret = QKeySequence::listFromString(str_QString, static_cast(format)); // Convert QList<> from C++ memory to manually-managed C memory @@ -204,17 +204,17 @@ struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int form for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QKeySequence_ListToString2(struct miqt_array* /* of QKeySequence* */ list, int format) { +struct miqt_string QKeySequence_ListToString2(struct miqt_array /* of QKeySequence* */ list, int format) { QList list_QList; - list_QList.reserve(list->len); - QKeySequence** list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + QKeySequence** list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(*(list_arr[i])); } QString _ret = QKeySequence::listToString(list_QList, static_cast(format)); diff --git a/qt6/gen_qkeysequence.go b/qt6/gen_qkeysequence.go index 64882915..7f68746e 100644 --- a/qt6/gen_qkeysequence.go +++ b/qt6/gen_qkeysequence.go @@ -250,7 +250,7 @@ func QKeySequence_ListFromString(str string) []QKeySequence { str_ms.data = C.CString(str) str_ms.len = C.size_t(len(str)) defer C.free(unsafe.Pointer(str_ms.data)) - var _ma *C.struct_miqt_array = C.QKeySequence_ListFromString(str_ms) + var _ma C.struct_miqt_array = C.QKeySequence_ListFromString(str_ms) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -259,19 +259,16 @@ func QKeySequence_ListFromString(str string) []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QKeySequence_ListToString(list []QKeySequence) string { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = list[i].cPointer() } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} var _ms C.struct_miqt_string = C.QKeySequence_ListToString(list_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) @@ -294,7 +291,7 @@ func QKeySequence_Mnemonic(text string) *QKeySequence { } func QKeySequence_KeyBindings(key QKeySequence__StandardKey) []QKeySequence { - var _ma *C.struct_miqt_array = C.QKeySequence_KeyBindings((C.int)(key)) + var _ma C.struct_miqt_array = C.QKeySequence_KeyBindings((C.int)(key)) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -303,7 +300,6 @@ func QKeySequence_KeyBindings(key QKeySequence__StandardKey) []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -373,7 +369,7 @@ func QKeySequence_ListFromString2(str string, format QKeySequence__SequenceForma str_ms.data = C.CString(str) str_ms.len = C.size_t(len(str)) defer C.free(unsafe.Pointer(str_ms.data)) - var _ma *C.struct_miqt_array = C.QKeySequence_ListFromString2(str_ms, (C.int)(format)) + var _ma C.struct_miqt_array = C.QKeySequence_ListFromString2(str_ms, (C.int)(format)) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -382,19 +378,16 @@ func QKeySequence_ListFromString2(str string, format QKeySequence__SequenceForma _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QKeySequence_ListToString2(list []QKeySequence, format QKeySequence__SequenceFormat) string { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = list[i].cPointer() } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} var _ms C.struct_miqt_string = C.QKeySequence_ListToString2(list_ma, (C.int)(format)) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt6/gen_qkeysequence.h b/qt6/gen_qkeysequence.h index 3eace6f9..94f8b85c 100644 --- a/qt6/gen_qkeysequence.h +++ b/qt6/gen_qkeysequence.h @@ -38,11 +38,11 @@ int QKeySequence_Count(const QKeySequence* self); bool QKeySequence_IsEmpty(const QKeySequence* self); struct miqt_string QKeySequence_ToString(const QKeySequence* self); QKeySequence* QKeySequence_FromString(struct miqt_string str); -struct miqt_array* QKeySequence_ListFromString(struct miqt_string str); -struct miqt_string QKeySequence_ListToString(struct miqt_array* /* of QKeySequence* */ list); +struct miqt_array QKeySequence_ListFromString(struct miqt_string str); +struct miqt_string QKeySequence_ListToString(struct miqt_array /* of QKeySequence* */ list); int QKeySequence_Matches(const QKeySequence* self, QKeySequence* seq); QKeySequence* QKeySequence_Mnemonic(struct miqt_string text); -struct miqt_array* QKeySequence_KeyBindings(int key); +struct miqt_array QKeySequence_KeyBindings(int key); QKeyCombination* QKeySequence_OperatorSubscript(const QKeySequence* self, unsigned int i); void QKeySequence_OperatorAssign(QKeySequence* self, QKeySequence* other); void QKeySequence_Swap(QKeySequence* self, QKeySequence* other); @@ -55,8 +55,8 @@ bool QKeySequence_OperatorGreaterOrEqual(const QKeySequence* self, QKeySequence* bool QKeySequence_IsDetached(const QKeySequence* self); struct miqt_string QKeySequence_ToString1(const QKeySequence* self, int format); QKeySequence* QKeySequence_FromString2(struct miqt_string str, int format); -struct miqt_array* QKeySequence_ListFromString2(struct miqt_string str, int format); -struct miqt_string QKeySequence_ListToString2(struct miqt_array* /* of QKeySequence* */ list, int format); +struct miqt_array QKeySequence_ListFromString2(struct miqt_string str, int format); +struct miqt_string QKeySequence_ListToString2(struct miqt_array /* of QKeySequence* */ list, int format); void QKeySequence_Delete(QKeySequence* self); #ifdef __cplusplus diff --git a/qt6/gen_qlibraryinfo.cpp b/qt6/gen_qlibraryinfo.cpp index 109fa48e..d53b9204 100644 --- a/qt6/gen_qlibraryinfo.cpp +++ b/qt6/gen_qlibraryinfo.cpp @@ -42,7 +42,7 @@ struct miqt_string QLibraryInfo_Location(int location) { return _ms; } -struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName) { +struct miqt_array QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName) { QString platformName_QString = QString::fromUtf8(platformName.data, platformName.len); QStringList _ret = QLibraryInfo::platformPluginArguments(platformName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -57,9 +57,9 @@ struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platf memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qlibraryinfo.go b/qt6/gen_qlibraryinfo.go index bb448c47..ee0f3e48 100644 --- a/qt6/gen_qlibraryinfo.go +++ b/qt6/gen_qlibraryinfo.go @@ -97,7 +97,7 @@ func QLibraryInfo_PlatformPluginArguments(platformName string) []string { platformName_ms.data = C.CString(platformName) platformName_ms.len = C.size_t(len(platformName)) defer C.free(unsafe.Pointer(platformName_ms.data)) - var _ma *C.struct_miqt_array = C.QLibraryInfo_PlatformPluginArguments(platformName_ms) + var _ma C.struct_miqt_array = C.QLibraryInfo_PlatformPluginArguments(platformName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -106,7 +106,6 @@ func QLibraryInfo_PlatformPluginArguments(platformName string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qlibraryinfo.h b/qt6/gen_qlibraryinfo.h index 79fb448e..4f8b600f 100644 --- a/qt6/gen_qlibraryinfo.h +++ b/qt6/gen_qlibraryinfo.h @@ -26,7 +26,7 @@ bool QLibraryInfo_IsDebugBuild(); QVersionNumber* QLibraryInfo_Version(); struct miqt_string QLibraryInfo_Path(int p); struct miqt_string QLibraryInfo_Location(int location); -struct miqt_array* QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName); +struct miqt_array QLibraryInfo_PlatformPluginArguments(struct miqt_string platformName); void QLibraryInfo_Delete(QLibraryInfo* self); #ifdef __cplusplus diff --git a/qt6/gen_qlistview.cpp b/qt6/gen_qlistview.cpp index a1cce36f..f096783f 100644 --- a/qt6/gen_qlistview.cpp +++ b/qt6/gen_qlistview.cpp @@ -194,11 +194,11 @@ void QListView_SetRootIndex(QListView* self, QModelIndex* index) { self->setRootIndex(*index); } -void QListView_IndexesMoved(QListView* self, struct miqt_array* /* of QModelIndex* */ indexes) { +void QListView_IndexesMoved(QListView* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } self->indexesMoved(indexes_QList); @@ -212,10 +212,10 @@ void QListView_connect_IndexesMoved(QListView* self, intptr_t slot) { for (size_t i = 0, e = indexes_ret.length(); i < e; ++i) { indexes_arr[i] = new QModelIndex(indexes_ret[i]); } - struct miqt_array* indexes_out = static_cast(malloc(sizeof(struct miqt_array))); - indexes_out->len = indexes_ret.length(); - indexes_out->data = static_cast(indexes_arr); - struct miqt_array* sigval1 = indexes_out; + struct miqt_array indexes_out; + indexes_out.len = indexes_ret.length(); + indexes_out.data = static_cast(indexes_arr); + struct miqt_array sigval1 = indexes_out; miqt_exec_callback_QListView_IndexesMoved(slot, sigval1); }); } diff --git a/qt6/gen_qlistview.go b/qt6/gen_qlistview.go index edaa6905..11b23572 100644 --- a/qt6/gen_qlistview.go +++ b/qt6/gen_qlistview.go @@ -269,14 +269,12 @@ func (this *QListView) SetRootIndex(index *QModelIndex) { } func (this *QListView) IndexesMoved(indexes []QModelIndex) { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} C.QListView_IndexesMoved(this.h, indexes_ma) } func (this *QListView) OnIndexesMoved(slot func(indexes []QModelIndex)) { @@ -284,14 +282,14 @@ func (this *QListView) OnIndexesMoved(slot func(indexes []QModelIndex)) { } //export miqt_exec_callback_QListView_IndexesMoved -func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes *C.struct_miqt_array) { +func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes C.struct_miqt_array) { gofunc, ok := cgo.Handle(cb).Value().(func(indexes []QModelIndex)) if !ok { panic("miqt: callback of non-callback type (heap corruption?)") } // Convert all CABI parameters to Go parameters - var indexes_ma *C.struct_miqt_array = indexes + var indexes_ma C.struct_miqt_array = indexes indexes_ret := make([]QModelIndex, int(indexes_ma.len)) indexes_outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(indexes_ma.data)) // hey ya for i := 0; i < int(indexes_ma.len); i++ { @@ -300,7 +298,6 @@ func miqt_exec_callback_QListView_IndexesMoved(cb C.intptr_t, indexes *C.struct_ indexes_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer indexes_ret[i] = *indexes_lv_goptr } - C.free(unsafe.Pointer(indexes_ma)) slotval1 := indexes_ret gofunc(slotval1) diff --git a/qt6/gen_qlistview.h b/qt6/gen_qlistview.h index 7695776d..b53e2354 100644 --- a/qt6/gen_qlistview.h +++ b/qt6/gen_qlistview.h @@ -73,7 +73,7 @@ QModelIndex* QListView_IndexAt(const QListView* self, QPoint* p); void QListView_DoItemsLayout(QListView* self); void QListView_Reset(QListView* self); void QListView_SetRootIndex(QListView* self, QModelIndex* index); -void QListView_IndexesMoved(QListView* self, struct miqt_array* /* of QModelIndex* */ indexes); +void QListView_IndexesMoved(QListView* self, struct miqt_array /* of QModelIndex* */ indexes); void QListView_connect_IndexesMoved(QListView* self, intptr_t slot); struct miqt_string QListView_Tr2(const char* s, const char* c); struct miqt_string QListView_Tr3(const char* s, const char* c, int n); diff --git a/qt6/gen_qlistwidget.cpp b/qt6/gen_qlistwidget.cpp index 7a2d3cc6..0ac9bb24 100644 --- a/qt6/gen_qlistwidget.cpp +++ b/qt6/gen_qlistwidget.cpp @@ -309,11 +309,11 @@ void QListWidget_InsertItem2(QListWidget* self, int row, struct miqt_string labe self->insertItem(static_cast(row), label_QString); } -void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array* /* of struct miqt_string */ labels) { +void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -329,11 +329,11 @@ void QListWidget_AddItemWithItem(QListWidget* self, QListWidgetItem* item) { self->addItem(item); } -void QListWidget_AddItems(QListWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QListWidget_AddItems(QListWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -424,20 +424,20 @@ void QListWidget_RemoveItemWidget(QListWidget* self, QListWidgetItem* item) { self->removeItemWidget(item); } -struct miqt_array* QListWidget_SelectedItems(const QListWidget* self) { +struct miqt_array QListWidget_SelectedItems(const QListWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QListWidgetItem** _arr = static_cast(malloc(sizeof(QListWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags) { +struct miqt_array QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -445,22 +445,22 @@ struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QListWidget_Items(const QListWidget* self, QMimeData* data) { +struct miqt_array QListWidget_Items(const QListWidget* self, QMimeData* data) { QList _ret = self->items(data); // Convert QList<> from C++ memory to manually-managed C memory QListWidgetItem** _arr = static_cast(malloc(sizeof(QListWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qlistwidget.go b/qt6/gen_qlistwidget.go index 8a7b9f25..d0abc9a3 100644 --- a/qt6/gen_qlistwidget.go +++ b/qt6/gen_qlistwidget.go @@ -436,7 +436,6 @@ func (this *QListWidget) InsertItem2(row int, label string) { } func (this *QListWidget) InsertItems(row int, labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -446,8 +445,7 @@ func (this *QListWidget) InsertItems(row int, labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QListWidget_InsertItems(this.h, (C.int)(row), labels_ma) } @@ -464,7 +462,6 @@ func (this *QListWidget) AddItemWithItem(item *QListWidgetItem) { } func (this *QListWidget) AddItems(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -474,8 +471,7 @@ func (this *QListWidget) AddItems(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QListWidget_AddItems(this.h, labels_ma) } @@ -567,13 +563,12 @@ func (this *QListWidget) RemoveItemWidget(item *QListWidgetItem) { } func (this *QListWidget) SelectedItems() []*QListWidgetItem { - var _ma *C.struct_miqt_array = C.QListWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QListWidget_SelectedItems(this.h) _ret := make([]*QListWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QListWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQListWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -582,24 +577,22 @@ func (this *QListWidget) FindItems(text string, flags MatchFlag) []*QListWidgetI text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QListWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QListWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QListWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QListWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQListWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QListWidget) Items(data *QMimeData) []*QListWidgetItem { - var _ma *C.struct_miqt_array = C.QListWidget_Items(this.h, data.cPointer()) + var _ma C.struct_miqt_array = C.QListWidget_Items(this.h, data.cPointer()) _ret := make([]*QListWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QListWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQListWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qlistwidget.h b/qt6/gen_qlistwidget.h index aae2548f..745ad6c8 100644 --- a/qt6/gen_qlistwidget.h +++ b/qt6/gen_qlistwidget.h @@ -108,10 +108,10 @@ QListWidgetItem* QListWidget_Item(const QListWidget* self, int row); int QListWidget_Row(const QListWidget* self, QListWidgetItem* item); void QListWidget_InsertItem(QListWidget* self, int row, QListWidgetItem* item); void QListWidget_InsertItem2(QListWidget* self, int row, struct miqt_string label); -void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array* /* of struct miqt_string */ labels); +void QListWidget_InsertItems(QListWidget* self, int row, struct miqt_array /* of struct miqt_string */ labels); void QListWidget_AddItem(QListWidget* self, struct miqt_string label); void QListWidget_AddItemWithItem(QListWidget* self, QListWidgetItem* item); -void QListWidget_AddItems(QListWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QListWidget_AddItems(QListWidget* self, struct miqt_array /* of struct miqt_string */ labels); QListWidgetItem* QListWidget_TakeItem(QListWidget* self, int row); int QListWidget_Count(const QListWidget* self); QListWidgetItem* QListWidget_CurrentItem(const QListWidget* self); @@ -133,9 +133,9 @@ bool QListWidget_IsPersistentEditorOpen(const QListWidget* self, QListWidgetItem QWidget* QListWidget_ItemWidget(const QListWidget* self, QListWidgetItem* item); void QListWidget_SetItemWidget(QListWidget* self, QListWidgetItem* item, QWidget* widget); void QListWidget_RemoveItemWidget(QListWidget* self, QListWidgetItem* item); -struct miqt_array* QListWidget_SelectedItems(const QListWidget* self); -struct miqt_array* QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags); -struct miqt_array* QListWidget_Items(const QListWidget* self, QMimeData* data); +struct miqt_array QListWidget_SelectedItems(const QListWidget* self); +struct miqt_array QListWidget_FindItems(const QListWidget* self, struct miqt_string text, int flags); +struct miqt_array QListWidget_Items(const QListWidget* self, QMimeData* data); QModelIndex* QListWidget_IndexFromItem(const QListWidget* self, QListWidgetItem* item); QListWidgetItem* QListWidget_ItemFromIndex(const QListWidget* self, QModelIndex* index); void QListWidget_ScrollToItem(QListWidget* self, QListWidgetItem* item); diff --git a/qt6/gen_qlocale.cpp b/qt6/gen_qlocale.cpp index f6c3708f..92fbf2fd 100644 --- a/qt6/gen_qlocale.cpp +++ b/qt6/gen_qlocale.cpp @@ -593,7 +593,7 @@ int QLocale_FirstDayOfWeek(const QLocale* self) { return static_cast(_ret); } -struct miqt_array* QLocale_Weekdays(const QLocale* self) { +struct miqt_array QLocale_Weekdays(const QLocale* self) { QList _ret = self->weekdays(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -601,9 +601,9 @@ struct miqt_array* QLocale_Weekdays(const QLocale* self) { Qt::DayOfWeek _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -777,7 +777,7 @@ struct miqt_string QLocale_FormattedDataSize(const QLocale* self, long long byte return _ms; } -struct miqt_array* QLocale_UiLanguages(const QLocale* self) { +struct miqt_array QLocale_UiLanguages(const QLocale* self) { QStringList _ret = self->uiLanguages(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -791,9 +791,9 @@ struct miqt_array* QLocale_UiLanguages(const QLocale* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -897,20 +897,20 @@ QLocale* QLocale_System() { return new QLocale(QLocale::system()); } -struct miqt_array* QLocale_MatchingLocales(uint16_t language, uint16_t script, uint16_t territory) { +struct miqt_array QLocale_MatchingLocales(uint16_t language, uint16_t script, uint16_t territory) { QList _ret = QLocale::matchingLocales(static_cast(language), static_cast(script), static_cast(territory)); // Convert QList<> from C++ memory to manually-managed C memory QLocale** _arr = static_cast(malloc(sizeof(QLocale*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QLocale(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QLocale_CountriesForLanguage(uint16_t lang) { +struct miqt_array QLocale_CountriesForLanguage(uint16_t lang) { QList _ret = QLocale::countriesForLanguage(static_cast(lang)); // Convert QList<> from C++ memory to manually-managed C memory uint16_t* _arr = static_cast(malloc(sizeof(uint16_t) * _ret.length())); @@ -918,9 +918,9 @@ struct miqt_array* QLocale_CountriesForLanguage(uint16_t lang) { QLocale::Country _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -945,11 +945,11 @@ struct miqt_string QLocale_QuoteString(const QLocale* self, struct miqt_string s return _ms; } -struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array* /* of struct miqt_string */ strl) { +struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array /* of struct miqt_string */ strl) { QStringList strl_QList; - strl_QList.reserve(strl->len); - struct miqt_string* strl_arr = static_cast(strl->data); - for(size_t i = 0; i < strl->len; ++i) { + strl_QList.reserve(strl.len); + struct miqt_string* strl_arr = static_cast(strl.data); + for(size_t i = 0; i < strl.len; ++i) { QString strl_arr_i_QString = QString::fromUtf8(strl_arr[i].data, strl_arr[i].len); strl_QList.push_back(strl_arr_i_QString); } diff --git a/qt6/gen_qlocale.go b/qt6/gen_qlocale.go index a72444b3..ff78f1b9 100644 --- a/qt6/gen_qlocale.go +++ b/qt6/gen_qlocale.go @@ -1474,13 +1474,12 @@ func (this *QLocale) FirstDayOfWeek() DayOfWeek { } func (this *QLocale) Weekdays() []DayOfWeek { - var _ma *C.struct_miqt_array = C.QLocale_Weekdays(this.h) + var _ma C.struct_miqt_array = C.QLocale_Weekdays(this.h) _ret := make([]DayOfWeek, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (DayOfWeek)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1606,7 +1605,7 @@ func (this *QLocale) FormattedDataSize(bytes int64) string { } func (this *QLocale) UiLanguages() []string { - var _ma *C.struct_miqt_array = C.QLocale_UiLanguages(this.h) + var _ma C.struct_miqt_array = C.QLocale_UiLanguages(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1615,7 +1614,6 @@ func (this *QLocale) UiLanguages() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1694,7 +1692,7 @@ func QLocale_System() *QLocale { } func QLocale_MatchingLocales(language QLocale__Language, script QLocale__Script, territory QLocale__Country) []QLocale { - var _ma *C.struct_miqt_array = C.QLocale_MatchingLocales((C.uint16_t)(language), (C.uint16_t)(script), (C.uint16_t)(territory)) + var _ma C.struct_miqt_array = C.QLocale_MatchingLocales((C.uint16_t)(language), (C.uint16_t)(script), (C.uint16_t)(territory)) _ret := make([]QLocale, int(_ma.len)) _outCast := (*[0xffff]*C.QLocale)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1703,18 +1701,16 @@ func QLocale_MatchingLocales(language QLocale__Language, script QLocale__Script, _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QLocale_CountriesForLanguage(lang QLocale__Language) []QLocale__Country { - var _ma *C.struct_miqt_array = C.QLocale_CountriesForLanguage((C.uint16_t)(lang)) + var _ma C.struct_miqt_array = C.QLocale_CountriesForLanguage((C.uint16_t)(lang)) _ret := make([]QLocale__Country, int(_ma.len)) _outCast := (*[0xffff]C.uint16_t)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QLocale__Country)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1738,7 +1734,6 @@ func (this *QLocale) QuoteString(str string) string { } func (this *QLocale) CreateSeparatedList(strl []string) string { - // For the C ABI, malloc a C array of structs strl_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strl)))) defer C.free(unsafe.Pointer(strl_CArray)) for i := range strl { @@ -1748,8 +1743,7 @@ func (this *QLocale) CreateSeparatedList(strl []string) string { defer C.free(unsafe.Pointer(strl_i_ms.data)) strl_CArray[i] = strl_i_ms } - strl_ma := &C.struct_miqt_array{len: C.size_t(len(strl)), data: unsafe.Pointer(strl_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strl_ma)) + strl_ma := C.struct_miqt_array{len: C.size_t(len(strl)), data: unsafe.Pointer(strl_CArray)} var _ms C.struct_miqt_string = C.QLocale_CreateSeparatedList(this.h, strl_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt6/gen_qlocale.h b/qt6/gen_qlocale.h index 709b0f3a..f32eb961 100644 --- a/qt6/gen_qlocale.h +++ b/qt6/gen_qlocale.h @@ -98,7 +98,7 @@ struct miqt_string QLocale_StandaloneMonthName(const QLocale* self, int param1); struct miqt_string QLocale_DayName(const QLocale* self, int param1); struct miqt_string QLocale_StandaloneDayName(const QLocale* self, int param1); int QLocale_FirstDayOfWeek(const QLocale* self); -struct miqt_array* QLocale_Weekdays(const QLocale* self); +struct miqt_array QLocale_Weekdays(const QLocale* self); struct miqt_string QLocale_AmText(const QLocale* self); struct miqt_string QLocale_PmText(const QLocale* self); int QLocale_MeasurementSystem(const QLocale* self); @@ -116,7 +116,7 @@ struct miqt_string QLocale_ToCurrencyStringWithUint(const QLocale* self, unsigne struct miqt_string QLocale_ToCurrencyStringWithDouble(const QLocale* self, double param1); struct miqt_string QLocale_ToCurrencyStringWithFloat(const QLocale* self, float i); struct miqt_string QLocale_FormattedDataSize(const QLocale* self, long long bytes); -struct miqt_array* QLocale_UiLanguages(const QLocale* self); +struct miqt_array QLocale_UiLanguages(const QLocale* self); struct miqt_string QLocale_LanguageToCode(uint16_t language); struct miqt_string QLocale_TerritoryToCode(uint16_t territory); struct miqt_string QLocale_CountryToCode(uint16_t country); @@ -128,12 +128,12 @@ struct miqt_string QLocale_ScriptToString(uint16_t script); void QLocale_SetDefault(QLocale* locale); QLocale* QLocale_C(); QLocale* QLocale_System(); -struct miqt_array* QLocale_MatchingLocales(uint16_t language, uint16_t script, uint16_t territory); -struct miqt_array* QLocale_CountriesForLanguage(uint16_t lang); +struct miqt_array QLocale_MatchingLocales(uint16_t language, uint16_t script, uint16_t territory); +struct miqt_array QLocale_CountriesForLanguage(uint16_t lang); void QLocale_SetNumberOptions(QLocale* self, int options); int QLocale_NumberOptions(const QLocale* self); struct miqt_string QLocale_QuoteString(const QLocale* self, struct miqt_string str); -struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array* /* of struct miqt_string */ strl); +struct miqt_string QLocale_CreateSeparatedList(const QLocale* self, struct miqt_array /* of struct miqt_string */ strl); int16_t QLocale_ToShort2(const QLocale* self, struct miqt_string s, bool* ok); uint16_t QLocale_ToUShort2(const QLocale* self, struct miqt_string s, bool* ok); int QLocale_ToInt2(const QLocale* self, struct miqt_string s, bool* ok); diff --git a/qt6/gen_qmainwindow.cpp b/qt6/gen_qmainwindow.cpp index 06cc75b3..176dea7b 100644 --- a/qt6/gen_qmainwindow.cpp +++ b/qt6/gen_qmainwindow.cpp @@ -219,16 +219,16 @@ void QMainWindow_TabifyDockWidget(QMainWindow* self, QDockWidget* first, QDockWi self->tabifyDockWidget(first, second); } -struct miqt_array* QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget) { +struct miqt_array QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget) { QList _ret = self->tabifiedDockWidgets(dockwidget); // Convert QList<> from C++ memory to manually-managed C memory QDockWidget** _arr = static_cast(malloc(sizeof(QDockWidget*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -245,17 +245,17 @@ int QMainWindow_DockWidgetArea(const QMainWindow* self, QDockWidget* dockwidget) return static_cast(_ret); } -void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array* /* of QDockWidget* */ docks, struct miqt_array* /* of int */ sizes, int orientation) { +void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array /* of QDockWidget* */ docks, struct miqt_array /* of int */ sizes, int orientation) { QList docks_QList; - docks_QList.reserve(docks->len); - QDockWidget** docks_arr = static_cast(docks->data); - for(size_t i = 0; i < docks->len; ++i) { + docks_QList.reserve(docks.len); + QDockWidget** docks_arr = static_cast(docks.data); + for(size_t i = 0; i < docks.len; ++i) { docks_QList.push_back(docks_arr[i]); } QList sizes_QList; - sizes_QList.reserve(sizes->len); - int* sizes_arr = static_cast(sizes->data); - for(size_t i = 0; i < sizes->len; ++i) { + sizes_QList.reserve(sizes.len); + int* sizes_arr = static_cast(sizes.data); + for(size_t i = 0; i < sizes.len; ++i) { sizes_QList.push_back(static_cast(sizes_arr[i])); } self->resizeDocks(docks_QList, sizes_QList, static_cast(orientation)); diff --git a/qt6/gen_qmainwindow.go b/qt6/gen_qmainwindow.go index f466be88..37167ab6 100644 --- a/qt6/gen_qmainwindow.go +++ b/qt6/gen_qmainwindow.go @@ -264,13 +264,12 @@ func (this *QMainWindow) TabifyDockWidget(first *QDockWidget, second *QDockWidge } func (this *QMainWindow) TabifiedDockWidgets(dockwidget *QDockWidget) []*QDockWidget { - var _ma *C.struct_miqt_array = C.QMainWindow_TabifiedDockWidgets(this.h, dockwidget.cPointer()) + var _ma C.struct_miqt_array = C.QMainWindow_TabifiedDockWidgets(this.h, dockwidget.cPointer()) _ret := make([]*QDockWidget, int(_ma.len)) _outCast := (*[0xffff]*C.QDockWidget)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQDockWidget(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -287,22 +286,18 @@ func (this *QMainWindow) DockWidgetArea(dockwidget *QDockWidget) DockWidgetArea } func (this *QMainWindow) ResizeDocks(docks []*QDockWidget, sizes []int, orientation Orientation) { - // For the C ABI, malloc a C array of raw pointers docks_CArray := (*[0xffff]*C.QDockWidget)(C.malloc(C.size_t(8 * len(docks)))) defer C.free(unsafe.Pointer(docks_CArray)) for i := range docks { docks_CArray[i] = docks[i].cPointer() } - docks_ma := &C.struct_miqt_array{len: C.size_t(len(docks)), data: unsafe.Pointer(docks_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(docks_ma)) - // For the C ABI, malloc a C array of raw pointers + docks_ma := C.struct_miqt_array{len: C.size_t(len(docks)), data: unsafe.Pointer(docks_CArray)} sizes_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(sizes)))) defer C.free(unsafe.Pointer(sizes_CArray)) for i := range sizes { sizes_CArray[i] = (C.int)(sizes[i]) } - sizes_ma := &C.struct_miqt_array{len: C.size_t(len(sizes)), data: unsafe.Pointer(sizes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(sizes_ma)) + sizes_ma := C.struct_miqt_array{len: C.size_t(len(sizes)), data: unsafe.Pointer(sizes_CArray)} C.QMainWindow_ResizeDocks(this.h, docks_ma, sizes_ma, (C.int)(orientation)) } diff --git a/qt6/gen_qmainwindow.h b/qt6/gen_qmainwindow.h index 84148a13..f46224ff 100644 --- a/qt6/gen_qmainwindow.h +++ b/qt6/gen_qmainwindow.h @@ -86,11 +86,11 @@ void QMainWindow_AddDockWidget(QMainWindow* self, int area, QDockWidget* dockwid void QMainWindow_AddDockWidget2(QMainWindow* self, int area, QDockWidget* dockwidget, int orientation); void QMainWindow_SplitDockWidget(QMainWindow* self, QDockWidget* after, QDockWidget* dockwidget, int orientation); void QMainWindow_TabifyDockWidget(QMainWindow* self, QDockWidget* first, QDockWidget* second); -struct miqt_array* QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget); +struct miqt_array QMainWindow_TabifiedDockWidgets(const QMainWindow* self, QDockWidget* dockwidget); void QMainWindow_RemoveDockWidget(QMainWindow* self, QDockWidget* dockwidget); bool QMainWindow_RestoreDockWidget(QMainWindow* self, QDockWidget* dockwidget); int QMainWindow_DockWidgetArea(const QMainWindow* self, QDockWidget* dockwidget); -void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array* /* of QDockWidget* */ docks, struct miqt_array* /* of int */ sizes, int orientation); +void QMainWindow_ResizeDocks(QMainWindow* self, struct miqt_array /* of QDockWidget* */ docks, struct miqt_array /* of int */ sizes, int orientation); struct miqt_string QMainWindow_SaveState(const QMainWindow* self); bool QMainWindow_RestoreState(QMainWindow* self, struct miqt_string state); QMenu* QMainWindow_CreatePopupMenu(QMainWindow* self); diff --git a/qt6/gen_qmdiarea.cpp b/qt6/gen_qmdiarea.cpp index 6ed7de36..028d6944 100644 --- a/qt6/gen_qmdiarea.cpp +++ b/qt6/gen_qmdiarea.cpp @@ -55,16 +55,16 @@ QMdiSubWindow* QMdiArea_ActiveSubWindow(const QMdiArea* self) { return self->activeSubWindow(); } -struct miqt_array* QMdiArea_SubWindowList(const QMdiArea* self) { +struct miqt_array QMdiArea_SubWindowList(const QMdiArea* self) { QList _ret = self->subWindowList(); // Convert QList<> from C++ memory to manually-managed C memory QMdiSubWindow** _arr = static_cast(malloc(sizeof(QMdiSubWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -213,16 +213,16 @@ struct miqt_string QMdiArea_Tr3(const char* s, const char* c, int n) { return _ms; } -struct miqt_array* QMdiArea_SubWindowList1(const QMdiArea* self, int order) { +struct miqt_array QMdiArea_SubWindowList1(const QMdiArea* self, int order) { QList _ret = self->subWindowList(static_cast(order)); // Convert QList<> from C++ memory to manually-managed C memory QMdiSubWindow** _arr = static_cast(malloc(sizeof(QMdiSubWindow*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmdiarea.go b/qt6/gen_qmdiarea.go index d6e3af71..fc447e25 100644 --- a/qt6/gen_qmdiarea.go +++ b/qt6/gen_qmdiarea.go @@ -119,13 +119,12 @@ func (this *QMdiArea) ActiveSubWindow() *QMdiSubWindow { } func (this *QMdiArea) SubWindowList() []*QMdiSubWindow { - var _ma *C.struct_miqt_array = C.QMdiArea_SubWindowList(this.h) + var _ma C.struct_miqt_array = C.QMdiArea_SubWindowList(this.h) _ret := make([]*QMdiSubWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QMdiSubWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQMdiSubWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -283,13 +282,12 @@ func QMdiArea_Tr3(s string, c string, n int) string { } func (this *QMdiArea) SubWindowList1(order QMdiArea__WindowOrder) []*QMdiSubWindow { - var _ma *C.struct_miqt_array = C.QMdiArea_SubWindowList1(this.h, (C.int)(order)) + var _ma C.struct_miqt_array = C.QMdiArea_SubWindowList1(this.h, (C.int)(order)) _ret := make([]*QMdiSubWindow, int(_ma.len)) _outCast := (*[0xffff]*C.QMdiSubWindow)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQMdiSubWindow(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmdiarea.h b/qt6/gen_qmdiarea.h index 049e09e6..46643ae8 100644 --- a/qt6/gen_qmdiarea.h +++ b/qt6/gen_qmdiarea.h @@ -38,7 +38,7 @@ QSize* QMdiArea_SizeHint(const QMdiArea* self); QSize* QMdiArea_MinimumSizeHint(const QMdiArea* self); QMdiSubWindow* QMdiArea_CurrentSubWindow(const QMdiArea* self); QMdiSubWindow* QMdiArea_ActiveSubWindow(const QMdiArea* self); -struct miqt_array* QMdiArea_SubWindowList(const QMdiArea* self); +struct miqt_array QMdiArea_SubWindowList(const QMdiArea* self); QMdiSubWindow* QMdiArea_AddSubWindow(QMdiArea* self, QWidget* widget); void QMdiArea_RemoveSubWindow(QMdiArea* self, QWidget* widget); QBrush* QMdiArea_Background(const QMdiArea* self); @@ -70,7 +70,7 @@ void QMdiArea_ActivateNextSubWindow(QMdiArea* self); void QMdiArea_ActivatePreviousSubWindow(QMdiArea* self); struct miqt_string QMdiArea_Tr2(const char* s, const char* c); struct miqt_string QMdiArea_Tr3(const char* s, const char* c, int n); -struct miqt_array* QMdiArea_SubWindowList1(const QMdiArea* self, int order); +struct miqt_array QMdiArea_SubWindowList1(const QMdiArea* self, int order); QMdiSubWindow* QMdiArea_AddSubWindow2(QMdiArea* self, QWidget* widget, int flags); void QMdiArea_SetOption2(QMdiArea* self, int option, bool on); void QMdiArea_Delete(QMdiArea* self); diff --git a/qt6/gen_qmenu.cpp b/qt6/gen_qmenu.cpp index 66111a17..3458d7d9 100644 --- a/qt6/gen_qmenu.cpp +++ b/qt6/gen_qmenu.cpp @@ -157,11 +157,11 @@ QAction* QMenu_ExecWithPos(QMenu* self, QPoint* pos) { return self->exec(*pos); } -QAction* QMenu_Exec2(struct miqt_array* /* of QAction* */ actions, QPoint* pos) { +QAction* QMenu_Exec2(struct miqt_array /* of QAction* */ actions, QPoint* pos) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos); @@ -303,21 +303,21 @@ QAction* QMenu_Exec22(QMenu* self, QPoint* pos, QAction* at) { return self->exec(*pos, at); } -QAction* QMenu_Exec3(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at) { +QAction* QMenu_Exec3(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos, at); } -QAction* QMenu_Exec4(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent) { +QAction* QMenu_Exec4(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } return QMenu::exec(actions_QList, *pos, at, parent); diff --git a/qt6/gen_qmenu.go b/qt6/gen_qmenu.go index 259dbd30..04b67eb8 100644 --- a/qt6/gen_qmenu.go +++ b/qt6/gen_qmenu.go @@ -220,14 +220,12 @@ func (this *QMenu) ExecWithPos(pos *QPoint) *QAction { } func QMenu_Exec2(actions []*QAction, pos *QPoint) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec2(actions_ma, pos.cPointer()))) } @@ -408,26 +406,22 @@ func (this *QMenu) Exec22(pos *QPoint, at *QAction) *QAction { } func QMenu_Exec3(actions []*QAction, pos *QPoint, at *QAction) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec3(actions_ma, pos.cPointer(), at.cPointer()))) } func QMenu_Exec4(actions []*QAction, pos *QPoint, at *QAction, parent *QWidget) *QAction { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} return UnsafeNewQAction(unsafe.Pointer(C.QMenu_Exec4(actions_ma, pos.cPointer(), at.cPointer(), parent.cPointer()))) } diff --git a/qt6/gen_qmenu.h b/qt6/gen_qmenu.h index 1c4df8b8..eb0c0582 100644 --- a/qt6/gen_qmenu.h +++ b/qt6/gen_qmenu.h @@ -65,7 +65,7 @@ QAction* QMenu_ActiveAction(const QMenu* self); void QMenu_Popup(QMenu* self, QPoint* pos); QAction* QMenu_Exec(QMenu* self); QAction* QMenu_ExecWithPos(QMenu* self, QPoint* pos); -QAction* QMenu_Exec2(struct miqt_array* /* of QAction* */ actions, QPoint* pos); +QAction* QMenu_Exec2(struct miqt_array /* of QAction* */ actions, QPoint* pos); QSize* QMenu_SizeHint(const QMenu* self); QRect* QMenu_ActionGeometry(const QMenu* self, QAction* param1); QAction* QMenu_ActionAt(const QMenu* self, QPoint* param1); @@ -92,8 +92,8 @@ struct miqt_string QMenu_Tr2(const char* s, const char* c); struct miqt_string QMenu_Tr3(const char* s, const char* c, int n); void QMenu_Popup2(QMenu* self, QPoint* pos, QAction* at); QAction* QMenu_Exec22(QMenu* self, QPoint* pos, QAction* at); -QAction* QMenu_Exec3(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at); -QAction* QMenu_Exec4(struct miqt_array* /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent); +QAction* QMenu_Exec3(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at); +QAction* QMenu_Exec4(struct miqt_array /* of QAction* */ actions, QPoint* pos, QAction* at, QWidget* parent); void QMenu_Delete(QMenu* self); #ifdef __cplusplus diff --git a/qt6/gen_qmessagebox.cpp b/qt6/gen_qmessagebox.cpp index 3954da90..bae31d92 100644 --- a/qt6/gen_qmessagebox.cpp +++ b/qt6/gen_qmessagebox.cpp @@ -99,16 +99,16 @@ void QMessageBox_RemoveButton(QMessageBox* self, QAbstractButton* button) { self->removeButton(button); } -struct miqt_array* QMessageBox_Buttons(const QMessageBox* self) { +struct miqt_array QMessageBox_Buttons(const QMessageBox* self) { QList _ret = self->buttons(); // Convert QList<> from C++ memory to manually-managed C memory QAbstractButton** _arr = static_cast(malloc(sizeof(QAbstractButton*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmessagebox.go b/qt6/gen_qmessagebox.go index 72eaed3f..fc97a6e3 100644 --- a/qt6/gen_qmessagebox.go +++ b/qt6/gen_qmessagebox.go @@ -252,13 +252,12 @@ func (this *QMessageBox) RemoveButton(button *QAbstractButton) { } func (this *QMessageBox) Buttons() []*QAbstractButton { - var _ma *C.struct_miqt_array = C.QMessageBox_Buttons(this.h) + var _ma C.struct_miqt_array = C.QMessageBox_Buttons(this.h) _ret := make([]*QAbstractButton, int(_ma.len)) _outCast := (*[0xffff]*C.QAbstractButton)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAbstractButton(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmessagebox.h b/qt6/gen_qmessagebox.h index c574da2a..cded259e 100644 --- a/qt6/gen_qmessagebox.h +++ b/qt6/gen_qmessagebox.h @@ -47,7 +47,7 @@ void QMessageBox_AddButton(QMessageBox* self, QAbstractButton* button, int role) QPushButton* QMessageBox_AddButton2(QMessageBox* self, struct miqt_string text, int role); QPushButton* QMessageBox_AddButtonWithButton(QMessageBox* self, int button); void QMessageBox_RemoveButton(QMessageBox* self, QAbstractButton* button); -struct miqt_array* QMessageBox_Buttons(const QMessageBox* self); +struct miqt_array QMessageBox_Buttons(const QMessageBox* self); int QMessageBox_ButtonRole(const QMessageBox* self, QAbstractButton* button); void QMessageBox_SetStandardButtons(QMessageBox* self, int buttons); int QMessageBox_StandardButtons(const QMessageBox* self); diff --git a/qt6/gen_qmetaobject.cpp b/qt6/gen_qmetaobject.cpp index fc86663a..cb1c335b 100644 --- a/qt6/gen_qmetaobject.cpp +++ b/qt6/gen_qmetaobject.cpp @@ -69,7 +69,7 @@ void QMetaMethod_GetParameterTypes(const QMetaMethod* self, int* types) { self->getParameterTypes(static_cast(types)); } -struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self) { +struct miqt_array QMetaMethod_ParameterTypes(const QMetaMethod* self) { QList _ret = self->parameterTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -81,9 +81,9 @@ struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -96,7 +96,7 @@ struct miqt_string QMetaMethod_ParameterTypeName(const QMetaMethod* self, int in return _ms; } -struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self) { +struct miqt_array QMetaMethod_ParameterNames(const QMetaMethod* self) { QList _ret = self->parameterNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -108,9 +108,9 @@ struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmetaobject.go b/qt6/gen_qmetaobject.go index 5658ee57..cb9cbdcf 100644 --- a/qt6/gen_qmetaobject.go +++ b/qt6/gen_qmetaobject.go @@ -129,7 +129,7 @@ func (this *QMetaMethod) GetParameterTypes(types *int) { } func (this *QMetaMethod) ParameterTypes() [][]byte { - var _ma *C.struct_miqt_array = C.QMetaMethod_ParameterTypes(this.h) + var _ma C.struct_miqt_array = C.QMetaMethod_ParameterTypes(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -138,7 +138,6 @@ func (this *QMetaMethod) ParameterTypes() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -150,7 +149,7 @@ func (this *QMetaMethod) ParameterTypeName(index int) []byte { } func (this *QMetaMethod) ParameterNames() [][]byte { - var _ma *C.struct_miqt_array = C.QMetaMethod_ParameterNames(this.h) + var _ma C.struct_miqt_array = C.QMetaMethod_ParameterNames(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -159,7 +158,6 @@ func (this *QMetaMethod) ParameterNames() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmetaobject.h b/qt6/gen_qmetaobject.h index 01503d9a..26250047 100644 --- a/qt6/gen_qmetaobject.h +++ b/qt6/gen_qmetaobject.h @@ -52,9 +52,9 @@ int QMetaMethod_ParameterCount(const QMetaMethod* self); int QMetaMethod_ParameterType(const QMetaMethod* self, int index); QMetaType* QMetaMethod_ParameterMetaType(const QMetaMethod* self, int index); void QMetaMethod_GetParameterTypes(const QMetaMethod* self, int* types); -struct miqt_array* QMetaMethod_ParameterTypes(const QMetaMethod* self); +struct miqt_array QMetaMethod_ParameterTypes(const QMetaMethod* self); struct miqt_string QMetaMethod_ParameterTypeName(const QMetaMethod* self, int index); -struct miqt_array* QMetaMethod_ParameterNames(const QMetaMethod* self); +struct miqt_array QMetaMethod_ParameterNames(const QMetaMethod* self); const char* QMetaMethod_Tag(const QMetaMethod* self); int QMetaMethod_Access(const QMetaMethod* self); int QMetaMethod_MethodType(const QMetaMethod* self); diff --git a/qt6/gen_qmimedata.cpp b/qt6/gen_qmimedata.cpp index d9f1e22c..83b7d514 100644 --- a/qt6/gen_qmimedata.cpp +++ b/qt6/gen_qmimedata.cpp @@ -34,24 +34,24 @@ struct miqt_string QMimeData_Tr(const char* s) { return _ms; } -struct miqt_array* QMimeData_Urls(const QMimeData* self) { +struct miqt_array QMimeData_Urls(const QMimeData* self) { QList _ret = self->urls(); // Convert QList<> from C++ memory to manually-managed C memory QUrl** _arr = static_cast(malloc(sizeof(QUrl*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QMimeData_SetUrls(QMimeData* self, struct miqt_array* /* of QUrl* */ urls) { +void QMimeData_SetUrls(QMimeData* self, struct miqt_array /* of QUrl* */ urls) { QList urls_QList; - urls_QList.reserve(urls->len); - QUrl** urls_arr = static_cast(urls->data); - for(size_t i = 0; i < urls->len; ++i) { + urls_QList.reserve(urls.len); + QUrl** urls_arr = static_cast(urls.data); + for(size_t i = 0; i < urls.len; ++i) { urls_QList.push_back(*(urls_arr[i])); } self->setUrls(urls_QList); @@ -151,7 +151,7 @@ bool QMimeData_HasFormat(const QMimeData* self, struct miqt_string mimetype) { return self->hasFormat(mimetype_QString); } -struct miqt_array* QMimeData_Formats(const QMimeData* self) { +struct miqt_array QMimeData_Formats(const QMimeData* self) { QStringList _ret = self->formats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -165,9 +165,9 @@ struct miqt_array* QMimeData_Formats(const QMimeData* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmimedata.go b/qt6/gen_qmimedata.go index 81da5ce7..99c1bcb2 100644 --- a/qt6/gen_qmimedata.go +++ b/qt6/gen_qmimedata.go @@ -69,7 +69,7 @@ func QMimeData_Tr(s string) string { } func (this *QMimeData) Urls() []QUrl { - var _ma *C.struct_miqt_array = C.QMimeData_Urls(this.h) + var _ma C.struct_miqt_array = C.QMimeData_Urls(this.h) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -78,19 +78,16 @@ func (this *QMimeData) Urls() []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeData) SetUrls(urls []QUrl) { - // For the C ABI, malloc a C array of raw pointers urls_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(urls)))) defer C.free(unsafe.Pointer(urls_CArray)) for i := range urls { urls_CArray[i] = urls[i].cPointer() } - urls_ma := &C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(urls_ma)) + urls_ma := C.struct_miqt_array{len: C.size_t(len(urls)), data: unsafe.Pointer(urls_CArray)} C.QMimeData_SetUrls(this.h, urls_ma) } @@ -205,7 +202,7 @@ func (this *QMimeData) HasFormat(mimetype string) bool { } func (this *QMimeData) Formats() []string { - var _ma *C.struct_miqt_array = C.QMimeData_Formats(this.h) + var _ma C.struct_miqt_array = C.QMimeData_Formats(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -214,7 +211,6 @@ func (this *QMimeData) Formats() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmimedata.h b/qt6/gen_qmimedata.h index 147175ac..62af47d4 100644 --- a/qt6/gen_qmimedata.h +++ b/qt6/gen_qmimedata.h @@ -31,8 +31,8 @@ QMimeData* QMimeData_new(); QMetaObject* QMimeData_MetaObject(const QMimeData* self); void* QMimeData_Metacast(QMimeData* self, const char* param1); struct miqt_string QMimeData_Tr(const char* s); -struct miqt_array* QMimeData_Urls(const QMimeData* self); -void QMimeData_SetUrls(QMimeData* self, struct miqt_array* /* of QUrl* */ urls); +struct miqt_array QMimeData_Urls(const QMimeData* self); +void QMimeData_SetUrls(QMimeData* self, struct miqt_array /* of QUrl* */ urls); bool QMimeData_HasUrls(const QMimeData* self); struct miqt_string QMimeData_Text(const QMimeData* self); void QMimeData_SetText(QMimeData* self, struct miqt_string text); @@ -50,7 +50,7 @@ struct miqt_string QMimeData_Data(const QMimeData* self, struct miqt_string mime void QMimeData_SetData(QMimeData* self, struct miqt_string mimetype, struct miqt_string data); void QMimeData_RemoveFormat(QMimeData* self, struct miqt_string mimetype); bool QMimeData_HasFormat(const QMimeData* self, struct miqt_string mimetype); -struct miqt_array* QMimeData_Formats(const QMimeData* self); +struct miqt_array QMimeData_Formats(const QMimeData* self); void QMimeData_Clear(QMimeData* self); struct miqt_string QMimeData_Tr2(const char* s, const char* c); struct miqt_string QMimeData_Tr3(const char* s, const char* c, int n); diff --git a/qt6/gen_qmimedatabase.cpp b/qt6/gen_qmimedatabase.cpp index 968ba9bd..13efa053 100644 --- a/qt6/gen_qmimedatabase.cpp +++ b/qt6/gen_qmimedatabase.cpp @@ -30,7 +30,7 @@ QMimeType* QMimeDatabase_MimeTypeForFileWithFileInfo(const QMimeDatabase* self, return new QMimeType(self->mimeTypeForFile(*fileInfo)); } -struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName) { +struct miqt_array QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QList _ret = self->mimeTypesForFileName(fileName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -38,9 +38,9 @@ struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QMimeType(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -80,16 +80,16 @@ struct miqt_string QMimeDatabase_SuffixForFileName(const QMimeDatabase* self, st return _ms; } -struct miqt_array* QMimeDatabase_AllMimeTypes(const QMimeDatabase* self) { +struct miqt_array QMimeDatabase_AllMimeTypes(const QMimeDatabase* self) { QList _ret = self->allMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory QMimeType** _arr = static_cast(malloc(sizeof(QMimeType*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QMimeType(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmimedatabase.go b/qt6/gen_qmimedatabase.go index 5ce33f0e..dfd226e2 100644 --- a/qt6/gen_qmimedatabase.go +++ b/qt6/gen_qmimedatabase.go @@ -90,7 +90,7 @@ func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType { fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, fileName_ms) + var _ma C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, fileName_ms) _ret := make([]QMimeType, int(_ma.len)) _outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -99,7 +99,6 @@ func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -164,7 +163,7 @@ func (this *QMimeDatabase) SuffixForFileName(fileName string) string { } func (this *QMimeDatabase) AllMimeTypes() []QMimeType { - var _ma *C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h) + var _ma C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h) _ret := make([]QMimeType, int(_ma.len)) _outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -173,7 +172,6 @@ func (this *QMimeDatabase) AllMimeTypes() []QMimeType { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmimedatabase.h b/qt6/gen_qmimedatabase.h index 6624fac4..4df66c7c 100644 --- a/qt6/gen_qmimedatabase.h +++ b/qt6/gen_qmimedatabase.h @@ -33,14 +33,14 @@ QMimeDatabase* QMimeDatabase_new(); QMimeType* QMimeDatabase_MimeTypeForName(const QMimeDatabase* self, struct miqt_string nameOrAlias); QMimeType* QMimeDatabase_MimeTypeForFile(const QMimeDatabase* self, struct miqt_string fileName); QMimeType* QMimeDatabase_MimeTypeForFileWithFileInfo(const QMimeDatabase* self, QFileInfo* fileInfo); -struct miqt_array* QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName); +struct miqt_array QMimeDatabase_MimeTypesForFileName(const QMimeDatabase* self, struct miqt_string fileName); QMimeType* QMimeDatabase_MimeTypeForData(const QMimeDatabase* self, struct miqt_string data); QMimeType* QMimeDatabase_MimeTypeForDataWithDevice(const QMimeDatabase* self, QIODevice* device); QMimeType* QMimeDatabase_MimeTypeForUrl(const QMimeDatabase* self, QUrl* url); QMimeType* QMimeDatabase_MimeTypeForFileNameAndData(const QMimeDatabase* self, struct miqt_string fileName, QIODevice* device); QMimeType* QMimeDatabase_MimeTypeForFileNameAndData2(const QMimeDatabase* self, struct miqt_string fileName, struct miqt_string data); struct miqt_string QMimeDatabase_SuffixForFileName(const QMimeDatabase* self, struct miqt_string fileName); -struct miqt_array* QMimeDatabase_AllMimeTypes(const QMimeDatabase* self); +struct miqt_array QMimeDatabase_AllMimeTypes(const QMimeDatabase* self); QMimeType* QMimeDatabase_MimeTypeForFile2(const QMimeDatabase* self, struct miqt_string fileName, int mode); QMimeType* QMimeDatabase_MimeTypeForFile22(const QMimeDatabase* self, QFileInfo* fileInfo, int mode); void QMimeDatabase_Delete(QMimeDatabase* self); diff --git a/qt6/gen_qmimetype.cpp b/qt6/gen_qmimetype.cpp index ee883f82..b02978a3 100644 --- a/qt6/gen_qmimetype.cpp +++ b/qt6/gen_qmimetype.cpp @@ -83,7 +83,7 @@ struct miqt_string QMimeType_IconName(const QMimeType* self) { return _ms; } -struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self) { +struct miqt_array QMimeType_GlobPatterns(const QMimeType* self) { QStringList _ret = self->globPatterns(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -97,13 +97,13 @@ struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self) { +struct miqt_array QMimeType_ParentMimeTypes(const QMimeType* self) { QStringList _ret = self->parentMimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -117,13 +117,13 @@ struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_AllAncestors(const QMimeType* self) { +struct miqt_array QMimeType_AllAncestors(const QMimeType* self) { QStringList _ret = self->allAncestors(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -137,13 +137,13 @@ struct miqt_array* QMimeType_AllAncestors(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_Aliases(const QMimeType* self) { +struct miqt_array QMimeType_Aliases(const QMimeType* self) { QStringList _ret = self->aliases(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -157,13 +157,13 @@ struct miqt_array* QMimeType_Aliases(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QMimeType_Suffixes(const QMimeType* self) { +struct miqt_array QMimeType_Suffixes(const QMimeType* self) { QStringList _ret = self->suffixes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -177,9 +177,9 @@ struct miqt_array* QMimeType_Suffixes(const QMimeType* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmimetype.go b/qt6/gen_qmimetype.go index 691e6a98..a31eb079 100644 --- a/qt6/gen_qmimetype.go +++ b/qt6/gen_qmimetype.go @@ -107,7 +107,7 @@ func (this *QMimeType) IconName() string { } func (this *QMimeType) GlobPatterns() []string { - var _ma *C.struct_miqt_array = C.QMimeType_GlobPatterns(this.h) + var _ma C.struct_miqt_array = C.QMimeType_GlobPatterns(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -116,12 +116,11 @@ func (this *QMimeType) GlobPatterns() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) ParentMimeTypes() []string { - var _ma *C.struct_miqt_array = C.QMimeType_ParentMimeTypes(this.h) + var _ma C.struct_miqt_array = C.QMimeType_ParentMimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -130,12 +129,11 @@ func (this *QMimeType) ParentMimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) AllAncestors() []string { - var _ma *C.struct_miqt_array = C.QMimeType_AllAncestors(this.h) + var _ma C.struct_miqt_array = C.QMimeType_AllAncestors(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -144,12 +142,11 @@ func (this *QMimeType) AllAncestors() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) Aliases() []string { - var _ma *C.struct_miqt_array = C.QMimeType_Aliases(this.h) + var _ma C.struct_miqt_array = C.QMimeType_Aliases(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -158,12 +155,11 @@ func (this *QMimeType) Aliases() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QMimeType) Suffixes() []string { - var _ma *C.struct_miqt_array = C.QMimeType_Suffixes(this.h) + var _ma C.struct_miqt_array = C.QMimeType_Suffixes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,7 +168,6 @@ func (this *QMimeType) Suffixes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmimetype.h b/qt6/gen_qmimetype.h index 557272d7..eb2b597b 100644 --- a/qt6/gen_qmimetype.h +++ b/qt6/gen_qmimetype.h @@ -31,11 +31,11 @@ struct miqt_string QMimeType_Name(const QMimeType* self); struct miqt_string QMimeType_Comment(const QMimeType* self); struct miqt_string QMimeType_GenericIconName(const QMimeType* self); struct miqt_string QMimeType_IconName(const QMimeType* self); -struct miqt_array* QMimeType_GlobPatterns(const QMimeType* self); -struct miqt_array* QMimeType_ParentMimeTypes(const QMimeType* self); -struct miqt_array* QMimeType_AllAncestors(const QMimeType* self); -struct miqt_array* QMimeType_Aliases(const QMimeType* self); -struct miqt_array* QMimeType_Suffixes(const QMimeType* self); +struct miqt_array QMimeType_GlobPatterns(const QMimeType* self); +struct miqt_array QMimeType_ParentMimeTypes(const QMimeType* self); +struct miqt_array QMimeType_AllAncestors(const QMimeType* self); +struct miqt_array QMimeType_Aliases(const QMimeType* self); +struct miqt_array QMimeType_Suffixes(const QMimeType* self); struct miqt_string QMimeType_PreferredSuffix(const QMimeType* self); bool QMimeType_Inherits(const QMimeType* self, struct miqt_string mimeTypeName); struct miqt_string QMimeType_FilterString(const QMimeType* self); diff --git a/qt6/gen_qmovie.cpp b/qt6/gen_qmovie.cpp index 1a7e9f1e..bd4ac268 100644 --- a/qt6/gen_qmovie.cpp +++ b/qt6/gen_qmovie.cpp @@ -74,7 +74,7 @@ struct miqt_string QMovie_Tr(const char* s) { return _ms; } -struct miqt_array* QMovie_SupportedFormats() { +struct miqt_array QMovie_SupportedFormats() { QList _ret = QMovie::supportedFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -86,9 +86,9 @@ struct miqt_array* QMovie_SupportedFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qmovie.go b/qt6/gen_qmovie.go index a7a7efa9..9e5f600d 100644 --- a/qt6/gen_qmovie.go +++ b/qt6/gen_qmovie.go @@ -151,7 +151,7 @@ func QMovie_Tr(s string) string { } func QMovie_SupportedFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QMovie_SupportedFormats() + var _ma C.struct_miqt_array = C.QMovie_SupportedFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -160,7 +160,6 @@ func QMovie_SupportedFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qmovie.h b/qt6/gen_qmovie.h index c5ff0a33..1c583c4a 100644 --- a/qt6/gen_qmovie.h +++ b/qt6/gen_qmovie.h @@ -48,7 +48,7 @@ QMovie* QMovie_new8(struct miqt_string fileName, struct miqt_string format, QObj QMetaObject* QMovie_MetaObject(const QMovie* self); void* QMovie_Metacast(QMovie* self, const char* param1); struct miqt_string QMovie_Tr(const char* s); -struct miqt_array* QMovie_SupportedFormats(); +struct miqt_array QMovie_SupportedFormats(); void QMovie_SetDevice(QMovie* self, QIODevice* device); QIODevice* QMovie_Device(const QMovie* self); void QMovie_SetFileName(QMovie* self, struct miqt_string fileName); diff --git a/qt6/gen_qobject.cpp b/qt6/gen_qobject.cpp index 9d4bd8c6..adb9d57b 100644 --- a/qt6/gen_qobject.cpp +++ b/qt6/gen_qobject.cpp @@ -112,16 +112,16 @@ void QObject_KillTimer(QObject* self, int id) { self->killTimer(static_cast(id)); } -struct miqt_array* QObject_Children(const QObject* self) { +struct miqt_array QObject_Children(const QObject* self) { const QObjectList& _ret = self->children(); // Convert QList<> from C++ memory to manually-managed C memory QObject** _arr = static_cast(malloc(sizeof(QObject*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -169,7 +169,7 @@ QVariant* QObject_Property(const QObject* self, const char* name) { return new QVariant(self->property(name)); } -struct miqt_array* QObject_DynamicPropertyNames(const QObject* self) { +struct miqt_array QObject_DynamicPropertyNames(const QObject* self) { QList _ret = self->dynamicPropertyNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -181,9 +181,9 @@ struct miqt_array* QObject_DynamicPropertyNames(const QObject* self) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qobject.go b/qt6/gen_qobject.go index 6a96d6bc..3bbd0ccc 100644 --- a/qt6/gen_qobject.go +++ b/qt6/gen_qobject.go @@ -183,13 +183,12 @@ func (this *QObject) KillTimer(id int) { } func (this *QObject) Children() []*QObject { - var _ma *C.struct_miqt_array = C.QObject_Children(this.h) + var _ma C.struct_miqt_array = C.QObject_Children(this.h) _ret := make([]*QObject, int(_ma.len)) _outCast := (*[0xffff]*C.QObject)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQObject(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -255,7 +254,7 @@ func (this *QObject) Property(name string) *QVariant { } func (this *QObject) DynamicPropertyNames() [][]byte { - var _ma *C.struct_miqt_array = C.QObject_DynamicPropertyNames(this.h) + var _ma C.struct_miqt_array = C.QObject_DynamicPropertyNames(this.h) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -264,7 +263,6 @@ func (this *QObject) DynamicPropertyNames() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qobject.h b/qt6/gen_qobject.h index 5c8b32b4..1f23589b 100644 --- a/qt6/gen_qobject.h +++ b/qt6/gen_qobject.h @@ -66,7 +66,7 @@ QThread* QObject_Thread(const QObject* self); void QObject_MoveToThread(QObject* self, QThread* thread); int QObject_StartTimer(QObject* self, int interval); void QObject_KillTimer(QObject* self, int id); -struct miqt_array* QObject_Children(const QObject* self); +struct miqt_array QObject_Children(const QObject* self); void QObject_SetParent(QObject* self, QObject* parent); void QObject_InstallEventFilter(QObject* self, QObject* filterObj); void QObject_RemoveEventFilter(QObject* self, QObject* obj); @@ -78,7 +78,7 @@ void QObject_DumpObjectTree(const QObject* self); void QObject_DumpObjectInfo(const QObject* self); bool QObject_SetProperty(QObject* self, const char* name, QVariant* value); QVariant* QObject_Property(const QObject* self, const char* name); -struct miqt_array* QObject_DynamicPropertyNames(const QObject* self); +struct miqt_array QObject_DynamicPropertyNames(const QObject* self); QBindingStorage* QObject_BindingStorage(QObject* self); QBindingStorage* QObject_BindingStorage2(const QObject* self); void QObject_Destroyed(QObject* self); diff --git a/qt6/gen_qpageranges.cpp b/qt6/gen_qpageranges.cpp index c0547a29..44f6299f 100644 --- a/qt6/gen_qpageranges.cpp +++ b/qt6/gen_qpageranges.cpp @@ -32,16 +32,16 @@ void QPageRanges_AddRange(QPageRanges* self, int from, int to) { self->addRange(static_cast(from), static_cast(to)); } -struct miqt_array* QPageRanges_ToRangeList(const QPageRanges* self) { +struct miqt_array QPageRanges_ToRangeList(const QPageRanges* self) { QList _ret = self->toRangeList(); // Convert QList<> from C++ memory to manually-managed C memory QPageRanges__Range** _arr = static_cast(malloc(sizeof(QPageRanges__Range*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPageRanges::Range(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qpageranges.go b/qt6/gen_qpageranges.go index 78a8ae57..7f6e4d4e 100644 --- a/qt6/gen_qpageranges.go +++ b/qt6/gen_qpageranges.go @@ -71,7 +71,7 @@ func (this *QPageRanges) AddRange(from int, to int) { } func (this *QPageRanges) ToRangeList() []QPageRanges__Range { - var _ma *C.struct_miqt_array = C.QPageRanges_ToRangeList(this.h) + var _ma C.struct_miqt_array = C.QPageRanges_ToRangeList(this.h) _ret := make([]QPageRanges__Range, int(_ma.len)) _outCast := (*[0xffff]*C.QPageRanges__Range)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -80,7 +80,6 @@ func (this *QPageRanges) ToRangeList() []QPageRanges__Range { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qpageranges.h b/qt6/gen_qpageranges.h index 29130336..c6865f23 100644 --- a/qt6/gen_qpageranges.h +++ b/qt6/gen_qpageranges.h @@ -31,7 +31,7 @@ void QPageRanges_OperatorAssign(QPageRanges* self, QPageRanges* other); void QPageRanges_Swap(QPageRanges* self, QPageRanges* other); void QPageRanges_AddPage(QPageRanges* self, int pageNumber); void QPageRanges_AddRange(QPageRanges* self, int from, int to); -struct miqt_array* QPageRanges_ToRangeList(const QPageRanges* self); +struct miqt_array QPageRanges_ToRangeList(const QPageRanges* self); void QPageRanges_Clear(QPageRanges* self); struct miqt_string QPageRanges_ToString(const QPageRanges* self); QPageRanges* QPageRanges_FromString(struct miqt_string ranges); diff --git a/qt6/gen_qpainter.cpp b/qt6/gen_qpainter.cpp index f001cfea..1063201a 100644 --- a/qt6/gen_qpainter.cpp +++ b/qt6/gen_qpainter.cpp @@ -361,11 +361,11 @@ void QPainter_DrawLines(QPainter* self, QLineF* lines, int lineCount) { self->drawLines(lines, static_cast(lineCount)); } -void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array* /* of QLineF* */ lines) { +void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array /* of QLineF* */ lines) { QList lines_QList; - lines_QList.reserve(lines->len); - QLineF** lines_arr = static_cast(lines->data); - for(size_t i = 0; i < lines->len; ++i) { + lines_QList.reserve(lines.len); + QLineF** lines_arr = static_cast(lines.data); + for(size_t i = 0; i < lines.len; ++i) { lines_QList.push_back(*(lines_arr[i])); } self->drawLines(lines_QList); @@ -375,11 +375,11 @@ void QPainter_DrawLines2(QPainter* self, QPointF* pointPairs, int lineCount) { self->drawLines(pointPairs, static_cast(lineCount)); } -void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array* /* of QPointF* */ pointPairs) { +void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array /* of QPointF* */ pointPairs) { QList pointPairs_QList; - pointPairs_QList.reserve(pointPairs->len); - QPointF** pointPairs_arr = static_cast(pointPairs->data); - for(size_t i = 0; i < pointPairs->len; ++i) { + pointPairs_QList.reserve(pointPairs.len); + QPointF** pointPairs_arr = static_cast(pointPairs.data); + for(size_t i = 0; i < pointPairs.len; ++i) { pointPairs_QList.push_back(*(pointPairs_arr[i])); } self->drawLines(pointPairs_QList); @@ -389,11 +389,11 @@ void QPainter_DrawLines3(QPainter* self, QLine* lines, int lineCount) { self->drawLines(lines, static_cast(lineCount)); } -void QPainter_DrawLines4(QPainter* self, struct miqt_array* /* of QLine* */ lines) { +void QPainter_DrawLines4(QPainter* self, struct miqt_array /* of QLine* */ lines) { QList lines_QList; - lines_QList.reserve(lines->len); - QLine** lines_arr = static_cast(lines->data); - for(size_t i = 0; i < lines->len; ++i) { + lines_QList.reserve(lines.len); + QLine** lines_arr = static_cast(lines.data); + for(size_t i = 0; i < lines.len; ++i) { lines_QList.push_back(*(lines_arr[i])); } self->drawLines(lines_QList); @@ -403,11 +403,11 @@ void QPainter_DrawLines5(QPainter* self, QPoint* pointPairs, int lineCount) { self->drawLines(pointPairs, static_cast(lineCount)); } -void QPainter_DrawLines6(QPainter* self, struct miqt_array* /* of QPoint* */ pointPairs) { +void QPainter_DrawLines6(QPainter* self, struct miqt_array /* of QPoint* */ pointPairs) { QList pointPairs_QList; - pointPairs_QList.reserve(pointPairs->len); - QPoint** pointPairs_arr = static_cast(pointPairs->data); - for(size_t i = 0; i < pointPairs->len; ++i) { + pointPairs_QList.reserve(pointPairs.len); + QPoint** pointPairs_arr = static_cast(pointPairs.data); + for(size_t i = 0; i < pointPairs.len; ++i) { pointPairs_QList.push_back(*(pointPairs_arr[i])); } self->drawLines(pointPairs_QList); @@ -429,11 +429,11 @@ void QPainter_DrawRects(QPainter* self, QRectF* rects, int rectCount) { self->drawRects(rects, static_cast(rectCount)); } -void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array* /* of QRectF* */ rectangles) { +void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array /* of QRectF* */ rectangles) { QList rectangles_QList; - rectangles_QList.reserve(rectangles->len); - QRectF** rectangles_arr = static_cast(rectangles->data); - for(size_t i = 0; i < rectangles->len; ++i) { + rectangles_QList.reserve(rectangles.len); + QRectF** rectangles_arr = static_cast(rectangles.data); + for(size_t i = 0; i < rectangles.len; ++i) { rectangles_QList.push_back(*(rectangles_arr[i])); } self->drawRects(rectangles_QList); @@ -443,11 +443,11 @@ void QPainter_DrawRects2(QPainter* self, QRect* rects, int rectCount) { self->drawRects(rects, static_cast(rectCount)); } -void QPainter_DrawRects3(QPainter* self, struct miqt_array* /* of QRect* */ rectangles) { +void QPainter_DrawRects3(QPainter* self, struct miqt_array /* of QRect* */ rectangles) { QList rectangles_QList; - rectangles_QList.reserve(rectangles->len); - QRect** rectangles_arr = static_cast(rectangles->data); - for(size_t i = 0; i < rectangles->len; ++i) { + rectangles_QList.reserve(rectangles.len); + QRect** rectangles_arr = static_cast(rectangles.data); + for(size_t i = 0; i < rectangles.len; ++i) { rectangles_QList.push_back(*(rectangles_arr[i])); } self->drawRects(rectangles_QList); diff --git a/qt6/gen_qpainter.go b/qt6/gen_qpainter.go index 39c3a7fd..e6254ae3 100644 --- a/qt6/gen_qpainter.go +++ b/qt6/gen_qpainter.go @@ -446,14 +446,12 @@ func (this *QPainter) DrawLines(lines *QLineF, lineCount int) { } func (this *QPainter) DrawLinesWithLines(lines []QLineF) { - // For the C ABI, malloc a C array of raw pointers lines_CArray := (*[0xffff]*C.QLineF)(C.malloc(C.size_t(8 * len(lines)))) defer C.free(unsafe.Pointer(lines_CArray)) for i := range lines { lines_CArray[i] = lines[i].cPointer() } - lines_ma := &C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lines_ma)) + lines_ma := C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} C.QPainter_DrawLinesWithLines(this.h, lines_ma) } @@ -462,14 +460,12 @@ func (this *QPainter) DrawLines2(pointPairs *QPointF, lineCount int) { } func (this *QPainter) DrawLinesWithPointPairs(pointPairs []QPointF) { - // For the C ABI, malloc a C array of raw pointers pointPairs_CArray := (*[0xffff]*C.QPointF)(C.malloc(C.size_t(8 * len(pointPairs)))) defer C.free(unsafe.Pointer(pointPairs_CArray)) for i := range pointPairs { pointPairs_CArray[i] = pointPairs[i].cPointer() } - pointPairs_ma := &C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pointPairs_ma)) + pointPairs_ma := C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} C.QPainter_DrawLinesWithPointPairs(this.h, pointPairs_ma) } @@ -478,14 +474,12 @@ func (this *QPainter) DrawLines3(lines *QLine, lineCount int) { } func (this *QPainter) DrawLines4(lines []QLine) { - // For the C ABI, malloc a C array of raw pointers lines_CArray := (*[0xffff]*C.QLine)(C.malloc(C.size_t(8 * len(lines)))) defer C.free(unsafe.Pointer(lines_CArray)) for i := range lines { lines_CArray[i] = lines[i].cPointer() } - lines_ma := &C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lines_ma)) + lines_ma := C.struct_miqt_array{len: C.size_t(len(lines)), data: unsafe.Pointer(lines_CArray)} C.QPainter_DrawLines4(this.h, lines_ma) } @@ -494,14 +488,12 @@ func (this *QPainter) DrawLines5(pointPairs *QPoint, lineCount int) { } func (this *QPainter) DrawLines6(pointPairs []QPoint) { - // For the C ABI, malloc a C array of raw pointers pointPairs_CArray := (*[0xffff]*C.QPoint)(C.malloc(C.size_t(8 * len(pointPairs)))) defer C.free(unsafe.Pointer(pointPairs_CArray)) for i := range pointPairs { pointPairs_CArray[i] = pointPairs[i].cPointer() } - pointPairs_ma := &C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pointPairs_ma)) + pointPairs_ma := C.struct_miqt_array{len: C.size_t(len(pointPairs)), data: unsafe.Pointer(pointPairs_CArray)} C.QPainter_DrawLines6(this.h, pointPairs_ma) } @@ -522,14 +514,12 @@ func (this *QPainter) DrawRects(rects *QRectF, rectCount int) { } func (this *QPainter) DrawRectsWithRectangles(rectangles []QRectF) { - // For the C ABI, malloc a C array of raw pointers rectangles_CArray := (*[0xffff]*C.QRectF)(C.malloc(C.size_t(8 * len(rectangles)))) defer C.free(unsafe.Pointer(rectangles_CArray)) for i := range rectangles { rectangles_CArray[i] = rectangles[i].cPointer() } - rectangles_ma := &C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rectangles_ma)) + rectangles_ma := C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} C.QPainter_DrawRectsWithRectangles(this.h, rectangles_ma) } @@ -538,14 +528,12 @@ func (this *QPainter) DrawRects2(rects *QRect, rectCount int) { } func (this *QPainter) DrawRects3(rectangles []QRect) { - // For the C ABI, malloc a C array of raw pointers rectangles_CArray := (*[0xffff]*C.QRect)(C.malloc(C.size_t(8 * len(rectangles)))) defer C.free(unsafe.Pointer(rectangles_CArray)) for i := range rectangles { rectangles_CArray[i] = rectangles[i].cPointer() } - rectangles_ma := &C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(rectangles_ma)) + rectangles_ma := C.struct_miqt_array{len: C.size_t(len(rectangles)), data: unsafe.Pointer(rectangles_CArray)} C.QPainter_DrawRects3(this.h, rectangles_ma) } diff --git a/qt6/gen_qpainter.h b/qt6/gen_qpainter.h index 4c5fd5fb..f0f90d55 100644 --- a/qt6/gen_qpainter.h +++ b/qt6/gen_qpainter.h @@ -151,20 +151,20 @@ void QPainter_DrawLine2(QPainter* self, int x1, int y1, int x2, int y2); void QPainter_DrawLine3(QPainter* self, QPoint* p1, QPoint* p2); void QPainter_DrawLine4(QPainter* self, QPointF* p1, QPointF* p2); void QPainter_DrawLines(QPainter* self, QLineF* lines, int lineCount); -void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array* /* of QLineF* */ lines); +void QPainter_DrawLinesWithLines(QPainter* self, struct miqt_array /* of QLineF* */ lines); void QPainter_DrawLines2(QPainter* self, QPointF* pointPairs, int lineCount); -void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array* /* of QPointF* */ pointPairs); +void QPainter_DrawLinesWithPointPairs(QPainter* self, struct miqt_array /* of QPointF* */ pointPairs); void QPainter_DrawLines3(QPainter* self, QLine* lines, int lineCount); -void QPainter_DrawLines4(QPainter* self, struct miqt_array* /* of QLine* */ lines); +void QPainter_DrawLines4(QPainter* self, struct miqt_array /* of QLine* */ lines); void QPainter_DrawLines5(QPainter* self, QPoint* pointPairs, int lineCount); -void QPainter_DrawLines6(QPainter* self, struct miqt_array* /* of QPoint* */ pointPairs); +void QPainter_DrawLines6(QPainter* self, struct miqt_array /* of QPoint* */ pointPairs); void QPainter_DrawRect(QPainter* self, QRectF* rect); void QPainter_DrawRect2(QPainter* self, int x1, int y1, int w, int h); void QPainter_DrawRectWithRect(QPainter* self, QRect* rect); void QPainter_DrawRects(QPainter* self, QRectF* rects, int rectCount); -void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array* /* of QRectF* */ rectangles); +void QPainter_DrawRectsWithRectangles(QPainter* self, struct miqt_array /* of QRectF* */ rectangles); void QPainter_DrawRects2(QPainter* self, QRect* rects, int rectCount); -void QPainter_DrawRects3(QPainter* self, struct miqt_array* /* of QRect* */ rectangles); +void QPainter_DrawRects3(QPainter* self, struct miqt_array /* of QRect* */ rectangles); void QPainter_DrawEllipse(QPainter* self, QRectF* r); void QPainter_DrawEllipseWithQRect(QPainter* self, QRect* r); void QPainter_DrawEllipse2(QPainter* self, int x, int y, int w, int h); diff --git a/qt6/gen_qpainterpath.cpp b/qt6/gen_qpainterpath.cpp index 825dbc71..ba496bb1 100644 --- a/qt6/gen_qpainterpath.cpp +++ b/qt6/gen_qpainterpath.cpp @@ -378,26 +378,26 @@ void QPainterPathStroker_SetDashPattern(QPainterPathStroker* self, int dashPatte self->setDashPattern(static_cast(dashPattern)); } -void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array* /* of double */ dashPattern) { +void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array /* of double */ dashPattern) { QList dashPattern_QList; - dashPattern_QList.reserve(dashPattern->len); - double* dashPattern_arr = static_cast(dashPattern->data); - for(size_t i = 0; i < dashPattern->len; ++i) { + dashPattern_QList.reserve(dashPattern.len); + double* dashPattern_arr = static_cast(dashPattern.data); + for(size_t i = 0; i < dashPattern.len; ++i) { dashPattern_QList.push_back(static_cast(dashPattern_arr[i])); } self->setDashPattern(dashPattern_QList); } -struct miqt_array* QPainterPathStroker_DashPattern(const QPainterPathStroker* self) { +struct miqt_array QPainterPathStroker_DashPattern(const QPainterPathStroker* self) { QList _ret = self->dashPattern(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qpainterpath.go b/qt6/gen_qpainterpath.go index f102c016..6b726a99 100644 --- a/qt6/gen_qpainterpath.go +++ b/qt6/gen_qpainterpath.go @@ -505,25 +505,22 @@ func (this *QPainterPathStroker) SetDashPattern(dashPattern PenStyle) { } func (this *QPainterPathStroker) SetDashPatternWithDashPattern(dashPattern []float64) { - // For the C ABI, malloc a C array of raw pointers dashPattern_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(dashPattern)))) defer C.free(unsafe.Pointer(dashPattern_CArray)) for i := range dashPattern { dashPattern_CArray[i] = (C.double)(dashPattern[i]) } - dashPattern_ma := &C.struct_miqt_array{len: C.size_t(len(dashPattern)), data: unsafe.Pointer(dashPattern_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(dashPattern_ma)) + dashPattern_ma := C.struct_miqt_array{len: C.size_t(len(dashPattern)), data: unsafe.Pointer(dashPattern_CArray)} C.QPainterPathStroker_SetDashPatternWithDashPattern(this.h, dashPattern_ma) } func (this *QPainterPathStroker) DashPattern() []float64 { - var _ma *C.struct_miqt_array = C.QPainterPathStroker_DashPattern(this.h) + var _ma C.struct_miqt_array = C.QPainterPathStroker_DashPattern(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qpainterpath.h b/qt6/gen_qpainterpath.h index ad3f543e..ff43ca7b 100644 --- a/qt6/gen_qpainterpath.h +++ b/qt6/gen_qpainterpath.h @@ -125,8 +125,8 @@ double QPainterPathStroker_MiterLimit(const QPainterPathStroker* self); void QPainterPathStroker_SetCurveThreshold(QPainterPathStroker* self, double threshold); double QPainterPathStroker_CurveThreshold(const QPainterPathStroker* self); void QPainterPathStroker_SetDashPattern(QPainterPathStroker* self, int dashPattern); -void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array* /* of double */ dashPattern); -struct miqt_array* QPainterPathStroker_DashPattern(const QPainterPathStroker* self); +void QPainterPathStroker_SetDashPatternWithDashPattern(QPainterPathStroker* self, struct miqt_array /* of double */ dashPattern); +struct miqt_array QPainterPathStroker_DashPattern(const QPainterPathStroker* self); void QPainterPathStroker_SetDashOffset(QPainterPathStroker* self, double offset); double QPainterPathStroker_DashOffset(const QPainterPathStroker* self); QPainterPath* QPainterPathStroker_CreateStroke(const QPainterPathStroker* self, QPainterPath* path); diff --git a/qt6/gen_qpen.cpp b/qt6/gen_qpen.cpp index fcf3ea9c..945d621f 100644 --- a/qt6/gen_qpen.cpp +++ b/qt6/gen_qpen.cpp @@ -55,24 +55,24 @@ void QPen_SetStyle(QPen* self, int style) { self->setStyle(static_cast(style)); } -struct miqt_array* QPen_DashPattern(const QPen* self) { +struct miqt_array QPen_DashPattern(const QPen* self) { QList _ret = self->dashPattern(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QPen_SetDashPattern(QPen* self, struct miqt_array* /* of double */ pattern) { +void QPen_SetDashPattern(QPen* self, struct miqt_array /* of double */ pattern) { QList pattern_QList; - pattern_QList.reserve(pattern->len); - double* pattern_arr = static_cast(pattern->data); - for(size_t i = 0; i < pattern->len; ++i) { + pattern_QList.reserve(pattern.len); + double* pattern_arr = static_cast(pattern.data); + for(size_t i = 0; i < pattern.len; ++i) { pattern_QList.push_back(static_cast(pattern_arr[i])); } self->setDashPattern(pattern_QList); diff --git a/qt6/gen_qpen.go b/qt6/gen_qpen.go index 36d79196..3179b9e8 100644 --- a/qt6/gen_qpen.go +++ b/qt6/gen_qpen.go @@ -107,25 +107,22 @@ func (this *QPen) SetStyle(style PenStyle) { } func (this *QPen) DashPattern() []float64 { - var _ma *C.struct_miqt_array = C.QPen_DashPattern(this.h) + var _ma C.struct_miqt_array = C.QPen_DashPattern(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QPen) SetDashPattern(pattern []float64) { - // For the C ABI, malloc a C array of raw pointers pattern_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(pattern)))) defer C.free(unsafe.Pointer(pattern_CArray)) for i := range pattern { pattern_CArray[i] = (C.double)(pattern[i]) } - pattern_ma := &C.struct_miqt_array{len: C.size_t(len(pattern)), data: unsafe.Pointer(pattern_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(pattern_ma)) + pattern_ma := C.struct_miqt_array{len: C.size_t(len(pattern)), data: unsafe.Pointer(pattern_CArray)} C.QPen_SetDashPattern(this.h, pattern_ma) } diff --git a/qt6/gen_qpen.h b/qt6/gen_qpen.h index 4d0b6b1d..8c50b282 100644 --- a/qt6/gen_qpen.h +++ b/qt6/gen_qpen.h @@ -35,8 +35,8 @@ void QPen_OperatorAssign(QPen* self, QPen* pen); void QPen_Swap(QPen* self, QPen* other); int QPen_Style(const QPen* self); void QPen_SetStyle(QPen* self, int style); -struct miqt_array* QPen_DashPattern(const QPen* self); -void QPen_SetDashPattern(QPen* self, struct miqt_array* /* of double */ pattern); +struct miqt_array QPen_DashPattern(const QPen* self); +void QPen_SetDashPattern(QPen* self, struct miqt_array /* of double */ pattern); double QPen_DashOffset(const QPen* self); void QPen_SetDashOffset(QPen* self, double doffset); double QPen_MiterLimit(const QPen* self); diff --git a/qt6/gen_qplaintextedit.cpp b/qt6/gen_qplaintextedit.cpp index 559d7b87..fbfe6d49 100644 --- a/qt6/gen_qplaintextedit.cpp +++ b/qt6/gen_qplaintextedit.cpp @@ -284,26 +284,26 @@ void QPlainTextEdit_SetCursorWidth(QPlainTextEdit* self, int width) { self->setCursorWidth(static_cast(width)); } -void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections) { +void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextEdit__ExtraSelection** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextEdit__ExtraSelection** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->setExtraSelections(selections_QList); } -struct miqt_array* QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self) { +struct miqt_array QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self) { QList _ret = self->extraSelections(); // Convert QList<> from C++ memory to manually-managed C memory QTextEdit__ExtraSelection** _arr = static_cast(malloc(sizeof(QTextEdit__ExtraSelection*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextEdit::ExtraSelection(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qplaintextedit.go b/qt6/gen_qplaintextedit.go index 07a78e6d..b4a6461a 100644 --- a/qt6/gen_qplaintextedit.go +++ b/qt6/gen_qplaintextedit.go @@ -329,19 +329,17 @@ func (this *QPlainTextEdit) SetCursorWidth(width int) { } func (this *QPlainTextEdit) SetExtraSelections(selections []QTextEdit__ExtraSelection) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextEdit__ExtraSelection)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QPlainTextEdit_SetExtraSelections(this.h, selections_ma) } func (this *QPlainTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { - var _ma *C.struct_miqt_array = C.QPlainTextEdit_ExtraSelections(this.h) + var _ma C.struct_miqt_array = C.QPlainTextEdit_ExtraSelections(this.h) _ret := make([]QTextEdit__ExtraSelection, int(_ma.len)) _outCast := (*[0xffff]*C.QTextEdit__ExtraSelection)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -350,7 +348,6 @@ func (this *QPlainTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qplaintextedit.h b/qt6/gen_qplaintextedit.h index 7dd117de..885c30bb 100644 --- a/qt6/gen_qplaintextedit.h +++ b/qt6/gen_qplaintextedit.h @@ -122,8 +122,8 @@ double QPlainTextEdit_TabStopDistance(const QPlainTextEdit* self); void QPlainTextEdit_SetTabStopDistance(QPlainTextEdit* self, double distance); int QPlainTextEdit_CursorWidth(const QPlainTextEdit* self); void QPlainTextEdit_SetCursorWidth(QPlainTextEdit* self, int width); -void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections); -struct miqt_array* QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self); +void QPlainTextEdit_SetExtraSelections(QPlainTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections); +struct miqt_array QPlainTextEdit_ExtraSelections(const QPlainTextEdit* self); void QPlainTextEdit_MoveCursor(QPlainTextEdit* self, int operation); bool QPlainTextEdit_CanPaste(const QPlainTextEdit* self); void QPlainTextEdit_Print(const QPlainTextEdit* self, QPagedPaintDevice* printer); diff --git a/qt6/gen_qpluginloader.cpp b/qt6/gen_qpluginloader.cpp index 7f9d8f1d..89c5b4b3 100644 --- a/qt6/gen_qpluginloader.cpp +++ b/qt6/gen_qpluginloader.cpp @@ -56,29 +56,29 @@ QJsonObject* QPluginLoader_MetaData(const QPluginLoader* self) { return new QJsonObject(self->metaData()); } -struct miqt_array* QPluginLoader_StaticInstances() { +struct miqt_array QPluginLoader_StaticInstances() { QObjectList _ret = QPluginLoader::staticInstances(); // Convert QList<> from C++ memory to manually-managed C memory QObject** _arr = static_cast(malloc(sizeof(QObject*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPluginLoader_StaticPlugins() { +struct miqt_array QPluginLoader_StaticPlugins() { QList _ret = QPluginLoader::staticPlugins(); // Convert QList<> from C++ memory to manually-managed C memory QStaticPlugin** _arr = static_cast(malloc(sizeof(QStaticPlugin*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QStaticPlugin(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qpluginloader.go b/qt6/gen_qpluginloader.go index 3824464d..e4cdb526 100644 --- a/qt6/gen_qpluginloader.go +++ b/qt6/gen_qpluginloader.go @@ -106,18 +106,17 @@ func (this *QPluginLoader) MetaData() *QJsonObject { } func QPluginLoader_StaticInstances() []*QObject { - var _ma *C.struct_miqt_array = C.QPluginLoader_StaticInstances() + var _ma C.struct_miqt_array = C.QPluginLoader_StaticInstances() _ret := make([]*QObject, int(_ma.len)) _outCast := (*[0xffff]*C.QObject)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQObject(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func QPluginLoader_StaticPlugins() []QStaticPlugin { - var _ma *C.struct_miqt_array = C.QPluginLoader_StaticPlugins() + var _ma C.struct_miqt_array = C.QPluginLoader_StaticPlugins() _ret := make([]QStaticPlugin, int(_ma.len)) _outCast := (*[0xffff]*C.QStaticPlugin)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -126,7 +125,6 @@ func QPluginLoader_StaticPlugins() []QStaticPlugin { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qpluginloader.h b/qt6/gen_qpluginloader.h index 22a7327e..d57fb042 100644 --- a/qt6/gen_qpluginloader.h +++ b/qt6/gen_qpluginloader.h @@ -36,8 +36,8 @@ void* QPluginLoader_Metacast(QPluginLoader* self, const char* param1); struct miqt_string QPluginLoader_Tr(const char* s); QObject* QPluginLoader_Instance(QPluginLoader* self); QJsonObject* QPluginLoader_MetaData(const QPluginLoader* self); -struct miqt_array* QPluginLoader_StaticInstances(); -struct miqt_array* QPluginLoader_StaticPlugins(); +struct miqt_array QPluginLoader_StaticInstances(); +struct miqt_array QPluginLoader_StaticPlugins(); bool QPluginLoader_Load(QPluginLoader* self); bool QPluginLoader_Unload(QPluginLoader* self); bool QPluginLoader_IsLoaded(const QPluginLoader* self); diff --git a/qt6/gen_qprocess.cpp b/qt6/gen_qprocess.cpp index 071e59a1..e0762f49 100644 --- a/qt6/gen_qprocess.cpp +++ b/qt6/gen_qprocess.cpp @@ -79,7 +79,7 @@ struct miqt_string QProcessEnvironment_Value(const QProcessEnvironment* self, st return _ms; } -struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* self) { +struct miqt_array QProcessEnvironment_ToStringList(const QProcessEnvironment* self) { QStringList _ret = self->toStringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -93,13 +93,13 @@ struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* s memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self) { +struct miqt_array QProcessEnvironment_Keys(const QProcessEnvironment* self) { QStringList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -113,9 +113,9 @@ struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -209,7 +209,7 @@ void QProcess_SetProgram(QProcess* self, struct miqt_string program) { self->setProgram(program_QString); } -struct miqt_array* QProcess_Arguments(const QProcess* self) { +struct miqt_array QProcess_Arguments(const QProcess* self) { QStringList _ret = self->arguments(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -223,17 +223,17 @@ struct miqt_array* QProcess_Arguments(const QProcess* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QProcess_SetArguments(QProcess* self, struct miqt_array* /* of struct miqt_string */ arguments) { +void QProcess_SetArguments(QProcess* self, struct miqt_array /* of struct miqt_string */ arguments) { QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -310,18 +310,18 @@ void QProcess_SetWorkingDirectory(QProcess* self, struct miqt_string dir) { self->setWorkingDirectory(dir_QString); } -void QProcess_SetEnvironment(QProcess* self, struct miqt_array* /* of struct miqt_string */ environment) { +void QProcess_SetEnvironment(QProcess* self, struct miqt_array /* of struct miqt_string */ environment) { QStringList environment_QList; - environment_QList.reserve(environment->len); - struct miqt_string* environment_arr = static_cast(environment->data); - for(size_t i = 0; i < environment->len; ++i) { + environment_QList.reserve(environment.len); + struct miqt_string* environment_arr = static_cast(environment.data); + for(size_t i = 0; i < environment.len; ++i) { QString environment_arr_i_QString = QString::fromUtf8(environment_arr[i].data, environment_arr[i].len); environment_QList.push_back(environment_arr_i_QString); } self->setEnvironment(environment_QList); } -struct miqt_array* QProcess_Environment(const QProcess* self) { +struct miqt_array QProcess_Environment(const QProcess* self) { QStringList _ret = self->environment(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -335,9 +335,9 @@ struct miqt_array* QProcess_Environment(const QProcess* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -430,7 +430,7 @@ bool QProcess_StartDetachedWithProgram(struct miqt_string program) { return QProcess::startDetached(program_QString); } -struct miqt_array* QProcess_SystemEnvironment() { +struct miqt_array QProcess_SystemEnvironment() { QStringList _ret = QProcess::systemEnvironment(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -444,9 +444,9 @@ struct miqt_array* QProcess_SystemEnvironment() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -514,24 +514,24 @@ struct miqt_string QProcess_Tr3(const char* s, const char* c, int n) { return _ms; } -void QProcess_Start22(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +void QProcess_Start22(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } self->start(program_QString, arguments_QList); } -void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, int mode) { +void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, int mode) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -581,36 +581,36 @@ bool QProcess_WaitForFinished1(QProcess* self, int msecs) { return self->waitForFinished(static_cast(msecs)); } -int QProcess_Execute2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +int QProcess_Execute2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } return QProcess::execute(program_QString, arguments_QList); } -bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments) { +bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } return QProcess::startDetached(program_QString, arguments_QList); } -bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory) { +bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } @@ -618,12 +618,12 @@ bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array* /* o return QProcess::startDetached(program_QString, arguments_QList, workingDirectory_QString); } -bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid) { +bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid) { QString program_QString = QString::fromUtf8(program.data, program.len); QStringList arguments_QList; - arguments_QList.reserve(arguments->len); - struct miqt_string* arguments_arr = static_cast(arguments->data); - for(size_t i = 0; i < arguments->len; ++i) { + arguments_QList.reserve(arguments.len); + struct miqt_string* arguments_arr = static_cast(arguments.data); + for(size_t i = 0; i < arguments.len; ++i) { QString arguments_arr_i_QString = QString::fromUtf8(arguments_arr[i].data, arguments_arr[i].len); arguments_QList.push_back(arguments_arr_i_QString); } diff --git a/qt6/gen_qprocess.go b/qt6/gen_qprocess.go index aae24e32..22d8ab40 100644 --- a/qt6/gen_qprocess.go +++ b/qt6/gen_qprocess.go @@ -185,7 +185,7 @@ func (this *QProcessEnvironment) Value(name string) string { } func (this *QProcessEnvironment) ToStringList() []string { - var _ma *C.struct_miqt_array = C.QProcessEnvironment_ToStringList(this.h) + var _ma C.struct_miqt_array = C.QProcessEnvironment_ToStringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -194,12 +194,11 @@ func (this *QProcessEnvironment) ToStringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QProcessEnvironment) Keys() []string { - var _ma *C.struct_miqt_array = C.QProcessEnvironment_Keys(this.h) + var _ma C.struct_miqt_array = C.QProcessEnvironment_Keys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -208,7 +207,6 @@ func (this *QProcessEnvironment) Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -357,7 +355,7 @@ func (this *QProcess) SetProgram(program string) { } func (this *QProcess) Arguments() []string { - var _ma *C.struct_miqt_array = C.QProcess_Arguments(this.h) + var _ma C.struct_miqt_array = C.QProcess_Arguments(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -366,12 +364,10 @@ func (this *QProcess) Arguments() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QProcess) SetArguments(arguments []string) { - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -381,8 +377,7 @@ func (this *QProcess) SetArguments(arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_SetArguments(this.h, arguments_ma) } @@ -462,7 +457,6 @@ func (this *QProcess) SetWorkingDirectory(dir string) { } func (this *QProcess) SetEnvironment(environment []string) { - // For the C ABI, malloc a C array of structs environment_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(environment)))) defer C.free(unsafe.Pointer(environment_CArray)) for i := range environment { @@ -472,13 +466,12 @@ func (this *QProcess) SetEnvironment(environment []string) { defer C.free(unsafe.Pointer(environment_i_ms.data)) environment_CArray[i] = environment_i_ms } - environment_ma := &C.struct_miqt_array{len: C.size_t(len(environment)), data: unsafe.Pointer(environment_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(environment_ma)) + environment_ma := C.struct_miqt_array{len: C.size_t(len(environment)), data: unsafe.Pointer(environment_CArray)} C.QProcess_SetEnvironment(this.h, environment_ma) } func (this *QProcess) Environment() []string { - var _ma *C.struct_miqt_array = C.QProcess_Environment(this.h) + var _ma C.struct_miqt_array = C.QProcess_Environment(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -487,7 +480,6 @@ func (this *QProcess) Environment() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -581,7 +573,7 @@ func QProcess_StartDetachedWithProgram(program string) bool { } func QProcess_SystemEnvironment() []string { - var _ma *C.struct_miqt_array = C.QProcess_SystemEnvironment() + var _ma C.struct_miqt_array = C.QProcess_SystemEnvironment() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -590,7 +582,6 @@ func QProcess_SystemEnvironment() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -676,7 +667,6 @@ func (this *QProcess) Start22(program string, arguments []string) { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -686,8 +676,7 @@ func (this *QProcess) Start22(program string, arguments []string) { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_Start22(this.h, program_ms, arguments_ma) } @@ -696,7 +685,6 @@ func (this *QProcess) Start3(program string, arguments []string, mode QIODeviceB program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -706,8 +694,7 @@ func (this *QProcess) Start3(program string, arguments []string, mode QIODeviceB defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} C.QProcess_Start3(this.h, program_ms, arguments_ma, (C.int)(mode)) } @@ -768,7 +755,6 @@ func QProcess_Execute2(program string, arguments []string) int { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -778,8 +764,7 @@ func QProcess_Execute2(program string, arguments []string) int { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (int)(C.QProcess_Execute2(program_ms, arguments_ma)) } @@ -788,7 +773,6 @@ func QProcess_StartDetached2(program string, arguments []string) bool { program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -798,8 +782,7 @@ func QProcess_StartDetached2(program string, arguments []string) bool { defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} return (bool)(C.QProcess_StartDetached2(program_ms, arguments_ma)) } @@ -808,7 +791,6 @@ func QProcess_StartDetached3(program string, arguments []string, workingDirector program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -818,8 +800,7 @@ func QProcess_StartDetached3(program string, arguments []string, workingDirector defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} workingDirectory_ms := C.struct_miqt_string{} workingDirectory_ms.data = C.CString(workingDirectory) workingDirectory_ms.len = C.size_t(len(workingDirectory)) @@ -832,7 +813,6 @@ func QProcess_StartDetached4(program string, arguments []string, workingDirector program_ms.data = C.CString(program) program_ms.len = C.size_t(len(program)) defer C.free(unsafe.Pointer(program_ms.data)) - // For the C ABI, malloc a C array of structs arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments)))) defer C.free(unsafe.Pointer(arguments_CArray)) for i := range arguments { @@ -842,8 +822,7 @@ func QProcess_StartDetached4(program string, arguments []string, workingDirector defer C.free(unsafe.Pointer(arguments_i_ms.data)) arguments_CArray[i] = arguments_i_ms } - arguments_ma := &C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(arguments_ma)) + arguments_ma := C.struct_miqt_array{len: C.size_t(len(arguments)), data: unsafe.Pointer(arguments_CArray)} workingDirectory_ms := C.struct_miqt_string{} workingDirectory_ms.data = C.CString(workingDirectory) workingDirectory_ms.len = C.size_t(len(workingDirectory)) diff --git a/qt6/gen_qprocess.h b/qt6/gen_qprocess.h index 5c43bfc7..93b84d7d 100644 --- a/qt6/gen_qprocess.h +++ b/qt6/gen_qprocess.h @@ -41,8 +41,8 @@ bool QProcessEnvironment_Contains(const QProcessEnvironment* self, struct miqt_s void QProcessEnvironment_Insert(QProcessEnvironment* self, struct miqt_string name, struct miqt_string value); void QProcessEnvironment_Remove(QProcessEnvironment* self, struct miqt_string name); struct miqt_string QProcessEnvironment_Value(const QProcessEnvironment* self, struct miqt_string name); -struct miqt_array* QProcessEnvironment_ToStringList(const QProcessEnvironment* self); -struct miqt_array* QProcessEnvironment_Keys(const QProcessEnvironment* self); +struct miqt_array QProcessEnvironment_ToStringList(const QProcessEnvironment* self); +struct miqt_array QProcessEnvironment_Keys(const QProcessEnvironment* self); void QProcessEnvironment_InsertWithQProcessEnvironment(QProcessEnvironment* self, QProcessEnvironment* e); QProcessEnvironment* QProcessEnvironment_SystemEnvironment(); struct miqt_string QProcessEnvironment_Value2(const QProcessEnvironment* self, struct miqt_string name, struct miqt_string defaultValue); @@ -60,8 +60,8 @@ bool QProcess_StartDetached(QProcess* self); bool QProcess_Open(QProcess* self); struct miqt_string QProcess_Program(const QProcess* self); void QProcess_SetProgram(QProcess* self, struct miqt_string program); -struct miqt_array* QProcess_Arguments(const QProcess* self); -void QProcess_SetArguments(QProcess* self, struct miqt_array* /* of struct miqt_string */ arguments); +struct miqt_array QProcess_Arguments(const QProcess* self); +void QProcess_SetArguments(QProcess* self, struct miqt_array /* of struct miqt_string */ arguments); int QProcess_ProcessChannelMode(const QProcess* self); void QProcess_SetProcessChannelMode(QProcess* self, int mode); int QProcess_InputChannelMode(const QProcess* self); @@ -76,8 +76,8 @@ void QProcess_SetStandardErrorFile(QProcess* self, struct miqt_string fileName); void QProcess_SetStandardOutputProcess(QProcess* self, QProcess* destination); struct miqt_string QProcess_WorkingDirectory(const QProcess* self); void QProcess_SetWorkingDirectory(QProcess* self, struct miqt_string dir); -void QProcess_SetEnvironment(QProcess* self, struct miqt_array* /* of struct miqt_string */ environment); -struct miqt_array* QProcess_Environment(const QProcess* self); +void QProcess_SetEnvironment(QProcess* self, struct miqt_array /* of struct miqt_string */ environment); +struct miqt_array QProcess_Environment(const QProcess* self); void QProcess_SetProcessEnvironment(QProcess* self, QProcessEnvironment* environment); QProcessEnvironment* QProcess_ProcessEnvironment(const QProcess* self); int QProcess_Error(const QProcess* self); @@ -96,7 +96,7 @@ bool QProcess_IsSequential(const QProcess* self); void QProcess_Close(QProcess* self); int QProcess_Execute(struct miqt_string program); bool QProcess_StartDetachedWithProgram(struct miqt_string program); -struct miqt_array* QProcess_SystemEnvironment(); +struct miqt_array QProcess_SystemEnvironment(); struct miqt_string QProcess_NullDevice(); void QProcess_Terminate(QProcess* self); void QProcess_Kill(QProcess* self); @@ -106,8 +106,8 @@ void QProcess_ErrorOccurred(QProcess* self, int error); void QProcess_connect_ErrorOccurred(QProcess* self, intptr_t slot); struct miqt_string QProcess_Tr2(const char* s, const char* c); struct miqt_string QProcess_Tr3(const char* s, const char* c, int n); -void QProcess_Start22(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); -void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, int mode); +void QProcess_Start22(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); +void QProcess_Start3(QProcess* self, struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, int mode); void QProcess_Start1(QProcess* self, int mode); void QProcess_StartCommand2(QProcess* self, struct miqt_string command, int mode); bool QProcess_StartDetached1(QProcess* self, long long* pid); @@ -118,10 +118,10 @@ bool QProcess_WaitForStarted1(QProcess* self, int msecs); bool QProcess_WaitForReadyRead1(QProcess* self, int msecs); bool QProcess_WaitForBytesWritten1(QProcess* self, int msecs); bool QProcess_WaitForFinished1(QProcess* self, int msecs); -int QProcess_Execute2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); -bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments); -bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory); -bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array* /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid); +int QProcess_Execute2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); +bool QProcess_StartDetached2(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments); +bool QProcess_StartDetached3(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory); +bool QProcess_StartDetached4(struct miqt_string program, struct miqt_array /* of struct miqt_string */ arguments, struct miqt_string workingDirectory, long long* pid); void QProcess_Finished2(QProcess* self, int exitCode, int exitStatus); void QProcess_connect_Finished2(QProcess* self, intptr_t slot); void QProcess_Delete(QProcess* self); diff --git a/qt6/gen_qrawfont.cpp b/qt6/gen_qrawfont.cpp index ff5d839e..90942704 100644 --- a/qt6/gen_qrawfont.cpp +++ b/qt6/gen_qrawfont.cpp @@ -94,7 +94,7 @@ int QRawFont_Weight(const QRawFont* self) { return self->weight(); } -struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text) { +struct miqt_array QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->glyphIndexesForString(text_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -102,17 +102,17 @@ struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct m for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes) { +struct miqt_array QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes) { QList glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } QList _ret = self->advancesForGlyphIndexes(glyphIndexes_QList); @@ -121,17 +121,17 @@ struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes, int layoutFlags) { +struct miqt_array QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes, int layoutFlags) { QList glyphIndexes_QList; - glyphIndexes_QList.reserve(glyphIndexes->len); - unsigned int* glyphIndexes_arr = static_cast(glyphIndexes->data); - for(size_t i = 0; i < glyphIndexes->len; ++i) { + glyphIndexes_QList.reserve(glyphIndexes.len); + unsigned int* glyphIndexes_arr = static_cast(glyphIndexes.data); + for(size_t i = 0; i < glyphIndexes.len; ++i) { glyphIndexes_QList.push_back(static_cast(glyphIndexes_arr[i])); } QList _ret = self->advancesForGlyphIndexes(glyphIndexes_QList, static_cast(layoutFlags)); @@ -140,9 +140,9 @@ struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struc for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPointF(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -252,7 +252,7 @@ bool QRawFont_SupportsCharacterWithCharacter(const QRawFont* self, QChar* charac return self->supportsCharacter(*character); } -struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self) { +struct miqt_array QRawFont_SupportedWritingSystems(const QRawFont* self) { QList _ret = self->supportedWritingSystems(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -260,9 +260,9 @@ struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self) { QFontDatabase::WritingSystem _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qrawfont.go b/qt6/gen_qrawfont.go index c9b03b30..f538b3ef 100644 --- a/qt6/gen_qrawfont.go +++ b/qt6/gen_qrawfont.go @@ -154,26 +154,23 @@ func (this *QRawFont) GlyphIndexesForString(text string) []uint { text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QRawFont_GlyphIndexesForString(this.h, text_ms) + var _ma C.struct_miqt_array = C.QRawFont_GlyphIndexesForString(this.h, text_ms) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QRawFont) AdvancesForGlyphIndexes(glyphIndexes []uint) []QPointF { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) - var _ma *C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes(this.h, glyphIndexes_ma) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} + var _ma C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes(this.h, glyphIndexes_ma) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -182,20 +179,17 @@ func (this *QRawFont) AdvancesForGlyphIndexes(glyphIndexes []uint) []QPointF { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QRawFont) AdvancesForGlyphIndexes2(glyphIndexes []uint, layoutFlags QRawFont__LayoutFlag) []QPointF { - // For the C ABI, malloc a C array of raw pointers glyphIndexes_CArray := (*[0xffff]C.uint)(C.malloc(C.size_t(8 * len(glyphIndexes)))) defer C.free(unsafe.Pointer(glyphIndexes_CArray)) for i := range glyphIndexes { glyphIndexes_CArray[i] = (C.uint)(glyphIndexes[i]) } - glyphIndexes_ma := &C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(glyphIndexes_ma)) - var _ma *C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes2(this.h, glyphIndexes_ma, (C.int)(layoutFlags)) + glyphIndexes_ma := C.struct_miqt_array{len: C.size_t(len(glyphIndexes)), data: unsafe.Pointer(glyphIndexes_CArray)} + var _ma C.struct_miqt_array = C.QRawFont_AdvancesForGlyphIndexes2(this.h, glyphIndexes_ma, (C.int)(layoutFlags)) _ret := make([]QPointF, int(_ma.len)) _outCast := (*[0xffff]*C.QPointF)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -204,7 +198,6 @@ func (this *QRawFont) AdvancesForGlyphIndexes2(glyphIndexes []uint, layoutFlags _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -317,13 +310,12 @@ func (this *QRawFont) SupportsCharacterWithCharacter(character QChar) bool { } func (this *QRawFont) SupportedWritingSystems() []QFontDatabase__WritingSystem { - var _ma *C.struct_miqt_array = C.QRawFont_SupportedWritingSystems(this.h) + var _ma C.struct_miqt_array = C.QRawFont_SupportedWritingSystems(this.h) _ret := make([]QFontDatabase__WritingSystem, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QFontDatabase__WritingSystem)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qrawfont.h b/qt6/gen_qrawfont.h index f9201f75..d13c72d4 100644 --- a/qt6/gen_qrawfont.h +++ b/qt6/gen_qrawfont.h @@ -50,9 +50,9 @@ struct miqt_string QRawFont_FamilyName(const QRawFont* self); struct miqt_string QRawFont_StyleName(const QRawFont* self); int QRawFont_Style(const QRawFont* self); int QRawFont_Weight(const QRawFont* self); -struct miqt_array* QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text); -struct miqt_array* QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes); -struct miqt_array* QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array* /* of unsigned int */ glyphIndexes, int layoutFlags); +struct miqt_array QRawFont_GlyphIndexesForString(const QRawFont* self, struct miqt_string text); +struct miqt_array QRawFont_AdvancesForGlyphIndexes(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes); +struct miqt_array QRawFont_AdvancesForGlyphIndexes2(const QRawFont* self, struct miqt_array /* of unsigned int */ glyphIndexes, int layoutFlags); bool QRawFont_GlyphIndexesForChars(const QRawFont* self, QChar* chars, int numChars, unsigned int* glyphIndexes, int* numGlyphs); bool QRawFont_AdvancesForGlyphIndexes3(const QRawFont* self, const unsigned int* glyphIndexes, QPointF* advances, int numGlyphs); bool QRawFont_AdvancesForGlyphIndexes4(const QRawFont* self, const unsigned int* glyphIndexes, QPointF* advances, int numGlyphs, int layoutFlags); @@ -76,7 +76,7 @@ void QRawFont_LoadFromFile(QRawFont* self, struct miqt_string fileName, double p void QRawFont_LoadFromData(QRawFont* self, struct miqt_string fontData, double pixelSize, int hintingPreference); bool QRawFont_SupportsCharacter(const QRawFont* self, unsigned int ucs4); bool QRawFont_SupportsCharacterWithCharacter(const QRawFont* self, QChar* character); -struct miqt_array* QRawFont_SupportedWritingSystems(const QRawFont* self); +struct miqt_array QRawFont_SupportedWritingSystems(const QRawFont* self); struct miqt_string QRawFont_FontTable(const QRawFont* self, const char* tagName); QRawFont* QRawFont_FromFont(QFont* font); QImage* QRawFont_AlphaMapForGlyph2(const QRawFont* self, unsigned int glyphIndex, int antialiasingType); diff --git a/qt6/gen_qregularexpression.cpp b/qt6/gen_qregularexpression.cpp index 0b9d9c8c..2a19e34f 100644 --- a/qt6/gen_qregularexpression.cpp +++ b/qt6/gen_qregularexpression.cpp @@ -86,7 +86,7 @@ int QRegularExpression_CaptureCount(const QRegularExpression* self) { return self->captureCount(); } -struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpression* self) { +struct miqt_array QRegularExpression_NamedCaptureGroups(const QRegularExpression* self) { QStringList _ret = self->namedCaptureGroups(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -100,9 +100,9 @@ struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpressio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -288,7 +288,7 @@ struct miqt_string QRegularExpressionMatch_CapturedWithName(const QRegularExpres return _ms; } -struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self) { +struct miqt_array QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self) { QStringList _ret = self->capturedTexts(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -302,9 +302,9 @@ struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressio memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qregularexpression.go b/qt6/gen_qregularexpression.go index 319353fd..9df7e5c9 100644 --- a/qt6/gen_qregularexpression.go +++ b/qt6/gen_qregularexpression.go @@ -163,7 +163,7 @@ func (this *QRegularExpression) CaptureCount() int { } func (this *QRegularExpression) NamedCaptureGroups() []string { - var _ma *C.struct_miqt_array = C.QRegularExpression_NamedCaptureGroups(this.h) + var _ma C.struct_miqt_array = C.QRegularExpression_NamedCaptureGroups(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -172,7 +172,6 @@ func (this *QRegularExpression) NamedCaptureGroups() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -445,7 +444,7 @@ func (this *QRegularExpressionMatch) CapturedWithName(name string) string { } func (this *QRegularExpressionMatch) CapturedTexts() []string { - var _ma *C.struct_miqt_array = C.QRegularExpressionMatch_CapturedTexts(this.h) + var _ma C.struct_miqt_array = C.QRegularExpressionMatch_CapturedTexts(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -454,7 +453,6 @@ func (this *QRegularExpressionMatch) CapturedTexts() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qregularexpression.h b/qt6/gen_qregularexpression.h index 310011bd..9599cc7a 100644 --- a/qt6/gen_qregularexpression.h +++ b/qt6/gen_qregularexpression.h @@ -49,7 +49,7 @@ bool QRegularExpression_IsValid(const QRegularExpression* self); ptrdiff_t QRegularExpression_PatternErrorOffset(const QRegularExpression* self); struct miqt_string QRegularExpression_ErrorString(const QRegularExpression* self); int QRegularExpression_CaptureCount(const QRegularExpression* self); -struct miqt_array* QRegularExpression_NamedCaptureGroups(const QRegularExpression* self); +struct miqt_array QRegularExpression_NamedCaptureGroups(const QRegularExpression* self); QRegularExpressionMatch* QRegularExpression_Match(const QRegularExpression* self, struct miqt_string subject); QRegularExpressionMatchIterator* QRegularExpression_GlobalMatch(const QRegularExpression* self, struct miqt_string subject); void QRegularExpression_Optimize(const QRegularExpression* self); @@ -82,7 +82,7 @@ bool QRegularExpressionMatch_HasCaptured(const QRegularExpressionMatch* self, st bool QRegularExpressionMatch_HasCapturedWithNth(const QRegularExpressionMatch* self, int nth); struct miqt_string QRegularExpressionMatch_Captured(const QRegularExpressionMatch* self); struct miqt_string QRegularExpressionMatch_CapturedWithName(const QRegularExpressionMatch* self, struct miqt_string name); -struct miqt_array* QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self); +struct miqt_array QRegularExpressionMatch_CapturedTexts(const QRegularExpressionMatch* self); ptrdiff_t QRegularExpressionMatch_CapturedStart(const QRegularExpressionMatch* self); ptrdiff_t QRegularExpressionMatch_CapturedLength(const QRegularExpressionMatch* self); ptrdiff_t QRegularExpressionMatch_CapturedEnd(const QRegularExpressionMatch* self); diff --git a/qt6/gen_qscreen.cpp b/qt6/gen_qscreen.cpp index 7ab6e3f2..92e4f378 100644 --- a/qt6/gen_qscreen.cpp +++ b/qt6/gen_qscreen.cpp @@ -136,16 +136,16 @@ QRect* QScreen_AvailableGeometry(const QScreen* self) { return new QRect(self->availableGeometry()); } -struct miqt_array* QScreen_VirtualSiblings(const QScreen* self) { +struct miqt_array QScreen_VirtualSiblings(const QScreen* self) { QList _ret = self->virtualSiblings(); // Convert QList<> from C++ memory to manually-managed C memory QScreen** _arr = static_cast(malloc(sizeof(QScreen*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qscreen.go b/qt6/gen_qscreen.go index 068262a6..0b7a3d01 100644 --- a/qt6/gen_qscreen.go +++ b/qt6/gen_qscreen.go @@ -159,13 +159,12 @@ func (this *QScreen) AvailableGeometry() *QRect { } func (this *QScreen) VirtualSiblings() []*QScreen { - var _ma *C.struct_miqt_array = C.QScreen_VirtualSiblings(this.h) + var _ma C.struct_miqt_array = C.QScreen_VirtualSiblings(this.h) _ret := make([]*QScreen, int(_ma.len)) _outCast := (*[0xffff]*C.QScreen)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScreen(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qscreen.h b/qt6/gen_qscreen.h index 0e19a25a..3e9bc650 100644 --- a/qt6/gen_qscreen.h +++ b/qt6/gen_qscreen.h @@ -53,7 +53,7 @@ double QScreen_LogicalDotsPerInch(const QScreen* self); double QScreen_DevicePixelRatio(const QScreen* self); QSize* QScreen_AvailableSize(const QScreen* self); QRect* QScreen_AvailableGeometry(const QScreen* self); -struct miqt_array* QScreen_VirtualSiblings(const QScreen* self); +struct miqt_array QScreen_VirtualSiblings(const QScreen* self); QScreen* QScreen_VirtualSiblingAt(QScreen* self, QPoint* point); QSize* QScreen_VirtualSize(const QScreen* self); QRect* QScreen_VirtualGeometry(const QScreen* self); diff --git a/qt6/gen_qscroller.cpp b/qt6/gen_qscroller.cpp index c18c85a9..e0297dab 100644 --- a/qt6/gen_qscroller.cpp +++ b/qt6/gen_qscroller.cpp @@ -57,16 +57,16 @@ void QScroller_UngrabGesture(QObject* target) { QScroller::ungrabGesture(target); } -struct miqt_array* QScroller_ActiveScrollers() { +struct miqt_array QScroller_ActiveScrollers() { QList _ret = QScroller::activeScrollers(); // Convert QList<> from C++ memory to manually-managed C memory QScroller** _arr = static_cast(malloc(sizeof(QScroller*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -103,11 +103,11 @@ QScrollerProperties* QScroller_ScrollerProperties(const QScroller* self) { return new QScrollerProperties(self->scrollerProperties()); } -void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array* /* of double */ positions) { +void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array /* of double */ positions) { QList positions_QList; - positions_QList.reserve(positions->len); - double* positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + double* positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(static_cast(positions_arr[i])); } self->setSnapPositionsX(positions_QList); @@ -117,11 +117,11 @@ void QScroller_SetSnapPositionsX2(QScroller* self, double first, double interval self->setSnapPositionsX(static_cast(first), static_cast(interval)); } -void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array* /* of double */ positions) { +void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array /* of double */ positions) { QList positions_QList; - positions_QList.reserve(positions->len); - double* positions_arr = static_cast(positions->data); - for(size_t i = 0; i < positions->len; ++i) { + positions_QList.reserve(positions.len); + double* positions_arr = static_cast(positions.data); + for(size_t i = 0; i < positions.len; ++i) { positions_QList.push_back(static_cast(positions_arr[i])); } self->setSnapPositionsY(positions_QList); diff --git a/qt6/gen_qscroller.go b/qt6/gen_qscroller.go index a7ee0d5c..7166b412 100644 --- a/qt6/gen_qscroller.go +++ b/qt6/gen_qscroller.go @@ -9,7 +9,6 @@ package qt6 import "C" import ( - "runtime" "runtime/cgo" "unsafe" ) @@ -114,13 +113,12 @@ func QScroller_UngrabGesture(target *QObject) { } func QScroller_ActiveScrollers() []*QScroller { - var _ma *C.struct_miqt_array = C.QScroller_ActiveScrollers() + var _ma C.struct_miqt_array = C.QScroller_ActiveScrollers() _ret := make([]*QScroller, int(_ma.len)) _outCast := (*[0xffff]*C.QScroller)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQScroller(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -169,14 +167,12 @@ func (this *QScroller) ScrollerProperties() *QScrollerProperties { } func (this *QScroller) SetSnapPositionsX(positions []float64) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = (C.double)(positions[i]) } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QScroller_SetSnapPositionsX(this.h, positions_ma) } @@ -185,14 +181,12 @@ func (this *QScroller) SetSnapPositionsX2(first float64, interval float64) { } func (this *QScroller) SetSnapPositionsY(positions []float64) { - // For the C ABI, malloc a C array of raw pointers positions_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(positions)))) defer C.free(unsafe.Pointer(positions_CArray)) for i := range positions { positions_CArray[i] = (C.double)(positions[i]) } - positions_ma := &C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(positions_ma)) + positions_ma := C.struct_miqt_array{len: C.size_t(len(positions)), data: unsafe.Pointer(positions_CArray)} C.QScroller_SetSnapPositionsY(this.h, positions_ma) } diff --git a/qt6/gen_qscroller.h b/qt6/gen_qscroller.h index 3cf5b7d0..8aef1907 100644 --- a/qt6/gen_qscroller.h +++ b/qt6/gen_qscroller.h @@ -38,7 +38,7 @@ QScroller* QScroller_ScrollerWithTarget(QObject* target); int QScroller_GrabGesture(QObject* target); int QScroller_GrabbedGesture(QObject* target); void QScroller_UngrabGesture(QObject* target); -struct miqt_array* QScroller_ActiveScrollers(); +struct miqt_array QScroller_ActiveScrollers(); QObject* QScroller_Target(const QScroller* self); int QScroller_State(const QScroller* self); bool QScroller_HandleInput(QScroller* self, int input, QPointF* position); @@ -47,9 +47,9 @@ QPointF* QScroller_Velocity(const QScroller* self); QPointF* QScroller_FinalPosition(const QScroller* self); QPointF* QScroller_PixelPerMeter(const QScroller* self); QScrollerProperties* QScroller_ScrollerProperties(const QScroller* self); -void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array* /* of double */ positions); +void QScroller_SetSnapPositionsX(QScroller* self, struct miqt_array /* of double */ positions); void QScroller_SetSnapPositionsX2(QScroller* self, double first, double interval); -void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array* /* of double */ positions); +void QScroller_SetSnapPositionsY(QScroller* self, struct miqt_array /* of double */ positions); void QScroller_SetSnapPositionsY2(QScroller* self, double first, double interval); void QScroller_SetScrollerProperties(QScroller* self, QScrollerProperties* prop); void QScroller_ScrollTo(QScroller* self, QPointF* pos); diff --git a/qt6/gen_qsessionmanager.cpp b/qt6/gen_qsessionmanager.cpp index 8ecd7277..27fc38b6 100644 --- a/qt6/gen_qsessionmanager.cpp +++ b/qt6/gen_qsessionmanager.cpp @@ -74,18 +74,18 @@ int QSessionManager_RestartHint(const QSessionManager* self) { return static_cast(_ret); } -void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ restartCommand) { +void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ restartCommand) { QStringList restartCommand_QList; - restartCommand_QList.reserve(restartCommand->len); - struct miqt_string* restartCommand_arr = static_cast(restartCommand->data); - for(size_t i = 0; i < restartCommand->len; ++i) { + restartCommand_QList.reserve(restartCommand.len); + struct miqt_string* restartCommand_arr = static_cast(restartCommand.data); + for(size_t i = 0; i < restartCommand.len; ++i) { QString restartCommand_arr_i_QString = QString::fromUtf8(restartCommand_arr[i].data, restartCommand_arr[i].len); restartCommand_QList.push_back(restartCommand_arr_i_QString); } self->setRestartCommand(restartCommand_QList); } -struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self) { +struct miqt_array QSessionManager_RestartCommand(const QSessionManager* self) { QStringList _ret = self->restartCommand(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -99,24 +99,24 @@ struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ discardCommand) { +void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ discardCommand) { QStringList discardCommand_QList; - discardCommand_QList.reserve(discardCommand->len); - struct miqt_string* discardCommand_arr = static_cast(discardCommand->data); - for(size_t i = 0; i < discardCommand->len; ++i) { + discardCommand_QList.reserve(discardCommand.len); + struct miqt_string* discardCommand_arr = static_cast(discardCommand.data); + for(size_t i = 0; i < discardCommand.len; ++i) { QString discardCommand_arr_i_QString = QString::fromUtf8(discardCommand_arr[i].data, discardCommand_arr[i].len); discardCommand_QList.push_back(discardCommand_arr_i_QString); } self->setDiscardCommand(discardCommand_QList); } -struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self) { +struct miqt_array QSessionManager_DiscardCommand(const QSessionManager* self) { QStringList _ret = self->discardCommand(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -130,9 +130,9 @@ struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -142,12 +142,12 @@ void QSessionManager_SetManagerProperty(QSessionManager* self, struct miqt_strin self->setManagerProperty(name_QString, value_QString); } -void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array* /* of struct miqt_string */ value) { +void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array /* of struct miqt_string */ value) { QString name_QString = QString::fromUtf8(name.data, name.len); QStringList value_QList; - value_QList.reserve(value->len); - struct miqt_string* value_arr = static_cast(value->data); - for(size_t i = 0; i < value->len; ++i) { + value_QList.reserve(value.len); + struct miqt_string* value_arr = static_cast(value.data); + for(size_t i = 0; i < value.len; ++i) { QString value_arr_i_QString = QString::fromUtf8(value_arr[i].data, value_arr[i].len); value_QList.push_back(value_arr_i_QString); } diff --git a/qt6/gen_qsessionmanager.go b/qt6/gen_qsessionmanager.go index b46a8ed6..88aef8d7 100644 --- a/qt6/gen_qsessionmanager.go +++ b/qt6/gen_qsessionmanager.go @@ -9,7 +9,6 @@ package qt6 import "C" import ( - "runtime" "unsafe" ) @@ -110,7 +109,6 @@ func (this *QSessionManager) RestartHint() QSessionManager__RestartHint { } func (this *QSessionManager) SetRestartCommand(restartCommand []string) { - // For the C ABI, malloc a C array of structs restartCommand_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(restartCommand)))) defer C.free(unsafe.Pointer(restartCommand_CArray)) for i := range restartCommand { @@ -120,13 +118,12 @@ func (this *QSessionManager) SetRestartCommand(restartCommand []string) { defer C.free(unsafe.Pointer(restartCommand_i_ms.data)) restartCommand_CArray[i] = restartCommand_i_ms } - restartCommand_ma := &C.struct_miqt_array{len: C.size_t(len(restartCommand)), data: unsafe.Pointer(restartCommand_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(restartCommand_ma)) + restartCommand_ma := C.struct_miqt_array{len: C.size_t(len(restartCommand)), data: unsafe.Pointer(restartCommand_CArray)} C.QSessionManager_SetRestartCommand(this.h, restartCommand_ma) } func (this *QSessionManager) RestartCommand() []string { - var _ma *C.struct_miqt_array = C.QSessionManager_RestartCommand(this.h) + var _ma C.struct_miqt_array = C.QSessionManager_RestartCommand(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -135,12 +132,10 @@ func (this *QSessionManager) RestartCommand() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSessionManager) SetDiscardCommand(discardCommand []string) { - // For the C ABI, malloc a C array of structs discardCommand_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(discardCommand)))) defer C.free(unsafe.Pointer(discardCommand_CArray)) for i := range discardCommand { @@ -150,13 +145,12 @@ func (this *QSessionManager) SetDiscardCommand(discardCommand []string) { defer C.free(unsafe.Pointer(discardCommand_i_ms.data)) discardCommand_CArray[i] = discardCommand_i_ms } - discardCommand_ma := &C.struct_miqt_array{len: C.size_t(len(discardCommand)), data: unsafe.Pointer(discardCommand_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(discardCommand_ma)) + discardCommand_ma := C.struct_miqt_array{len: C.size_t(len(discardCommand)), data: unsafe.Pointer(discardCommand_CArray)} C.QSessionManager_SetDiscardCommand(this.h, discardCommand_ma) } func (this *QSessionManager) DiscardCommand() []string { - var _ma *C.struct_miqt_array = C.QSessionManager_DiscardCommand(this.h) + var _ma C.struct_miqt_array = C.QSessionManager_DiscardCommand(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -165,7 +159,6 @@ func (this *QSessionManager) DiscardCommand() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -186,7 +179,6 @@ func (this *QSessionManager) SetManagerProperty2(name string, value []string) { name_ms.data = C.CString(name) name_ms.len = C.size_t(len(name)) defer C.free(unsafe.Pointer(name_ms.data)) - // For the C ABI, malloc a C array of structs value_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(value)))) defer C.free(unsafe.Pointer(value_CArray)) for i := range value { @@ -196,8 +188,7 @@ func (this *QSessionManager) SetManagerProperty2(name string, value []string) { defer C.free(unsafe.Pointer(value_i_ms.data)) value_CArray[i] = value_i_ms } - value_ma := &C.struct_miqt_array{len: C.size_t(len(value)), data: unsafe.Pointer(value_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(value_ma)) + value_ma := C.struct_miqt_array{len: C.size_t(len(value)), data: unsafe.Pointer(value_CArray)} C.QSessionManager_SetManagerProperty2(this.h, name_ms, value_ma) } diff --git a/qt6/gen_qsessionmanager.h b/qt6/gen_qsessionmanager.h index a4602f72..0db0e8e1 100644 --- a/qt6/gen_qsessionmanager.h +++ b/qt6/gen_qsessionmanager.h @@ -32,12 +32,12 @@ void QSessionManager_Release(QSessionManager* self); void QSessionManager_Cancel(QSessionManager* self); void QSessionManager_SetRestartHint(QSessionManager* self, int restartHint); int QSessionManager_RestartHint(const QSessionManager* self); -void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ restartCommand); -struct miqt_array* QSessionManager_RestartCommand(const QSessionManager* self); -void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array* /* of struct miqt_string */ discardCommand); -struct miqt_array* QSessionManager_DiscardCommand(const QSessionManager* self); +void QSessionManager_SetRestartCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ restartCommand); +struct miqt_array QSessionManager_RestartCommand(const QSessionManager* self); +void QSessionManager_SetDiscardCommand(QSessionManager* self, struct miqt_array /* of struct miqt_string */ discardCommand); +struct miqt_array QSessionManager_DiscardCommand(const QSessionManager* self); void QSessionManager_SetManagerProperty(QSessionManager* self, struct miqt_string name, struct miqt_string value); -void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array* /* of struct miqt_string */ value); +void QSessionManager_SetManagerProperty2(QSessionManager* self, struct miqt_string name, struct miqt_array /* of struct miqt_string */ value); bool QSessionManager_IsPhase2(const QSessionManager* self); void QSessionManager_RequestPhase2(QSessionManager* self); struct miqt_string QSessionManager_Tr2(const char* s, const char* c); diff --git a/qt6/gen_qsettings.cpp b/qt6/gen_qsettings.cpp index d386d62a..a52a7907 100644 --- a/qt6/gen_qsettings.cpp +++ b/qt6/gen_qsettings.cpp @@ -163,7 +163,7 @@ void QSettings_SetArrayIndex(QSettings* self, int i) { self->setArrayIndex(static_cast(i)); } -struct miqt_array* QSettings_AllKeys(const QSettings* self) { +struct miqt_array QSettings_AllKeys(const QSettings* self) { QStringList _ret = self->allKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -177,13 +177,13 @@ struct miqt_array* QSettings_AllKeys(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSettings_ChildKeys(const QSettings* self) { +struct miqt_array QSettings_ChildKeys(const QSettings* self) { QStringList _ret = self->childKeys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -197,13 +197,13 @@ struct miqt_array* QSettings_ChildKeys(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSettings_ChildGroups(const QSettings* self) { +struct miqt_array QSettings_ChildGroups(const QSettings* self) { QStringList _ret = self->childGroups(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -217,9 +217,9 @@ struct miqt_array* QSettings_ChildGroups(const QSettings* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qsettings.go b/qt6/gen_qsettings.go index a56c29f7..10017288 100644 --- a/qt6/gen_qsettings.go +++ b/qt6/gen_qsettings.go @@ -311,7 +311,7 @@ func (this *QSettings) SetArrayIndex(i int) { } func (this *QSettings) AllKeys() []string { - var _ma *C.struct_miqt_array = C.QSettings_AllKeys(this.h) + var _ma C.struct_miqt_array = C.QSettings_AllKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -320,12 +320,11 @@ func (this *QSettings) AllKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSettings) ChildKeys() []string { - var _ma *C.struct_miqt_array = C.QSettings_ChildKeys(this.h) + var _ma C.struct_miqt_array = C.QSettings_ChildKeys(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -334,12 +333,11 @@ func (this *QSettings) ChildKeys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSettings) ChildGroups() []string { - var _ma *C.struct_miqt_array = C.QSettings_ChildGroups(this.h) + var _ma C.struct_miqt_array = C.QSettings_ChildGroups(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -348,7 +346,6 @@ func (this *QSettings) ChildGroups() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qsettings.h b/qt6/gen_qsettings.h index 3bde93dc..7e232a93 100644 --- a/qt6/gen_qsettings.h +++ b/qt6/gen_qsettings.h @@ -57,9 +57,9 @@ int QSettings_BeginReadArray(QSettings* self, QAnyStringView* prefix); void QSettings_BeginWriteArray(QSettings* self, QAnyStringView* prefix); void QSettings_EndArray(QSettings* self); void QSettings_SetArrayIndex(QSettings* self, int i); -struct miqt_array* QSettings_AllKeys(const QSettings* self); -struct miqt_array* QSettings_ChildKeys(const QSettings* self); -struct miqt_array* QSettings_ChildGroups(const QSettings* self); +struct miqt_array QSettings_AllKeys(const QSettings* self); +struct miqt_array QSettings_ChildKeys(const QSettings* self); +struct miqt_array QSettings_ChildGroups(const QSettings* self); bool QSettings_IsWritable(const QSettings* self); void QSettings_SetValue(QSettings* self, QAnyStringView* key, QVariant* value); QVariant* QSettings_Value(const QSettings* self, QAnyStringView* key, QVariant* defaultValue); diff --git a/qt6/gen_qshortcut.cpp b/qt6/gen_qshortcut.cpp index ec0e6b61..2e269ae8 100644 --- a/qt6/gen_qshortcut.cpp +++ b/qt6/gen_qshortcut.cpp @@ -77,26 +77,26 @@ void QShortcut_SetKeys(QShortcut* self, int key) { self->setKeys(static_cast(key)); } -void QShortcut_SetKeysWithKeys(QShortcut* self, struct miqt_array* /* of QKeySequence* */ keys) { +void QShortcut_SetKeysWithKeys(QShortcut* self, struct miqt_array /* of QKeySequence* */ keys) { QList keys_QList; - keys_QList.reserve(keys->len); - QKeySequence** keys_arr = static_cast(keys->data); - for(size_t i = 0; i < keys->len; ++i) { + keys_QList.reserve(keys.len); + QKeySequence** keys_arr = static_cast(keys.data); + for(size_t i = 0; i < keys.len; ++i) { keys_QList.push_back(*(keys_arr[i])); } self->setKeys(keys_QList); } -struct miqt_array* QShortcut_Keys(const QShortcut* self) { +struct miqt_array QShortcut_Keys(const QShortcut* self) { QList _ret = self->keys(); // Convert QList<> from C++ memory to manually-managed C memory QKeySequence** _arr = static_cast(malloc(sizeof(QKeySequence*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QKeySequence(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qshortcut.go b/qt6/gen_qshortcut.go index b32d2f20..db350a36 100644 --- a/qt6/gen_qshortcut.go +++ b/qt6/gen_qshortcut.go @@ -153,19 +153,17 @@ func (this *QShortcut) SetKeys(key QKeySequence__StandardKey) { } func (this *QShortcut) SetKeysWithKeys(keys []QKeySequence) { - // For the C ABI, malloc a C array of raw pointers keys_CArray := (*[0xffff]*C.QKeySequence)(C.malloc(C.size_t(8 * len(keys)))) defer C.free(unsafe.Pointer(keys_CArray)) for i := range keys { keys_CArray[i] = keys[i].cPointer() } - keys_ma := &C.struct_miqt_array{len: C.size_t(len(keys)), data: unsafe.Pointer(keys_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(keys_ma)) + keys_ma := C.struct_miqt_array{len: C.size_t(len(keys)), data: unsafe.Pointer(keys_CArray)} C.QShortcut_SetKeysWithKeys(this.h, keys_ma) } func (this *QShortcut) Keys() []QKeySequence { - var _ma *C.struct_miqt_array = C.QShortcut_Keys(this.h) + var _ma C.struct_miqt_array = C.QShortcut_Keys(this.h) _ret := make([]QKeySequence, int(_ma.len)) _outCast := (*[0xffff]*C.QKeySequence)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -174,7 +172,6 @@ func (this *QShortcut) Keys() []QKeySequence { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qshortcut.h b/qt6/gen_qshortcut.h index 1f4e2dad..b094c6da 100644 --- a/qt6/gen_qshortcut.h +++ b/qt6/gen_qshortcut.h @@ -40,8 +40,8 @@ struct miqt_string QShortcut_Tr(const char* s); void QShortcut_SetKey(QShortcut* self, QKeySequence* key); QKeySequence* QShortcut_Key(const QShortcut* self); void QShortcut_SetKeys(QShortcut* self, int key); -void QShortcut_SetKeysWithKeys(QShortcut* self, struct miqt_array* /* of QKeySequence* */ keys); -struct miqt_array* QShortcut_Keys(const QShortcut* self); +void QShortcut_SetKeysWithKeys(QShortcut* self, struct miqt_array /* of QKeySequence* */ keys); +struct miqt_array QShortcut_Keys(const QShortcut* self); void QShortcut_SetEnabled(QShortcut* self, bool enable); bool QShortcut_IsEnabled(const QShortcut* self); void QShortcut_SetContext(QShortcut* self, int context); diff --git a/qt6/gen_qsortfilterproxymodel.cpp b/qt6/gen_qsortfilterproxymodel.cpp index a88f9f35..1f9834e5 100644 --- a/qt6/gen_qsortfilterproxymodel.cpp +++ b/qt6/gen_qsortfilterproxymodel.cpp @@ -204,11 +204,11 @@ bool QSortFilterProxyModel_SetHeaderData(QSortFilterProxyModel* self, int sectio return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } -QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -251,16 +251,16 @@ QModelIndex* QSortFilterProxyModel_Buddy(const QSortFilterProxyModel* self, QMod return new QModelIndex(self->buddy(*index)); } -struct miqt_array* QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value) { +struct miqt_array QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value) { QModelIndexList _ret = self->match(*start, static_cast(role), *value); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -272,7 +272,7 @@ void QSortFilterProxyModel_Sort(QSortFilterProxyModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self) { +struct miqt_array QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -286,9 +286,9 @@ struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -457,29 +457,29 @@ bool QSortFilterProxyModel_RemoveColumns3(QSortFilterProxyModel* self, int colum return self->removeColumns(static_cast(column), static_cast(count), *parent); } -struct miqt_array* QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { +struct miqt_array QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { +struct miqt_array QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags) { QModelIndexList _ret = self->match(*start, static_cast(role), *value, static_cast(hits), static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory QModelIndex** _arr = static_cast(malloc(sizeof(QModelIndex*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QModelIndex(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qsortfilterproxymodel.go b/qt6/gen_qsortfilterproxymodel.go index 9aa911f6..7f6e04b7 100644 --- a/qt6/gen_qsortfilterproxymodel.go +++ b/qt6/gen_qsortfilterproxymodel.go @@ -268,14 +268,12 @@ func (this *QSortFilterProxyModel) SetHeaderData(section int, orientation Orient } func (this *QSortFilterProxyModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QSortFilterProxyModel_MimeData(this.h, indexes_ma))) } @@ -319,7 +317,7 @@ func (this *QSortFilterProxyModel) Buddy(index *QModelIndex) *QModelIndex { } func (this *QSortFilterProxyModel) Match(start *QModelIndex, role int, value *QVariant) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match(this.h, start.cPointer(), (C.int)(role), value.cPointer()) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -328,7 +326,6 @@ func (this *QSortFilterProxyModel) Match(start *QModelIndex, role int, value *QV _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -344,7 +341,7 @@ func (this *QSortFilterProxyModel) Sort(column int) { } func (this *QSortFilterProxyModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -353,7 +350,6 @@ func (this *QSortFilterProxyModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -601,7 +597,7 @@ func (this *QSortFilterProxyModel) RemoveColumns3(column int, count int, parent } func (this *QSortFilterProxyModel) Match4(start *QModelIndex, role int, value *QVariant, hits int) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match4(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -610,12 +606,11 @@ func (this *QSortFilterProxyModel) Match4(start *QModelIndex, role int, value *Q _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSortFilterProxyModel) Match5(start *QModelIndex, role int, value *QVariant, hits int, flags MatchFlag) []QModelIndex { - var _ma *C.struct_miqt_array = C.QSortFilterProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) + var _ma C.struct_miqt_array = C.QSortFilterProxyModel_Match5(this.h, start.cPointer(), (C.int)(role), value.cPointer(), (C.int)(hits), (C.int)(flags)) _ret := make([]QModelIndex, int(_ma.len)) _outCast := (*[0xffff]*C.QModelIndex)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -624,7 +619,6 @@ func (this *QSortFilterProxyModel) Match5(start *QModelIndex, role int, value *Q _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qsortfilterproxymodel.h b/qt6/gen_qsortfilterproxymodel.h index a2533f8f..9d9f72c9 100644 --- a/qt6/gen_qsortfilterproxymodel.h +++ b/qt6/gen_qsortfilterproxymodel.h @@ -79,7 +79,7 @@ QVariant* QSortFilterProxyModel_Data(const QSortFilterProxyModel* self, QModelIn bool QSortFilterProxyModel_SetData(QSortFilterProxyModel* self, QModelIndex* index, QVariant* value); QVariant* QSortFilterProxyModel_HeaderData(const QSortFilterProxyModel* self, int section, int orientation); bool QSortFilterProxyModel_SetHeaderData(QSortFilterProxyModel* self, int section, int orientation, QVariant* value); -QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +QMimeData* QSortFilterProxyModel_MimeData(const QSortFilterProxyModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QSortFilterProxyModel_DropMimeData(QSortFilterProxyModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); bool QSortFilterProxyModel_InsertRows(QSortFilterProxyModel* self, int row, int count); bool QSortFilterProxyModel_InsertColumns(QSortFilterProxyModel* self, int column, int count); @@ -89,10 +89,10 @@ void QSortFilterProxyModel_FetchMore(QSortFilterProxyModel* self, QModelIndex* p bool QSortFilterProxyModel_CanFetchMore(const QSortFilterProxyModel* self, QModelIndex* parent); int QSortFilterProxyModel_Flags(const QSortFilterProxyModel* self, QModelIndex* index); QModelIndex* QSortFilterProxyModel_Buddy(const QSortFilterProxyModel* self, QModelIndex* index); -struct miqt_array* QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value); +struct miqt_array QSortFilterProxyModel_Match(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value); QSize* QSortFilterProxyModel_Span(const QSortFilterProxyModel* self, QModelIndex* index); void QSortFilterProxyModel_Sort(QSortFilterProxyModel* self, int column); -struct miqt_array* QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self); +struct miqt_array QSortFilterProxyModel_MimeTypes(const QSortFilterProxyModel* self); int QSortFilterProxyModel_SupportedDropActions(const QSortFilterProxyModel* self); void QSortFilterProxyModel_DynamicSortFilterChanged(QSortFilterProxyModel* self, bool dynamicSortFilter); void QSortFilterProxyModel_connect_DynamicSortFilterChanged(QSortFilterProxyModel* self, intptr_t slot); @@ -124,8 +124,8 @@ bool QSortFilterProxyModel_InsertRows3(QSortFilterProxyModel* self, int row, int bool QSortFilterProxyModel_InsertColumns3(QSortFilterProxyModel* self, int column, int count, QModelIndex* parent); bool QSortFilterProxyModel_RemoveRows3(QSortFilterProxyModel* self, int row, int count, QModelIndex* parent); bool QSortFilterProxyModel_RemoveColumns3(QSortFilterProxyModel* self, int column, int count, QModelIndex* parent); -struct miqt_array* QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); -struct miqt_array* QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); +struct miqt_array QSortFilterProxyModel_Match4(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits); +struct miqt_array QSortFilterProxyModel_Match5(const QSortFilterProxyModel* self, QModelIndex* start, int role, QVariant* value, int hits, int flags); void QSortFilterProxyModel_Sort2(QSortFilterProxyModel* self, int column, int order); void QSortFilterProxyModel_Delete(QSortFilterProxyModel* self); diff --git a/qt6/gen_qsplitter.cpp b/qt6/gen_qsplitter.cpp index cc14ea86..fb9b59da 100644 --- a/qt6/gen_qsplitter.cpp +++ b/qt6/gen_qsplitter.cpp @@ -104,24 +104,24 @@ QSize* QSplitter_MinimumSizeHint(const QSplitter* self) { return new QSize(self->minimumSizeHint()); } -struct miqt_array* QSplitter_Sizes(const QSplitter* self) { +struct miqt_array QSplitter_Sizes(const QSplitter* self) { QList _ret = self->sizes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QSplitter_SetSizes(QSplitter* self, struct miqt_array* /* of int */ list) { +void QSplitter_SetSizes(QSplitter* self, struct miqt_array /* of int */ list) { QList list_QList; - list_QList.reserve(list->len); - int* list_arr = static_cast(list->data); - for(size_t i = 0; i < list->len; ++i) { + list_QList.reserve(list.len); + int* list_arr = static_cast(list.data); + for(size_t i = 0; i < list.len; ++i) { list_QList.push_back(static_cast(list_arr[i])); } self->setSizes(list_QList); diff --git a/qt6/gen_qsplitter.go b/qt6/gen_qsplitter.go index c2b5ef2f..0521ff45 100644 --- a/qt6/gen_qsplitter.go +++ b/qt6/gen_qsplitter.go @@ -150,25 +150,22 @@ func (this *QSplitter) MinimumSizeHint() *QSize { } func (this *QSplitter) Sizes() []int { - var _ma *C.struct_miqt_array = C.QSplitter_Sizes(this.h) + var _ma C.struct_miqt_array = C.QSplitter_Sizes(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QSplitter) SetSizes(list []int) { - // For the C ABI, malloc a C array of raw pointers list_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(list)))) defer C.free(unsafe.Pointer(list_CArray)) for i := range list { list_CArray[i] = (C.int)(list[i]) } - list_ma := &C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(list_ma)) + list_ma := C.struct_miqt_array{len: C.size_t(len(list)), data: unsafe.Pointer(list_CArray)} C.QSplitter_SetSizes(this.h, list_ma) } diff --git a/qt6/gen_qsplitter.h b/qt6/gen_qsplitter.h index 474c736d..fc579555 100644 --- a/qt6/gen_qsplitter.h +++ b/qt6/gen_qsplitter.h @@ -50,8 +50,8 @@ bool QSplitter_OpaqueResize(const QSplitter* self); void QSplitter_Refresh(QSplitter* self); QSize* QSplitter_SizeHint(const QSplitter* self); QSize* QSplitter_MinimumSizeHint(const QSplitter* self); -struct miqt_array* QSplitter_Sizes(const QSplitter* self); -void QSplitter_SetSizes(QSplitter* self, struct miqt_array* /* of int */ list); +struct miqt_array QSplitter_Sizes(const QSplitter* self); +void QSplitter_SetSizes(QSplitter* self, struct miqt_array /* of int */ list); struct miqt_string QSplitter_SaveState(const QSplitter* self); bool QSplitter_RestoreState(QSplitter* self, struct miqt_string state); int QSplitter_HandleWidth(const QSplitter* self); diff --git a/qt6/gen_qstandarditemmodel.cpp b/qt6/gen_qstandarditemmodel.cpp index 080c84cf..b2c0abce 100644 --- a/qt6/gen_qstandarditemmodel.cpp +++ b/qt6/gen_qstandarditemmodel.cpp @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -336,31 +338,31 @@ void QStandardItem_SetChild2(QStandardItem* self, int row, QStandardItem* item) self->setChild(static_cast(row), item); } -void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRow(static_cast(row), items_QList); } -void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertColumn(static_cast(column), items_QList); } -void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRows(static_cast(row), items_QList); @@ -390,31 +392,31 @@ void QStandardItem_RemoveColumns(QStandardItem* self, int column, int count) { self->removeColumns(static_cast(column), static_cast(count)); } -void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRow(items_QList); } -void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRows(items_QList); } -void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendColumn(items_QList); @@ -432,29 +434,29 @@ QStandardItem* QStandardItem_TakeChild(QStandardItem* self, int row) { return self->takeChild(static_cast(row)); } -struct miqt_array* QStandardItem_TakeRow(QStandardItem* self, int row) { +struct miqt_array QStandardItem_TakeRow(QStandardItem* self, int row) { QList _ret = self->takeRow(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItem_TakeColumn(QStandardItem* self, int column) { +struct miqt_array QStandardItem_TakeColumn(QStandardItem* self, int column) { QList _ret = self->takeColumn(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -541,6 +543,41 @@ struct miqt_string QStandardItemModel_Tr(const char* s) { return _ms; } +void QStandardItemModel_SetItemRoleNames(QStandardItemModel* self, struct miqt_map roleNames) { + QHash roleNames_QMap; + roleNames_QMap.reserve(roleNames.len); + int* roleNames_karr = static_cast(roleNames.keys); + struct miqt_string* roleNames_varr = static_cast(roleNames.values); + for(size_t i = 0; i < roleNames.len; ++i) { + QByteArray roleNames_varr_i_QByteArray(roleNames_varr[i].data, roleNames_varr[i].len); + roleNames_QMap[static_cast(roleNames_karr[i])] = roleNames_varr_i_QByteArray; + } + self->setItemRoleNames(roleNames_QMap); +} + +struct miqt_map QStandardItemModel_RoleNames(const QStandardItemModel* self) { + QHash _ret = self->roleNames(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + struct miqt_string* _varr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + QByteArray _hashval_qb = _itr->second; + struct miqt_string _hashval_ms; + _hashval_ms.len = _hashval_qb.length(); + _hashval_ms.data = static_cast(malloc(_hashval_ms.len)); + memcpy(_hashval_ms.data, _hashval_qb.data(), _hashval_ms.len); + _varr[_ctr] = _hashval_ms; + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QModelIndex* QStandardItemModel_Index(const QStandardItemModel* self, int row, int column) { return new QModelIndex(self->index(static_cast(row), static_cast(column))); } @@ -611,6 +648,34 @@ int QStandardItemModel_SupportedDropActions(const QStandardItemModel* self) { return static_cast(_ret); } +struct miqt_map QStandardItemModel_ItemData(const QStandardItemModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QStandardItemModel_SetItemData(QStandardItemModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + void QStandardItemModel_Clear(QStandardItemModel* self) { self->clear(); } @@ -659,22 +724,22 @@ void QStandardItemModel_SetVerticalHeaderItem(QStandardItemModel* self, int row, self->setVerticalHeaderItem(static_cast(row), item); } -void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } self->setHorizontalHeaderLabels(labels_QList); } -void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -689,21 +754,21 @@ void QStandardItemModel_SetColumnCount(QStandardItemModel* self, int columns) { self->setColumnCount(static_cast(columns)); } -void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendRow(items_QList); } -void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->appendColumn(items_QList); @@ -713,21 +778,21 @@ void QStandardItemModel_AppendRowWithItem(QStandardItemModel* self, QStandardIte self->appendRow(item); } -void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertRow(static_cast(row), items_QList); } -void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array* /* of QStandardItem* */ items) { +void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array /* of QStandardItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QStandardItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QStandardItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertColumn(static_cast(column), items_QList); @@ -749,29 +814,29 @@ QStandardItem* QStandardItemModel_TakeItem(QStandardItemModel* self, int row) { return self->takeItem(static_cast(row)); } -struct miqt_array* QStandardItemModel_TakeRow(QStandardItemModel* self, int row) { +struct miqt_array QStandardItemModel_TakeRow(QStandardItemModel* self, int row) { QList _ret = self->takeRow(static_cast(row)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItemModel_TakeColumn(QStandardItemModel* self, int column) { +struct miqt_array QStandardItemModel_TakeColumn(QStandardItemModel* self, int column) { QList _ret = self->takeColumn(static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory QStandardItem** _arr = static_cast(malloc(sizeof(QStandardItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -791,7 +856,7 @@ void QStandardItemModel_SetItemPrototype(QStandardItemModel* self, QStandardItem self->setItemPrototype(item); } -struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text) { +struct miqt_array QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -799,9 +864,9 @@ struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -813,7 +878,7 @@ void QStandardItemModel_SetSortRole(QStandardItemModel* self, int role) { self->setSortRole(static_cast(role)); } -struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self) { +struct miqt_array QStandardItemModel_MimeTypes(const QStandardItemModel* self) { QStringList _ret = self->mimeTypes(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -827,17 +892,17 @@ struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self) memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes) { +QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array /* of QModelIndex* */ indexes) { QModelIndexList indexes_QList; - indexes_QList.reserve(indexes->len); - QModelIndex** indexes_arr = static_cast(indexes->data); - for(size_t i = 0; i < indexes->len; ++i) { + indexes_QList.reserve(indexes.len); + QModelIndex** indexes_arr = static_cast(indexes.data); + for(size_t i = 0; i < indexes.len; ++i) { indexes_QList.push_back(*(indexes_arr[i])); } return self->mimeData(indexes_QList); @@ -948,7 +1013,7 @@ QStandardItem* QStandardItemModel_TakeItem2(QStandardItemModel* self, int row, i return self->takeItem(static_cast(row), static_cast(column)); } -struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags) { +struct miqt_array QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -956,13 +1021,13 @@ struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column) { +struct miqt_array QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags), static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory @@ -970,9 +1035,9 @@ struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qstandarditemmodel.go b/qt6/gen_qstandarditemmodel.go index 45755b27..19edc1ca 100644 --- a/qt6/gen_qstandarditemmodel.go +++ b/qt6/gen_qstandarditemmodel.go @@ -396,38 +396,32 @@ func (this *QStandardItem) SetChild2(row int, item *QStandardItem) { } func (this *QStandardItem) InsertRow(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertRow(this.h, (C.int)(row), items_ma) } func (this *QStandardItem) InsertColumn(column int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertColumn(this.h, (C.int)(column), items_ma) } func (this *QStandardItem) InsertRows(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_InsertRows(this.h, (C.int)(row), items_ma) } @@ -456,38 +450,32 @@ func (this *QStandardItem) RemoveColumns(column int, count int) { } func (this *QStandardItem) AppendRow(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendRow(this.h, items_ma) } func (this *QStandardItem) AppendRows(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendRows(this.h, items_ma) } func (this *QStandardItem) AppendColumn(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItem_AppendColumn(this.h, items_ma) } @@ -504,24 +492,22 @@ func (this *QStandardItem) TakeChild(row int) *QStandardItem { } func (this *QStandardItem) TakeRow(row int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItem_TakeRow(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QStandardItem_TakeRow(this.h, (C.int)(row)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItem) TakeColumn(column int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItem_TakeColumn(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItem_TakeColumn(this.h, (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -659,6 +645,45 @@ func QStandardItemModel_Tr(s string) string { return _ret } +func (this *QStandardItemModel) SetItemRoleNames(roleNames map[int][]byte) { + roleNames_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roleNames)))) + defer C.free(unsafe.Pointer(roleNames_Keys_CArray)) + roleNames_Values_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(roleNames)))) + defer C.free(unsafe.Pointer(roleNames_Values_CArray)) + roleNames_ctr := 0 + for roleNames_k, roleNames_v := range roleNames { + roleNames_Keys_CArray[roleNames_ctr] = (C.int)(roleNames_k) + roleNames_v_alias := C.struct_miqt_string{} + roleNames_v_alias.data = (*C.char)(unsafe.Pointer(&roleNames_v[0])) + roleNames_v_alias.len = C.size_t(len(roleNames_v)) + roleNames_Values_CArray[roleNames_ctr] = roleNames_v_alias + roleNames_ctr++ + } + roleNames_mm := C.struct_miqt_map{ + len: C.size_t(len(roleNames)), + keys: unsafe.Pointer(roleNames_Keys_CArray), + values: unsafe.Pointer(roleNames_Values_CArray), + } + C.QStandardItemModel_SetItemRoleNames(this.h, roleNames_mm) +} + +func (this *QStandardItemModel) RoleNames() map[int][]byte { + var _mm C.struct_miqt_map = C.QStandardItemModel_RoleNames(this.h) + _ret := make(map[int][]byte, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + var _hashval_bytearray C.struct_miqt_string = _Values[i] + _hashval_ret := C.GoBytes(unsafe.Pointer(_hashval_bytearray.data), C.int(int64(_hashval_bytearray.len))) + C.free(unsafe.Pointer(_hashval_bytearray.data)) + _entry_Value := _hashval_ret + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QStandardItemModel) Index(row int, column int) *QModelIndex { _ret := C.QStandardItemModel_Index(this.h, (C.int)(row), (C.int)(column)) _goptr := newQModelIndex(_ret) @@ -739,6 +764,43 @@ func (this *QStandardItemModel) SupportedDropActions() DropAction { return (DropAction)(C.QStandardItemModel_SupportedDropActions(this.h)) } +func (this *QStandardItemModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QStandardItemModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QStandardItemModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QStandardItemModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QStandardItemModel) Clear() { C.QStandardItemModel_Clear(this.h) } @@ -791,7 +853,6 @@ func (this *QStandardItemModel) SetVerticalHeaderItem(row int, item *QStandardIt } func (this *QStandardItemModel) SetHorizontalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -801,13 +862,11 @@ func (this *QStandardItemModel) SetHorizontalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QStandardItemModel_SetHorizontalHeaderLabels(this.h, labels_ma) } func (this *QStandardItemModel) SetVerticalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -817,8 +876,7 @@ func (this *QStandardItemModel) SetVerticalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QStandardItemModel_SetVerticalHeaderLabels(this.h, labels_ma) } @@ -831,26 +889,22 @@ func (this *QStandardItemModel) SetColumnCount(columns int) { } func (this *QStandardItemModel) AppendRow(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_AppendRow(this.h, items_ma) } func (this *QStandardItemModel) AppendColumn(items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_AppendColumn(this.h, items_ma) } @@ -859,26 +913,22 @@ func (this *QStandardItemModel) AppendRowWithItem(item *QStandardItem) { } func (this *QStandardItemModel) InsertRow(row int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_InsertRow(this.h, (C.int)(row), items_ma) } func (this *QStandardItemModel) InsertColumn(column int, items []*QStandardItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QStandardItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QStandardItemModel_InsertColumn(this.h, (C.int)(column), items_ma) } @@ -899,24 +949,22 @@ func (this *QStandardItemModel) TakeItem(row int) *QStandardItem { } func (this *QStandardItemModel) TakeRow(row int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItemModel_TakeRow(this.h, (C.int)(row)) + var _ma C.struct_miqt_array = C.QStandardItemModel_TakeRow(this.h, (C.int)(row)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItemModel) TakeColumn(column int) []*QStandardItem { - var _ma *C.struct_miqt_array = C.QStandardItemModel_TakeColumn(this.h, (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItemModel_TakeColumn(this.h, (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -941,13 +989,12 @@ func (this *QStandardItemModel) FindItems(text string) []*QStandardItem { text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems(this.h, text_ms) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems(this.h, text_ms) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -960,7 +1007,7 @@ func (this *QStandardItemModel) SetSortRole(role int) { } func (this *QStandardItemModel) MimeTypes() []string { - var _ma *C.struct_miqt_array = C.QStandardItemModel_MimeTypes(this.h) + var _ma C.struct_miqt_array = C.QStandardItemModel_MimeTypes(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -969,19 +1016,16 @@ func (this *QStandardItemModel) MimeTypes() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStandardItemModel) MimeData(indexes []QModelIndex) *QMimeData { - // For the C ABI, malloc a C array of raw pointers indexes_CArray := (*[0xffff]*C.QModelIndex)(C.malloc(C.size_t(8 * len(indexes)))) defer C.free(unsafe.Pointer(indexes_CArray)) for i := range indexes { indexes_CArray[i] = indexes[i].cPointer() } - indexes_ma := &C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(indexes_ma)) + indexes_ma := C.struct_miqt_array{len: C.size_t(len(indexes)), data: unsafe.Pointer(indexes_CArray)} return UnsafeNewQMimeData(unsafe.Pointer(C.QStandardItemModel_MimeData(this.h, indexes_ma))) } @@ -1113,13 +1157,12 @@ func (this *QStandardItemModel) FindItems2(text string, flags MatchFlag) []*QSta text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems2(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems2(this.h, text_ms, (C.int)(flags)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1128,13 +1171,12 @@ func (this *QStandardItemModel) FindItems3(text string, flags MatchFlag, column text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardItemModel_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) + var _ma C.struct_miqt_array = C.QStandardItemModel_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) _ret := make([]*QStandardItem, int(_ma.len)) _outCast := (*[0xffff]*C.QStandardItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQStandardItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qstandarditemmodel.h b/qt6/gen_qstandarditemmodel.h index 9135c6cc..35f8465f 100644 --- a/qt6/gen_qstandarditemmodel.h +++ b/qt6/gen_qstandarditemmodel.h @@ -15,6 +15,7 @@ extern "C" { #ifdef __cplusplus class QBrush; +class QByteArray; class QDataStream; class QFont; class QIcon; @@ -29,6 +30,7 @@ class QStandardItemModel; class QVariant; #else typedef struct QBrush QBrush; +typedef struct QByteArray QByteArray; typedef struct QDataStream QDataStream; typedef struct QFont QFont; typedef struct QIcon QIcon; @@ -109,23 +111,23 @@ bool QStandardItem_HasChildren(const QStandardItem* self); QStandardItem* QStandardItem_Child(const QStandardItem* self, int row); void QStandardItem_SetChild(QStandardItem* self, int row, int column, QStandardItem* item); void QStandardItem_SetChild2(QStandardItem* self, int row, QStandardItem* item); -void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItem_InsertRow(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_InsertColumn(QStandardItem* self, int column, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_InsertRows(QStandardItem* self, int row, struct miqt_array /* of QStandardItem* */ items); void QStandardItem_InsertRows2(QStandardItem* self, int row, int count); void QStandardItem_InsertColumns(QStandardItem* self, int column, int count); void QStandardItem_RemoveRow(QStandardItem* self, int row); void QStandardItem_RemoveColumn(QStandardItem* self, int column); void QStandardItem_RemoveRows(QStandardItem* self, int row, int count); void QStandardItem_RemoveColumns(QStandardItem* self, int column, int count); -void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItem_AppendRow(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_AppendRows(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItem_AppendColumn(QStandardItem* self, struct miqt_array /* of QStandardItem* */ items); void QStandardItem_InsertRow2(QStandardItem* self, int row, QStandardItem* item); void QStandardItem_AppendRowWithItem(QStandardItem* self, QStandardItem* item); QStandardItem* QStandardItem_TakeChild(QStandardItem* self, int row); -struct miqt_array* QStandardItem_TakeRow(QStandardItem* self, int row); -struct miqt_array* QStandardItem_TakeColumn(QStandardItem* self, int column); +struct miqt_array QStandardItem_TakeRow(QStandardItem* self, int row); +struct miqt_array QStandardItem_TakeColumn(QStandardItem* self, int column); void QStandardItem_SortChildren(QStandardItem* self, int column); QStandardItem* QStandardItem_Clone(const QStandardItem* self); int QStandardItem_Type(const QStandardItem* self); @@ -146,6 +148,8 @@ QStandardItemModel* QStandardItemModel_new4(int rows, int columns, QObject* pare QMetaObject* QStandardItemModel_MetaObject(const QStandardItemModel* self); void* QStandardItemModel_Metacast(QStandardItemModel* self, const char* param1); struct miqt_string QStandardItemModel_Tr(const char* s); +void QStandardItemModel_SetItemRoleNames(QStandardItemModel* self, struct miqt_map roleNames); +struct miqt_map QStandardItemModel_RoleNames(const QStandardItemModel* self); QModelIndex* QStandardItemModel_Index(const QStandardItemModel* self, int row, int column); QModelIndex* QStandardItemModel_Parent(const QStandardItemModel* self, QModelIndex* child); int QStandardItemModel_RowCount(const QStandardItemModel* self); @@ -163,6 +167,8 @@ bool QStandardItemModel_RemoveRows(QStandardItemModel* self, int row, int count) bool QStandardItemModel_RemoveColumns(QStandardItemModel* self, int column, int count); int QStandardItemModel_Flags(const QStandardItemModel* self, QModelIndex* index); int QStandardItemModel_SupportedDropActions(const QStandardItemModel* self); +struct miqt_map QStandardItemModel_ItemData(const QStandardItemModel* self, QModelIndex* index); +bool QStandardItemModel_SetItemData(QStandardItemModel* self, QModelIndex* index, struct miqt_map roles); void QStandardItemModel_Clear(QStandardItemModel* self); void QStandardItemModel_Sort(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_ItemFromIndex(const QStandardItemModel* self, QModelIndex* index); @@ -175,30 +181,30 @@ QStandardItem* QStandardItemModel_HorizontalHeaderItem(const QStandardItemModel* void QStandardItemModel_SetHorizontalHeaderItem(QStandardItemModel* self, int column, QStandardItem* item); QStandardItem* QStandardItemModel_VerticalHeaderItem(const QStandardItemModel* self, int row); void QStandardItemModel_SetVerticalHeaderItem(QStandardItemModel* self, int row, QStandardItem* item); -void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels); -void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array* /* of struct miqt_string */ labels); +void QStandardItemModel_SetHorizontalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels); +void QStandardItemModel_SetVerticalHeaderLabels(QStandardItemModel* self, struct miqt_array /* of struct miqt_string */ labels); void QStandardItemModel_SetRowCount(QStandardItemModel* self, int rows); void QStandardItemModel_SetColumnCount(QStandardItemModel* self, int columns); -void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItemModel_AppendRow(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items); +void QStandardItemModel_AppendColumn(QStandardItemModel* self, struct miqt_array /* of QStandardItem* */ items); void QStandardItemModel_AppendRowWithItem(QStandardItemModel* self, QStandardItem* item); -void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array* /* of QStandardItem* */ items); -void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array* /* of QStandardItem* */ items); +void QStandardItemModel_InsertRow(QStandardItemModel* self, int row, struct miqt_array /* of QStandardItem* */ items); +void QStandardItemModel_InsertColumn(QStandardItemModel* self, int column, struct miqt_array /* of QStandardItem* */ items); void QStandardItemModel_InsertRow2(QStandardItemModel* self, int row, QStandardItem* item); bool QStandardItemModel_InsertRowWithRow(QStandardItemModel* self, int row); bool QStandardItemModel_InsertColumnWithColumn(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeItem(QStandardItemModel* self, int row); -struct miqt_array* QStandardItemModel_TakeRow(QStandardItemModel* self, int row); -struct miqt_array* QStandardItemModel_TakeColumn(QStandardItemModel* self, int column); +struct miqt_array QStandardItemModel_TakeRow(QStandardItemModel* self, int row); +struct miqt_array QStandardItemModel_TakeColumn(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeHorizontalHeaderItem(QStandardItemModel* self, int column); QStandardItem* QStandardItemModel_TakeVerticalHeaderItem(QStandardItemModel* self, int row); QStandardItem* QStandardItemModel_ItemPrototype(const QStandardItemModel* self); void QStandardItemModel_SetItemPrototype(QStandardItemModel* self, QStandardItem* item); -struct miqt_array* QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text); +struct miqt_array QStandardItemModel_FindItems(const QStandardItemModel* self, struct miqt_string text); int QStandardItemModel_SortRole(const QStandardItemModel* self); void QStandardItemModel_SetSortRole(QStandardItemModel* self, int role); -struct miqt_array* QStandardItemModel_MimeTypes(const QStandardItemModel* self); -QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array* /* of QModelIndex* */ indexes); +struct miqt_array QStandardItemModel_MimeTypes(const QStandardItemModel* self); +QMimeData* QStandardItemModel_MimeData(const QStandardItemModel* self, struct miqt_array /* of QModelIndex* */ indexes); bool QStandardItemModel_DropMimeData(QStandardItemModel* self, QMimeData* data, int action, int row, int column, QModelIndex* parent); void QStandardItemModel_ItemChanged(QStandardItemModel* self, QStandardItem* item); void QStandardItemModel_connect_ItemChanged(QStandardItemModel* self, intptr_t slot); @@ -221,8 +227,8 @@ QStandardItem* QStandardItemModel_Item2(const QStandardItemModel* self, int row, bool QStandardItemModel_InsertRow22(QStandardItemModel* self, int row, QModelIndex* parent); bool QStandardItemModel_InsertColumn2(QStandardItemModel* self, int column, QModelIndex* parent); QStandardItem* QStandardItemModel_TakeItem2(QStandardItemModel* self, int row, int column); -struct miqt_array* QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags); -struct miqt_array* QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column); +struct miqt_array QStandardItemModel_FindItems2(const QStandardItemModel* self, struct miqt_string text, int flags); +struct miqt_array QStandardItemModel_FindItems3(const QStandardItemModel* self, struct miqt_string text, int flags, int column); void QStandardItemModel_Delete(QStandardItemModel* self); #ifdef __cplusplus diff --git a/qt6/gen_qstandardpaths.cpp b/qt6/gen_qstandardpaths.cpp index affdb540..0c172ffc 100644 --- a/qt6/gen_qstandardpaths.cpp +++ b/qt6/gen_qstandardpaths.cpp @@ -18,7 +18,7 @@ struct miqt_string QStandardPaths_WritableLocation(int typeVal) { return _ms; } -struct miqt_array* QStandardPaths_StandardLocations(int typeVal) { +struct miqt_array QStandardPaths_StandardLocations(int typeVal) { QStringList _ret = QStandardPaths::standardLocations(static_cast(typeVal)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -32,9 +32,9 @@ struct miqt_array* QStandardPaths_StandardLocations(int typeVal) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -50,7 +50,7 @@ struct miqt_string QStandardPaths_Locate(int typeVal, struct miqt_string fileNam return _ms; } -struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName) { +struct miqt_array QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QStringList _ret = QStandardPaths::locateAll(static_cast(typeVal), fileName_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -65,9 +65,9 @@ struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string file memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -114,7 +114,7 @@ struct miqt_string QStandardPaths_Locate3(int typeVal, struct miqt_string fileNa return _ms; } -struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options) { +struct miqt_array QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options) { QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len); QStringList _ret = QStandardPaths::locateAll(static_cast(typeVal), fileName_QString, static_cast(options)); // Convert QList<> from C++ memory to manually-managed C memory @@ -129,18 +129,18 @@ struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fil memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array* /* of struct miqt_string */ paths) { +struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array /* of struct miqt_string */ paths) { QString executableName_QString = QString::fromUtf8(executableName.data, executableName.len); QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } diff --git a/qt6/gen_qstandardpaths.go b/qt6/gen_qstandardpaths.go index abc965a2..414e89af 100644 --- a/qt6/gen_qstandardpaths.go +++ b/qt6/gen_qstandardpaths.go @@ -9,7 +9,6 @@ package qt6 import "C" import ( - "runtime" "unsafe" ) @@ -83,7 +82,7 @@ func QStandardPaths_WritableLocation(typeVal QStandardPaths__StandardLocation) s } func QStandardPaths_StandardLocations(typeVal QStandardPaths__StandardLocation) []string { - var _ma *C.struct_miqt_array = C.QStandardPaths_StandardLocations((C.int)(typeVal)) + var _ma C.struct_miqt_array = C.QStandardPaths_StandardLocations((C.int)(typeVal)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -92,7 +91,6 @@ func QStandardPaths_StandardLocations(typeVal QStandardPaths__StandardLocation) C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -112,7 +110,7 @@ func QStandardPaths_LocateAll(typeVal QStandardPaths__StandardLocation, fileName fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardPaths_LocateAll((C.int)(typeVal), fileName_ms) + var _ma C.struct_miqt_array = C.QStandardPaths_LocateAll((C.int)(typeVal), fileName_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -121,7 +119,6 @@ func QStandardPaths_LocateAll(typeVal QStandardPaths__StandardLocation, fileName C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -167,7 +164,7 @@ func QStandardPaths_LocateAll3(typeVal QStandardPaths__StandardLocation, fileNam fileName_ms.data = C.CString(fileName) fileName_ms.len = C.size_t(len(fileName)) defer C.free(unsafe.Pointer(fileName_ms.data)) - var _ma *C.struct_miqt_array = C.QStandardPaths_LocateAll3((C.int)(typeVal), fileName_ms, (C.int)(options)) + var _ma C.struct_miqt_array = C.QStandardPaths_LocateAll3((C.int)(typeVal), fileName_ms, (C.int)(options)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -176,7 +173,6 @@ func QStandardPaths_LocateAll3(typeVal QStandardPaths__StandardLocation, fileNam C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -185,7 +181,6 @@ func QStandardPaths_FindExecutable2(executableName string, paths []string) strin executableName_ms.data = C.CString(executableName) executableName_ms.len = C.size_t(len(executableName)) defer C.free(unsafe.Pointer(executableName_ms.data)) - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -195,8 +190,7 @@ func QStandardPaths_FindExecutable2(executableName string, paths []string) strin defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} var _ms C.struct_miqt_string = C.QStandardPaths_FindExecutable2(executableName_ms, paths_ma) _ret := C.GoStringN(_ms.data, C.int(int64(_ms.len))) C.free(unsafe.Pointer(_ms.data)) diff --git a/qt6/gen_qstandardpaths.h b/qt6/gen_qstandardpaths.h index cabac034..fe63dabd 100644 --- a/qt6/gen_qstandardpaths.h +++ b/qt6/gen_qstandardpaths.h @@ -20,16 +20,16 @@ typedef struct QStandardPaths QStandardPaths; #endif struct miqt_string QStandardPaths_WritableLocation(int typeVal); -struct miqt_array* QStandardPaths_StandardLocations(int typeVal); +struct miqt_array QStandardPaths_StandardLocations(int typeVal); struct miqt_string QStandardPaths_Locate(int typeVal, struct miqt_string fileName); -struct miqt_array* QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName); +struct miqt_array QStandardPaths_LocateAll(int typeVal, struct miqt_string fileName); struct miqt_string QStandardPaths_DisplayName(int typeVal); struct miqt_string QStandardPaths_FindExecutable(struct miqt_string executableName); void QStandardPaths_SetTestModeEnabled(bool testMode); bool QStandardPaths_IsTestModeEnabled(); struct miqt_string QStandardPaths_Locate3(int typeVal, struct miqt_string fileName, int options); -struct miqt_array* QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options); -struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QStandardPaths_LocateAll3(int typeVal, struct miqt_string fileName, int options); +struct miqt_string QStandardPaths_FindExecutable2(struct miqt_string executableName, struct miqt_array /* of struct miqt_string */ paths); #ifdef __cplusplus } /* extern C */ diff --git a/qt6/gen_qstorageinfo.cpp b/qt6/gen_qstorageinfo.cpp index 4da16e0b..b5f91814 100644 --- a/qt6/gen_qstorageinfo.cpp +++ b/qt6/gen_qstorageinfo.cpp @@ -138,16 +138,16 @@ void QStorageInfo_Refresh(QStorageInfo* self) { self->refresh(); } -struct miqt_array* QStorageInfo_MountedVolumes() { +struct miqt_array QStorageInfo_MountedVolumes() { QList _ret = QStorageInfo::mountedVolumes(); // Convert QList<> from C++ memory to manually-managed C memory QStorageInfo** _arr = static_cast(malloc(sizeof(QStorageInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QStorageInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qstorageinfo.go b/qt6/gen_qstorageinfo.go index 05acca56..67fd791b 100644 --- a/qt6/gen_qstorageinfo.go +++ b/qt6/gen_qstorageinfo.go @@ -165,7 +165,7 @@ func (this *QStorageInfo) Refresh() { } func QStorageInfo_MountedVolumes() []QStorageInfo { - var _ma *C.struct_miqt_array = C.QStorageInfo_MountedVolumes() + var _ma C.struct_miqt_array = C.QStorageInfo_MountedVolumes() _ret := make([]QStorageInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QStorageInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -174,7 +174,6 @@ func QStorageInfo_MountedVolumes() []QStorageInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qstorageinfo.h b/qt6/gen_qstorageinfo.h index c1eb70bc..03ebafa5 100644 --- a/qt6/gen_qstorageinfo.h +++ b/qt6/gen_qstorageinfo.h @@ -45,7 +45,7 @@ bool QStorageInfo_IsReadOnly(const QStorageInfo* self); bool QStorageInfo_IsReady(const QStorageInfo* self); bool QStorageInfo_IsValid(const QStorageInfo* self); void QStorageInfo_Refresh(QStorageInfo* self); -struct miqt_array* QStorageInfo_MountedVolumes(); +struct miqt_array QStorageInfo_MountedVolumes(); QStorageInfo* QStorageInfo_Root(); void QStorageInfo_Delete(QStorageInfo* self); diff --git a/qt6/gen_qstringlistmodel.cpp b/qt6/gen_qstringlistmodel.cpp index d3cf501a..dcab7c09 100644 --- a/qt6/gen_qstringlistmodel.cpp +++ b/qt6/gen_qstringlistmodel.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -15,11 +16,11 @@ QStringListModel* QStringListModel_new() { return new QStringListModel(); } -QStringListModel* QStringListModel_new2(struct miqt_array* /* of struct miqt_string */ strings) { +QStringListModel* QStringListModel_new2(struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -30,11 +31,11 @@ QStringListModel* QStringListModel_new3(QObject* parent) { return new QStringListModel(parent); } -QStringListModel* QStringListModel_new4(struct miqt_array* /* of struct miqt_string */ strings, QObject* parent) { +QStringListModel* QStringListModel_new4(struct miqt_array /* of struct miqt_string */ strings, QObject* parent) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -97,11 +98,39 @@ bool QStringListModel_MoveRows(QStringListModel* self, QModelIndex* sourceParent return self->moveRows(*sourceParent, static_cast(sourceRow), static_cast(count), *destinationParent, static_cast(destinationChild)); } +struct miqt_map QStringListModel_ItemData(const QStringListModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +bool QStringListModel_SetItemData(QStringListModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + void QStringListModel_Sort(QStringListModel* self, int column) { self->sort(static_cast(column)); } -struct miqt_array* QStringListModel_StringList(const QStringListModel* self) { +struct miqt_array QStringListModel_StringList(const QStringListModel* self) { QStringList _ret = self->stringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -115,17 +144,17 @@ struct miqt_array* QStringListModel_StringList(const QStringListModel* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array* /* of struct miqt_string */ strings) { +void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } diff --git a/qt6/gen_qstringlistmodel.go b/qt6/gen_qstringlistmodel.go index 276d0bf7..3274e69d 100644 --- a/qt6/gen_qstringlistmodel.go +++ b/qt6/gen_qstringlistmodel.go @@ -51,7 +51,6 @@ func NewQStringListModel() *QStringListModel { // NewQStringListModel2 constructs a new QStringListModel object. func NewQStringListModel2(strings []string) *QStringListModel { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -61,8 +60,7 @@ func NewQStringListModel2(strings []string) *QStringListModel { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QStringListModel_new2(strings_ma) return newQStringListModel(ret) } @@ -75,7 +73,6 @@ func NewQStringListModel3(parent *QObject) *QStringListModel { // NewQStringListModel4 constructs a new QStringListModel object. func NewQStringListModel4(strings []string, parent *QObject) *QStringListModel { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -85,8 +82,7 @@ func NewQStringListModel4(strings []string, parent *QObject) *QStringListModel { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QStringListModel_new4(strings_ma, parent.cPointer()) return newQStringListModel(ret) } @@ -152,12 +148,49 @@ func (this *QStringListModel) MoveRows(sourceParent *QModelIndex, sourceRow int, return (bool)(C.QStringListModel_MoveRows(this.h, sourceParent.cPointer(), (C.int)(sourceRow), (C.int)(count), destinationParent.cPointer(), (C.int)(destinationChild))) } +func (this *QStringListModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QStringListModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QStringListModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QStringListModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QStringListModel) Sort(column int) { C.QStringListModel_Sort(this.h, (C.int)(column)) } func (this *QStringListModel) StringList() []string { - var _ma *C.struct_miqt_array = C.QStringListModel_StringList(this.h) + var _ma C.struct_miqt_array = C.QStringListModel_StringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -166,12 +199,10 @@ func (this *QStringListModel) StringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QStringListModel) SetStringList(strings []string) { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -181,8 +212,7 @@ func (this *QStringListModel) SetStringList(strings []string) { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} C.QStringListModel_SetStringList(this.h, strings_ma) } diff --git a/qt6/gen_qstringlistmodel.h b/qt6/gen_qstringlistmodel.h index 105ba0d4..27b34064 100644 --- a/qt6/gen_qstringlistmodel.h +++ b/qt6/gen_qstringlistmodel.h @@ -28,9 +28,9 @@ typedef struct QVariant QVariant; #endif QStringListModel* QStringListModel_new(); -QStringListModel* QStringListModel_new2(struct miqt_array* /* of struct miqt_string */ strings); +QStringListModel* QStringListModel_new2(struct miqt_array /* of struct miqt_string */ strings); QStringListModel* QStringListModel_new3(QObject* parent); -QStringListModel* QStringListModel_new4(struct miqt_array* /* of struct miqt_string */ strings, QObject* parent); +QStringListModel* QStringListModel_new4(struct miqt_array /* of struct miqt_string */ strings, QObject* parent); QMetaObject* QStringListModel_MetaObject(const QStringListModel* self); void* QStringListModel_Metacast(QStringListModel* self, const char* param1); struct miqt_string QStringListModel_Tr(const char* s); @@ -43,9 +43,11 @@ int QStringListModel_Flags(const QStringListModel* self, QModelIndex* index); bool QStringListModel_InsertRows(QStringListModel* self, int row, int count); bool QStringListModel_RemoveRows(QStringListModel* self, int row, int count); bool QStringListModel_MoveRows(QStringListModel* self, QModelIndex* sourceParent, int sourceRow, int count, QModelIndex* destinationParent, int destinationChild); +struct miqt_map QStringListModel_ItemData(const QStringListModel* self, QModelIndex* index); +bool QStringListModel_SetItemData(QStringListModel* self, QModelIndex* index, struct miqt_map roles); void QStringListModel_Sort(QStringListModel* self, int column); -struct miqt_array* QStringListModel_StringList(const QStringListModel* self); -void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array* /* of struct miqt_string */ strings); +struct miqt_array QStringListModel_StringList(const QStringListModel* self); +void QStringListModel_SetStringList(QStringListModel* self, struct miqt_array /* of struct miqt_string */ strings); int QStringListModel_SupportedDropActions(const QStringListModel* self); struct miqt_string QStringListModel_Tr2(const char* s, const char* c); struct miqt_string QStringListModel_Tr3(const char* s, const char* c, int n); diff --git a/qt6/gen_qstringview.cpp b/qt6/gen_qstringview.cpp index b9196161..3349071c 100644 --- a/qt6/gen_qstringview.cpp +++ b/qt6/gen_qstringview.cpp @@ -72,16 +72,16 @@ struct miqt_string QStringView_ToLocal8Bit(const QStringView* self) { return _ms; } -struct miqt_array* QStringView_ToUcs4(const QStringView* self) { +struct miqt_array QStringView_ToUcs4(const QStringView* self) { QList _ret = self->toUcs4(); // Convert QList<> from C++ memory to manually-managed C memory unsigned int* _arr = static_cast(malloc(sizeof(unsigned int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qstringview.go b/qt6/gen_qstringview.go index e5552486..08997b6b 100644 --- a/qt6/gen_qstringview.go +++ b/qt6/gen_qstringview.go @@ -96,13 +96,12 @@ func (this *QStringView) ToLocal8Bit() []byte { } func (this *QStringView) ToUcs4() []uint { - var _ma *C.struct_miqt_array = C.QStringView_ToUcs4(this.h) + var _ma C.struct_miqt_array = C.QStringView_ToUcs4(this.h) _ret := make([]uint, int(_ma.len)) _outCast := (*[0xffff]C.uint)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (uint)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qstringview.h b/qt6/gen_qstringview.h index d436fb08..91657f28 100644 --- a/qt6/gen_qstringview.h +++ b/qt6/gen_qstringview.h @@ -36,7 +36,7 @@ QChar* QStringView_OperatorSubscript(const QStringView* self, ptrdiff_t n); struct miqt_string QStringView_ToLatin1(const QStringView* self); struct miqt_string QStringView_ToUtf8(const QStringView* self); struct miqt_string QStringView_ToLocal8Bit(const QStringView* self); -struct miqt_array* QStringView_ToUcs4(const QStringView* self); +struct miqt_array QStringView_ToUcs4(const QStringView* self); QChar* QStringView_At(const QStringView* self, ptrdiff_t n); void QStringView_Truncate(QStringView* self, ptrdiff_t n); void QStringView_Chop(QStringView* self, ptrdiff_t n); diff --git a/qt6/gen_qstylefactory.cpp b/qt6/gen_qstylefactory.cpp index 799aee8a..2a4035f8 100644 --- a/qt6/gen_qstylefactory.cpp +++ b/qt6/gen_qstylefactory.cpp @@ -8,7 +8,7 @@ #include "gen_qstylefactory.h" #include "_cgo_export.h" -struct miqt_array* QStyleFactory_Keys() { +struct miqt_array QStyleFactory_Keys() { QStringList _ret = QStyleFactory::keys(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -22,9 +22,9 @@ struct miqt_array* QStyleFactory_Keys() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qstylefactory.go b/qt6/gen_qstylefactory.go index 6c3d4437..d01073ec 100644 --- a/qt6/gen_qstylefactory.go +++ b/qt6/gen_qstylefactory.go @@ -43,7 +43,7 @@ func UnsafeNewQStyleFactory(h unsafe.Pointer) *QStyleFactory { } func QStyleFactory_Keys() []string { - var _ma *C.struct_miqt_array = C.QStyleFactory_Keys() + var _ma C.struct_miqt_array = C.QStyleFactory_Keys() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -52,7 +52,6 @@ func QStyleFactory_Keys() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qstylefactory.h b/qt6/gen_qstylefactory.h index 609ea164..4e0ef7c7 100644 --- a/qt6/gen_qstylefactory.h +++ b/qt6/gen_qstylefactory.h @@ -21,7 +21,7 @@ typedef struct QStyle QStyle; typedef struct QStyleFactory QStyleFactory; #endif -struct miqt_array* QStyleFactory_Keys(); +struct miqt_array QStyleFactory_Keys(); QStyle* QStyleFactory_Create(struct miqt_string param1); void QStyleFactory_Delete(QStyleFactory* self); diff --git a/qt6/gen_qtablewidget.cpp b/qt6/gen_qtablewidget.cpp index 91156324..b84baf13 100644 --- a/qt6/gen_qtablewidget.cpp +++ b/qt6/gen_qtablewidget.cpp @@ -354,16 +354,16 @@ QTableWidgetItem* QTableWidget_TakeItem(QTableWidget* self, int row, int column) return self->takeItem(static_cast(row), static_cast(column)); } -struct miqt_array* QTableWidget_Items(const QTableWidget* self, QMimeData* data) { +struct miqt_array QTableWidget_Items(const QTableWidget* self, QMimeData* data) { QList _ret = self->items(data); // Convert QList<> from C++ memory to manually-managed C memory QTableWidgetItem** _arr = static_cast(malloc(sizeof(QTableWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -399,22 +399,22 @@ QTableWidgetItem* QTableWidget_TakeHorizontalHeaderItem(QTableWidget* self, int return self->takeHorizontalHeaderItem(static_cast(column)); } -void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } self->setVerticalHeaderLabels(labels_QList); } -void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -493,33 +493,33 @@ void QTableWidget_SetRangeSelected(QTableWidget* self, QTableWidgetSelectionRang self->setRangeSelected(*rangeVal, selectVal); } -struct miqt_array* QTableWidget_SelectedRanges(const QTableWidget* self) { +struct miqt_array QTableWidget_SelectedRanges(const QTableWidget* self) { QList _ret = self->selectedRanges(); // Convert QList<> from C++ memory to manually-managed C memory QTableWidgetSelectionRange** _arr = static_cast(malloc(sizeof(QTableWidgetSelectionRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTableWidgetSelectionRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTableWidget_SelectedItems(const QTableWidget* self) { +struct miqt_array QTableWidget_SelectedItems(const QTableWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QTableWidgetItem** _arr = static_cast(malloc(sizeof(QTableWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags) { +struct miqt_array QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -527,9 +527,9 @@ struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_ for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtablewidget.go b/qt6/gen_qtablewidget.go index cebb677a..6cb7e6b4 100644 --- a/qt6/gen_qtablewidget.go +++ b/qt6/gen_qtablewidget.go @@ -513,13 +513,12 @@ func (this *QTableWidget) TakeItem(row int, column int) *QTableWidgetItem { } func (this *QTableWidget) Items(data *QMimeData) []*QTableWidgetItem { - var _ma *C.struct_miqt_array = C.QTableWidget_Items(this.h, data.cPointer()) + var _ma C.struct_miqt_array = C.QTableWidget_Items(this.h, data.cPointer()) _ret := make([]*QTableWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTableWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -559,7 +558,6 @@ func (this *QTableWidget) TakeHorizontalHeaderItem(column int) *QTableWidgetItem } func (this *QTableWidget) SetVerticalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -569,13 +567,11 @@ func (this *QTableWidget) SetVerticalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTableWidget_SetVerticalHeaderLabels(this.h, labels_ma) } func (this *QTableWidget) SetHorizontalHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -585,8 +581,7 @@ func (this *QTableWidget) SetHorizontalHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTableWidget_SetHorizontalHeaderLabels(this.h, labels_ma) } @@ -663,7 +658,7 @@ func (this *QTableWidget) SetRangeSelected(rangeVal *QTableWidgetSelectionRange, } func (this *QTableWidget) SelectedRanges() []QTableWidgetSelectionRange { - var _ma *C.struct_miqt_array = C.QTableWidget_SelectedRanges(this.h) + var _ma C.struct_miqt_array = C.QTableWidget_SelectedRanges(this.h) _ret := make([]QTableWidgetSelectionRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetSelectionRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -672,18 +667,16 @@ func (this *QTableWidget) SelectedRanges() []QTableWidgetSelectionRange { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTableWidget) SelectedItems() []*QTableWidgetItem { - var _ma *C.struct_miqt_array = C.QTableWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QTableWidget_SelectedItems(this.h) _ret := make([]*QTableWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTableWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -692,13 +685,12 @@ func (this *QTableWidget) FindItems(text string, flags MatchFlag) []*QTableWidge text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTableWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QTableWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QTableWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTableWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTableWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtablewidget.h b/qt6/gen_qtablewidget.h index 7825aa70..ced438b6 100644 --- a/qt6/gen_qtablewidget.h +++ b/qt6/gen_qtablewidget.h @@ -121,7 +121,7 @@ int QTableWidget_Column(const QTableWidget* self, QTableWidgetItem* item); QTableWidgetItem* QTableWidget_Item(const QTableWidget* self, int row, int column); void QTableWidget_SetItem(QTableWidget* self, int row, int column, QTableWidgetItem* item); QTableWidgetItem* QTableWidget_TakeItem(QTableWidget* self, int row, int column); -struct miqt_array* QTableWidget_Items(const QTableWidget* self, QMimeData* data); +struct miqt_array QTableWidget_Items(const QTableWidget* self, QMimeData* data); QModelIndex* QTableWidget_IndexFromItem(const QTableWidget* self, QTableWidgetItem* item); QTableWidgetItem* QTableWidget_ItemFromIndex(const QTableWidget* self, QModelIndex* index); QTableWidgetItem* QTableWidget_VerticalHeaderItem(const QTableWidget* self, int row); @@ -130,8 +130,8 @@ QTableWidgetItem* QTableWidget_TakeVerticalHeaderItem(QTableWidget* self, int ro QTableWidgetItem* QTableWidget_HorizontalHeaderItem(const QTableWidget* self, int column); void QTableWidget_SetHorizontalHeaderItem(QTableWidget* self, int column, QTableWidgetItem* item); QTableWidgetItem* QTableWidget_TakeHorizontalHeaderItem(QTableWidget* self, int column); -void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels); -void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QTableWidget_SetVerticalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels); +void QTableWidget_SetHorizontalHeaderLabels(QTableWidget* self, struct miqt_array /* of struct miqt_string */ labels); int QTableWidget_CurrentRow(const QTableWidget* self); int QTableWidget_CurrentColumn(const QTableWidget* self); QTableWidgetItem* QTableWidget_CurrentItem(const QTableWidget* self); @@ -150,9 +150,9 @@ QWidget* QTableWidget_CellWidget(const QTableWidget* self, int row, int column); void QTableWidget_SetCellWidget(QTableWidget* self, int row, int column, QWidget* widget); void QTableWidget_RemoveCellWidget(QTableWidget* self, int row, int column); void QTableWidget_SetRangeSelected(QTableWidget* self, QTableWidgetSelectionRange* rangeVal, bool selectVal); -struct miqt_array* QTableWidget_SelectedRanges(const QTableWidget* self); -struct miqt_array* QTableWidget_SelectedItems(const QTableWidget* self); -struct miqt_array* QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags); +struct miqt_array QTableWidget_SelectedRanges(const QTableWidget* self); +struct miqt_array QTableWidget_SelectedItems(const QTableWidget* self); +struct miqt_array QTableWidget_FindItems(const QTableWidget* self, struct miqt_string text, int flags); int QTableWidget_VisualRow(const QTableWidget* self, int logicalRow); int QTableWidget_VisualColumn(const QTableWidget* self, int logicalColumn); QTableWidgetItem* QTableWidget_ItemAt(const QTableWidget* self, QPoint* p); diff --git a/qt6/gen_qtextbrowser.cpp b/qt6/gen_qtextbrowser.cpp index 179d2aa8..2b1f096e 100644 --- a/qt6/gen_qtextbrowser.cpp +++ b/qt6/gen_qtextbrowser.cpp @@ -47,7 +47,7 @@ int QTextBrowser_SourceType(const QTextBrowser* self) { return static_cast(_ret); } -struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self) { +struct miqt_array QTextBrowser_SearchPaths(const QTextBrowser* self) { QStringList _ret = self->searchPaths(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -61,17 +61,17 @@ struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array* /* of struct miqt_string */ paths) { +void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array /* of struct miqt_string */ paths) { QStringList paths_QList; - paths_QList.reserve(paths->len); - struct miqt_string* paths_arr = static_cast(paths->data); - for(size_t i = 0; i < paths->len; ++i) { + paths_QList.reserve(paths.len); + struct miqt_string* paths_arr = static_cast(paths.data); + for(size_t i = 0; i < paths.len; ++i) { QString paths_arr_i_QString = QString::fromUtf8(paths_arr[i].data, paths_arr[i].len); paths_QList.push_back(paths_arr_i_QString); } diff --git a/qt6/gen_qtextbrowser.go b/qt6/gen_qtextbrowser.go index ffbb3e8e..c034866f 100644 --- a/qt6/gen_qtextbrowser.go +++ b/qt6/gen_qtextbrowser.go @@ -87,7 +87,7 @@ func (this *QTextBrowser) SourceType() QTextDocument__ResourceType { } func (this *QTextBrowser) SearchPaths() []string { - var _ma *C.struct_miqt_array = C.QTextBrowser_SearchPaths(this.h) + var _ma C.struct_miqt_array = C.QTextBrowser_SearchPaths(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -96,12 +96,10 @@ func (this *QTextBrowser) SearchPaths() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextBrowser) SetSearchPaths(paths []string) { - // For the C ABI, malloc a C array of structs paths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(paths)))) defer C.free(unsafe.Pointer(paths_CArray)) for i := range paths { @@ -111,8 +109,7 @@ func (this *QTextBrowser) SetSearchPaths(paths []string) { defer C.free(unsafe.Pointer(paths_i_ms.data)) paths_CArray[i] = paths_i_ms } - paths_ma := &C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(paths_ma)) + paths_ma := C.struct_miqt_array{len: C.size_t(len(paths)), data: unsafe.Pointer(paths_CArray)} C.QTextBrowser_SetSearchPaths(this.h, paths_ma) } diff --git a/qt6/gen_qtextbrowser.h b/qt6/gen_qtextbrowser.h index cf8afa24..6176efa4 100644 --- a/qt6/gen_qtextbrowser.h +++ b/qt6/gen_qtextbrowser.h @@ -34,8 +34,8 @@ void* QTextBrowser_Metacast(QTextBrowser* self, const char* param1); struct miqt_string QTextBrowser_Tr(const char* s); QUrl* QTextBrowser_Source(const QTextBrowser* self); int QTextBrowser_SourceType(const QTextBrowser* self); -struct miqt_array* QTextBrowser_SearchPaths(const QTextBrowser* self); -void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array* /* of struct miqt_string */ paths); +struct miqt_array QTextBrowser_SearchPaths(const QTextBrowser* self); +void QTextBrowser_SetSearchPaths(QTextBrowser* self, struct miqt_array /* of struct miqt_string */ paths); QVariant* QTextBrowser_LoadResource(QTextBrowser* self, int typeVal, QUrl* name); bool QTextBrowser_IsBackwardAvailable(const QTextBrowser* self); bool QTextBrowser_IsForwardAvailable(const QTextBrowser* self); diff --git a/qt6/gen_qtextdocument.cpp b/qt6/gen_qtextdocument.cpp index 3a76568d..3eddbcf9 100644 --- a/qt6/gen_qtextdocument.cpp +++ b/qt6/gen_qtextdocument.cpp @@ -331,16 +331,16 @@ void QTextDocument_AddResource(QTextDocument* self, int typeVal, QUrl* name, QVa self->addResource(static_cast(typeVal), *name, *resource); } -struct miqt_array* QTextDocument_AllFormats(const QTextDocument* self) { +struct miqt_array QTextDocument_AllFormats(const QTextDocument* self) { QList _ret = self->allFormats(); // Convert QList<> from C++ memory to manually-managed C memory QTextFormat** _arr = static_cast(malloc(sizeof(QTextFormat*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextFormat(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextdocument.go b/qt6/gen_qtextdocument.go index a1227ebe..442dee7e 100644 --- a/qt6/gen_qtextdocument.go +++ b/qt6/gen_qtextdocument.go @@ -486,7 +486,7 @@ func (this *QTextDocument) AddResource(typeVal int, name *QUrl, resource *QVaria } func (this *QTextDocument) AllFormats() []QTextFormat { - var _ma *C.struct_miqt_array = C.QTextDocument_AllFormats(this.h) + var _ma C.struct_miqt_array = C.QTextDocument_AllFormats(this.h) _ret := make([]QTextFormat, int(_ma.len)) _outCast := (*[0xffff]*C.QTextFormat)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -495,7 +495,6 @@ func (this *QTextDocument) AllFormats() []QTextFormat { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextdocument.h b/qt6/gen_qtextdocument.h index 741a65ed..2e92deab 100644 --- a/qt6/gen_qtextdocument.h +++ b/qt6/gen_qtextdocument.h @@ -121,7 +121,7 @@ bool QTextDocument_IsModified(const QTextDocument* self); void QTextDocument_Print(const QTextDocument* self, QPagedPaintDevice* printer); QVariant* QTextDocument_Resource(const QTextDocument* self, int typeVal, QUrl* name); void QTextDocument_AddResource(QTextDocument* self, int typeVal, QUrl* name, QVariant* resource); -struct miqt_array* QTextDocument_AllFormats(const QTextDocument* self); +struct miqt_array QTextDocument_AllFormats(const QTextDocument* self); void QTextDocument_MarkContentsDirty(QTextDocument* self, int from, int length); void QTextDocument_SetUseDesignMetrics(QTextDocument* self, bool b); bool QTextDocument_UseDesignMetrics(const QTextDocument* self); diff --git a/qt6/gen_qtextdocumentwriter.cpp b/qt6/gen_qtextdocumentwriter.cpp index 0d439846..03bde4a9 100644 --- a/qt6/gen_qtextdocumentwriter.cpp +++ b/qt6/gen_qtextdocumentwriter.cpp @@ -77,7 +77,7 @@ bool QTextDocumentWriter_WriteWithFragment(QTextDocumentWriter* self, QTextDocum return self->write(*fragment); } -struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats() { +struct miqt_array QTextDocumentWriter_SupportedDocumentFormats() { QList _ret = QTextDocumentWriter::supportedDocumentFormats(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -89,9 +89,9 @@ struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextdocumentwriter.go b/qt6/gen_qtextdocumentwriter.go index 945241c1..2d08e9ff 100644 --- a/qt6/gen_qtextdocumentwriter.go +++ b/qt6/gen_qtextdocumentwriter.go @@ -126,7 +126,7 @@ func (this *QTextDocumentWriter) WriteWithFragment(fragment *QTextDocumentFragme } func QTextDocumentWriter_SupportedDocumentFormats() [][]byte { - var _ma *C.struct_miqt_array = C.QTextDocumentWriter_SupportedDocumentFormats() + var _ma C.struct_miqt_array = C.QTextDocumentWriter_SupportedDocumentFormats() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -135,7 +135,6 @@ func QTextDocumentWriter_SupportedDocumentFormats() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextdocumentwriter.h b/qt6/gen_qtextdocumentwriter.h index ffafe331..daed1ad6 100644 --- a/qt6/gen_qtextdocumentwriter.h +++ b/qt6/gen_qtextdocumentwriter.h @@ -39,7 +39,7 @@ void QTextDocumentWriter_SetFileName(QTextDocumentWriter* self, struct miqt_stri struct miqt_string QTextDocumentWriter_FileName(const QTextDocumentWriter* self); bool QTextDocumentWriter_Write(QTextDocumentWriter* self, QTextDocument* document); bool QTextDocumentWriter_WriteWithFragment(QTextDocumentWriter* self, QTextDocumentFragment* fragment); -struct miqt_array* QTextDocumentWriter_SupportedDocumentFormats(); +struct miqt_array QTextDocumentWriter_SupportedDocumentFormats(); void QTextDocumentWriter_Delete(QTextDocumentWriter* self); #ifdef __cplusplus diff --git a/qt6/gen_qtextedit.cpp b/qt6/gen_qtextedit.cpp index 26056d6a..a2540801 100644 --- a/qt6/gen_qtextedit.cpp +++ b/qt6/gen_qtextedit.cpp @@ -346,26 +346,26 @@ void QTextEdit_SetAcceptRichText(QTextEdit* self, bool accept) { self->setAcceptRichText(accept); } -void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections) { +void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextEdit__ExtraSelection** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextEdit__ExtraSelection** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->setExtraSelections(selections_QList); } -struct miqt_array* QTextEdit_ExtraSelections(const QTextEdit* self) { +struct miqt_array QTextEdit_ExtraSelections(const QTextEdit* self) { QList _ret = self->extraSelections(); // Convert QList<> from C++ memory to manually-managed C memory QTextEdit__ExtraSelection** _arr = static_cast(malloc(sizeof(QTextEdit__ExtraSelection*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextEdit::ExtraSelection(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextedit.go b/qt6/gen_qtextedit.go index e7a9c947..70204a37 100644 --- a/qt6/gen_qtextedit.go +++ b/qt6/gen_qtextedit.go @@ -401,19 +401,17 @@ func (this *QTextEdit) SetAcceptRichText(accept bool) { } func (this *QTextEdit) SetExtraSelections(selections []QTextEdit__ExtraSelection) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextEdit__ExtraSelection)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextEdit_SetExtraSelections(this.h, selections_ma) } func (this *QTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { - var _ma *C.struct_miqt_array = C.QTextEdit_ExtraSelections(this.h) + var _ma C.struct_miqt_array = C.QTextEdit_ExtraSelections(this.h) _ret := make([]QTextEdit__ExtraSelection, int(_ma.len)) _outCast := (*[0xffff]*C.QTextEdit__ExtraSelection)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -422,7 +420,6 @@ func (this *QTextEdit) ExtraSelections() []QTextEdit__ExtraSelection { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextedit.h b/qt6/gen_qtextedit.h index e04b680a..8f486d7e 100644 --- a/qt6/gen_qtextedit.h +++ b/qt6/gen_qtextedit.h @@ -117,8 +117,8 @@ int QTextEdit_CursorWidth(const QTextEdit* self); void QTextEdit_SetCursorWidth(QTextEdit* self, int width); bool QTextEdit_AcceptRichText(const QTextEdit* self); void QTextEdit_SetAcceptRichText(QTextEdit* self, bool accept); -void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array* /* of QTextEdit__ExtraSelection* */ selections); -struct miqt_array* QTextEdit_ExtraSelections(const QTextEdit* self); +void QTextEdit_SetExtraSelections(QTextEdit* self, struct miqt_array /* of QTextEdit__ExtraSelection* */ selections); +struct miqt_array QTextEdit_ExtraSelections(const QTextEdit* self); void QTextEdit_MoveCursor(QTextEdit* self, int operation); bool QTextEdit_CanPaste(const QTextEdit* self); void QTextEdit_Print(const QTextEdit* self, QPagedPaintDevice* printer); diff --git a/qt6/gen_qtextformat.cpp b/qt6/gen_qtextformat.cpp index 054aaa7c..09b113e3 100644 --- a/qt6/gen_qtextformat.cpp +++ b/qt6/gen_qtextformat.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -160,29 +161,47 @@ QTextLength* QTextFormat_LengthProperty(const QTextFormat* self, int propertyId) return new QTextLength(self->lengthProperty(static_cast(propertyId))); } -struct miqt_array* QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId) { +struct miqt_array QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId) { QList _ret = self->lengthVectorProperty(static_cast(propertyId)); // Convert QList<> from C++ memory to manually-managed C memory QTextLength** _arr = static_cast(malloc(sizeof(QTextLength*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLength(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array* /* of QTextLength* */ lengths) { +void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array /* of QTextLength* */ lengths) { QList lengths_QList; - lengths_QList.reserve(lengths->len); - QTextLength** lengths_arr = static_cast(lengths->data); - for(size_t i = 0; i < lengths->len; ++i) { + lengths_QList.reserve(lengths.len); + QTextLength** lengths_arr = static_cast(lengths.data); + for(size_t i = 0; i < lengths.len; ++i) { lengths_QList.push_back(*(lengths_arr[i])); } self->setProperty(static_cast(propertyId), lengths_QList); } +struct miqt_map QTextFormat_Properties(const QTextFormat* self) { + QMap _ret = self->properties(); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + int QTextFormat_PropertyCount(const QTextFormat* self) { return self->propertyCount(); } @@ -332,11 +351,11 @@ struct miqt_string QTextCharFormat_FontFamily(const QTextCharFormat* self) { return _ms; } -void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ families) { +void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ families) { QStringList families_QList; - families_QList.reserve(families->len); - struct miqt_string* families_arr = static_cast(families->data); - for(size_t i = 0; i < families->len; ++i) { + families_QList.reserve(families.len); + struct miqt_string* families_arr = static_cast(families.data); + for(size_t i = 0; i < families.len; ++i) { QString families_arr_i_QString = QString::fromUtf8(families_arr[i].data, families_arr[i].len); families_QList.push_back(families_arr_i_QString); } @@ -593,18 +612,18 @@ struct miqt_string QTextCharFormat_AnchorHref(const QTextCharFormat* self) { return _ms; } -void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ names) { +void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ names) { QStringList names_QList; - names_QList.reserve(names->len); - struct miqt_string* names_arr = static_cast(names->data); - for(size_t i = 0; i < names->len; ++i) { + names_QList.reserve(names.len); + struct miqt_string* names_arr = static_cast(names.data); + for(size_t i = 0; i < names.len; ++i) { QString names_arr_i_QString = QString::fromUtf8(names_arr[i].data, names_arr[i].len); names_QList.push_back(names_arr_i_QString); } self->setAnchorNames(names_QList); } -struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self) { +struct miqt_array QTextCharFormat_AnchorNames(const QTextCharFormat* self) { QStringList _ret = self->anchorNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -618,9 +637,9 @@ struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -769,26 +788,26 @@ int QTextBlockFormat_PageBreakPolicy(const QTextBlockFormat* self) { return static_cast(_ret); } -void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array* /* of QTextOption__Tab* */ tabs) { +void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array /* of QTextOption__Tab* */ tabs) { QList tabs_QList; - tabs_QList.reserve(tabs->len); - QTextOption__Tab** tabs_arr = static_cast(tabs->data); - for(size_t i = 0; i < tabs->len; ++i) { + tabs_QList.reserve(tabs.len); + QTextOption__Tab** tabs_arr = static_cast(tabs.data); + for(size_t i = 0; i < tabs.len; ++i) { tabs_QList.push_back(*(tabs_arr[i])); } self->setTabPositions(tabs_QList); } -struct miqt_array* QTextBlockFormat_TabPositions(const QTextBlockFormat* self) { +struct miqt_array QTextBlockFormat_TabPositions(const QTextBlockFormat* self) { QList _ret = self->tabPositions(); // Convert QList<> from C++ memory to manually-managed C memory QTextOption__Tab** _arr = static_cast(malloc(sizeof(QTextOption__Tab*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextOption::Tab(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -1082,26 +1101,26 @@ void QTextTableFormat_SetColumns(QTextTableFormat* self, int columns) { self->setColumns(static_cast(columns)); } -void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array* /* of QTextLength* */ constraints) { +void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array /* of QTextLength* */ constraints) { QList constraints_QList; - constraints_QList.reserve(constraints->len); - QTextLength** constraints_arr = static_cast(constraints->data); - for(size_t i = 0; i < constraints->len; ++i) { + constraints_QList.reserve(constraints.len); + QTextLength** constraints_arr = static_cast(constraints.data); + for(size_t i = 0; i < constraints.len; ++i) { constraints_QList.push_back(*(constraints_arr[i])); } self->setColumnWidthConstraints(constraints_QList); } -struct miqt_array* QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self) { +struct miqt_array QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self) { QList _ret = self->columnWidthConstraints(); // Convert QList<> from C++ memory to manually-managed C memory QTextLength** _arr = static_cast(malloc(sizeof(QTextLength*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLength(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextformat.go b/qt6/gen_qtextformat.go index be6de2a3..a84d0e61 100644 --- a/qt6/gen_qtextformat.go +++ b/qt6/gen_qtextformat.go @@ -482,7 +482,7 @@ func (this *QTextFormat) LengthProperty(propertyId int) *QTextLength { } func (this *QTextFormat) LengthVectorProperty(propertyId int) []QTextLength { - var _ma *C.struct_miqt_array = C.QTextFormat_LengthVectorProperty(this.h, (C.int)(propertyId)) + var _ma C.struct_miqt_array = C.QTextFormat_LengthVectorProperty(this.h, (C.int)(propertyId)) _ret := make([]QTextLength, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLength)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -491,22 +491,37 @@ func (this *QTextFormat) LengthVectorProperty(propertyId int) []QTextLength { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFormat) SetProperty2(propertyId int, lengths []QTextLength) { - // For the C ABI, malloc a C array of raw pointers lengths_CArray := (*[0xffff]*C.QTextLength)(C.malloc(C.size_t(8 * len(lengths)))) defer C.free(unsafe.Pointer(lengths_CArray)) for i := range lengths { lengths_CArray[i] = lengths[i].cPointer() } - lengths_ma := &C.struct_miqt_array{len: C.size_t(len(lengths)), data: unsafe.Pointer(lengths_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(lengths_ma)) + lengths_ma := C.struct_miqt_array{len: C.size_t(len(lengths)), data: unsafe.Pointer(lengths_CArray)} C.QTextFormat_SetProperty2(this.h, (C.int)(propertyId), lengths_ma) } +func (this *QTextFormat) Properties() map[int]QVariant { + var _mm C.struct_miqt_map = C.QTextFormat_Properties(this.h) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QTextFormat) PropertyCount() int { return (int)(C.QTextFormat_PropertyCount(this.h)) } @@ -729,7 +744,6 @@ func (this *QTextCharFormat) FontFamily() string { } func (this *QTextCharFormat) SetFontFamilies(families []string) { - // For the C ABI, malloc a C array of structs families_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(families)))) defer C.free(unsafe.Pointer(families_CArray)) for i := range families { @@ -739,8 +753,7 @@ func (this *QTextCharFormat) SetFontFamilies(families []string) { defer C.free(unsafe.Pointer(families_i_ms.data)) families_CArray[i] = families_i_ms } - families_ma := &C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(families_ma)) + families_ma := C.struct_miqt_array{len: C.size_t(len(families)), data: unsafe.Pointer(families_CArray)} C.QTextCharFormat_SetFontFamilies(this.h, families_ma) } @@ -995,7 +1008,6 @@ func (this *QTextCharFormat) AnchorHref() string { } func (this *QTextCharFormat) SetAnchorNames(names []string) { - // For the C ABI, malloc a C array of structs names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names)))) defer C.free(unsafe.Pointer(names_CArray)) for i := range names { @@ -1005,13 +1017,12 @@ func (this *QTextCharFormat) SetAnchorNames(names []string) { defer C.free(unsafe.Pointer(names_i_ms.data)) names_CArray[i] = names_i_ms } - names_ma := &C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(names_ma)) + names_ma := C.struct_miqt_array{len: C.size_t(len(names)), data: unsafe.Pointer(names_CArray)} C.QTextCharFormat_SetAnchorNames(this.h, names_ma) } func (this *QTextCharFormat) AnchorNames() []string { - var _ma *C.struct_miqt_array = C.QTextCharFormat_AnchorNames(this.h) + var _ma C.struct_miqt_array = C.QTextCharFormat_AnchorNames(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1020,7 +1031,6 @@ func (this *QTextCharFormat) AnchorNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1205,19 +1215,17 @@ func (this *QTextBlockFormat) PageBreakPolicy() QTextFormat__PageBreakFlag { } func (this *QTextBlockFormat) SetTabPositions(tabs []QTextOption__Tab) { - // For the C ABI, malloc a C array of raw pointers tabs_CArray := (*[0xffff]*C.QTextOption__Tab)(C.malloc(C.size_t(8 * len(tabs)))) defer C.free(unsafe.Pointer(tabs_CArray)) for i := range tabs { tabs_CArray[i] = tabs[i].cPointer() } - tabs_ma := &C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabs_ma)) + tabs_ma := C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} C.QTextBlockFormat_SetTabPositions(this.h, tabs_ma) } func (this *QTextBlockFormat) TabPositions() []QTextOption__Tab { - var _ma *C.struct_miqt_array = C.QTextBlockFormat_TabPositions(this.h) + var _ma C.struct_miqt_array = C.QTextBlockFormat_TabPositions(this.h) _ret := make([]QTextOption__Tab, int(_ma.len)) _outCast := (*[0xffff]*C.QTextOption__Tab)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1226,7 +1234,6 @@ func (this *QTextBlockFormat) TabPositions() []QTextOption__Tab { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1685,19 +1692,17 @@ func (this *QTextTableFormat) SetColumns(columns int) { } func (this *QTextTableFormat) SetColumnWidthConstraints(constraints []QTextLength) { - // For the C ABI, malloc a C array of raw pointers constraints_CArray := (*[0xffff]*C.QTextLength)(C.malloc(C.size_t(8 * len(constraints)))) defer C.free(unsafe.Pointer(constraints_CArray)) for i := range constraints { constraints_CArray[i] = constraints[i].cPointer() } - constraints_ma := &C.struct_miqt_array{len: C.size_t(len(constraints)), data: unsafe.Pointer(constraints_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(constraints_ma)) + constraints_ma := C.struct_miqt_array{len: C.size_t(len(constraints)), data: unsafe.Pointer(constraints_CArray)} C.QTextTableFormat_SetColumnWidthConstraints(this.h, constraints_ma) } func (this *QTextTableFormat) ColumnWidthConstraints() []QTextLength { - var _ma *C.struct_miqt_array = C.QTextTableFormat_ColumnWidthConstraints(this.h) + var _ma C.struct_miqt_array = C.QTextTableFormat_ColumnWidthConstraints(this.h) _ret := make([]QTextLength, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLength)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -1706,7 +1711,6 @@ func (this *QTextTableFormat) ColumnWidthConstraints() []QTextLength { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextformat.h b/qt6/gen_qtextformat.h index 5a36a6c4..a4f5c74d 100644 --- a/qt6/gen_qtextformat.h +++ b/qt6/gen_qtextformat.h @@ -84,8 +84,9 @@ QColor* QTextFormat_ColorProperty(const QTextFormat* self, int propertyId); QPen* QTextFormat_PenProperty(const QTextFormat* self, int propertyId); QBrush* QTextFormat_BrushProperty(const QTextFormat* self, int propertyId); QTextLength* QTextFormat_LengthProperty(const QTextFormat* self, int propertyId); -struct miqt_array* QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId); -void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array* /* of QTextLength* */ lengths); +struct miqt_array QTextFormat_LengthVectorProperty(const QTextFormat* self, int propertyId); +void QTextFormat_SetProperty2(QTextFormat* self, int propertyId, struct miqt_array /* of QTextLength* */ lengths); +struct miqt_map QTextFormat_Properties(const QTextFormat* self); int QTextFormat_PropertyCount(const QTextFormat* self); void QTextFormat_SetObjectType(QTextFormat* self, int typeVal); int QTextFormat_ObjectType(const QTextFormat* self); @@ -122,7 +123,7 @@ void QTextCharFormat_SetFont(QTextCharFormat* self, QFont* font); QFont* QTextCharFormat_Font(const QTextCharFormat* self); void QTextCharFormat_SetFontFamily(QTextCharFormat* self, struct miqt_string family); struct miqt_string QTextCharFormat_FontFamily(const QTextCharFormat* self); -void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ families); +void QTextCharFormat_SetFontFamilies(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ families); QVariant* QTextCharFormat_FontFamilies(const QTextCharFormat* self); void QTextCharFormat_SetFontStyleName(QTextCharFormat* self, struct miqt_string styleName); QVariant* QTextCharFormat_FontStyleName(const QTextCharFormat* self); @@ -178,8 +179,8 @@ void QTextCharFormat_SetAnchor(QTextCharFormat* self, bool anchor); bool QTextCharFormat_IsAnchor(const QTextCharFormat* self); void QTextCharFormat_SetAnchorHref(QTextCharFormat* self, struct miqt_string value); struct miqt_string QTextCharFormat_AnchorHref(const QTextCharFormat* self); -void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array* /* of struct miqt_string */ names); -struct miqt_array* QTextCharFormat_AnchorNames(const QTextCharFormat* self); +void QTextCharFormat_SetAnchorNames(QTextCharFormat* self, struct miqt_array /* of struct miqt_string */ names); +struct miqt_array QTextCharFormat_AnchorNames(const QTextCharFormat* self); void QTextCharFormat_SetTableCellRowSpan(QTextCharFormat* self, int tableCellRowSpan); int QTextCharFormat_TableCellRowSpan(const QTextCharFormat* self); void QTextCharFormat_SetTableCellColumnSpan(QTextCharFormat* self, int tableCellColumnSpan); @@ -215,8 +216,8 @@ void QTextBlockFormat_SetNonBreakableLines(QTextBlockFormat* self, bool b); bool QTextBlockFormat_NonBreakableLines(const QTextBlockFormat* self); void QTextBlockFormat_SetPageBreakPolicy(QTextBlockFormat* self, int flags); int QTextBlockFormat_PageBreakPolicy(const QTextBlockFormat* self); -void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array* /* of QTextOption__Tab* */ tabs); -struct miqt_array* QTextBlockFormat_TabPositions(const QTextBlockFormat* self); +void QTextBlockFormat_SetTabPositions(QTextBlockFormat* self, struct miqt_array /* of QTextOption__Tab* */ tabs); +struct miqt_array QTextBlockFormat_TabPositions(const QTextBlockFormat* self); void QTextBlockFormat_SetMarker(QTextBlockFormat* self, int marker); int QTextBlockFormat_Marker(const QTextBlockFormat* self); void QTextBlockFormat_Delete(QTextBlockFormat* self); @@ -284,8 +285,8 @@ QTextTableFormat* QTextTableFormat_new(); bool QTextTableFormat_IsValid(const QTextTableFormat* self); int QTextTableFormat_Columns(const QTextTableFormat* self); void QTextTableFormat_SetColumns(QTextTableFormat* self, int columns); -void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array* /* of QTextLength* */ constraints); -struct miqt_array* QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self); +void QTextTableFormat_SetColumnWidthConstraints(QTextTableFormat* self, struct miqt_array /* of QTextLength* */ constraints); +struct miqt_array QTextTableFormat_ColumnWidthConstraints(const QTextTableFormat* self); void QTextTableFormat_ClearColumnWidthConstraints(QTextTableFormat* self); double QTextTableFormat_CellSpacing(const QTextTableFormat* self); void QTextTableFormat_SetCellSpacing(QTextTableFormat* self, double spacing); diff --git a/qt6/gen_qtextlayout.cpp b/qt6/gen_qtextlayout.cpp index bfec9bbe..14e39d9b 100644 --- a/qt6/gen_qtextlayout.cpp +++ b/qt6/gen_qtextlayout.cpp @@ -166,26 +166,26 @@ struct miqt_string QTextLayout_PreeditAreaText(const QTextLayout* self) { return _ms; } -void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides) { +void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides) { QList overrides_QList; - overrides_QList.reserve(overrides->len); - QTextLayout__FormatRange** overrides_arr = static_cast(overrides->data); - for(size_t i = 0; i < overrides->len; ++i) { + overrides_QList.reserve(overrides.len); + QTextLayout__FormatRange** overrides_arr = static_cast(overrides.data); + for(size_t i = 0; i < overrides.len; ++i) { overrides_QList.push_back(*(overrides_arr[i])); } self->setFormats(overrides_QList); } -struct miqt_array* QTextLayout_Formats(const QTextLayout* self) { +struct miqt_array QTextLayout_Formats(const QTextLayout* self) { QList _ret = self->formats(); // Convert QList<> from C++ memory to manually-managed C memory QTextLayout__FormatRange** _arr = static_cast(malloc(sizeof(QTextLayout__FormatRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLayout::FormatRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -292,16 +292,16 @@ double QTextLayout_MaximumWidth(const QTextLayout* self) { return static_cast(_ret); } -struct miqt_array* QTextLayout_GlyphRuns(const QTextLayout* self) { +struct miqt_array QTextLayout_GlyphRuns(const QTextLayout* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -317,49 +317,49 @@ int QTextLayout_PreviousCursorPosition2(const QTextLayout* self, int oldPos, int return self->previousCursorPosition(static_cast(oldPos), static_cast(mode)); } -void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections) { +void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextLayout__FormatRange** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextLayout__FormatRange** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->draw(p, *pos, selections_QList); } -void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections, QRectF* clip) { +void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections, QRectF* clip) { QList selections_QList; - selections_QList.reserve(selections->len); - QTextLayout__FormatRange** selections_arr = static_cast(selections->data); - for(size_t i = 0; i < selections->len; ++i) { + selections_QList.reserve(selections.len); + QTextLayout__FormatRange** selections_arr = static_cast(selections.data); + for(size_t i = 0; i < selections.len; ++i) { selections_QList.push_back(*(selections_arr[i])); } self->draw(p, *pos, selections_QList, *clip); } -struct miqt_array* QTextLayout_GlyphRuns1(const QTextLayout* self, int from) { +struct miqt_array QTextLayout_GlyphRuns1(const QTextLayout* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length) { +struct miqt_array QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -486,16 +486,16 @@ void QTextLine_Draw(const QTextLine* self, QPainter* painter, QPointF* position) self->draw(painter, *position); } -struct miqt_array* QTextLine_GlyphRuns(const QTextLine* self) { +struct miqt_array QTextLine_GlyphRuns(const QTextLine* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -513,29 +513,29 @@ int QTextLine_XToCursor2(const QTextLine* self, double x, int param2) { return self->xToCursor(static_cast(x), static_cast(param2)); } -struct miqt_array* QTextLine_GlyphRuns1(const QTextLine* self, int from) { +struct miqt_array QTextLine_GlyphRuns1(const QTextLine* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextLine_GlyphRuns2(const QTextLine* self, int from, int length) { +struct miqt_array QTextLine_GlyphRuns2(const QTextLine* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextlayout.go b/qt6/gen_qtextlayout.go index ad4a9f9a..d4b1205d 100644 --- a/qt6/gen_qtextlayout.go +++ b/qt6/gen_qtextlayout.go @@ -270,19 +270,17 @@ func (this *QTextLayout) PreeditAreaText() string { } func (this *QTextLayout) SetFormats(overrides []QTextLayout__FormatRange) { - // For the C ABI, malloc a C array of raw pointers overrides_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(overrides)))) defer C.free(unsafe.Pointer(overrides_CArray)) for i := range overrides { overrides_CArray[i] = overrides[i].cPointer() } - overrides_ma := &C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(overrides_ma)) + overrides_ma := C.struct_miqt_array{len: C.size_t(len(overrides)), data: unsafe.Pointer(overrides_CArray)} C.QTextLayout_SetFormats(this.h, overrides_ma) } func (this *QTextLayout) Formats() []QTextLayout__FormatRange { - var _ma *C.struct_miqt_array = C.QTextLayout_Formats(this.h) + var _ma C.struct_miqt_array = C.QTextLayout_Formats(this.h) _ret := make([]QTextLayout__FormatRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLayout__FormatRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -291,7 +289,6 @@ func (this *QTextLayout) Formats() []QTextLayout__FormatRange { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -411,7 +408,7 @@ func (this *QTextLayout) MaximumWidth() float64 { } func (this *QTextLayout) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -420,7 +417,6 @@ func (this *QTextLayout) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -437,31 +433,27 @@ func (this *QTextLayout) PreviousCursorPosition2(oldPos int, mode QTextLayout__C } func (this *QTextLayout) Draw3(p *QPainter, pos *QPointF, selections []QTextLayout__FormatRange) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextLayout_Draw3(this.h, p.cPointer(), pos.cPointer(), selections_ma) } func (this *QTextLayout) Draw4(p *QPainter, pos *QPointF, selections []QTextLayout__FormatRange, clip *QRectF) { - // For the C ABI, malloc a C array of raw pointers selections_CArray := (*[0xffff]*C.QTextLayout__FormatRange)(C.malloc(C.size_t(8 * len(selections)))) defer C.free(unsafe.Pointer(selections_CArray)) for i := range selections { selections_CArray[i] = selections[i].cPointer() } - selections_ma := &C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(selections_ma)) + selections_ma := C.struct_miqt_array{len: C.size_t(len(selections)), data: unsafe.Pointer(selections_CArray)} C.QTextLayout_Draw4(this.h, p.cPointer(), pos.cPointer(), selections_ma, clip.cPointer()) } func (this *QTextLayout) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -470,12 +462,11 @@ func (this *QTextLayout) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextLayout) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLayout_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextLayout_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -484,7 +475,6 @@ func (this *QTextLayout) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -651,7 +641,7 @@ func (this *QTextLine) Draw(painter *QPainter, position *QPointF) { } func (this *QTextLine) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -660,7 +650,6 @@ func (this *QTextLine) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -677,7 +666,7 @@ func (this *QTextLine) XToCursor2(x float64, param2 QTextLine__CursorPosition) i } func (this *QTextLine) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -686,12 +675,11 @@ func (this *QTextLine) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextLine) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextLine_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextLine_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -700,7 +688,6 @@ func (this *QTextLine) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextlayout.h b/qt6/gen_qtextlayout.h index bd3437d5..f18c95c2 100644 --- a/qt6/gen_qtextlayout.h +++ b/qt6/gen_qtextlayout.h @@ -80,8 +80,8 @@ QTextOption* QTextLayout_TextOption(const QTextLayout* self); void QTextLayout_SetPreeditArea(QTextLayout* self, int position, struct miqt_string text); int QTextLayout_PreeditAreaPosition(const QTextLayout* self); struct miqt_string QTextLayout_PreeditAreaText(const QTextLayout* self); -void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array* /* of QTextLayout__FormatRange* */ overrides); -struct miqt_array* QTextLayout_Formats(const QTextLayout* self); +void QTextLayout_SetFormats(QTextLayout* self, struct miqt_array /* of QTextLayout__FormatRange* */ overrides); +struct miqt_array QTextLayout_Formats(const QTextLayout* self); void QTextLayout_ClearFormats(QTextLayout* self); void QTextLayout_SetCacheEnabled(QTextLayout* self, bool enable); bool QTextLayout_CacheEnabled(const QTextLayout* self); @@ -107,14 +107,14 @@ void QTextLayout_SetPosition(QTextLayout* self, QPointF* p); QRectF* QTextLayout_BoundingRect(const QTextLayout* self); double QTextLayout_MinimumWidth(const QTextLayout* self); double QTextLayout_MaximumWidth(const QTextLayout* self); -struct miqt_array* QTextLayout_GlyphRuns(const QTextLayout* self); +struct miqt_array QTextLayout_GlyphRuns(const QTextLayout* self); void QTextLayout_SetFlags(QTextLayout* self, int flags); int QTextLayout_NextCursorPosition2(const QTextLayout* self, int oldPos, int mode); int QTextLayout_PreviousCursorPosition2(const QTextLayout* self, int oldPos, int mode); -void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections); -void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array* /* of QTextLayout__FormatRange* */ selections, QRectF* clip); -struct miqt_array* QTextLayout_GlyphRuns1(const QTextLayout* self, int from); -struct miqt_array* QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length); +void QTextLayout_Draw3(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections); +void QTextLayout_Draw4(const QTextLayout* self, QPainter* p, QPointF* pos, struct miqt_array /* of QTextLayout__FormatRange* */ selections, QRectF* clip); +struct miqt_array QTextLayout_GlyphRuns1(const QTextLayout* self, int from); +struct miqt_array QTextLayout_GlyphRuns2(const QTextLayout* self, int from, int length); void QTextLayout_Delete(QTextLayout* self); QTextLine* QTextLine_new(); @@ -144,12 +144,12 @@ int QTextLine_TextStart(const QTextLine* self); int QTextLine_TextLength(const QTextLine* self); int QTextLine_LineNumber(const QTextLine* self); void QTextLine_Draw(const QTextLine* self, QPainter* painter, QPointF* position); -struct miqt_array* QTextLine_GlyphRuns(const QTextLine* self); +struct miqt_array QTextLine_GlyphRuns(const QTextLine* self); double QTextLine_CursorToX2(const QTextLine* self, int* cursorPos, int edge); double QTextLine_CursorToX22(const QTextLine* self, int cursorPos, int edge); int QTextLine_XToCursor2(const QTextLine* self, double x, int param2); -struct miqt_array* QTextLine_GlyphRuns1(const QTextLine* self, int from); -struct miqt_array* QTextLine_GlyphRuns2(const QTextLine* self, int from, int length); +struct miqt_array QTextLine_GlyphRuns1(const QTextLine* self, int from); +struct miqt_array QTextLine_GlyphRuns2(const QTextLine* self, int from, int length); void QTextLine_Delete(QTextLine* self); QTextLayout__FormatRange* QTextLayout__FormatRange_new(QTextLayout__FormatRange* param1); diff --git a/qt6/gen_qtextobject.cpp b/qt6/gen_qtextobject.cpp index a2e813b6..86fc902c 100644 --- a/qt6/gen_qtextobject.cpp +++ b/qt6/gen_qtextobject.cpp @@ -187,16 +187,16 @@ void QTextFrame_SetLayoutData(QTextFrame* self, QTextFrameLayoutData* data) { self->setLayoutData(data); } -struct miqt_array* QTextFrame_ChildFrames(const QTextFrame* self) { +struct miqt_array QTextFrame_ChildFrames(const QTextFrame* self) { QList _ret = self->childFrames(); // Convert QList<> from C++ memory to manually-managed C memory QTextFrame** _arr = static_cast(malloc(sizeof(QTextFrame*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -326,16 +326,16 @@ struct miqt_string QTextBlock_Text(const QTextBlock* self) { return _ms; } -struct miqt_array* QTextBlock_TextFormats(const QTextBlock* self) { +struct miqt_array QTextBlock_TextFormats(const QTextBlock* self) { QList _ret = self->textFormats(); // Convert QList<> from C++ memory to manually-managed C memory QTextLayout__FormatRange** _arr = static_cast(malloc(sizeof(QTextLayout__FormatRange*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextLayout::FormatRange(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -478,42 +478,42 @@ struct miqt_string QTextFragment_Text(const QTextFragment* self) { return _ms; } -struct miqt_array* QTextFragment_GlyphRuns(const QTextFragment* self) { +struct miqt_array QTextFragment_GlyphRuns(const QTextFragment* self) { QList _ret = self->glyphRuns(); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextFragment_GlyphRuns1(const QTextFragment* self, int from) { +struct miqt_array QTextFragment_GlyphRuns1(const QTextFragment* self, int from) { QList _ret = self->glyphRuns(static_cast(from)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length) { +struct miqt_array QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length) { QList _ret = self->glyphRuns(static_cast(from), static_cast(length)); // Convert QList<> from C++ memory to manually-managed C memory QGlyphRun** _arr = static_cast(malloc(sizeof(QGlyphRun*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QGlyphRun(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextobject.go b/qt6/gen_qtextobject.go index 324527ee..fdc50a60 100644 --- a/qt6/gen_qtextobject.go +++ b/qt6/gen_qtextobject.go @@ -318,13 +318,12 @@ func (this *QTextFrame) SetLayoutData(data *QTextFrameLayoutData) { } func (this *QTextFrame) ChildFrames() []*QTextFrame { - var _ma *C.struct_miqt_array = C.QTextFrame_ChildFrames(this.h) + var _ma C.struct_miqt_array = C.QTextFrame_ChildFrames(this.h) _ret := make([]*QTextFrame, int(_ma.len)) _outCast := (*[0xffff]*C.QTextFrame)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTextFrame(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -544,7 +543,7 @@ func (this *QTextBlock) Text() string { } func (this *QTextBlock) TextFormats() []QTextLayout__FormatRange { - var _ma *C.struct_miqt_array = C.QTextBlock_TextFormats(this.h) + var _ma C.struct_miqt_array = C.QTextBlock_TextFormats(this.h) _ret := make([]QTextLayout__FormatRange, int(_ma.len)) _outCast := (*[0xffff]*C.QTextLayout__FormatRange)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -553,7 +552,6 @@ func (this *QTextBlock) TextFormats() []QTextLayout__FormatRange { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -751,7 +749,7 @@ func (this *QTextFragment) Text() string { } func (this *QTextFragment) GlyphRuns() []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns(this.h) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns(this.h) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -760,12 +758,11 @@ func (this *QTextFragment) GlyphRuns() []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFragment) GlyphRuns1(from int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns1(this.h, (C.int)(from)) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns1(this.h, (C.int)(from)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -774,12 +771,11 @@ func (this *QTextFragment) GlyphRuns1(from int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextFragment) GlyphRuns2(from int, length int) []QGlyphRun { - var _ma *C.struct_miqt_array = C.QTextFragment_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) + var _ma C.struct_miqt_array = C.QTextFragment_GlyphRuns2(this.h, (C.int)(from), (C.int)(length)) _ret := make([]QGlyphRun, int(_ma.len)) _outCast := (*[0xffff]*C.QGlyphRun)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -788,7 +784,6 @@ func (this *QTextFragment) GlyphRuns2(from int, length int) []QGlyphRun { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextobject.h b/qt6/gen_qtextobject.h index 31cb6e0f..678fb72a 100644 --- a/qt6/gen_qtextobject.h +++ b/qt6/gen_qtextobject.h @@ -100,7 +100,7 @@ int QTextFrame_FirstPosition(const QTextFrame* self); int QTextFrame_LastPosition(const QTextFrame* self); QTextFrameLayoutData* QTextFrame_LayoutData(const QTextFrame* self); void QTextFrame_SetLayoutData(QTextFrame* self, QTextFrameLayoutData* data); -struct miqt_array* QTextFrame_ChildFrames(const QTextFrame* self); +struct miqt_array QTextFrame_ChildFrames(const QTextFrame* self); QTextFrame* QTextFrame_ParentFrame(const QTextFrame* self); QTextFrame__iterator* QTextFrame_Begin(const QTextFrame* self); QTextFrame__iterator* QTextFrame_End(const QTextFrame* self); @@ -129,7 +129,7 @@ QTextCharFormat* QTextBlock_CharFormat(const QTextBlock* self); int QTextBlock_CharFormatIndex(const QTextBlock* self); int QTextBlock_TextDirection(const QTextBlock* self); struct miqt_string QTextBlock_Text(const QTextBlock* self); -struct miqt_array* QTextBlock_TextFormats(const QTextBlock* self); +struct miqt_array QTextBlock_TextFormats(const QTextBlock* self); QTextDocument* QTextBlock_Document(const QTextBlock* self); QTextList* QTextBlock_TextList(const QTextBlock* self); QTextBlockUserData* QTextBlock_UserData(const QTextBlock* self); @@ -164,9 +164,9 @@ bool QTextFragment_Contains(const QTextFragment* self, int position); QTextCharFormat* QTextFragment_CharFormat(const QTextFragment* self); int QTextFragment_CharFormatIndex(const QTextFragment* self); struct miqt_string QTextFragment_Text(const QTextFragment* self); -struct miqt_array* QTextFragment_GlyphRuns(const QTextFragment* self); -struct miqt_array* QTextFragment_GlyphRuns1(const QTextFragment* self, int from); -struct miqt_array* QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length); +struct miqt_array QTextFragment_GlyphRuns(const QTextFragment* self); +struct miqt_array QTextFragment_GlyphRuns1(const QTextFragment* self, int from); +struct miqt_array QTextFragment_GlyphRuns2(const QTextFragment* self, int from, int length); void QTextFragment_Delete(QTextFragment* self); QTextFrame__iterator* QTextFrame__iterator_new(); diff --git a/qt6/gen_qtextoption.cpp b/qt6/gen_qtextoption.cpp index a2d1f94b..9dd0d615 100644 --- a/qt6/gen_qtextoption.cpp +++ b/qt6/gen_qtextoption.cpp @@ -67,49 +67,49 @@ double QTextOption_TabStopDistance(const QTextOption* self) { return static_cast(_ret); } -void QTextOption_SetTabArray(QTextOption* self, struct miqt_array* /* of double */ tabStops) { +void QTextOption_SetTabArray(QTextOption* self, struct miqt_array /* of double */ tabStops) { QList tabStops_QList; - tabStops_QList.reserve(tabStops->len); - double* tabStops_arr = static_cast(tabStops->data); - for(size_t i = 0; i < tabStops->len; ++i) { + tabStops_QList.reserve(tabStops.len); + double* tabStops_arr = static_cast(tabStops.data); + for(size_t i = 0; i < tabStops.len; ++i) { tabStops_QList.push_back(static_cast(tabStops_arr[i])); } self->setTabArray(tabStops_QList); } -struct miqt_array* QTextOption_TabArray(const QTextOption* self) { +struct miqt_array QTextOption_TabArray(const QTextOption* self) { QList _ret = self->tabArray(); // Convert QList<> from C++ memory to manually-managed C memory double* _arr = static_cast(malloc(sizeof(double) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QTextOption_SetTabs(QTextOption* self, struct miqt_array* /* of QTextOption__Tab* */ tabStops) { +void QTextOption_SetTabs(QTextOption* self, struct miqt_array /* of QTextOption__Tab* */ tabStops) { QList tabStops_QList; - tabStops_QList.reserve(tabStops->len); - QTextOption__Tab** tabStops_arr = static_cast(tabStops->data); - for(size_t i = 0; i < tabStops->len; ++i) { + tabStops_QList.reserve(tabStops.len); + QTextOption__Tab** tabStops_arr = static_cast(tabStops.data); + for(size_t i = 0; i < tabStops.len; ++i) { tabStops_QList.push_back(*(tabStops_arr[i])); } self->setTabs(tabStops_QList); } -struct miqt_array* QTextOption_Tabs(const QTextOption* self) { +struct miqt_array QTextOption_Tabs(const QTextOption* self) { QList _ret = self->tabs(); // Convert QList<> from C++ memory to manually-managed C memory QTextOption__Tab** _arr = static_cast(malloc(sizeof(QTextOption__Tab*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTextOption::Tab(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtextoption.go b/qt6/gen_qtextoption.go index 6d781db6..f24bc353 100644 --- a/qt6/gen_qtextoption.go +++ b/qt6/gen_qtextoption.go @@ -135,42 +135,37 @@ func (this *QTextOption) TabStopDistance() float64 { } func (this *QTextOption) SetTabArray(tabStops []float64) { - // For the C ABI, malloc a C array of raw pointers tabStops_CArray := (*[0xffff]C.double)(C.malloc(C.size_t(8 * len(tabStops)))) defer C.free(unsafe.Pointer(tabStops_CArray)) for i := range tabStops { tabStops_CArray[i] = (C.double)(tabStops[i]) } - tabStops_ma := &C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabStops_ma)) + tabStops_ma := C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} C.QTextOption_SetTabArray(this.h, tabStops_ma) } func (this *QTextOption) TabArray() []float64 { - var _ma *C.struct_miqt_array = C.QTextOption_TabArray(this.h) + var _ma C.struct_miqt_array = C.QTextOption_TabArray(this.h) _ret := make([]float64, int(_ma.len)) _outCast := (*[0xffff]C.double)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (float64)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QTextOption) SetTabs(tabStops []QTextOption__Tab) { - // For the C ABI, malloc a C array of raw pointers tabStops_CArray := (*[0xffff]*C.QTextOption__Tab)(C.malloc(C.size_t(8 * len(tabStops)))) defer C.free(unsafe.Pointer(tabStops_CArray)) for i := range tabStops { tabStops_CArray[i] = tabStops[i].cPointer() } - tabStops_ma := &C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabStops_ma)) + tabStops_ma := C.struct_miqt_array{len: C.size_t(len(tabStops)), data: unsafe.Pointer(tabStops_CArray)} C.QTextOption_SetTabs(this.h, tabStops_ma) } func (this *QTextOption) Tabs() []QTextOption__Tab { - var _ma *C.struct_miqt_array = C.QTextOption_Tabs(this.h) + var _ma C.struct_miqt_array = C.QTextOption_Tabs(this.h) _ret := make([]QTextOption__Tab, int(_ma.len)) _outCast := (*[0xffff]*C.QTextOption__Tab)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -179,7 +174,6 @@ func (this *QTextOption) Tabs() []QTextOption__Tab { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtextoption.h b/qt6/gen_qtextoption.h index 4385862f..608af5cc 100644 --- a/qt6/gen_qtextoption.h +++ b/qt6/gen_qtextoption.h @@ -41,10 +41,10 @@ void QTextOption_SetFlags(QTextOption* self, int flags); int QTextOption_Flags(const QTextOption* self); void QTextOption_SetTabStopDistance(QTextOption* self, double tabStopDistance); double QTextOption_TabStopDistance(const QTextOption* self); -void QTextOption_SetTabArray(QTextOption* self, struct miqt_array* /* of double */ tabStops); -struct miqt_array* QTextOption_TabArray(const QTextOption* self); -void QTextOption_SetTabs(QTextOption* self, struct miqt_array* /* of QTextOption__Tab* */ tabStops); -struct miqt_array* QTextOption_Tabs(const QTextOption* self); +void QTextOption_SetTabArray(QTextOption* self, struct miqt_array /* of double */ tabStops); +struct miqt_array QTextOption_TabArray(const QTextOption* self); +void QTextOption_SetTabs(QTextOption* self, struct miqt_array /* of QTextOption__Tab* */ tabStops); +struct miqt_array QTextOption_Tabs(const QTextOption* self); void QTextOption_SetUseDesignMetrics(QTextOption* self, bool b); bool QTextOption_UseDesignMetrics(const QTextOption* self); void QTextOption_Delete(QTextOption* self); diff --git a/qt6/gen_qtimezone.cpp b/qt6/gen_qtimezone.cpp index 2fce9ca5..53d4a884 100644 --- a/qt6/gen_qtimezone.cpp +++ b/qt6/gen_qtimezone.cpp @@ -161,16 +161,16 @@ QTimeZone__OffsetData* QTimeZone_PreviousTransition(const QTimeZone* self, QDate return new QTimeZone::OffsetData(self->previousTransition(*beforeDateTime)); } -struct miqt_array* QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime) { +struct miqt_array QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime) { QTimeZone::OffsetDataList _ret = self->transitions(*fromDateTime, *toDateTime); // Convert QList<> from C++ memory to manually-managed C memory QTimeZone__OffsetData** _arr = static_cast(malloc(sizeof(QTimeZone__OffsetData*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QTimeZone::OffsetData(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -196,7 +196,7 @@ bool QTimeZone_IsTimeZoneIdAvailable(struct miqt_string ianaId) { return QTimeZone::isTimeZoneIdAvailable(ianaId_QByteArray); } -struct miqt_array* QTimeZone_AvailableTimeZoneIds() { +struct miqt_array QTimeZone_AvailableTimeZoneIds() { QList _ret = QTimeZone::availableTimeZoneIds(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -208,13 +208,13 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIds() { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithTerritory(uint16_t territory) { +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithTerritory(uint16_t territory) { QList _ret = QTimeZone::availableTimeZoneIds(static_cast(territory)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -226,13 +226,13 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithTerritory(uint16_t territor memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds) { +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds) { QList _ret = QTimeZone::availableTimeZoneIds(static_cast(offsetSeconds)); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -244,9 +244,9 @@ struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSec memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -280,7 +280,7 @@ struct miqt_string QTimeZone_WindowsIdToDefaultIanaId2(struct miqt_string window return _ms; } -struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { +struct miqt_array QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { QByteArray windowsId_QByteArray(windowsId.data, windowsId.len); QList _ret = QTimeZone::windowsIdToIanaIds(windowsId_QByteArray); // Convert QList<> from C++ memory to manually-managed C memory @@ -293,13 +293,13 @@ struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId) { memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, uint16_t territory) { +struct miqt_array QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, uint16_t territory) { QByteArray windowsId_QByteArray(windowsId.data, windowsId.len); QList _ret = QTimeZone::windowsIdToIanaIds(windowsId_QByteArray, static_cast(territory)); // Convert QList<> from C++ memory to manually-managed C memory @@ -312,9 +312,9 @@ struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, u memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtimezone.go b/qt6/gen_qtimezone.go index da916d42..0cdc73bc 100644 --- a/qt6/gen_qtimezone.go +++ b/qt6/gen_qtimezone.go @@ -249,7 +249,7 @@ func (this *QTimeZone) PreviousTransition(beforeDateTime *QDateTime) *QTimeZone_ } func (this *QTimeZone) Transitions(fromDateTime *QDateTime, toDateTime *QDateTime) []QTimeZone__OffsetData { - var _ma *C.struct_miqt_array = C.QTimeZone_Transitions(this.h, fromDateTime.cPointer(), toDateTime.cPointer()) + var _ma C.struct_miqt_array = C.QTimeZone_Transitions(this.h, fromDateTime.cPointer(), toDateTime.cPointer()) _ret := make([]QTimeZone__OffsetData, int(_ma.len)) _outCast := (*[0xffff]*C.QTimeZone__OffsetData)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -258,7 +258,6 @@ func (this *QTimeZone) Transitions(fromDateTime *QDateTime, toDateTime *QDateTim _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -291,7 +290,7 @@ func QTimeZone_IsTimeZoneIdAvailable(ianaId []byte) bool { } func QTimeZone_AvailableTimeZoneIds() [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIds() + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIds() _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -300,12 +299,11 @@ func QTimeZone_AvailableTimeZoneIds() [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QTimeZone_AvailableTimeZoneIdsWithTerritory(territory QLocale__Country) [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithTerritory((C.uint16_t)(territory)) + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithTerritory((C.uint16_t)(territory)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -314,12 +312,11 @@ func QTimeZone_AvailableTimeZoneIdsWithTerritory(territory QLocale__Country) [][ C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(offsetSeconds int) [][]byte { - var _ma *C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds((C.int)(offsetSeconds)) + var _ma C.struct_miqt_array = C.QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds((C.int)(offsetSeconds)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -328,7 +325,6 @@ func QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(offsetSeconds int) [][]byte C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -366,7 +362,7 @@ func QTimeZone_WindowsIdToIanaIds(windowsId []byte) [][]byte { windowsId_alias := C.struct_miqt_string{} windowsId_alias.data = (*C.char)(unsafe.Pointer(&windowsId[0])) windowsId_alias.len = C.size_t(len(windowsId)) - var _ma *C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds(windowsId_alias) + var _ma C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds(windowsId_alias) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -375,7 +371,6 @@ func QTimeZone_WindowsIdToIanaIds(windowsId []byte) [][]byte { C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -383,7 +378,7 @@ func QTimeZone_WindowsIdToIanaIds2(windowsId []byte, territory QLocale__Country) windowsId_alias := C.struct_miqt_string{} windowsId_alias.data = (*C.char)(unsafe.Pointer(&windowsId[0])) windowsId_alias.len = C.size_t(len(windowsId)) - var _ma *C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds2(windowsId_alias, (C.uint16_t)(territory)) + var _ma C.struct_miqt_array = C.QTimeZone_WindowsIdToIanaIds2(windowsId_alias, (C.uint16_t)(territory)) _ret := make([][]byte, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -392,7 +387,6 @@ func QTimeZone_WindowsIdToIanaIds2(windowsId []byte, territory QLocale__Country) C.free(unsafe.Pointer(_lv_bytearray.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtimezone.h b/qt6/gen_qtimezone.h index ea92723b..a86b1827 100644 --- a/qt6/gen_qtimezone.h +++ b/qt6/gen_qtimezone.h @@ -57,19 +57,19 @@ QTimeZone__OffsetData* QTimeZone_OffsetData(const QTimeZone* self, QDateTime* fo bool QTimeZone_HasTransitions(const QTimeZone* self); QTimeZone__OffsetData* QTimeZone_NextTransition(const QTimeZone* self, QDateTime* afterDateTime); QTimeZone__OffsetData* QTimeZone_PreviousTransition(const QTimeZone* self, QDateTime* beforeDateTime); -struct miqt_array* QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime); +struct miqt_array QTimeZone_Transitions(const QTimeZone* self, QDateTime* fromDateTime, QDateTime* toDateTime); struct miqt_string QTimeZone_SystemTimeZoneId(); QTimeZone* QTimeZone_SystemTimeZone(); QTimeZone* QTimeZone_Utc(); bool QTimeZone_IsTimeZoneIdAvailable(struct miqt_string ianaId); -struct miqt_array* QTimeZone_AvailableTimeZoneIds(); -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithTerritory(uint16_t territory); -struct miqt_array* QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds); +struct miqt_array QTimeZone_AvailableTimeZoneIds(); +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithTerritory(uint16_t territory); +struct miqt_array QTimeZone_AvailableTimeZoneIdsWithOffsetSeconds(int offsetSeconds); struct miqt_string QTimeZone_IanaIdToWindowsId(struct miqt_string ianaId); struct miqt_string QTimeZone_WindowsIdToDefaultIanaId(struct miqt_string windowsId); struct miqt_string QTimeZone_WindowsIdToDefaultIanaId2(struct miqt_string windowsId, uint16_t territory); -struct miqt_array* QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId); -struct miqt_array* QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, uint16_t territory); +struct miqt_array QTimeZone_WindowsIdToIanaIds(struct miqt_string windowsId); +struct miqt_array QTimeZone_WindowsIdToIanaIds2(struct miqt_string windowsId, uint16_t territory); struct miqt_string QTimeZone_DisplayName2(const QTimeZone* self, QDateTime* atDateTime, int nameType); struct miqt_string QTimeZone_DisplayName3(const QTimeZone* self, QDateTime* atDateTime, int nameType, QLocale* locale); struct miqt_string QTimeZone_DisplayName22(const QTimeZone* self, int timeType, int nameType); diff --git a/qt6/gen_qtransposeproxymodel.cpp b/qt6/gen_qtransposeproxymodel.cpp index d75eed3a..8befaa05 100644 --- a/qt6/gen_qtransposeproxymodel.cpp +++ b/qt6/gen_qtransposeproxymodel.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -59,10 +60,38 @@ bool QTransposeProxyModel_SetHeaderData(QTransposeProxyModel* self, int section, return self->setHeaderData(static_cast(section), static_cast(orientation), *value); } +bool QTransposeProxyModel_SetItemData(QTransposeProxyModel* self, QModelIndex* index, struct miqt_map roles) { + QMap roles_QMap; + int* roles_karr = static_cast(roles.keys); + QVariant** roles_varr = static_cast(roles.values); + for(size_t i = 0; i < roles.len; ++i) { + roles_QMap[static_cast(roles_karr[i])] = *(roles_varr[i]); + } + return self->setItemData(*index, roles_QMap); +} + QSize* QTransposeProxyModel_Span(const QTransposeProxyModel* self, QModelIndex* index) { return new QSize(self->span(*index)); } +struct miqt_map QTransposeProxyModel_ItemData(const QTransposeProxyModel* self, QModelIndex* index) { + QMap _ret = self->itemData(*index); + // Convert QMap<> from C++ memory to manually-managed C memory + int* _karr = static_cast(malloc(sizeof(int) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + _karr[_ctr] = _itr->first; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QModelIndex* QTransposeProxyModel_MapFromSource(const QTransposeProxyModel* self, QModelIndex* sourceIndex) { return new QModelIndex(self->mapFromSource(*sourceIndex)); } diff --git a/qt6/gen_qtransposeproxymodel.go b/qt6/gen_qtransposeproxymodel.go index 2c1a761c..fd62abcd 100644 --- a/qt6/gen_qtransposeproxymodel.go +++ b/qt6/gen_qtransposeproxymodel.go @@ -97,6 +97,25 @@ func (this *QTransposeProxyModel) SetHeaderData(section int, orientation Orienta return (bool)(C.QTransposeProxyModel_SetHeaderData(this.h, (C.int)(section), (C.int)(orientation), value.cPointer())) } +func (this *QTransposeProxyModel) SetItemData(index *QModelIndex, roles map[int]QVariant) bool { + roles_Keys_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Keys_CArray)) + roles_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(roles)))) + defer C.free(unsafe.Pointer(roles_Values_CArray)) + roles_ctr := 0 + for roles_k, roles_v := range roles { + roles_Keys_CArray[roles_ctr] = (C.int)(roles_k) + roles_Values_CArray[roles_ctr] = roles_v.cPointer() + roles_ctr++ + } + roles_mm := C.struct_miqt_map{ + len: C.size_t(len(roles)), + keys: unsafe.Pointer(roles_Keys_CArray), + values: unsafe.Pointer(roles_Values_CArray), + } + return (bool)(C.QTransposeProxyModel_SetItemData(this.h, index.cPointer(), roles_mm)) +} + func (this *QTransposeProxyModel) Span(index *QModelIndex) *QSize { _ret := C.QTransposeProxyModel_Span(this.h, index.cPointer()) _goptr := newQSize(_ret) @@ -104,6 +123,24 @@ func (this *QTransposeProxyModel) Span(index *QModelIndex) *QSize { return _goptr } +func (this *QTransposeProxyModel) ItemData(index *QModelIndex) map[int]QVariant { + var _mm C.struct_miqt_map = C.QTransposeProxyModel_ItemData(this.h, index.cPointer()) + _ret := make(map[int]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.int)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + _entry_Key := (int)(_Keys[i]) + + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QTransposeProxyModel) MapFromSource(sourceIndex *QModelIndex) *QModelIndex { _ret := C.QTransposeProxyModel_MapFromSource(this.h, sourceIndex.cPointer()) _goptr := newQModelIndex(_ret) diff --git a/qt6/gen_qtransposeproxymodel.h b/qt6/gen_qtransposeproxymodel.h index eef04f20..7a423021 100644 --- a/qt6/gen_qtransposeproxymodel.h +++ b/qt6/gen_qtransposeproxymodel.h @@ -41,7 +41,9 @@ int QTransposeProxyModel_RowCount(const QTransposeProxyModel* self); int QTransposeProxyModel_ColumnCount(const QTransposeProxyModel* self); QVariant* QTransposeProxyModel_HeaderData(const QTransposeProxyModel* self, int section, int orientation); bool QTransposeProxyModel_SetHeaderData(QTransposeProxyModel* self, int section, int orientation, QVariant* value); +bool QTransposeProxyModel_SetItemData(QTransposeProxyModel* self, QModelIndex* index, struct miqt_map roles); QSize* QTransposeProxyModel_Span(const QTransposeProxyModel* self, QModelIndex* index); +struct miqt_map QTransposeProxyModel_ItemData(const QTransposeProxyModel* self, QModelIndex* index); QModelIndex* QTransposeProxyModel_MapFromSource(const QTransposeProxyModel* self, QModelIndex* sourceIndex); QModelIndex* QTransposeProxyModel_MapToSource(const QTransposeProxyModel* self, QModelIndex* proxyIndex); QModelIndex* QTransposeProxyModel_Parent(const QTransposeProxyModel* self, QModelIndex* index); diff --git a/qt6/gen_qtreeview.cpp b/qt6/gen_qtreeview.cpp index a288fc1d..222887df 100644 --- a/qt6/gen_qtreeview.cpp +++ b/qt6/gen_qtreeview.cpp @@ -343,11 +343,11 @@ void QTreeView_ScrollTo2(QTreeView* self, QModelIndex* index, int hint) { self->scrollTo(*index, static_cast(hint)); } -void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles) { +void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles) { QList roles_QList; - roles_QList.reserve(roles->len); - int* roles_arr = static_cast(roles->data); - for(size_t i = 0; i < roles->len; ++i) { + roles_QList.reserve(roles.len); + int* roles_arr = static_cast(roles.data); + for(size_t i = 0; i < roles.len; ++i) { roles_QList.push_back(static_cast(roles_arr[i])); } self->dataChanged(*topLeft, *bottomRight, roles_QList); diff --git a/qt6/gen_qtreeview.go b/qt6/gen_qtreeview.go index 8dbaa1a4..9a5da524 100644 --- a/qt6/gen_qtreeview.go +++ b/qt6/gen_qtreeview.go @@ -406,14 +406,12 @@ func (this *QTreeView) ScrollTo2(index *QModelIndex, hint QAbstractItemView__Scr } func (this *QTreeView) DataChanged3(topLeft *QModelIndex, bottomRight *QModelIndex, roles []int) { - // For the C ABI, malloc a C array of raw pointers roles_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(roles)))) defer C.free(unsafe.Pointer(roles_CArray)) for i := range roles { roles_CArray[i] = (C.int)(roles[i]) } - roles_ma := &C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(roles_ma)) + roles_ma := C.struct_miqt_array{len: C.size_t(len(roles)), data: unsafe.Pointer(roles_CArray)} C.QTreeView_DataChanged3(this.h, topLeft.cPointer(), bottomRight.cPointer(), roles_ma) } diff --git a/qt6/gen_qtreeview.h b/qt6/gen_qtreeview.h index ec1ec736..ff767988 100644 --- a/qt6/gen_qtreeview.h +++ b/qt6/gen_qtreeview.h @@ -109,7 +109,7 @@ void QTreeView_ExpandToDepth(QTreeView* self, int depth); struct miqt_string QTreeView_Tr2(const char* s, const char* c); struct miqt_string QTreeView_Tr3(const char* s, const char* c, int n); void QTreeView_ScrollTo2(QTreeView* self, QModelIndex* index, int hint); -void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array* /* of int */ roles); +void QTreeView_DataChanged3(QTreeView* self, QModelIndex* topLeft, QModelIndex* bottomRight, struct miqt_array /* of int */ roles); void QTreeView_ExpandRecursively2(QTreeView* self, QModelIndex* index, int depth); void QTreeView_Delete(QTreeView* self); diff --git a/qt6/gen_qtreewidget.cpp b/qt6/gen_qtreewidget.cpp index d9939235..3271e0a2 100644 --- a/qt6/gen_qtreewidget.cpp +++ b/qt6/gen_qtreewidget.cpp @@ -24,11 +24,11 @@ QTreeWidgetItem* QTreeWidgetItem_new() { return new QTreeWidgetItem(); } -QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -39,11 +39,11 @@ QTreeWidgetItem* QTreeWidgetItem_new3(QTreeWidget* treeview) { return new QTreeWidgetItem(treeview); } -QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -58,11 +58,11 @@ QTreeWidgetItem* QTreeWidgetItem_new6(QTreeWidgetItem* parent) { return new QTreeWidgetItem(parent); } -QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings) { +QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -81,11 +81,11 @@ QTreeWidgetItem* QTreeWidgetItem_new10(int typeVal) { return new QTreeWidgetItem(static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -96,11 +96,11 @@ QTreeWidgetItem* QTreeWidgetItem_new12(QTreeWidget* treeview, int typeVal) { return new QTreeWidgetItem(treeview, static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -115,11 +115,11 @@ QTreeWidgetItem* QTreeWidgetItem_new15(QTreeWidgetItem* parent, int typeVal) { return new QTreeWidgetItem(parent, static_cast(typeVal)); } -QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings, int typeVal) { +QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings, int typeVal) { QStringList strings_QList; - strings_QList.reserve(strings->len); - struct miqt_string* strings_arr = static_cast(strings->data); - for(size_t i = 0; i < strings->len; ++i) { + strings_QList.reserve(strings.len); + struct miqt_string* strings_arr = static_cast(strings.data); + for(size_t i = 0; i < strings.len; ++i) { QString strings_arr_i_QString = QString::fromUtf8(strings_arr[i].data, strings_arr[i].len); strings_QList.push_back(strings_arr_i_QString); } @@ -385,36 +385,36 @@ QTreeWidgetItem* QTreeWidgetItem_TakeChild(QTreeWidgetItem* self, int index) { return self->takeChild(static_cast(index)); } -void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array* /* of QTreeWidgetItem* */ children) { +void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array /* of QTreeWidgetItem* */ children) { QList children_QList; - children_QList.reserve(children->len); - QTreeWidgetItem** children_arr = static_cast(children->data); - for(size_t i = 0; i < children->len; ++i) { + children_QList.reserve(children.len); + QTreeWidgetItem** children_arr = static_cast(children.data); + for(size_t i = 0; i < children.len; ++i) { children_QList.push_back(children_arr[i]); } self->addChildren(children_QList); } -void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ children) { +void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array /* of QTreeWidgetItem* */ children) { QList children_QList; - children_QList.reserve(children->len); - QTreeWidgetItem** children_arr = static_cast(children->data); - for(size_t i = 0; i < children->len; ++i) { + children_QList.reserve(children.len); + QTreeWidgetItem** children_arr = static_cast(children.data); + for(size_t i = 0; i < children.len; ++i) { children_QList.push_back(children_arr[i]); } self->insertChildren(static_cast(index), children_QList); } -struct miqt_array* QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self) { +struct miqt_array QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self) { QList _ret = self->takeChildren(); // Convert QList<> from C++ memory to manually-managed C memory QTreeWidgetItem** _arr = static_cast(malloc(sizeof(QTreeWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -493,21 +493,21 @@ int QTreeWidget_IndexOfTopLevelItem(const QTreeWidget* self, QTreeWidgetItem* it return self->indexOfTopLevelItem(item); } -void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ items) { +void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array /* of QTreeWidgetItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QTreeWidgetItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QTreeWidgetItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->insertTopLevelItems(static_cast(index), items_QList); } -void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array* /* of QTreeWidgetItem* */ items) { +void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array /* of QTreeWidgetItem* */ items) { QList items_QList; - items_QList.reserve(items->len); - QTreeWidgetItem** items_arr = static_cast(items->data); - for(size_t i = 0; i < items->len; ++i) { + items_QList.reserve(items.len); + QTreeWidgetItem** items_arr = static_cast(items.data); + for(size_t i = 0; i < items.len; ++i) { items_QList.push_back(items_arr[i]); } self->addTopLevelItems(items_QList); @@ -521,11 +521,11 @@ void QTreeWidget_SetHeaderItem(QTreeWidget* self, QTreeWidgetItem* item) { self->setHeaderItem(item); } -void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array* /* of struct miqt_string */ labels) { +void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array /* of struct miqt_string */ labels) { QStringList labels_QList; - labels_QList.reserve(labels->len); - struct miqt_string* labels_arr = static_cast(labels->data); - for(size_t i = 0; i < labels->len; ++i) { + labels_QList.reserve(labels.len); + struct miqt_string* labels_arr = static_cast(labels.data); + for(size_t i = 0; i < labels.len; ++i) { QString labels_arr_i_QString = QString::fromUtf8(labels_arr[i].data, labels_arr[i].len); labels_QList.push_back(labels_arr_i_QString); } @@ -605,20 +605,20 @@ void QTreeWidget_RemoveItemWidget(QTreeWidget* self, QTreeWidgetItem* item, int self->removeItemWidget(item, static_cast(column)); } -struct miqt_array* QTreeWidget_SelectedItems(const QTreeWidget* self) { +struct miqt_array QTreeWidget_SelectedItems(const QTreeWidget* self) { QList _ret = self->selectedItems(); // Convert QList<> from C++ memory to manually-managed C memory QTreeWidgetItem** _arr = static_cast(malloc(sizeof(QTreeWidgetItem*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags) { +struct miqt_array QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags)); // Convert QList<> from C++ memory to manually-managed C memory @@ -626,9 +626,9 @@ struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_st for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -822,7 +822,7 @@ bool QTreeWidget_IsPersistentEditorOpen2(const QTreeWidget* self, QTreeWidgetIte return self->isPersistentEditorOpen(item, static_cast(column)); } -struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column) { +struct miqt_array QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column) { QString text_QString = QString::fromUtf8(text.data, text.len); QList _ret = self->findItems(text_QString, static_cast(flags), static_cast(column)); // Convert QList<> from C++ memory to manually-managed C memory @@ -830,9 +830,9 @@ struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_s for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qtreewidget.go b/qt6/gen_qtreewidget.go index 79fce455..853aa5bd 100644 --- a/qt6/gen_qtreewidget.go +++ b/qt6/gen_qtreewidget.go @@ -66,7 +66,6 @@ func NewQTreeWidgetItem() *QTreeWidgetItem { // NewQTreeWidgetItem2 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem2(strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -76,8 +75,7 @@ func NewQTreeWidgetItem2(strings []string) *QTreeWidgetItem { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new2(strings_ma) return newQTreeWidgetItem(ret) } @@ -90,7 +88,6 @@ func NewQTreeWidgetItem3(treeview *QTreeWidget) *QTreeWidgetItem { // NewQTreeWidgetItem4 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem4(treeview *QTreeWidget, strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -100,8 +97,7 @@ func NewQTreeWidgetItem4(treeview *QTreeWidget, strings []string) *QTreeWidgetIt defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new4(treeview.cPointer(), strings_ma) return newQTreeWidgetItem(ret) } @@ -120,7 +116,6 @@ func NewQTreeWidgetItem6(parent *QTreeWidgetItem) *QTreeWidgetItem { // NewQTreeWidgetItem7 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem7(parent *QTreeWidgetItem, strings []string) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -130,8 +125,7 @@ func NewQTreeWidgetItem7(parent *QTreeWidgetItem, strings []string) *QTreeWidget defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new7(parent.cPointer(), strings_ma) return newQTreeWidgetItem(ret) } @@ -156,7 +150,6 @@ func NewQTreeWidgetItem10(typeVal int) *QTreeWidgetItem { // NewQTreeWidgetItem11 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem11(strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -166,8 +159,7 @@ func NewQTreeWidgetItem11(strings []string, typeVal int) *QTreeWidgetItem { defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new11(strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -180,7 +172,6 @@ func NewQTreeWidgetItem12(treeview *QTreeWidget, typeVal int) *QTreeWidgetItem { // NewQTreeWidgetItem13 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem13(treeview *QTreeWidget, strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -190,8 +181,7 @@ func NewQTreeWidgetItem13(treeview *QTreeWidget, strings []string, typeVal int) defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new13(treeview.cPointer(), strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -210,7 +200,6 @@ func NewQTreeWidgetItem15(parent *QTreeWidgetItem, typeVal int) *QTreeWidgetItem // NewQTreeWidgetItem16 constructs a new QTreeWidgetItem object. func NewQTreeWidgetItem16(parent *QTreeWidgetItem, strings []string, typeVal int) *QTreeWidgetItem { - // For the C ABI, malloc a C array of structs strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings)))) defer C.free(unsafe.Pointer(strings_CArray)) for i := range strings { @@ -220,8 +209,7 @@ func NewQTreeWidgetItem16(parent *QTreeWidgetItem, strings []string, typeVal int defer C.free(unsafe.Pointer(strings_i_ms.data)) strings_CArray[i] = strings_i_ms } - strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(strings_ma)) + strings_ma := C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)} ret := C.QTreeWidgetItem_new16(parent.cPointer(), strings_ma, (C.int)(typeVal)) return newQTreeWidgetItem(ret) } @@ -499,37 +487,32 @@ func (this *QTreeWidgetItem) TakeChild(index int) *QTreeWidgetItem { } func (this *QTreeWidgetItem) AddChildren(children []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers children_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(children)))) defer C.free(unsafe.Pointer(children_CArray)) for i := range children { children_CArray[i] = children[i].cPointer() } - children_ma := &C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(children_ma)) + children_ma := C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} C.QTreeWidgetItem_AddChildren(this.h, children_ma) } func (this *QTreeWidgetItem) InsertChildren(index int, children []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers children_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(children)))) defer C.free(unsafe.Pointer(children_CArray)) for i := range children { children_CArray[i] = children[i].cPointer() } - children_ma := &C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(children_ma)) + children_ma := C.struct_miqt_array{len: C.size_t(len(children)), data: unsafe.Pointer(children_CArray)} C.QTreeWidgetItem_InsertChildren(this.h, (C.int)(index), children_ma) } func (this *QTreeWidgetItem) TakeChildren() []*QTreeWidgetItem { - var _ma *C.struct_miqt_array = C.QTreeWidgetItem_TakeChildren(this.h) + var _ma C.struct_miqt_array = C.QTreeWidgetItem_TakeChildren(this.h) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -653,26 +636,22 @@ func (this *QTreeWidget) IndexOfTopLevelItem(item *QTreeWidgetItem) int { } func (this *QTreeWidget) InsertTopLevelItems(index int, items []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QTreeWidget_InsertTopLevelItems(this.h, (C.int)(index), items_ma) } func (this *QTreeWidget) AddTopLevelItems(items []*QTreeWidgetItem) { - // For the C ABI, malloc a C array of raw pointers items_CArray := (*[0xffff]*C.QTreeWidgetItem)(C.malloc(C.size_t(8 * len(items)))) defer C.free(unsafe.Pointer(items_CArray)) for i := range items { items_CArray[i] = items[i].cPointer() } - items_ma := &C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(items_ma)) + items_ma := C.struct_miqt_array{len: C.size_t(len(items)), data: unsafe.Pointer(items_CArray)} C.QTreeWidget_AddTopLevelItems(this.h, items_ma) } @@ -685,7 +664,6 @@ func (this *QTreeWidget) SetHeaderItem(item *QTreeWidgetItem) { } func (this *QTreeWidget) SetHeaderLabels(labels []string) { - // For the C ABI, malloc a C array of structs labels_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(labels)))) defer C.free(unsafe.Pointer(labels_CArray)) for i := range labels { @@ -695,8 +673,7 @@ func (this *QTreeWidget) SetHeaderLabels(labels []string) { defer C.free(unsafe.Pointer(labels_i_ms.data)) labels_CArray[i] = labels_i_ms } - labels_ma := &C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(labels_ma)) + labels_ma := C.struct_miqt_array{len: C.size_t(len(labels)), data: unsafe.Pointer(labels_CArray)} C.QTreeWidget_SetHeaderLabels(this.h, labels_ma) } @@ -780,13 +757,12 @@ func (this *QTreeWidget) RemoveItemWidget(item *QTreeWidgetItem, column int) { } func (this *QTreeWidget) SelectedItems() []*QTreeWidgetItem { - var _ma *C.struct_miqt_array = C.QTreeWidget_SelectedItems(this.h) + var _ma C.struct_miqt_array = C.QTreeWidget_SelectedItems(this.h) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -795,13 +771,12 @@ func (this *QTreeWidget) FindItems(text string, flags MatchFlag) []*QTreeWidgetI text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTreeWidget_FindItems(this.h, text_ms, (C.int)(flags)) + var _ma C.struct_miqt_array = C.QTreeWidget_FindItems(this.h, text_ms, (C.int)(flags)) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -1091,13 +1066,12 @@ func (this *QTreeWidget) FindItems3(text string, flags MatchFlag, column int) [] text_ms.data = C.CString(text) text_ms.len = C.size_t(len(text)) defer C.free(unsafe.Pointer(text_ms.data)) - var _ma *C.struct_miqt_array = C.QTreeWidget_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) + var _ma C.struct_miqt_array = C.QTreeWidget_FindItems3(this.h, text_ms, (C.int)(flags), (C.int)(column)) _ret := make([]*QTreeWidgetItem, int(_ma.len)) _outCast := (*[0xffff]*C.QTreeWidgetItem)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQTreeWidgetItem(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qtreewidget.h b/qt6/gen_qtreewidget.h index 20ef4dc1..3dbe73ef 100644 --- a/qt6/gen_qtreewidget.h +++ b/qt6/gen_qtreewidget.h @@ -46,21 +46,21 @@ typedef struct QWidget QWidget; #endif QTreeWidgetItem* QTreeWidgetItem_new(); -QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new2(struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new3(QTreeWidget* treeview); -QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new4(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new5(QTreeWidget* treeview, QTreeWidgetItem* after); QTreeWidgetItem* QTreeWidgetItem_new6(QTreeWidgetItem* parent); -QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings); +QTreeWidgetItem* QTreeWidgetItem_new7(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings); QTreeWidgetItem* QTreeWidgetItem_new8(QTreeWidgetItem* parent, QTreeWidgetItem* after); QTreeWidgetItem* QTreeWidgetItem_new9(QTreeWidgetItem* other); QTreeWidgetItem* QTreeWidgetItem_new10(int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new11(struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new12(QTreeWidget* treeview, int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new13(QTreeWidget* treeview, struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new14(QTreeWidget* treeview, QTreeWidgetItem* after, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new15(QTreeWidgetItem* parent, int typeVal); -QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array* /* of struct miqt_string */ strings, int typeVal); +QTreeWidgetItem* QTreeWidgetItem_new16(QTreeWidgetItem* parent, struct miqt_array /* of struct miqt_string */ strings, int typeVal); QTreeWidgetItem* QTreeWidgetItem_new17(QTreeWidgetItem* parent, QTreeWidgetItem* after, int typeVal); QTreeWidgetItem* QTreeWidgetItem_Clone(const QTreeWidgetItem* self); QTreeWidget* QTreeWidgetItem_TreeWidget(const QTreeWidgetItem* self); @@ -117,9 +117,9 @@ void QTreeWidgetItem_AddChild(QTreeWidgetItem* self, QTreeWidgetItem* child); void QTreeWidgetItem_InsertChild(QTreeWidgetItem* self, int index, QTreeWidgetItem* child); void QTreeWidgetItem_RemoveChild(QTreeWidgetItem* self, QTreeWidgetItem* child); QTreeWidgetItem* QTreeWidgetItem_TakeChild(QTreeWidgetItem* self, int index); -void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array* /* of QTreeWidgetItem* */ children); -void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ children); -struct miqt_array* QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self); +void QTreeWidgetItem_AddChildren(QTreeWidgetItem* self, struct miqt_array /* of QTreeWidgetItem* */ children); +void QTreeWidgetItem_InsertChildren(QTreeWidgetItem* self, int index, struct miqt_array /* of QTreeWidgetItem* */ children); +struct miqt_array QTreeWidgetItem_TakeChildren(QTreeWidgetItem* self); int QTreeWidgetItem_Type(const QTreeWidgetItem* self); void QTreeWidgetItem_SortChildren(QTreeWidgetItem* self, int column, int order); void QTreeWidgetItem_Delete(QTreeWidgetItem* self); @@ -138,11 +138,11 @@ void QTreeWidget_InsertTopLevelItem(QTreeWidget* self, int index, QTreeWidgetIte void QTreeWidget_AddTopLevelItem(QTreeWidget* self, QTreeWidgetItem* item); QTreeWidgetItem* QTreeWidget_TakeTopLevelItem(QTreeWidget* self, int index); int QTreeWidget_IndexOfTopLevelItem(const QTreeWidget* self, QTreeWidgetItem* item); -void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array* /* of QTreeWidgetItem* */ items); -void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array* /* of QTreeWidgetItem* */ items); +void QTreeWidget_InsertTopLevelItems(QTreeWidget* self, int index, struct miqt_array /* of QTreeWidgetItem* */ items); +void QTreeWidget_AddTopLevelItems(QTreeWidget* self, struct miqt_array /* of QTreeWidgetItem* */ items); QTreeWidgetItem* QTreeWidget_HeaderItem(const QTreeWidget* self); void QTreeWidget_SetHeaderItem(QTreeWidget* self, QTreeWidgetItem* item); -void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array* /* of struct miqt_string */ labels); +void QTreeWidget_SetHeaderLabels(QTreeWidget* self, struct miqt_array /* of struct miqt_string */ labels); void QTreeWidget_SetHeaderLabel(QTreeWidget* self, struct miqt_string label); QTreeWidgetItem* QTreeWidget_CurrentItem(const QTreeWidget* self); int QTreeWidget_CurrentColumn(const QTreeWidget* self); @@ -161,8 +161,8 @@ bool QTreeWidget_IsPersistentEditorOpen(const QTreeWidget* self, QTreeWidgetItem QWidget* QTreeWidget_ItemWidget(const QTreeWidget* self, QTreeWidgetItem* item, int column); void QTreeWidget_SetItemWidget(QTreeWidget* self, QTreeWidgetItem* item, int column, QWidget* widget); void QTreeWidget_RemoveItemWidget(QTreeWidget* self, QTreeWidgetItem* item, int column); -struct miqt_array* QTreeWidget_SelectedItems(const QTreeWidget* self); -struct miqt_array* QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags); +struct miqt_array QTreeWidget_SelectedItems(const QTreeWidget* self); +struct miqt_array QTreeWidget_FindItems(const QTreeWidget* self, struct miqt_string text, int flags); QTreeWidgetItem* QTreeWidget_ItemAbove(const QTreeWidget* self, QTreeWidgetItem* item); QTreeWidgetItem* QTreeWidget_ItemBelow(const QTreeWidget* self, QTreeWidgetItem* item); QModelIndex* QTreeWidget_IndexFromItem(const QTreeWidget* self, QTreeWidgetItem* item); @@ -198,7 +198,7 @@ void QTreeWidget_EditItem2(QTreeWidget* self, QTreeWidgetItem* item, int column) void QTreeWidget_OpenPersistentEditor2(QTreeWidget* self, QTreeWidgetItem* item, int column); void QTreeWidget_ClosePersistentEditor2(QTreeWidget* self, QTreeWidgetItem* item, int column); bool QTreeWidget_IsPersistentEditorOpen2(const QTreeWidget* self, QTreeWidgetItem* item, int column); -struct miqt_array* QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column); +struct miqt_array QTreeWidget_FindItems3(const QTreeWidget* self, struct miqt_string text, int flags, int column); QModelIndex* QTreeWidget_IndexFromItem2(const QTreeWidget* self, QTreeWidgetItem* item, int column); void QTreeWidget_ScrollToItem2(QTreeWidget* self, QTreeWidgetItem* item, int hint); void QTreeWidget_Delete(QTreeWidget* self); diff --git a/qt6/gen_qundogroup.cpp b/qt6/gen_qundogroup.cpp index 4c996f40..8b36a496 100644 --- a/qt6/gen_qundogroup.cpp +++ b/qt6/gen_qundogroup.cpp @@ -46,16 +46,16 @@ void QUndoGroup_RemoveStack(QUndoGroup* self, QUndoStack* stack) { self->removeStack(stack); } -struct miqt_array* QUndoGroup_Stacks(const QUndoGroup* self) { +struct miqt_array QUndoGroup_Stacks(const QUndoGroup* self) { QList _ret = self->stacks(); // Convert QList<> from C++ memory to manually-managed C memory QUndoStack** _arr = static_cast(malloc(sizeof(QUndoStack*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qundogroup.go b/qt6/gen_qundogroup.go index 35b61c2a..6e4ba67b 100644 --- a/qt6/gen_qundogroup.go +++ b/qt6/gen_qundogroup.go @@ -84,13 +84,12 @@ func (this *QUndoGroup) RemoveStack(stack *QUndoStack) { } func (this *QUndoGroup) Stacks() []*QUndoStack { - var _ma *C.struct_miqt_array = C.QUndoGroup_Stacks(this.h) + var _ma C.struct_miqt_array = C.QUndoGroup_Stacks(this.h) _ret := make([]*QUndoStack, int(_ma.len)) _outCast := (*[0xffff]*C.QUndoStack)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQUndoStack(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qundogroup.h b/qt6/gen_qundogroup.h index f5c2834b..f045923b 100644 --- a/qt6/gen_qundogroup.h +++ b/qt6/gen_qundogroup.h @@ -34,7 +34,7 @@ void* QUndoGroup_Metacast(QUndoGroup* self, const char* param1); struct miqt_string QUndoGroup_Tr(const char* s); void QUndoGroup_AddStack(QUndoGroup* self, QUndoStack* stack); void QUndoGroup_RemoveStack(QUndoGroup* self, QUndoStack* stack); -struct miqt_array* QUndoGroup_Stacks(const QUndoGroup* self); +struct miqt_array QUndoGroup_Stacks(const QUndoGroup* self); QUndoStack* QUndoGroup_ActiveStack(const QUndoGroup* self); QAction* QUndoGroup_CreateUndoAction(const QUndoGroup* self, QObject* parent); QAction* QUndoGroup_CreateRedoAction(const QUndoGroup* self, QObject* parent); diff --git a/qt6/gen_qurl.cpp b/qt6/gen_qurl.cpp index bbfec8bf..8fd61d3b 100644 --- a/qt6/gen_qurl.cpp +++ b/qt6/gen_qurl.cpp @@ -391,7 +391,7 @@ struct miqt_string QUrl_ToAce(struct miqt_string domain) { return _ms; } -struct miqt_array* QUrl_IdnWhitelist() { +struct miqt_array QUrl_IdnWhitelist() { QStringList _ret = QUrl::idnWhitelist(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -405,17 +405,17 @@ struct miqt_array* QUrl_IdnWhitelist() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris) { +struct miqt_array QUrl_ToStringList(struct miqt_array /* of QUrl* */ uris) { QList uris_QList; - uris_QList.reserve(uris->len); - QUrl** uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + QUrl** uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { uris_QList.push_back(*(uris_arr[i])); } QStringList _ret = QUrl::toStringList(uris_QList); @@ -431,17 +431,17 @@ struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_string */ uris) { +struct miqt_array QUrl_FromStringList(struct miqt_array /* of struct miqt_string */ uris) { QStringList uris_QList; - uris_QList.reserve(uris->len); - struct miqt_string* uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + struct miqt_string* uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { QString uris_arr_i_QString = QString::fromUtf8(uris_arr[i].data, uris_arr[i].len); uris_QList.push_back(uris_arr_i_QString); } @@ -451,17 +451,17 @@ struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_stri for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -void QUrl_SetIdnWhitelist(struct miqt_array* /* of struct miqt_string */ idnWhitelist) { +void QUrl_SetIdnWhitelist(struct miqt_array /* of struct miqt_string */ idnWhitelist) { QStringList idnWhitelist_QList; - idnWhitelist_QList.reserve(idnWhitelist->len); - struct miqt_string* idnWhitelist_arr = static_cast(idnWhitelist->data); - for(size_t i = 0; i < idnWhitelist->len; ++i) { + idnWhitelist_QList.reserve(idnWhitelist.len); + struct miqt_string* idnWhitelist_arr = static_cast(idnWhitelist.data); + for(size_t i = 0; i < idnWhitelist.len; ++i) { QString idnWhitelist_arr_i_QString = QString::fromUtf8(idnWhitelist_arr[i].data, idnWhitelist_arr[i].len); idnWhitelist_QList.push_back(idnWhitelist_arr_i_QString); } @@ -678,11 +678,11 @@ struct miqt_string QUrl_ToAce2(struct miqt_string domain, unsigned int options) return _ms; } -struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_string */ uris, int mode) { +struct miqt_array QUrl_FromStringList2(struct miqt_array /* of struct miqt_string */ uris, int mode) { QStringList uris_QList; - uris_QList.reserve(uris->len); - struct miqt_string* uris_arr = static_cast(uris->data); - for(size_t i = 0; i < uris->len; ++i) { + uris_QList.reserve(uris.len); + struct miqt_string* uris_arr = static_cast(uris.data); + for(size_t i = 0; i < uris.len; ++i) { QString uris_arr_i_QString = QString::fromUtf8(uris_arr[i].data, uris_arr[i].len); uris_QList.push_back(uris_arr_i_QString); } @@ -692,9 +692,9 @@ struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_str for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QUrl(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qurl.go b/qt6/gen_qurl.go index 65e9c945..178215e6 100644 --- a/qt6/gen_qurl.go +++ b/qt6/gen_qurl.go @@ -481,7 +481,7 @@ func QUrl_ToAce(domain string) []byte { } func QUrl_IdnWhitelist() []string { - var _ma *C.struct_miqt_array = C.QUrl_IdnWhitelist() + var _ma C.struct_miqt_array = C.QUrl_IdnWhitelist() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -490,20 +490,17 @@ func QUrl_IdnWhitelist() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_ToStringList(uris []QUrl) []string { - // For the C ABI, malloc a C array of raw pointers uris_CArray := (*[0xffff]*C.QUrl)(C.malloc(C.size_t(8 * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { uris_CArray[i] = uris[i].cPointer() } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_ToStringList(uris_ma) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_ToStringList(uris_ma) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -512,12 +509,10 @@ func QUrl_ToStringList(uris []QUrl) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_FromStringList(uris []string) []QUrl { - // For the C ABI, malloc a C array of structs uris_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { @@ -527,9 +522,8 @@ func QUrl_FromStringList(uris []string) []QUrl { defer C.free(unsafe.Pointer(uris_i_ms.data)) uris_CArray[i] = uris_i_ms } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_FromStringList(uris_ma) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_FromStringList(uris_ma) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -538,12 +532,10 @@ func QUrl_FromStringList(uris []string) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func QUrl_SetIdnWhitelist(idnWhitelist []string) { - // For the C ABI, malloc a C array of structs idnWhitelist_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(idnWhitelist)))) defer C.free(unsafe.Pointer(idnWhitelist_CArray)) for i := range idnWhitelist { @@ -553,8 +545,7 @@ func QUrl_SetIdnWhitelist(idnWhitelist []string) { defer C.free(unsafe.Pointer(idnWhitelist_i_ms.data)) idnWhitelist_CArray[i] = idnWhitelist_i_ms } - idnWhitelist_ma := &C.struct_miqt_array{len: C.size_t(len(idnWhitelist)), data: unsafe.Pointer(idnWhitelist_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(idnWhitelist_ma)) + idnWhitelist_ma := C.struct_miqt_array{len: C.size_t(len(idnWhitelist)), data: unsafe.Pointer(idnWhitelist_CArray)} C.QUrl_SetIdnWhitelist(idnWhitelist_ma) } @@ -790,7 +781,6 @@ func QUrl_ToAce2(domain string, options QUrl__AceProcessingOption) []byte { } func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { - // For the C ABI, malloc a C array of structs uris_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(uris)))) defer C.free(unsafe.Pointer(uris_CArray)) for i := range uris { @@ -800,9 +790,8 @@ func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { defer C.free(unsafe.Pointer(uris_i_ms.data)) uris_CArray[i] = uris_i_ms } - uris_ma := &C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(uris_ma)) - var _ma *C.struct_miqt_array = C.QUrl_FromStringList2(uris_ma, (C.int)(mode)) + uris_ma := C.struct_miqt_array{len: C.size_t(len(uris)), data: unsafe.Pointer(uris_CArray)} + var _ma C.struct_miqt_array = C.QUrl_FromStringList2(uris_ma, (C.int)(mode)) _ret := make([]QUrl, int(_ma.len)) _outCast := (*[0xffff]*C.QUrl)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -811,7 +800,6 @@ func QUrl_FromStringList2(uris []string, mode QUrl__ParsingMode) []QUrl { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qurl.h b/qt6/gen_qurl.h index b28754e4..b23d2425 100644 --- a/qt6/gen_qurl.h +++ b/qt6/gen_qurl.h @@ -80,10 +80,10 @@ struct miqt_string QUrl_FromPercentEncoding(struct miqt_string param1); struct miqt_string QUrl_ToPercentEncoding(struct miqt_string param1); struct miqt_string QUrl_FromAce(struct miqt_string domain); struct miqt_string QUrl_ToAce(struct miqt_string domain); -struct miqt_array* QUrl_IdnWhitelist(); -struct miqt_array* QUrl_ToStringList(struct miqt_array* /* of QUrl* */ uris); -struct miqt_array* QUrl_FromStringList(struct miqt_array* /* of struct miqt_string */ uris); -void QUrl_SetIdnWhitelist(struct miqt_array* /* of struct miqt_string */ idnWhitelist); +struct miqt_array QUrl_IdnWhitelist(); +struct miqt_array QUrl_ToStringList(struct miqt_array /* of QUrl* */ uris); +struct miqt_array QUrl_FromStringList(struct miqt_array /* of struct miqt_string */ uris); +void QUrl_SetIdnWhitelist(struct miqt_array /* of struct miqt_string */ idnWhitelist); void QUrl_SetUrl2(QUrl* self, struct miqt_string url, int mode); QUrl* QUrl_FromEncoded2(struct miqt_string url, int mode); QUrl* QUrl_FromUserInput2(struct miqt_string userInput, struct miqt_string workingDirectory); @@ -110,7 +110,7 @@ struct miqt_string QUrl_ToPercentEncoding2(struct miqt_string param1, struct miq struct miqt_string QUrl_ToPercentEncoding3(struct miqt_string param1, struct miqt_string exclude, struct miqt_string include); struct miqt_string QUrl_FromAce2(struct miqt_string domain, unsigned int options); struct miqt_string QUrl_ToAce2(struct miqt_string domain, unsigned int options); -struct miqt_array* QUrl_FromStringList2(struct miqt_array* /* of struct miqt_string */ uris, int mode); +struct miqt_array QUrl_FromStringList2(struct miqt_array /* of struct miqt_string */ uris, int mode); void QUrl_Delete(QUrl* self); #ifdef __cplusplus diff --git a/qt6/gen_qurlquery.cpp b/qt6/gen_qurlquery.cpp index 0c870159..83ad6517 100644 --- a/qt6/gen_qurlquery.cpp +++ b/qt6/gen_qurlquery.cpp @@ -121,7 +121,7 @@ struct miqt_string QUrlQuery_QueryItemValue(const QUrlQuery* self, struct miqt_s return _ms; } -struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key) { +struct miqt_array QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key) { QString key_QString = QString::fromUtf8(key.data, key.len); QStringList _ret = self->allQueryItemValues(key_QString); // Convert QList<> from C++ memory to manually-managed C memory @@ -136,9 +136,9 @@ struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct mi memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -181,7 +181,7 @@ struct miqt_string QUrlQuery_QueryItemValue2(const QUrlQuery* self, struct miqt_ return _ms; } -struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, unsigned int encoding) { +struct miqt_array QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, unsigned int encoding) { QString key_QString = QString::fromUtf8(key.data, key.len); QStringList _ret = self->allQueryItemValues(key_QString, static_cast(encoding)); // Convert QList<> from C++ memory to manually-managed C memory @@ -196,9 +196,9 @@ struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct m memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qurlquery.go b/qt6/gen_qurlquery.go index d5c695ec..41d86fe0 100644 --- a/qt6/gen_qurlquery.go +++ b/qt6/gen_qurlquery.go @@ -182,7 +182,7 @@ func (this *QUrlQuery) AllQueryItemValues(key string) []string { key_ms.data = C.CString(key) key_ms.len = C.size_t(len(key)) defer C.free(unsafe.Pointer(key_ms.data)) - var _ma *C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues(this.h, key_ms) + var _ma C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues(this.h, key_ms) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -191,7 +191,6 @@ func (this *QUrlQuery) AllQueryItemValues(key string) []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -233,7 +232,7 @@ func (this *QUrlQuery) AllQueryItemValues2(key string, encoding QUrl__ComponentF key_ms.data = C.CString(key) key_ms.len = C.size_t(len(key)) defer C.free(unsafe.Pointer(key_ms.data)) - var _ma *C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues2(this.h, key_ms, (C.uint)(encoding)) + var _ma C.struct_miqt_array = C.QUrlQuery_AllQueryItemValues2(this.h, key_ms, (C.uint)(encoding)) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -242,7 +241,6 @@ func (this *QUrlQuery) AllQueryItemValues2(key string, encoding QUrl__ComponentF C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qurlquery.h b/qt6/gen_qurlquery.h index 88eeb13f..0ee94330 100644 --- a/qt6/gen_qurlquery.h +++ b/qt6/gen_qurlquery.h @@ -44,12 +44,12 @@ bool QUrlQuery_HasQueryItem(const QUrlQuery* self, struct miqt_string key); void QUrlQuery_AddQueryItem(QUrlQuery* self, struct miqt_string key, struct miqt_string value); void QUrlQuery_RemoveQueryItem(QUrlQuery* self, struct miqt_string key); struct miqt_string QUrlQuery_QueryItemValue(const QUrlQuery* self, struct miqt_string key); -struct miqt_array* QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key); +struct miqt_array QUrlQuery_AllQueryItemValues(const QUrlQuery* self, struct miqt_string key); void QUrlQuery_RemoveAllQueryItems(QUrlQuery* self, struct miqt_string key); struct miqt_string QUrlQuery_Query1(const QUrlQuery* self, unsigned int encoding); struct miqt_string QUrlQuery_ToString1(const QUrlQuery* self, unsigned int encoding); struct miqt_string QUrlQuery_QueryItemValue2(const QUrlQuery* self, struct miqt_string key, unsigned int encoding); -struct miqt_array* QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, unsigned int encoding); +struct miqt_array QUrlQuery_AllQueryItemValues2(const QUrlQuery* self, struct miqt_string key, unsigned int encoding); void QUrlQuery_Delete(QUrlQuery* self); #ifdef __cplusplus diff --git a/qt6/gen_qvariant.cpp b/qt6/gen_qvariant.cpp index 1ccfe3bf..22b77f85 100644 --- a/qt6/gen_qvariant.cpp +++ b/qt6/gen_qvariant.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -95,11 +96,11 @@ QVariant* QVariant_new14(struct miqt_string stringVal) { return new QVariant(stringVal_QString); } -QVariant* QVariant_new15(struct miqt_array* /* of struct miqt_string */ stringlist) { +QVariant* QVariant_new15(struct miqt_array /* of struct miqt_string */ stringlist) { QStringList stringlist_QList; - stringlist_QList.reserve(stringlist->len); - struct miqt_string* stringlist_arr = static_cast(stringlist->data); - for(size_t i = 0; i < stringlist->len; ++i) { + stringlist_QList.reserve(stringlist.len); + struct miqt_string* stringlist_arr = static_cast(stringlist.data); + for(size_t i = 0; i < stringlist.len; ++i) { QString stringlist_arr_i_QString = QString::fromUtf8(stringlist_arr[i].data, stringlist_arr[i].len); stringlist_QList.push_back(stringlist_arr_i_QString); } @@ -122,87 +123,110 @@ QVariant* QVariant_new19(QDateTime* datetime) { return new QVariant(*datetime); } -QVariant* QVariant_new20(QSize* size) { +QVariant* QVariant_new20(struct miqt_map mapVal) { + QMap mapVal_QMap; + struct miqt_string* mapVal_karr = static_cast(mapVal.keys); + QVariant** mapVal_varr = static_cast(mapVal.values); + for(size_t i = 0; i < mapVal.len; ++i) { + QString mapVal_karr_i_QString = QString::fromUtf8(mapVal_karr[i].data, mapVal_karr[i].len); + mapVal_QMap[mapVal_karr_i_QString] = *(mapVal_varr[i]); + } + return new QVariant(mapVal_QMap); +} + +QVariant* QVariant_new21(struct miqt_map hash) { + QHash hash_QMap; + hash_QMap.reserve(hash.len); + struct miqt_string* hash_karr = static_cast(hash.keys); + QVariant** hash_varr = static_cast(hash.values); + for(size_t i = 0; i < hash.len; ++i) { + QString hash_karr_i_QString = QString::fromUtf8(hash_karr[i].data, hash_karr[i].len); + hash_QMap[hash_karr_i_QString] = *(hash_varr[i]); + } + return new QVariant(hash_QMap); +} + +QVariant* QVariant_new22(QSize* size) { return new QVariant(*size); } -QVariant* QVariant_new21(QSizeF* size) { +QVariant* QVariant_new23(QSizeF* size) { return new QVariant(*size); } -QVariant* QVariant_new22(QPoint* pt) { +QVariant* QVariant_new24(QPoint* pt) { return new QVariant(*pt); } -QVariant* QVariant_new23(QPointF* pt) { +QVariant* QVariant_new25(QPointF* pt) { return new QVariant(*pt); } -QVariant* QVariant_new24(QLine* line) { +QVariant* QVariant_new26(QLine* line) { return new QVariant(*line); } -QVariant* QVariant_new25(QLineF* line) { +QVariant* QVariant_new27(QLineF* line) { return new QVariant(*line); } -QVariant* QVariant_new26(QRect* rect) { +QVariant* QVariant_new28(QRect* rect) { return new QVariant(*rect); } -QVariant* QVariant_new27(QRectF* rect) { +QVariant* QVariant_new29(QRectF* rect) { return new QVariant(*rect); } -QVariant* QVariant_new28(QLocale* locale) { +QVariant* QVariant_new30(QLocale* locale) { return new QVariant(*locale); } -QVariant* QVariant_new29(QRegularExpression* re) { +QVariant* QVariant_new31(QRegularExpression* re) { return new QVariant(*re); } -QVariant* QVariant_new30(QEasingCurve* easing) { +QVariant* QVariant_new32(QEasingCurve* easing) { return new QVariant(*easing); } -QVariant* QVariant_new31(QUuid* uuid) { +QVariant* QVariant_new33(QUuid* uuid) { return new QVariant(*uuid); } -QVariant* QVariant_new32(QUrl* url) { +QVariant* QVariant_new34(QUrl* url) { return new QVariant(*url); } -QVariant* QVariant_new33(QJsonValue* jsonValue) { +QVariant* QVariant_new35(QJsonValue* jsonValue) { return new QVariant(*jsonValue); } -QVariant* QVariant_new34(QJsonObject* jsonObject) { +QVariant* QVariant_new36(QJsonObject* jsonObject) { return new QVariant(*jsonObject); } -QVariant* QVariant_new35(QJsonArray* jsonArray) { +QVariant* QVariant_new37(QJsonArray* jsonArray) { return new QVariant(*jsonArray); } -QVariant* QVariant_new36(QJsonDocument* jsonDocument) { +QVariant* QVariant_new38(QJsonDocument* jsonDocument) { return new QVariant(*jsonDocument); } -QVariant* QVariant_new37(QModelIndex* modelIndex) { +QVariant* QVariant_new39(QModelIndex* modelIndex) { return new QVariant(*modelIndex); } -QVariant* QVariant_new38(QPersistentModelIndex* modelIndex) { +QVariant* QVariant_new40(QPersistentModelIndex* modelIndex) { return new QVariant(*modelIndex); } -QVariant* QVariant_new39(int typeVal) { +QVariant* QVariant_new41(int typeVal) { return new QVariant(static_cast(typeVal)); } -QVariant* QVariant_new40(QMetaType* typeVal, const void* copyVal) { +QVariant* QVariant_new42(QMetaType* typeVal, const void* copyVal) { return new QVariant(*typeVal, copyVal); } @@ -330,7 +354,7 @@ struct miqt_string QVariant_ToString(const QVariant* self) { return _ms; } -struct miqt_array* QVariant_ToStringList(const QVariant* self) { +struct miqt_array QVariant_ToStringList(const QVariant* self) { QStringList _ret = self->toStringList(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -344,9 +368,9 @@ struct miqt_array* QVariant_ToStringList(const QVariant* self) { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -366,6 +390,56 @@ QDateTime* QVariant_ToDateTime(const QVariant* self) { return new QDateTime(self->toDateTime()); } +struct miqt_map QVariant_ToMap(const QVariant* self) { + QMap _ret = self->toMap(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _mapkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _mapkey_b = _mapkey_ret.toUtf8(); + struct miqt_string _mapkey_ms; + _mapkey_ms.len = _mapkey_b.length(); + _mapkey_ms.data = static_cast(malloc(_mapkey_ms.len)); + memcpy(_mapkey_ms.data, _mapkey_b.data(), _mapkey_ms.len); + _karr[_ctr] = _mapkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + +struct miqt_map QVariant_ToHash(const QVariant* self) { + QHash _ret = self->toHash(); + // Convert QMap<> from C++ memory to manually-managed C memory + struct miqt_string* _karr = static_cast(malloc(sizeof(struct miqt_string) * _ret.size())); + QVariant** _varr = static_cast(malloc(sizeof(QVariant*) * _ret.size())); + int _ctr = 0; + for (auto _itr = _ret.keyValueBegin(); _itr != _ret.keyValueEnd(); ++_itr) { + QString _hashkey_ret = _itr->first; + // Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory + QByteArray _hashkey_b = _hashkey_ret.toUtf8(); + struct miqt_string _hashkey_ms; + _hashkey_ms.len = _hashkey_b.length(); + _hashkey_ms.data = static_cast(malloc(_hashkey_ms.len)); + memcpy(_hashkey_ms.data, _hashkey_b.data(), _hashkey_ms.len); + _karr[_ctr] = _hashkey_ms; + _varr[_ctr] = new QVariant(_itr->second); + _ctr++; + } + struct miqt_map _out; + _out.len = _ret.size(); + _out.keys = static_cast(_karr); + _out.values = static_cast(_varr); + return _out; +} + QPoint* QVariant_ToPoint(const QVariant* self) { return new QPoint(self->toPoint()); } diff --git a/qt6/gen_qvariant.go b/qt6/gen_qvariant.go index d498c60a..4383beb6 100644 --- a/qt6/gen_qvariant.go +++ b/qt6/gen_qvariant.go @@ -202,7 +202,6 @@ func NewQVariant14(stringVal string) *QVariant { // NewQVariant15 constructs a new QVariant object. func NewQVariant15(stringlist []string) *QVariant { - // For the C ABI, malloc a C array of structs stringlist_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(stringlist)))) defer C.free(unsafe.Pointer(stringlist_CArray)) for i := range stringlist { @@ -212,8 +211,7 @@ func NewQVariant15(stringlist []string) *QVariant { defer C.free(unsafe.Pointer(stringlist_i_ms.data)) stringlist_CArray[i] = stringlist_i_ms } - stringlist_ma := &C.struct_miqt_array{len: C.size_t(len(stringlist)), data: unsafe.Pointer(stringlist_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(stringlist_ma)) + stringlist_ma := C.struct_miqt_array{len: C.size_t(len(stringlist)), data: unsafe.Pointer(stringlist_CArray)} ret := C.QVariant_new15(stringlist_ma) return newQVariant(ret) } @@ -243,128 +241,178 @@ func NewQVariant19(datetime *QDateTime) *QVariant { } // NewQVariant20 constructs a new QVariant object. -func NewQVariant20(size *QSize) *QVariant { - ret := C.QVariant_new20(size.cPointer()) +func NewQVariant20(mapVal map[string]QVariant) *QVariant { + mapVal_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Keys_CArray)) + mapVal_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(mapVal)))) + defer C.free(unsafe.Pointer(mapVal_Values_CArray)) + mapVal_ctr := 0 + for mapVal_k, mapVal_v := range mapVal { + mapVal_k_ms := C.struct_miqt_string{} + mapVal_k_ms.data = C.CString(mapVal_k) + mapVal_k_ms.len = C.size_t(len(mapVal_k)) + defer C.free(unsafe.Pointer(mapVal_k_ms.data)) + mapVal_Keys_CArray[mapVal_ctr] = mapVal_k_ms + mapVal_Values_CArray[mapVal_ctr] = mapVal_v.cPointer() + mapVal_ctr++ + } + mapVal_mm := C.struct_miqt_map{ + len: C.size_t(len(mapVal)), + keys: unsafe.Pointer(mapVal_Keys_CArray), + values: unsafe.Pointer(mapVal_Values_CArray), + } + ret := C.QVariant_new20(mapVal_mm) return newQVariant(ret) } // NewQVariant21 constructs a new QVariant object. -func NewQVariant21(size *QSizeF) *QVariant { - ret := C.QVariant_new21(size.cPointer()) +func NewQVariant21(hash map[string]QVariant) *QVariant { + hash_Keys_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(hash)))) + defer C.free(unsafe.Pointer(hash_Keys_CArray)) + hash_Values_CArray := (*[0xffff]*C.QVariant)(C.malloc(C.size_t(8 * len(hash)))) + defer C.free(unsafe.Pointer(hash_Values_CArray)) + hash_ctr := 0 + for hash_k, hash_v := range hash { + hash_k_ms := C.struct_miqt_string{} + hash_k_ms.data = C.CString(hash_k) + hash_k_ms.len = C.size_t(len(hash_k)) + defer C.free(unsafe.Pointer(hash_k_ms.data)) + hash_Keys_CArray[hash_ctr] = hash_k_ms + hash_Values_CArray[hash_ctr] = hash_v.cPointer() + hash_ctr++ + } + hash_mm := C.struct_miqt_map{ + len: C.size_t(len(hash)), + keys: unsafe.Pointer(hash_Keys_CArray), + values: unsafe.Pointer(hash_Values_CArray), + } + ret := C.QVariant_new21(hash_mm) return newQVariant(ret) } // NewQVariant22 constructs a new QVariant object. -func NewQVariant22(pt *QPoint) *QVariant { - ret := C.QVariant_new22(pt.cPointer()) +func NewQVariant22(size *QSize) *QVariant { + ret := C.QVariant_new22(size.cPointer()) return newQVariant(ret) } // NewQVariant23 constructs a new QVariant object. -func NewQVariant23(pt *QPointF) *QVariant { - ret := C.QVariant_new23(pt.cPointer()) +func NewQVariant23(size *QSizeF) *QVariant { + ret := C.QVariant_new23(size.cPointer()) return newQVariant(ret) } // NewQVariant24 constructs a new QVariant object. -func NewQVariant24(line *QLine) *QVariant { - ret := C.QVariant_new24(line.cPointer()) +func NewQVariant24(pt *QPoint) *QVariant { + ret := C.QVariant_new24(pt.cPointer()) return newQVariant(ret) } // NewQVariant25 constructs a new QVariant object. -func NewQVariant25(line *QLineF) *QVariant { - ret := C.QVariant_new25(line.cPointer()) +func NewQVariant25(pt *QPointF) *QVariant { + ret := C.QVariant_new25(pt.cPointer()) return newQVariant(ret) } // NewQVariant26 constructs a new QVariant object. -func NewQVariant26(rect *QRect) *QVariant { - ret := C.QVariant_new26(rect.cPointer()) +func NewQVariant26(line *QLine) *QVariant { + ret := C.QVariant_new26(line.cPointer()) return newQVariant(ret) } // NewQVariant27 constructs a new QVariant object. -func NewQVariant27(rect *QRectF) *QVariant { - ret := C.QVariant_new27(rect.cPointer()) +func NewQVariant27(line *QLineF) *QVariant { + ret := C.QVariant_new27(line.cPointer()) return newQVariant(ret) } // NewQVariant28 constructs a new QVariant object. -func NewQVariant28(locale *QLocale) *QVariant { - ret := C.QVariant_new28(locale.cPointer()) +func NewQVariant28(rect *QRect) *QVariant { + ret := C.QVariant_new28(rect.cPointer()) return newQVariant(ret) } // NewQVariant29 constructs a new QVariant object. -func NewQVariant29(re *QRegularExpression) *QVariant { - ret := C.QVariant_new29(re.cPointer()) +func NewQVariant29(rect *QRectF) *QVariant { + ret := C.QVariant_new29(rect.cPointer()) return newQVariant(ret) } // NewQVariant30 constructs a new QVariant object. -func NewQVariant30(easing *QEasingCurve) *QVariant { - ret := C.QVariant_new30(easing.cPointer()) +func NewQVariant30(locale *QLocale) *QVariant { + ret := C.QVariant_new30(locale.cPointer()) return newQVariant(ret) } // NewQVariant31 constructs a new QVariant object. -func NewQVariant31(uuid *QUuid) *QVariant { - ret := C.QVariant_new31(uuid.cPointer()) +func NewQVariant31(re *QRegularExpression) *QVariant { + ret := C.QVariant_new31(re.cPointer()) return newQVariant(ret) } // NewQVariant32 constructs a new QVariant object. -func NewQVariant32(url *QUrl) *QVariant { - ret := C.QVariant_new32(url.cPointer()) +func NewQVariant32(easing *QEasingCurve) *QVariant { + ret := C.QVariant_new32(easing.cPointer()) return newQVariant(ret) } // NewQVariant33 constructs a new QVariant object. -func NewQVariant33(jsonValue *QJsonValue) *QVariant { - ret := C.QVariant_new33(jsonValue.cPointer()) +func NewQVariant33(uuid *QUuid) *QVariant { + ret := C.QVariant_new33(uuid.cPointer()) return newQVariant(ret) } // NewQVariant34 constructs a new QVariant object. -func NewQVariant34(jsonObject *QJsonObject) *QVariant { - ret := C.QVariant_new34(jsonObject.cPointer()) +func NewQVariant34(url *QUrl) *QVariant { + ret := C.QVariant_new34(url.cPointer()) return newQVariant(ret) } // NewQVariant35 constructs a new QVariant object. -func NewQVariant35(jsonArray *QJsonArray) *QVariant { - ret := C.QVariant_new35(jsonArray.cPointer()) +func NewQVariant35(jsonValue *QJsonValue) *QVariant { + ret := C.QVariant_new35(jsonValue.cPointer()) return newQVariant(ret) } // NewQVariant36 constructs a new QVariant object. -func NewQVariant36(jsonDocument *QJsonDocument) *QVariant { - ret := C.QVariant_new36(jsonDocument.cPointer()) +func NewQVariant36(jsonObject *QJsonObject) *QVariant { + ret := C.QVariant_new36(jsonObject.cPointer()) return newQVariant(ret) } // NewQVariant37 constructs a new QVariant object. -func NewQVariant37(modelIndex *QModelIndex) *QVariant { - ret := C.QVariant_new37(modelIndex.cPointer()) +func NewQVariant37(jsonArray *QJsonArray) *QVariant { + ret := C.QVariant_new37(jsonArray.cPointer()) return newQVariant(ret) } // NewQVariant38 constructs a new QVariant object. -func NewQVariant38(modelIndex *QPersistentModelIndex) *QVariant { - ret := C.QVariant_new38(modelIndex.cPointer()) +func NewQVariant38(jsonDocument *QJsonDocument) *QVariant { + ret := C.QVariant_new38(jsonDocument.cPointer()) return newQVariant(ret) } // NewQVariant39 constructs a new QVariant object. -func NewQVariant39(typeVal QVariant__Type) *QVariant { - ret := C.QVariant_new39((C.int)(typeVal)) +func NewQVariant39(modelIndex *QModelIndex) *QVariant { + ret := C.QVariant_new39(modelIndex.cPointer()) return newQVariant(ret) } // NewQVariant40 constructs a new QVariant object. -func NewQVariant40(typeVal QMetaType, copyVal unsafe.Pointer) *QVariant { - ret := C.QVariant_new40(typeVal.cPointer(), copyVal) +func NewQVariant40(modelIndex *QPersistentModelIndex) *QVariant { + ret := C.QVariant_new40(modelIndex.cPointer()) + return newQVariant(ret) +} + +// NewQVariant41 constructs a new QVariant object. +func NewQVariant41(typeVal QVariant__Type) *QVariant { + ret := C.QVariant_new41((C.int)(typeVal)) + return newQVariant(ret) +} + +// NewQVariant42 constructs a new QVariant object. +func NewQVariant42(typeVal QMetaType, copyVal unsafe.Pointer) *QVariant { + ret := C.QVariant_new42(typeVal.cPointer(), copyVal) return newQVariant(ret) } @@ -490,7 +538,7 @@ func (this *QVariant) ToString() string { } func (this *QVariant) ToStringList() []string { - var _ma *C.struct_miqt_array = C.QVariant_ToStringList(this.h) + var _ma C.struct_miqt_array = C.QVariant_ToStringList(this.h) _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -499,7 +547,6 @@ func (this *QVariant) ToStringList() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -531,6 +578,46 @@ func (this *QVariant) ToDateTime() *QDateTime { return _goptr } +func (this *QVariant) ToMap() map[string]QVariant { + var _mm C.struct_miqt_map = C.QVariant_ToMap(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _mapkey_ms C.struct_miqt_string = _Keys[i] + _mapkey_ret := C.GoStringN(_mapkey_ms.data, C.int(int64(_mapkey_ms.len))) + C.free(unsafe.Pointer(_mapkey_ms.data)) + _entry_Key := _mapkey_ret + _mapval_ret := _Values[i] + _mapval_goptr := newQVariant(_mapval_ret) + _mapval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_mapval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + +func (this *QVariant) ToHash() map[string]QVariant { + var _mm C.struct_miqt_map = C.QVariant_ToHash(this.h) + _ret := make(map[string]QVariant, int(_mm.len)) + _Keys := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_mm.keys)) + _Values := (*[0xffff]*C.QVariant)(unsafe.Pointer(_mm.values)) + for i := 0; i < int(_mm.len); i++ { + var _hashkey_ms C.struct_miqt_string = _Keys[i] + _hashkey_ret := C.GoStringN(_hashkey_ms.data, C.int(int64(_hashkey_ms.len))) + C.free(unsafe.Pointer(_hashkey_ms.data)) + _entry_Key := _hashkey_ret + _hashval_ret := _Values[i] + _hashval_goptr := newQVariant(_hashval_ret) + _hashval_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer + _entry_Value := *_hashval_goptr + + _ret[_entry_Key] = _entry_Value + } + return _ret +} + func (this *QVariant) ToPoint() *QPoint { _ret := C.QVariant_ToPoint(this.h) _goptr := newQPoint(_ret) diff --git a/qt6/gen_qvariant.h b/qt6/gen_qvariant.h index 0adfcf23..2d43b1fe 100644 --- a/qt6/gen_qvariant.h +++ b/qt6/gen_qvariant.h @@ -97,32 +97,34 @@ QVariant* QVariant_new11(const char* str); QVariant* QVariant_new12(struct miqt_string bytearray); QVariant* QVariant_new13(QBitArray* bitarray); QVariant* QVariant_new14(struct miqt_string stringVal); -QVariant* QVariant_new15(struct miqt_array* /* of struct miqt_string */ stringlist); +QVariant* QVariant_new15(struct miqt_array /* of struct miqt_string */ stringlist); QVariant* QVariant_new16(QChar* qchar); QVariant* QVariant_new17(QDate* date); QVariant* QVariant_new18(QTime* time); QVariant* QVariant_new19(QDateTime* datetime); -QVariant* QVariant_new20(QSize* size); -QVariant* QVariant_new21(QSizeF* size); -QVariant* QVariant_new22(QPoint* pt); -QVariant* QVariant_new23(QPointF* pt); -QVariant* QVariant_new24(QLine* line); -QVariant* QVariant_new25(QLineF* line); -QVariant* QVariant_new26(QRect* rect); -QVariant* QVariant_new27(QRectF* rect); -QVariant* QVariant_new28(QLocale* locale); -QVariant* QVariant_new29(QRegularExpression* re); -QVariant* QVariant_new30(QEasingCurve* easing); -QVariant* QVariant_new31(QUuid* uuid); -QVariant* QVariant_new32(QUrl* url); -QVariant* QVariant_new33(QJsonValue* jsonValue); -QVariant* QVariant_new34(QJsonObject* jsonObject); -QVariant* QVariant_new35(QJsonArray* jsonArray); -QVariant* QVariant_new36(QJsonDocument* jsonDocument); -QVariant* QVariant_new37(QModelIndex* modelIndex); -QVariant* QVariant_new38(QPersistentModelIndex* modelIndex); -QVariant* QVariant_new39(int typeVal); -QVariant* QVariant_new40(QMetaType* typeVal, const void* copyVal); +QVariant* QVariant_new20(struct miqt_map mapVal); +QVariant* QVariant_new21(struct miqt_map hash); +QVariant* QVariant_new22(QSize* size); +QVariant* QVariant_new23(QSizeF* size); +QVariant* QVariant_new24(QPoint* pt); +QVariant* QVariant_new25(QPointF* pt); +QVariant* QVariant_new26(QLine* line); +QVariant* QVariant_new27(QLineF* line); +QVariant* QVariant_new28(QRect* rect); +QVariant* QVariant_new29(QRectF* rect); +QVariant* QVariant_new30(QLocale* locale); +QVariant* QVariant_new31(QRegularExpression* re); +QVariant* QVariant_new32(QEasingCurve* easing); +QVariant* QVariant_new33(QUuid* uuid); +QVariant* QVariant_new34(QUrl* url); +QVariant* QVariant_new35(QJsonValue* jsonValue); +QVariant* QVariant_new36(QJsonObject* jsonObject); +QVariant* QVariant_new37(QJsonArray* jsonArray); +QVariant* QVariant_new38(QJsonDocument* jsonDocument); +QVariant* QVariant_new39(QModelIndex* modelIndex); +QVariant* QVariant_new40(QPersistentModelIndex* modelIndex); +QVariant* QVariant_new41(int typeVal); +QVariant* QVariant_new42(QMetaType* typeVal, const void* copyVal); void QVariant_OperatorAssign(QVariant* self, QVariant* other); void QVariant_Swap(QVariant* self, QVariant* other); int QVariant_UserType(const QVariant* self); @@ -150,11 +152,13 @@ double QVariant_ToReal(const QVariant* self); struct miqt_string QVariant_ToByteArray(const QVariant* self); QBitArray* QVariant_ToBitArray(const QVariant* self); struct miqt_string QVariant_ToString(const QVariant* self); -struct miqt_array* QVariant_ToStringList(const QVariant* self); +struct miqt_array QVariant_ToStringList(const QVariant* self); QChar* QVariant_ToChar(const QVariant* self); QDate* QVariant_ToDate(const QVariant* self); QTime* QVariant_ToTime(const QVariant* self); QDateTime* QVariant_ToDateTime(const QVariant* self); +struct miqt_map QVariant_ToMap(const QVariant* self); +struct miqt_map QVariant_ToHash(const QVariant* self); QPoint* QVariant_ToPoint(const QVariant* self); QPointF* QVariant_ToPointF(const QVariant* self); QRect* QVariant_ToRect(const QVariant* self); diff --git a/qt6/gen_qversionnumber.cpp b/qt6/gen_qversionnumber.cpp index 8a163b21..f2be1539 100644 --- a/qt6/gen_qversionnumber.cpp +++ b/qt6/gen_qversionnumber.cpp @@ -13,11 +13,11 @@ QVersionNumber* QVersionNumber_new() { return new QVersionNumber(); } -QVersionNumber* QVersionNumber_new2(struct miqt_array* /* of int */ seg) { +QVersionNumber* QVersionNumber_new2(struct miqt_array /* of int */ seg) { QList seg_QList; - seg_QList.reserve(seg->len); - int* seg_arr = static_cast(seg->data); - for(size_t i = 0; i < seg->len; ++i) { + seg_QList.reserve(seg.len); + int* seg_arr = static_cast(seg.data); + for(size_t i = 0; i < seg.len; ++i) { seg_QList.push_back(static_cast(seg_arr[i])); } return new QVersionNumber(seg_QList); @@ -63,16 +63,16 @@ QVersionNumber* QVersionNumber_Normalized(const QVersionNumber* self) { return new QVersionNumber(self->normalized()); } -struct miqt_array* QVersionNumber_Segments(const QVersionNumber* self) { +struct miqt_array QVersionNumber_Segments(const QVersionNumber* self) { QList _ret = self->segments(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qversionnumber.go b/qt6/gen_qversionnumber.go index 1ba2d1c1..ec21c77c 100644 --- a/qt6/gen_qversionnumber.go +++ b/qt6/gen_qversionnumber.go @@ -50,14 +50,12 @@ func NewQVersionNumber() *QVersionNumber { // NewQVersionNumber2 constructs a new QVersionNumber object. func NewQVersionNumber2(seg []int) *QVersionNumber { - // For the C ABI, malloc a C array of raw pointers seg_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(seg)))) defer C.free(unsafe.Pointer(seg_CArray)) for i := range seg { seg_CArray[i] = (C.int)(seg[i]) } - seg_ma := &C.struct_miqt_array{len: C.size_t(len(seg)), data: unsafe.Pointer(seg_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(seg_ma)) + seg_ma := C.struct_miqt_array{len: C.size_t(len(seg)), data: unsafe.Pointer(seg_CArray)} ret := C.QVersionNumber_new2(seg_ma) return newQVersionNumber(ret) } @@ -114,13 +112,12 @@ func (this *QVersionNumber) Normalized() *QVersionNumber { } func (this *QVersionNumber) Segments() []int { - var _ma *C.struct_miqt_array = C.QVersionNumber_Segments(this.h) + var _ma C.struct_miqt_array = C.QVersionNumber_Segments(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qversionnumber.h b/qt6/gen_qversionnumber.h index 01799332..6fa71b0c 100644 --- a/qt6/gen_qversionnumber.h +++ b/qt6/gen_qversionnumber.h @@ -24,7 +24,7 @@ typedef struct QVersionNumber QVersionNumber; #endif QVersionNumber* QVersionNumber_new(); -QVersionNumber* QVersionNumber_new2(struct miqt_array* /* of int */ seg); +QVersionNumber* QVersionNumber_new2(struct miqt_array /* of int */ seg); QVersionNumber* QVersionNumber_new3(int maj); QVersionNumber* QVersionNumber_new4(int maj, int min); QVersionNumber* QVersionNumber_new5(int maj, int min, int mic); @@ -35,7 +35,7 @@ int QVersionNumber_MajorVersion(const QVersionNumber* self); int QVersionNumber_MinorVersion(const QVersionNumber* self); int QVersionNumber_MicroVersion(const QVersionNumber* self); QVersionNumber* QVersionNumber_Normalized(const QVersionNumber* self); -struct miqt_array* QVersionNumber_Segments(const QVersionNumber* self); +struct miqt_array QVersionNumber_Segments(const QVersionNumber* self); int QVersionNumber_SegmentAt(const QVersionNumber* self, ptrdiff_t index); ptrdiff_t QVersionNumber_SegmentCount(const QVersionNumber* self); bool QVersionNumber_IsPrefixOf(const QVersionNumber* self, QVersionNumber* other); diff --git a/qt6/gen_qwidget.cpp b/qt6/gen_qwidget.cpp index 0c27de1d..644e8822 100644 --- a/qt6/gen_qwidget.cpp +++ b/qt6/gen_qwidget.cpp @@ -1077,21 +1077,21 @@ void QWidget_AddAction(QWidget* self, QAction* action) { self->addAction(action); } -void QWidget_AddActions(QWidget* self, struct miqt_array* /* of QAction* */ actions) { +void QWidget_AddActions(QWidget* self, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->addActions(actions_QList); } -void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions) { +void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions) { QList actions_QList; - actions_QList.reserve(actions->len); - QAction** actions_arr = static_cast(actions->data); - for(size_t i = 0; i < actions->len; ++i) { + actions_QList.reserve(actions.len); + QAction** actions_arr = static_cast(actions.data); + for(size_t i = 0; i < actions.len; ++i) { actions_QList.push_back(actions_arr[i]); } self->insertActions(before, actions_QList); @@ -1105,16 +1105,16 @@ void QWidget_RemoveAction(QWidget* self, QAction* action) { self->removeAction(action); } -struct miqt_array* QWidget_Actions(const QWidget* self) { +struct miqt_array QWidget_Actions(const QWidget* self) { QList _ret = self->actions(); // Convert QList<> from C++ memory to manually-managed C memory QAction** _arr = static_cast(malloc(sizeof(QAction*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qwidget.go b/qt6/gen_qwidget.go index ae4e60e0..aee42103 100644 --- a/qt6/gen_qwidget.go +++ b/qt6/gen_qwidget.go @@ -1223,26 +1223,22 @@ func (this *QWidget) AddAction(action *QAction) { } func (this *QWidget) AddActions(actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QWidget_AddActions(this.h, actions_ma) } func (this *QWidget) InsertActions(before *QAction, actions []*QAction) { - // For the C ABI, malloc a C array of raw pointers actions_CArray := (*[0xffff]*C.QAction)(C.malloc(C.size_t(8 * len(actions)))) defer C.free(unsafe.Pointer(actions_CArray)) for i := range actions { actions_CArray[i] = actions[i].cPointer() } - actions_ma := &C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(actions_ma)) + actions_ma := C.struct_miqt_array{len: C.size_t(len(actions)), data: unsafe.Pointer(actions_CArray)} C.QWidget_InsertActions(this.h, before.cPointer(), actions_ma) } @@ -1255,13 +1251,12 @@ func (this *QWidget) RemoveAction(action *QAction) { } func (this *QWidget) Actions() []*QAction { - var _ma *C.struct_miqt_array = C.QWidget_Actions(this.h) + var _ma C.struct_miqt_array = C.QWidget_Actions(this.h) _ret := make([]*QAction, int(_ma.len)) _outCast := (*[0xffff]*C.QAction)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = UnsafeNewQAction(unsafe.Pointer(_outCast[i])) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qwidget.h b/qt6/gen_qwidget.h index 52d454d7..e9d6f3bd 100644 --- a/qt6/gen_qwidget.h +++ b/qt6/gen_qwidget.h @@ -316,11 +316,11 @@ QWidget* QWidget_PreviousInFocusChain(const QWidget* self); bool QWidget_AcceptDrops(const QWidget* self); void QWidget_SetAcceptDrops(QWidget* self, bool on); void QWidget_AddAction(QWidget* self, QAction* action); -void QWidget_AddActions(QWidget* self, struct miqt_array* /* of QAction* */ actions); -void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array* /* of QAction* */ actions); +void QWidget_AddActions(QWidget* self, struct miqt_array /* of QAction* */ actions); +void QWidget_InsertActions(QWidget* self, QAction* before, struct miqt_array /* of QAction* */ actions); void QWidget_InsertAction(QWidget* self, QAction* before, QAction* action); void QWidget_RemoveAction(QWidget* self, QAction* action); -struct miqt_array* QWidget_Actions(const QWidget* self); +struct miqt_array QWidget_Actions(const QWidget* self); QAction* QWidget_AddActionWithText(QWidget* self, struct miqt_string text); QAction* QWidget_AddAction2(QWidget* self, QIcon* icon, struct miqt_string text); QAction* QWidget_AddAction3(QWidget* self, struct miqt_string text, QKeySequence* shortcut); diff --git a/qt6/gen_qwizard.cpp b/qt6/gen_qwizard.cpp index 50337bdb..a6202ebf 100644 --- a/qt6/gen_qwizard.cpp +++ b/qt6/gen_qwizard.cpp @@ -65,29 +65,29 @@ bool QWizard_HasVisitedPage(const QWizard* self, int id) { return self->hasVisitedPage(static_cast(id)); } -struct miqt_array* QWizard_VisitedIds(const QWizard* self) { +struct miqt_array QWizard_VisitedIds(const QWizard* self) { QList _ret = self->visitedIds(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QWizard_PageIds(const QWizard* self) { +struct miqt_array QWizard_PageIds(const QWizard* self) { QList _ret = self->pageIds(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -167,11 +167,11 @@ struct miqt_string QWizard_ButtonText(const QWizard* self, int which) { return _ms; } -void QWizard_SetButtonLayout(QWizard* self, struct miqt_array* /* of int */ layout) { +void QWizard_SetButtonLayout(QWizard* self, struct miqt_array /* of int */ layout) { QList layout_QList; - layout_QList.reserve(layout->len); - int* layout_arr = static_cast(layout->data); - for(size_t i = 0; i < layout->len; ++i) { + layout_QList.reserve(layout.len); + int* layout_arr = static_cast(layout.data); + for(size_t i = 0; i < layout.len; ++i) { layout_QList.push_back(static_cast(layout_arr[i])); } self->setButtonLayout(layout_QList); diff --git a/qt6/gen_qwizard.go b/qt6/gen_qwizard.go index 2587e78b..95df9e67 100644 --- a/qt6/gen_qwizard.go +++ b/qt6/gen_qwizard.go @@ -162,24 +162,22 @@ func (this *QWizard) HasVisitedPage(id int) bool { } func (this *QWizard) VisitedIds() []int { - var _ma *C.struct_miqt_array = C.QWizard_VisitedIds(this.h) + var _ma C.struct_miqt_array = C.QWizard_VisitedIds(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QWizard) PageIds() []int { - var _ma *C.struct_miqt_array = C.QWizard_PageIds(this.h) + var _ma C.struct_miqt_array = C.QWizard_PageIds(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -266,14 +264,12 @@ func (this *QWizard) ButtonText(which QWizard__WizardButton) string { } func (this *QWizard) SetButtonLayout(layout []QWizard__WizardButton) { - // For the C ABI, malloc a C array of raw pointers layout_CArray := (*[0xffff]C.int)(C.malloc(C.size_t(8 * len(layout)))) defer C.free(unsafe.Pointer(layout_CArray)) for i := range layout { layout_CArray[i] = (C.int)(layout[i]) } - layout_ma := &C.struct_miqt_array{len: C.size_t(len(layout)), data: unsafe.Pointer(layout_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(layout_ma)) + layout_ma := C.struct_miqt_array{len: C.size_t(len(layout)), data: unsafe.Pointer(layout_CArray)} C.QWizard_SetButtonLayout(this.h, layout_ma) } diff --git a/qt6/gen_qwizard.h b/qt6/gen_qwizard.h index ad57f4ac..7a294914 100644 --- a/qt6/gen_qwizard.h +++ b/qt6/gen_qwizard.h @@ -44,8 +44,8 @@ void QWizard_SetPage(QWizard* self, int id, QWizardPage* page); void QWizard_RemovePage(QWizard* self, int id); QWizardPage* QWizard_Page(const QWizard* self, int id); bool QWizard_HasVisitedPage(const QWizard* self, int id); -struct miqt_array* QWizard_VisitedIds(const QWizard* self); -struct miqt_array* QWizard_PageIds(const QWizard* self); +struct miqt_array QWizard_VisitedIds(const QWizard* self); +struct miqt_array QWizard_PageIds(const QWizard* self); void QWizard_SetStartId(QWizard* self, int id); int QWizard_StartId(const QWizard* self); QWizardPage* QWizard_CurrentPage(const QWizard* self); @@ -62,7 +62,7 @@ void QWizard_SetOptions(QWizard* self, int options); int QWizard_Options(const QWizard* self); void QWizard_SetButtonText(QWizard* self, int which, struct miqt_string text); struct miqt_string QWizard_ButtonText(const QWizard* self, int which); -void QWizard_SetButtonLayout(QWizard* self, struct miqt_array* /* of int */ layout); +void QWizard_SetButtonLayout(QWizard* self, struct miqt_array /* of int */ layout); void QWizard_SetButton(QWizard* self, int which, QAbstractButton* button); QAbstractButton* QWizard_Button(const QWizard* self, int which); void QWizard_SetTitleFormat(QWizard* self, int format); diff --git a/qt6/gen_qxmlstream.cpp b/qt6/gen_qxmlstream.cpp index 437fcff5..73f8e6c7 100644 --- a/qt6/gen_qxmlstream.cpp +++ b/qt6/gen_qxmlstream.cpp @@ -330,16 +330,16 @@ struct miqt_string QXmlStreamReader_ReadElementText(QXmlStreamReader* self) { return _ms; } -struct miqt_array* QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self) { QXmlStreamNamespaceDeclarations _ret = self->namespaceDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamNamespaceDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamNamespaceDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamNamespaceDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -347,39 +347,39 @@ void QXmlStreamReader_AddExtraNamespaceDeclaration(QXmlStreamReader* self, QXmlS self->addExtraNamespaceDeclaration(*extraNamespaceDeclaraction); } -void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array* /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions) { +void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions) { QXmlStreamNamespaceDeclarations extraNamespaceDeclaractions_QList; - extraNamespaceDeclaractions_QList.reserve(extraNamespaceDeclaractions->len); - QXmlStreamNamespaceDeclaration** extraNamespaceDeclaractions_arr = static_cast(extraNamespaceDeclaractions->data); - for(size_t i = 0; i < extraNamespaceDeclaractions->len; ++i) { + extraNamespaceDeclaractions_QList.reserve(extraNamespaceDeclaractions.len); + QXmlStreamNamespaceDeclaration** extraNamespaceDeclaractions_arr = static_cast(extraNamespaceDeclaractions.data); + for(size_t i = 0; i < extraNamespaceDeclaractions.len; ++i) { extraNamespaceDeclaractions_QList.push_back(*(extraNamespaceDeclaractions_arr[i])); } self->addExtraNamespaceDeclarations(extraNamespaceDeclaractions_QList); } -struct miqt_array* QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self) { QXmlStreamNotationDeclarations _ret = self->notationDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamNotationDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamNotationDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamNotationDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self) { +struct miqt_array QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self) { QXmlStreamEntityDeclarations _ret = self->entityDeclarations(); // Convert QList<> from C++ memory to manually-managed C memory QXmlStreamEntityDeclaration** _arr = static_cast(malloc(sizeof(QXmlStreamEntityDeclaration*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QXmlStreamEntityDeclaration(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/gen_qxmlstream.go b/qt6/gen_qxmlstream.go index 122ca4e8..11a8e2c8 100644 --- a/qt6/gen_qxmlstream.go +++ b/qt6/gen_qxmlstream.go @@ -683,7 +683,7 @@ func (this *QXmlStreamReader) ReadElementText() string { } func (this *QXmlStreamReader) NamespaceDeclarations() []QXmlStreamNamespaceDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_NamespaceDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_NamespaceDeclarations(this.h) _ret := make([]QXmlStreamNamespaceDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamNamespaceDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -692,7 +692,6 @@ func (this *QXmlStreamReader) NamespaceDeclarations() []QXmlStreamNamespaceDecla _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -701,19 +700,17 @@ func (this *QXmlStreamReader) AddExtraNamespaceDeclaration(extraNamespaceDeclara } func (this *QXmlStreamReader) AddExtraNamespaceDeclarations(extraNamespaceDeclaractions []QXmlStreamNamespaceDeclaration) { - // For the C ABI, malloc a C array of raw pointers extraNamespaceDeclaractions_CArray := (*[0xffff]*C.QXmlStreamNamespaceDeclaration)(C.malloc(C.size_t(8 * len(extraNamespaceDeclaractions)))) defer C.free(unsafe.Pointer(extraNamespaceDeclaractions_CArray)) for i := range extraNamespaceDeclaractions { extraNamespaceDeclaractions_CArray[i] = extraNamespaceDeclaractions[i].cPointer() } - extraNamespaceDeclaractions_ma := &C.struct_miqt_array{len: C.size_t(len(extraNamespaceDeclaractions)), data: unsafe.Pointer(extraNamespaceDeclaractions_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(extraNamespaceDeclaractions_ma)) + extraNamespaceDeclaractions_ma := C.struct_miqt_array{len: C.size_t(len(extraNamespaceDeclaractions)), data: unsafe.Pointer(extraNamespaceDeclaractions_CArray)} C.QXmlStreamReader_AddExtraNamespaceDeclarations(this.h, extraNamespaceDeclaractions_ma) } func (this *QXmlStreamReader) NotationDeclarations() []QXmlStreamNotationDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_NotationDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_NotationDeclarations(this.h) _ret := make([]QXmlStreamNotationDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamNotationDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -722,12 +719,11 @@ func (this *QXmlStreamReader) NotationDeclarations() []QXmlStreamNotationDeclara _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } func (this *QXmlStreamReader) EntityDeclarations() []QXmlStreamEntityDeclaration { - var _ma *C.struct_miqt_array = C.QXmlStreamReader_EntityDeclarations(this.h) + var _ma C.struct_miqt_array = C.QXmlStreamReader_EntityDeclarations(this.h) _ret := make([]QXmlStreamEntityDeclaration, int(_ma.len)) _outCast := (*[0xffff]*C.QXmlStreamEntityDeclaration)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -736,7 +732,6 @@ func (this *QXmlStreamReader) EntityDeclarations() []QXmlStreamEntityDeclaration _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/gen_qxmlstream.h b/qt6/gen_qxmlstream.h index 3b6178bc..9da82375 100644 --- a/qt6/gen_qxmlstream.h +++ b/qt6/gen_qxmlstream.h @@ -113,11 +113,11 @@ long long QXmlStreamReader_LineNumber(const QXmlStreamReader* self); long long QXmlStreamReader_ColumnNumber(const QXmlStreamReader* self); long long QXmlStreamReader_CharacterOffset(const QXmlStreamReader* self); struct miqt_string QXmlStreamReader_ReadElementText(QXmlStreamReader* self); -struct miqt_array* QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self); +struct miqt_array QXmlStreamReader_NamespaceDeclarations(const QXmlStreamReader* self); void QXmlStreamReader_AddExtraNamespaceDeclaration(QXmlStreamReader* self, QXmlStreamNamespaceDeclaration* extraNamespaceDeclaraction); -void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array* /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions); -struct miqt_array* QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self); -struct miqt_array* QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self); +void QXmlStreamReader_AddExtraNamespaceDeclarations(QXmlStreamReader* self, struct miqt_array /* of QXmlStreamNamespaceDeclaration* */ extraNamespaceDeclaractions); +struct miqt_array QXmlStreamReader_NotationDeclarations(const QXmlStreamReader* self); +struct miqt_array QXmlStreamReader_EntityDeclarations(const QXmlStreamReader* self); int QXmlStreamReader_EntityExpansionLimit(const QXmlStreamReader* self); void QXmlStreamReader_SetEntityExpansionLimit(QXmlStreamReader* self, int limit); void QXmlStreamReader_RaiseError(QXmlStreamReader* self); diff --git a/qt6/qprintsupport/gen_qabstractprintdialog.cpp b/qt6/qprintsupport/gen_qabstractprintdialog.cpp index b75b93b4..b30e036b 100644 --- a/qt6/qprintsupport/gen_qabstractprintdialog.cpp +++ b/qt6/qprintsupport/gen_qabstractprintdialog.cpp @@ -37,11 +37,11 @@ struct miqt_string QAbstractPrintDialog_Tr(const char* s) { return _ms; } -void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array* /* of QWidget* */ tabs) { +void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array /* of QWidget* */ tabs) { QList tabs_QList; - tabs_QList.reserve(tabs->len); - QWidget** tabs_arr = static_cast(tabs->data); - for(size_t i = 0; i < tabs->len; ++i) { + tabs_QList.reserve(tabs.len); + QWidget** tabs_arr = static_cast(tabs.data); + for(size_t i = 0; i < tabs.len; ++i) { tabs_QList.push_back(tabs_arr[i]); } self->setOptionTabs(tabs_QList); diff --git a/qt6/qprintsupport/gen_qabstractprintdialog.go b/qt6/qprintsupport/gen_qabstractprintdialog.go index 7713de02..e288cb4c 100644 --- a/qt6/qprintsupport/gen_qabstractprintdialog.go +++ b/qt6/qprintsupport/gen_qabstractprintdialog.go @@ -96,14 +96,12 @@ func QAbstractPrintDialog_Tr(s string) string { } func (this *QAbstractPrintDialog) SetOptionTabs(tabs []*qt6.QWidget) { - // For the C ABI, malloc a C array of raw pointers tabs_CArray := (*[0xffff]*C.QWidget)(C.malloc(C.size_t(8 * len(tabs)))) defer C.free(unsafe.Pointer(tabs_CArray)) for i := range tabs { tabs_CArray[i] = (*C.QWidget)(tabs[i].UnsafePointer()) } - tabs_ma := &C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} - defer runtime.KeepAlive(unsafe.Pointer(tabs_ma)) + tabs_ma := C.struct_miqt_array{len: C.size_t(len(tabs)), data: unsafe.Pointer(tabs_CArray)} C.QAbstractPrintDialog_SetOptionTabs(this.h, tabs_ma) } diff --git a/qt6/qprintsupport/gen_qabstractprintdialog.h b/qt6/qprintsupport/gen_qabstractprintdialog.h index fc4edad9..e6cb0542 100644 --- a/qt6/qprintsupport/gen_qabstractprintdialog.h +++ b/qt6/qprintsupport/gen_qabstractprintdialog.h @@ -30,7 +30,7 @@ QAbstractPrintDialog* QAbstractPrintDialog_new2(QPrinter* printer, QWidget* pare QMetaObject* QAbstractPrintDialog_MetaObject(const QAbstractPrintDialog* self); void* QAbstractPrintDialog_Metacast(QAbstractPrintDialog* self, const char* param1); struct miqt_string QAbstractPrintDialog_Tr(const char* s); -void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array* /* of QWidget* */ tabs); +void QAbstractPrintDialog_SetOptionTabs(QAbstractPrintDialog* self, struct miqt_array /* of QWidget* */ tabs); void QAbstractPrintDialog_SetPrintRange(QAbstractPrintDialog* self, int rangeVal); int QAbstractPrintDialog_PrintRange(const QAbstractPrintDialog* self); void QAbstractPrintDialog_SetMinMax(QAbstractPrintDialog* self, int min, int max); diff --git a/qt6/qprintsupport/gen_qprinter.cpp b/qt6/qprintsupport/gen_qprinter.cpp index 2ff6519e..dc41d588 100644 --- a/qt6/qprintsupport/gen_qprinter.cpp +++ b/qt6/qprintsupport/gen_qprinter.cpp @@ -205,16 +205,16 @@ int QPrinter_Duplex(const QPrinter* self) { return static_cast(_ret); } -struct miqt_array* QPrinter_SupportedResolutions(const QPrinter* self) { +struct miqt_array QPrinter_SupportedResolutions(const QPrinter* self) { QList _ret = self->supportedResolutions(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/qprintsupport/gen_qprinter.go b/qt6/qprintsupport/gen_qprinter.go index b0e98628..87e2a4a5 100644 --- a/qt6/qprintsupport/gen_qprinter.go +++ b/qt6/qprintsupport/gen_qprinter.go @@ -326,13 +326,12 @@ func (this *QPrinter) Duplex() QPrinter__DuplexMode { } func (this *QPrinter) SupportedResolutions() []int { - var _ma *C.struct_miqt_array = C.QPrinter_SupportedResolutions(this.h) + var _ma C.struct_miqt_array = C.QPrinter_SupportedResolutions(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/qprintsupport/gen_qprinter.h b/qt6/qprintsupport/gen_qprinter.h index 1a3711c5..c9a3909b 100644 --- a/qt6/qprintsupport/gen_qprinter.h +++ b/qt6/qprintsupport/gen_qprinter.h @@ -64,7 +64,7 @@ void QPrinter_SetPaperSource(QPrinter* self, int paperSource); int QPrinter_PaperSource(const QPrinter* self); void QPrinter_SetDuplex(QPrinter* self, int duplex); int QPrinter_Duplex(const QPrinter* self); -struct miqt_array* QPrinter_SupportedResolutions(const QPrinter* self); +struct miqt_array QPrinter_SupportedResolutions(const QPrinter* self); void QPrinter_SetFontEmbeddingEnabled(QPrinter* self, bool enable); bool QPrinter_FontEmbeddingEnabled(const QPrinter* self); QRectF* QPrinter_PaperRect(const QPrinter* self, int param1); diff --git a/qt6/qprintsupport/gen_qprinterinfo.cpp b/qt6/qprintsupport/gen_qprinterinfo.cpp index 6d64dd69..93d6734f 100644 --- a/qt6/qprintsupport/gen_qprinterinfo.cpp +++ b/qt6/qprintsupport/gen_qprinterinfo.cpp @@ -86,16 +86,16 @@ int QPrinterInfo_State(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self) { QList _ret = self->supportedPageSizes(); // Convert QList<> from C++ memory to manually-managed C memory QPageSize** _arr = static_cast(malloc(sizeof(QPageSize*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPageSize(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -115,16 +115,16 @@ QPageSize* QPrinterInfo_MaximumPhysicalPageSize(const QPrinterInfo* self) { return new QPageSize(self->maximumPhysicalPageSize()); } -struct miqt_array* QPrinterInfo_SupportedResolutions(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedResolutions(const QPrinterInfo* self) { QList _ret = self->supportedResolutions(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = _ret[i]; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -133,7 +133,7 @@ int QPrinterInfo_DefaultDuplexMode(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { QList _ret = self->supportedDuplexModes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -141,9 +141,9 @@ struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self) { QPrinter::DuplexMode _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } @@ -152,7 +152,7 @@ int QPrinterInfo_DefaultColorMode(const QPrinterInfo* self) { return static_cast(_ret); } -struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { +struct miqt_array QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { QList _ret = self->supportedColorModes(); // Convert QList<> from C++ memory to manually-managed C memory int* _arr = static_cast(malloc(sizeof(int) * _ret.length())); @@ -160,13 +160,13 @@ struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self) { QPrinter::ColorMode _lv_ret = _ret[i]; _arr[i] = static_cast(_lv_ret); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPrinterInfo_AvailablePrinterNames() { +struct miqt_array QPrinterInfo_AvailablePrinterNames() { QStringList _ret = QPrinterInfo::availablePrinterNames(); // Convert QList<> from C++ memory to manually-managed C memory struct miqt_string* _arr = static_cast(malloc(sizeof(struct miqt_string) * _ret.length())); @@ -180,22 +180,22 @@ struct miqt_array* QPrinterInfo_AvailablePrinterNames() { memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len); _arr[i] = _lv_ms; } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } -struct miqt_array* QPrinterInfo_AvailablePrinters() { +struct miqt_array QPrinterInfo_AvailablePrinters() { QList _ret = QPrinterInfo::availablePrinters(); // Convert QList<> from C++ memory to manually-managed C memory QPrinterInfo** _arr = static_cast(malloc(sizeof(QPrinterInfo*) * _ret.length())); for (size_t i = 0, e = _ret.length(); i < e; ++i) { _arr[i] = new QPrinterInfo(_ret[i]); } - struct miqt_array* _out = static_cast(malloc(sizeof(struct miqt_array))); - _out->len = _ret.length(); - _out->data = static_cast(_arr); + struct miqt_array _out; + _out.len = _ret.length(); + _out.data = static_cast(_arr); return _out; } diff --git a/qt6/qprintsupport/gen_qprinterinfo.go b/qt6/qprintsupport/gen_qprinterinfo.go index 797351f1..db0b7325 100644 --- a/qt6/qprintsupport/gen_qprinterinfo.go +++ b/qt6/qprintsupport/gen_qprinterinfo.go @@ -110,7 +110,7 @@ func (this *QPrinterInfo) State() QPrinter__PrinterState { } func (this *QPrinterInfo) SupportedPageSizes() []qt6.QPageSize { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedPageSizes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedPageSizes(this.h) _ret := make([]qt6.QPageSize, int(_ma.len)) _outCast := (*[0xffff]*C.QPageSize)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -119,7 +119,6 @@ func (this *QPrinterInfo) SupportedPageSizes() []qt6.QPageSize { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -149,13 +148,12 @@ func (this *QPrinterInfo) MaximumPhysicalPageSize() *qt6.QPageSize { } func (this *QPrinterInfo) SupportedResolutions() []int { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedResolutions(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedResolutions(this.h) _ret := make([]int, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (int)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -164,13 +162,12 @@ func (this *QPrinterInfo) DefaultDuplexMode() QPrinter__DuplexMode { } func (this *QPrinterInfo) SupportedDuplexModes() []QPrinter__DuplexMode { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedDuplexModes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedDuplexModes(this.h) _ret := make([]QPrinter__DuplexMode, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QPrinter__DuplexMode)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } @@ -179,18 +176,17 @@ func (this *QPrinterInfo) DefaultColorMode() QPrinter__ColorMode { } func (this *QPrinterInfo) SupportedColorModes() []QPrinter__ColorMode { - var _ma *C.struct_miqt_array = C.QPrinterInfo_SupportedColorModes(this.h) + var _ma C.struct_miqt_array = C.QPrinterInfo_SupportedColorModes(this.h) _ret := make([]QPrinter__ColorMode, int(_ma.len)) _outCast := (*[0xffff]C.int)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { _ret[i] = (QPrinter__ColorMode)(_outCast[i]) } - C.free(unsafe.Pointer(_ma)) return _ret } func QPrinterInfo_AvailablePrinterNames() []string { - var _ma *C.struct_miqt_array = C.QPrinterInfo_AvailablePrinterNames() + var _ma C.struct_miqt_array = C.QPrinterInfo_AvailablePrinterNames() _ret := make([]string, int(_ma.len)) _outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -199,12 +195,11 @@ func QPrinterInfo_AvailablePrinterNames() []string { C.free(unsafe.Pointer(_lv_ms.data)) _ret[i] = _lv_ret } - C.free(unsafe.Pointer(_ma)) return _ret } func QPrinterInfo_AvailablePrinters() []QPrinterInfo { - var _ma *C.struct_miqt_array = C.QPrinterInfo_AvailablePrinters() + var _ma C.struct_miqt_array = C.QPrinterInfo_AvailablePrinters() _ret := make([]QPrinterInfo, int(_ma.len)) _outCast := (*[0xffff]*C.QPrinterInfo)(unsafe.Pointer(_ma.data)) // hey ya for i := 0; i < int(_ma.len); i++ { @@ -213,7 +208,6 @@ func QPrinterInfo_AvailablePrinters() []QPrinterInfo { _lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer _ret[i] = *_lv_goptr } - C.free(unsafe.Pointer(_ma)) return _ret } diff --git a/qt6/qprintsupport/gen_qprinterinfo.h b/qt6/qprintsupport/gen_qprinterinfo.h index a5b781ab..675dc804 100644 --- a/qt6/qprintsupport/gen_qprinterinfo.h +++ b/qt6/qprintsupport/gen_qprinterinfo.h @@ -35,18 +35,18 @@ bool QPrinterInfo_IsNull(const QPrinterInfo* self); bool QPrinterInfo_IsDefault(const QPrinterInfo* self); bool QPrinterInfo_IsRemote(const QPrinterInfo* self); int QPrinterInfo_State(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedPageSizes(const QPrinterInfo* self); QPageSize* QPrinterInfo_DefaultPageSize(const QPrinterInfo* self); bool QPrinterInfo_SupportsCustomPageSizes(const QPrinterInfo* self); QPageSize* QPrinterInfo_MinimumPhysicalPageSize(const QPrinterInfo* self); QPageSize* QPrinterInfo_MaximumPhysicalPageSize(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedResolutions(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedResolutions(const QPrinterInfo* self); int QPrinterInfo_DefaultDuplexMode(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_SupportedDuplexModes(const QPrinterInfo* self); int QPrinterInfo_DefaultColorMode(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_SupportedColorModes(const QPrinterInfo* self); -struct miqt_array* QPrinterInfo_AvailablePrinterNames(); -struct miqt_array* QPrinterInfo_AvailablePrinters(); +struct miqt_array QPrinterInfo_SupportedColorModes(const QPrinterInfo* self); +struct miqt_array QPrinterInfo_AvailablePrinterNames(); +struct miqt_array QPrinterInfo_AvailablePrinters(); struct miqt_string QPrinterInfo_DefaultPrinterName(); QPrinterInfo* QPrinterInfo_DefaultPrinter(); QPrinterInfo* QPrinterInfo_PrinterInfo(struct miqt_string printerName);