mirror of
https://github.com/mappu/miqt.git
synced 2025-03-14 11:20:23 +00:00
genbindings: further work on exceptions
This commit is contained in:
parent
d92e87b49d
commit
f9a9b4a9b4
@ -510,8 +510,10 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
tokens := strings.Split(strings.TrimSpace(p), " ")
|
tokens := strings.Split(strings.TrimSpace(p), " ")
|
||||||
insert := CppParameter{}
|
insert := CppParameter{}
|
||||||
for _, tok := range tokens {
|
for _, tok := range tokens {
|
||||||
|
|
||||||
if tok == "" {
|
if tok == "" {
|
||||||
continue // extra space
|
continue // extra space
|
||||||
|
|
||||||
} else if tok == "const" || tok == "*const" {
|
} else if tok == "const" || tok == "*const" {
|
||||||
// *const happens for QPixmap, clang reports `const char *const *` which
|
// *const happens for QPixmap, clang reports `const char *const *` which
|
||||||
// isn't even valid syntax
|
// isn't even valid syntax
|
||||||
@ -519,17 +521,41 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
|
|
||||||
} else if tok == "&" { // U+0026
|
} else if tok == "&" { // U+0026
|
||||||
insert.ByRef = true
|
insert.ByRef = true
|
||||||
|
|
||||||
} else if tok == "*" {
|
} else if tok == "*" {
|
||||||
insert.Pointer = true
|
insert.Pointer = true
|
||||||
|
|
||||||
} else if tok == "WId" {
|
} else if tok == "WId" {
|
||||||
// Transform typedef
|
// Transform typedef
|
||||||
insert.ParameterType += " uintptr_t"
|
insert.ParameterType += " uintptr_t"
|
||||||
|
|
||||||
|
} else if tok == "Q_PID" {
|
||||||
|
// Transform typedef
|
||||||
|
// This is a uint64 PID on Linux/mac and a PROCESS_INFORMATION* on Windows
|
||||||
|
// A uintptr should be tolerable for both cases until we do better
|
||||||
|
// @ref https://doc.qt.io/qt-5/qprocess.html#Q_PID-typedef
|
||||||
|
insert.ParameterType += " uintptr_t"
|
||||||
|
|
||||||
} else if tok == "QStringList" {
|
} else if tok == "QStringList" {
|
||||||
insert.ParameterType += " QList<QString>"
|
insert.ParameterType += " QList<QString>"
|
||||||
} else if len(tok) > 4 && strings.HasSuffix(tok, "List") && tok != "QTextList" {
|
|
||||||
|
} else if len(tok) > 4 && strings.HasSuffix(tok, "List") {
|
||||||
|
// Classes ending in --List are usually better represented as a QList
|
||||||
|
// type directly, so that the binding uses proper Go slices
|
||||||
// Typedef e.g. QObjectList
|
// Typedef e.g. QObjectList
|
||||||
// QObjectList is a pointer, but QStringList is a whole custom class
|
switch tok {
|
||||||
|
case "QModelIndexList":
|
||||||
|
// These types are defined as a QList of values
|
||||||
|
insert.ParameterType += " QList<QModelIndex>"
|
||||||
|
case "QTextList":
|
||||||
|
// This is really a custom class, preserve as-is
|
||||||
|
insert.ParameterType += " " + tok
|
||||||
|
default:
|
||||||
|
// These types are defined as a QList of pointers.
|
||||||
|
// QList<QFoo*>. This is the most common case
|
||||||
insert.ParameterType += " QList<" + tok[0:len(tok)-4] + " *>"
|
insert.ParameterType += " QList<" + tok[0:len(tok)-4] + " *>"
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Valid part of the type name
|
// Valid part of the type name
|
||||||
insert.ParameterType += " " + tok
|
insert.ParameterType += " " + tok
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func goReservedWord(s string) bool {
|
func goReservedWord(s string) bool {
|
||||||
switch s {
|
switch s {
|
||||||
case "default", "const", "func", "var", "type", "len", "new", "copy", "import", "range":
|
case "default", "const", "func", "var", "type", "len", "new", "copy", "import", "range", "string", "map", "int", "select":
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
@ -1,10 +1,41 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AllowHeader(fullpath string) bool {
|
func AllowHeader(fullpath string) bool {
|
||||||
|
fname := filepath.Base(fullpath)
|
||||||
|
|
||||||
|
if strings.HasSuffix(fname, `_impl.h`) {
|
||||||
|
return false // Not meant to be imported
|
||||||
|
}
|
||||||
|
|
||||||
|
fname_lc := strings.ToLower(fname)
|
||||||
|
if strings.Contains(fname_lc, `opengl`) || strings.Contains(fname_lc, `vulkan`) {
|
||||||
|
return false // Too hard
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fname {
|
||||||
|
case // QtCore
|
||||||
|
"qatomic_bootstrap.h",
|
||||||
|
"qatomic_cxx11.h",
|
||||||
|
"qatomic_msvc.h",
|
||||||
|
"qgenericatomic.h", // Clang error
|
||||||
|
"qt_windows.h", // Clang error
|
||||||
|
"qmaccocoaviewcontainer_mac.h", // Needs NSView* headers. TODO allow with darwin build tag
|
||||||
|
"qmacnativewidget_mac.h", // Needs NSView* headers. TODO allow with darwin build tag
|
||||||
|
"qaccessible.h", // Almost everything in here is virtual
|
||||||
|
"qaccessiblebridge.h", // Almost everything in here is virtual
|
||||||
|
"qaccessibleobject.h", // Almost everything in here is virtual
|
||||||
|
"qaccessibleplugin.h", // Almost everything in here is virtual
|
||||||
|
"qstring.h", // QString does not exist in this binding
|
||||||
|
"qlist.h", // QList does not exist in this binding
|
||||||
|
"qvector.h": // QVector does not exist in this binding
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +84,7 @@ func AllowClass(className string) bool {
|
|||||||
|
|
||||||
switch className {
|
switch className {
|
||||||
case
|
case
|
||||||
|
"QTextStreamManipulator", // Only seems to contain garbage methods
|
||||||
"QException", // Extends std::exception, too hard
|
"QException", // Extends std::exception, too hard
|
||||||
"QItemSelection", // Extends a QList<>, too hard
|
"QItemSelection", // Extends a QList<>, too hard
|
||||||
"QXmlStreamAttributes", // Extends a QList<>, too hard
|
"QXmlStreamAttributes", // Extends a QList<>, too hard
|
||||||
@ -80,6 +112,10 @@ func CheckComplexity(p CppParameter) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(p.ParameterType, "StringResult<") {
|
||||||
|
return ErrTooComplex // e.g. qcborstreamreader.h
|
||||||
|
}
|
||||||
|
|
||||||
switch p.ParameterType {
|
switch p.ParameterType {
|
||||||
case
|
case
|
||||||
"QList<QVariant>", // e.g. QVariant constructor - this has a deleted copy-constructor so we can't get it over the CABI boundary by value
|
"QList<QVariant>", // e.g. QVariant constructor - this has a deleted copy-constructor so we can't get it over the CABI boundary by value
|
||||||
@ -100,6 +136,11 @@ func CheckComplexity(p CppParameter) error {
|
|||||||
"QGraphicsEffectSource", // e.g. used by qgraphicseffect.h, but the definition is in ????
|
"QGraphicsEffectSource", // e.g. used by qgraphicseffect.h, but the definition is in ????
|
||||||
"QAbstractUndoItem", // e.g. Defined in qtextdocument.h
|
"QAbstractUndoItem", // e.g. Defined in qtextdocument.h
|
||||||
"QTextObjectInterface", // e.g. qabstracttextdocumentlayout.h
|
"QTextObjectInterface", // e.g. qabstracttextdocumentlayout.h
|
||||||
|
"QXmlStreamEntityDeclarations", // e.g. qxmlstream.h. The class definition was blacklisted for ???? reason so don't allow it as a parameter either
|
||||||
|
"QXmlStreamNamespaceDeclarations", // e.g. qxmlstream.h. As above
|
||||||
|
"QXmlStreamNotationDeclarations", // e.g. qxmlstream.h. As above
|
||||||
|
"QVariantMap", // e.g. qcbormap.h
|
||||||
|
"QVariantHash", // e.g. qcbormap.h
|
||||||
"QPlatformPixmap", // e.g. qpixmap.h. as below
|
"QPlatformPixmap", // e.g. qpixmap.h. as below
|
||||||
"QPlatformScreen", // e.g. qscreen.h. as below
|
"QPlatformScreen", // e.g. qscreen.h. as below
|
||||||
"QPlatformSurface", // e.g. qsurface.h. as below
|
"QPlatformSurface", // e.g. qsurface.h. as below
|
||||||
|
Loading…
x
Reference in New Issue
Block a user