mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 14:18:37 +00:00
genbindings: more exceptions
This commit is contained in:
parent
b84d816609
commit
9dac446a82
@ -633,6 +633,14 @@ func tokenizeMultipleParameters(p string) []string {
|
|||||||
|
|
||||||
func parseSingleTypeString(p string) CppParameter {
|
func parseSingleTypeString(p string) CppParameter {
|
||||||
|
|
||||||
|
if strings.HasPrefix(p, "QFlag<") {
|
||||||
|
return CppParameter{ParameterType: "int"}
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(p, "(*)") {
|
||||||
|
return CppParameter{ParameterType: "uintptr"} // Function pointer, nonrepresentible
|
||||||
|
}
|
||||||
|
|
||||||
tokens := strings.Split(strings.TrimSpace(p), " ")
|
tokens := strings.Split(strings.TrimSpace(p), " ")
|
||||||
insert := CppParameter{}
|
insert := CppParameter{}
|
||||||
for _, tok := range tokens {
|
for _, tok := range tokens {
|
||||||
@ -648,6 +656,9 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
} else if tok == "&" { // U+0026
|
} else if tok == "&" { // U+0026
|
||||||
insert.ByRef = true
|
insert.ByRef = true
|
||||||
|
|
||||||
|
} else if tok == "signed" {
|
||||||
|
// continue
|
||||||
|
|
||||||
} else if tok == "*" {
|
} else if tok == "*" {
|
||||||
insert.Pointer = true
|
insert.Pointer = true
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ func (p CppParameter) RenderTypeCabi() string {
|
|||||||
ret = "intptr_t"
|
ret = "intptr_t"
|
||||||
case "quintptr":
|
case "quintptr":
|
||||||
ret = "uintptr_t"
|
ret = "uintptr_t"
|
||||||
|
case "qptrdiff":
|
||||||
|
ret = "ptrdiff_t"
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(p.ParameterType, `::`) {
|
if strings.Contains(p.ParameterType, `::`) {
|
||||||
@ -238,6 +240,7 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f
|
|||||||
// Don't use RenderTypeCabi() since it canonicalizes some int types for CABI
|
// Don't use RenderTypeCabi() since it canonicalizes some int types for CABI
|
||||||
castSrc := p.ParameterName
|
castSrc := p.ParameterName
|
||||||
castType := p.RenderTypeQtCpp()
|
castType := p.RenderTypeQtCpp()
|
||||||
|
|
||||||
if p.ByRef { // e.g. QDataStream::operator>>() overloads
|
if p.ByRef { // e.g. QDataStream::operator>>() overloads
|
||||||
castSrc = "*" + castSrc
|
castSrc = "*" + castSrc
|
||||||
}
|
}
|
||||||
@ -465,13 +468,9 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
|
|||||||
ret.WriteString(`#include <` + ref + ">\n")
|
ret.WriteString(`#include <` + ref + ">\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.WriteString(`#include "gen_` + filename + `"
|
ret.WriteString(`#include "` + filename + "\"\n\n")
|
||||||
#include "` + filename + `"
|
ret.WriteString(`#include "gen_` + filename + "\"\n")
|
||||||
|
|
||||||
`)
|
|
||||||
|
|
||||||
ret.WriteString(`
|
ret.WriteString(`
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
ret += "float32"
|
ret += "float32"
|
||||||
case "double", "qreal":
|
case "double", "qreal":
|
||||||
ret += "float64"
|
ret += "float64"
|
||||||
case "qsizetype", "size_t":
|
case "qsizetype", "size_t", "qptrdiff", "ptrdiff_t":
|
||||||
if C.sizeof_size_t == 4 {
|
if C.sizeof_size_t == 4 {
|
||||||
ret += "uint32"
|
ret += "uint32"
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,6 +67,10 @@ func AllowClass(className string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(className, "QPrivateSignal") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
switch className {
|
switch className {
|
||||||
case
|
case
|
||||||
"QTextStreamManipulator", // Only seems to contain garbage methods
|
"QTextStreamManipulator", // Only seems to contain garbage methods
|
||||||
@ -101,6 +105,12 @@ func CheckComplexity(p CppParameter) error {
|
|||||||
if strings.HasPrefix(p.ParameterType, "StringResult<") {
|
if strings.HasPrefix(p.ParameterType, "StringResult<") {
|
||||||
return ErrTooComplex // e.g. qcborstreamreader.h
|
return ErrTooComplex // e.g. qcborstreamreader.h
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(p.ParameterType, "std::initializer") {
|
||||||
|
return ErrTooComplex // e.g. qcborarray.h
|
||||||
|
}
|
||||||
|
if strings.Contains(p.ParameterType, `::QPrivate`) {
|
||||||
|
return ErrTooComplex // e.g. QAbstractItemModel::QPrivateSignal
|
||||||
|
}
|
||||||
|
|
||||||
switch p.ParameterType {
|
switch p.ParameterType {
|
||||||
case
|
case
|
||||||
@ -117,6 +127,8 @@ func CheckComplexity(p CppParameter) error {
|
|||||||
"char16_t", // e.g. QChar() constructor overload, just unnecessary
|
"char16_t", // e.g. QChar() constructor overload, just unnecessary
|
||||||
"char32_t", // e.g. QDebug().operator<< overload, unnecessary
|
"char32_t", // e.g. QDebug().operator<< overload, unnecessary
|
||||||
"wchar_t", // e.g. qstringview.h overloads, unnecessary
|
"wchar_t", // e.g. qstringview.h overloads, unnecessary
|
||||||
|
"FILE", // e.g. qfile.h constructors
|
||||||
|
"qInternalCallback", // e.g. qnamespace.h
|
||||||
"picture_io_handler", // e.g. QPictureIO::DefineIOHandler callback function
|
"picture_io_handler", // e.g. QPictureIO::DefineIOHandler callback function
|
||||||
"QPlatformNativeInterface", // e.g. QGuiApplication::platformNativeInterface(). Private type, could probably expose as uintptr. n.b. Changes in Qt6
|
"QPlatformNativeInterface", // e.g. QGuiApplication::platformNativeInterface(). Private type, could probably expose as uintptr. n.b. Changes in Qt6
|
||||||
"QFunctionPointer", // e.g. QGuiApplication_PlatformFunction
|
"QFunctionPointer", // e.g. QGuiApplication_PlatformFunction
|
||||||
|
@ -116,6 +116,7 @@ func (p CppParameter) IntType() bool {
|
|||||||
"longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long",
|
"longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long",
|
||||||
"qintptr", "quintptr", "uintptr_t", "intptr_t",
|
"qintptr", "quintptr", "uintptr_t", "intptr_t",
|
||||||
"qsizetype", "size_t",
|
"qsizetype", "size_t",
|
||||||
|
"qptrdiff", "ptrdiff_t",
|
||||||
"double", "float", "qreal":
|
"double", "float", "qreal":
|
||||||
return true
|
return true
|
||||||
|
|
||||||
@ -232,6 +233,16 @@ func (nm CppMethod) SafeMethodName() string {
|
|||||||
return tmp
|
return tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CppEnumEntry struct {
|
||||||
|
EntryName string
|
||||||
|
EntryValue string
|
||||||
|
}
|
||||||
|
|
||||||
|
type CppEnum struct {
|
||||||
|
EnumName string
|
||||||
|
Entries []CppEnumEntry
|
||||||
|
}
|
||||||
|
|
||||||
type CppClass struct {
|
type CppClass struct {
|
||||||
ClassName string
|
ClassName string
|
||||||
Abstract bool
|
Abstract bool
|
||||||
@ -243,6 +254,7 @@ type CppClass struct {
|
|||||||
|
|
||||||
ChildTypedefs []CppTypedef
|
ChildTypedefs []CppTypedef
|
||||||
ChildClassdefs []CppClass
|
ChildClassdefs []CppClass
|
||||||
|
ChildEnums []CppEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
type CppTypedef struct {
|
type CppTypedef struct {
|
||||||
@ -253,6 +265,7 @@ type CppTypedef struct {
|
|||||||
type CppParsedHeader struct {
|
type CppParsedHeader struct {
|
||||||
Filename string
|
Filename string
|
||||||
Typedefs []CppTypedef
|
Typedefs []CppTypedef
|
||||||
|
Enums []CppEnum
|
||||||
Classes []CppClass
|
Classes []CppClass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user