mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
qnetwork: add support in genbindings
This commit is contained in:
parent
910babe1d2
commit
e41f991a23
@ -865,6 +865,10 @@ func parseSingleTypeString(p string) CppParameter {
|
||||
} else if tok == "const" {
|
||||
insert.Const = true
|
||||
|
||||
} else if tok == "class" {
|
||||
// QNetwork has some references to 'class QSslCertificate'. Flatten
|
||||
continue
|
||||
|
||||
} else if tok == "&" { // U+0026
|
||||
insert.ByRef = true
|
||||
|
||||
|
@ -244,6 +244,14 @@ func AllowType(p CppParameter, isReturnType bool) error {
|
||||
if err := AllowType(vType, isReturnType); err != nil {
|
||||
return err
|
||||
}
|
||||
// Additionally, Go maps do not support []byte keys
|
||||
// This affects qnetwork qsslconfiguration BackendConfiguration
|
||||
if kType.ParameterType == "QByteArray" {
|
||||
return ErrTooComplex
|
||||
}
|
||||
}
|
||||
if p.QMultiMapOf() {
|
||||
return ErrTooComplex // e.g. Qt5 QNetwork qsslcertificate.h has a QMultiMap<QSsl::AlternativeNameEntryType, QString>
|
||||
}
|
||||
|
||||
if !AllowClass(p.ParameterType) {
|
||||
@ -379,6 +387,7 @@ func AllowType(p CppParameter, isReturnType bool) error {
|
||||
"char32_t", // e.g. QDebug().operator<< overload, unnecessary
|
||||
"wchar_t", // e.g. qstringview.h overloads, unnecessary
|
||||
"FILE", // e.g. qfile.h constructors
|
||||
"sockaddr", // Qt network Qhostaddress. Should be possible to make this work but may be platform-specific
|
||||
"qInternalCallback", // e.g. qnamespace.h
|
||||
"QGraphicsEffectSource", // e.g. used by qgraphicseffect.h, but the definition is in ????
|
||||
"QXmlStreamEntityDeclarations", // e.g. qxmlstream.h. The class definition was blacklisted for ???? reason so don't allow it as a parameter either
|
||||
|
@ -66,6 +66,18 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
|
||||
ClangMatchSameHeaderDefinitionOnly,
|
||||
)
|
||||
|
||||
generate(
|
||||
"qt/network",
|
||||
[]string{
|
||||
"/usr/include/x86_64-linux-gnu/qt5/QtNetwork",
|
||||
},
|
||||
AllowAllHeaders,
|
||||
clangBin,
|
||||
pkgConfigCflags("Qt5Network"),
|
||||
outDir,
|
||||
ClangMatchSameHeaderDefinitionOnly,
|
||||
)
|
||||
|
||||
// Depends on QtCore/Gui/Widgets, QPrintSupport
|
||||
generate(
|
||||
"qt-restricted-extras/qscintilla",
|
||||
@ -152,4 +164,23 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
|
||||
outDir,
|
||||
ClangMatchSameHeaderDefinitionOnly,
|
||||
)
|
||||
|
||||
// Qt 6 QtNetwork
|
||||
generate(
|
||||
"qt6/network",
|
||||
[]string{
|
||||
"/usr/include/x86_64-linux-gnu/qt6/QtNetwork",
|
||||
},
|
||||
func(fullpath string) bool {
|
||||
fname := filepath.Base(fullpath)
|
||||
if fname == "qtnetwork-config.h" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
clangBin,
|
||||
"--std=c++17 "+pkgConfigCflags("Qt6Network"),
|
||||
outDir,
|
||||
ClangMatchSameHeaderDefinitionOnly,
|
||||
)
|
||||
}
|
||||
|
@ -232,7 +232,13 @@ func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, for
|
||||
preamble += indent + "\t" + nameprefix + "_QList.push_back(" + addFwd + ");\n"
|
||||
|
||||
preamble += indent + "}\n"
|
||||
return preamble, nameprefix + "_QList"
|
||||
|
||||
// Support passing QList<>* (very rare, but used in qnetwork)
|
||||
if p.Pointer {
|
||||
return preamble, "&" + nameprefix + "_QList"
|
||||
} else {
|
||||
return preamble, nameprefix + "_QList"
|
||||
}
|
||||
|
||||
} else if kType, vType, ok := p.QMapOf(); ok {
|
||||
preamble += indent + p.GetQtCppType().ParameterType + " " + nameprefix + "_QMap;\n"
|
||||
|
@ -191,6 +191,15 @@ func (p CppParameter) QSetOf() (CppParameter, bool) {
|
||||
return CppParameter{}, false
|
||||
}
|
||||
|
||||
func (p CppParameter) QMultiMapOf() bool {
|
||||
if strings.HasPrefix(p.ParameterType, `QMultiMap<`) ||
|
||||
strings.HasPrefix(p.ParameterType, `QMultiHash<`) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p CppParameter) IntType() bool {
|
||||
|
||||
if p.IsKnownEnum() {
|
||||
|
@ -32,7 +32,7 @@ func astTransformOptional(parsed *CppParsedHeader) {
|
||||
|
||||
// Add method copies
|
||||
for x := optionalStart; x < len(m.Parameters); x++ {
|
||||
dupMethod := m // copy
|
||||
dupMethod := m // shallow copy
|
||||
dupMethod.Rename(m.MethodName + fmt.Sprintf("%d", x+1))
|
||||
dupMethod.Parameters = m.Parameters[0 : x+1]
|
||||
dupMethod.HiddenParams = m.Parameters[x+1:]
|
||||
@ -68,7 +68,7 @@ func astTransformOptional(parsed *CppParsedHeader) {
|
||||
|
||||
// Add ctor copies
|
||||
for x := optionalStart; x < len(m.Parameters); x++ {
|
||||
dupCtor := m // copy
|
||||
dupCtor := m // shallow copy
|
||||
dupCtor.Parameters = m.Parameters[0 : x+1]
|
||||
dupCtor.HiddenParams = m.Parameters[x+1:]
|
||||
c.Ctors = append(c.Ctors, dupCtor)
|
||||
|
Loading…
Reference in New Issue
Block a user