diff --git a/cmd/genbindings/exceptions.go b/cmd/genbindings/exceptions.go index 5b1ed189..058f93af 100644 --- a/cmd/genbindings/exceptions.go +++ b/cmd/genbindings/exceptions.go @@ -24,6 +24,7 @@ func InsertTypedefs() { // QFile doesn't see QFileDevice parent class enum KnownTypedefs["QFile::Permissions"] = lookupResultTypedef{"qt", CppTypedef{"QFile::Permissions", parseSingleTypeString("QFileDevice::Permissions")}} KnownTypedefs["QFileDevice::Permissions"] = lookupResultTypedef{"qt", CppTypedef{"QFile::Permissions", parseSingleTypeString("QFlags")}} + } func AllowHeader(fullpath string) bool { @@ -95,6 +96,10 @@ func AllowClass(className string) bool { return false } + if strings.HasPrefix(className, `std::`) { + return false // Scintilla bindings find some of these + } + switch className { case "QTextStreamManipulator", // Only seems to contain garbage methods @@ -135,7 +140,6 @@ func AllowMethod(mm CppMethod) error { } return nil // OK, allow - } func CheckComplexity(p CppParameter, isReturnType bool) error { @@ -187,12 +191,16 @@ func CheckComplexity(p CppParameter, isReturnType bool) error { if strings.HasPrefix(p.ParameterType, "QUrlTwoFlags<") { return ErrTooComplex // e.g. qurl.h } + if strings.HasPrefix(p.ParameterType, "FillResult<") { + return ErrTooComplex // Scintilla + } if strings.HasPrefix(p.ParameterType, "std::") { // std::initializer e.g. qcborarray.h // std::string QByteArray->toStdString(). There are QString overloads already // std::nullptr_t Qcborstreamwriter // std::chrono::nanoseconds QDeadlineTimer_RemainingTimeAsDuration // std::seed_seq QRandom + // std::exception Scintilla return ErrTooComplex } if strings.Contains(p.ParameterType, `Iterator::value_type`) { @@ -264,6 +272,7 @@ func CheckComplexity(p CppParameter, isReturnType bool) error { "QXmlStreamNamespaceDeclarations", // e.g. qxmlstream.h. As above "QXmlStreamNotationDeclarations", // e.g. qxmlstream.h. As above "QXmlStreamAttributes", // e.g. qxmlstream.h + "LineLayout::ValidLevel", // .. "QtMsgType", // e.g. qdebug.h TODO Defined in qlogging.h, but omitted because it's predefined in qglobal.h, and our clangexec is too agressive "QTextStreamFunction", // e.g. qdebug.h "QFactoryInterface", // qfactoryinterface.h diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index 87148f5e..76b601d7 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -110,6 +110,10 @@ func (p CppParameter) QtClassType() bool { return true } + if p.ParameterType == "Scintilla::Internal::Point" { + return true + } + if p.ParameterType == "QString" || p.ParameterType == "QByteArray" { return true } diff --git a/cmd/genbindings/main.go b/cmd/genbindings/main.go index 52150a55..ac512839 100644 --- a/cmd/genbindings/main.go +++ b/cmd/genbindings/main.go @@ -25,6 +25,8 @@ func importPathForQtPackage(packageName string) string { return BaseModule + "/qt" case "qscintilla": return BaseModule + "/qt-restricted-extras/" + packageName + case "scintillaedit": + return BaseModule + "/qt-extras/" + packageName default: return BaseModule + "/qt/" + packageName } @@ -102,6 +104,7 @@ func pkgConfigCflags(packageName string) string { func main() { clang := flag.String("clang", "clang", "Custom path to clang") outDir := flag.String("outdir", "../../", "Output directory for generated gen_** files") + extraLibsDir := flag.String("extralibs", "/usr/local/src/", "Base directory to find extra library checkouts") flag.Parse() @@ -140,6 +143,18 @@ func main() { filepath.Join(*outDir, "qt-restricted-extras/qscintilla"), ClangMatchSameHeaderDefinitionOnly, ) + + // Depends on QtCore/Gui/Widgets + generate( + "scintillaedit", + []string{ + filepath.Join(*extraLibsDir, "scintilla/qt/ScintillaEdit/ScintillaEdit.h"), + }, + *clang, + strings.Fields("--std=c++1z "+pkgConfigCflags("ScintillaEdit")), + filepath.Join(*outDir, "qt-extras/scintillaedit"), + (&clangMatchUnderPath{filepath.Join(*extraLibsDir, "scintilla")}).Match, + ) } func generate(packageName string, srcDirs []string, clangBin string, cflags []string, outDir string, matcher ClangMatcher) { diff --git a/docker/genbindings.Dockerfile b/docker/genbindings.Dockerfile index 0589d25d..6ef7b241 100644 --- a/docker/genbindings.Dockerfile +++ b/docker/genbindings.Dockerfile @@ -11,6 +11,23 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ pkg-config \ build-essential && \ apt-get clean + +RUN mkdir -p /usr/local/src/scintilla && \ + git clone 'https://github.com/mirror/scintilla.git' /usr/local/src/scintilla && \ + git -C /usr/local/src/scintilla checkout rel-5-5-2 + +RUN \ + cd /usr/local/src/scintilla/qt/ScintillaEditBase && \ + qmake && \ + make && \ + cd /usr/local/src/scintilla/qt/ScintillaEdit && \ + python3 WidgetGen.py && \ + qmake && \ + make + RUN mkdir -p /usr/local/lib/pkgconfig + COPY pkg-config/QScintilla.pc.example /usr/local/lib/pkgconfig/QScintilla.pc +COPY pkg-config/ScintillaEdit.pc.example /usr/local/lib/pkgconfig/ScintillaEdit.pc + ENV GOFLAGS=-buildvcs=false diff --git a/pkg-config/ScintillaEdit.pc.example b/pkg-config/ScintillaEdit.pc.example new file mode 100644 index 00000000..9146b64b --- /dev/null +++ b/pkg-config/ScintillaEdit.pc.example @@ -0,0 +1,9 @@ +srcdir=/usr/local/src/scintilla/ + +Name: ScintillaEdit +Description: Scintilla's own upstream Qt port +URL: https://www.scintilla.org/ +Version: 5.5.2 +Requires: Qt5Widgets +Libs: -L${srcdir}/bin -lScintillaEdit +Cflags: -include stdint.h -I${srcdir}/qt/ScintillaEdit -I${srcdir}/qt/ScintillaEditBase -I${srcdir}/include -I${srcdir}/src diff --git a/qt-extras/scintillaedit/cflags.go b/qt-extras/scintillaedit/cflags.go new file mode 100644 index 00000000..a162df60 --- /dev/null +++ b/qt-extras/scintillaedit/cflags.go @@ -0,0 +1,8 @@ +package scintillaedit + +/* +#cgo CFLAGS: +#cgo CXXFLAGS: --std=c++1z +#cgo pkg-config: ScintillaEdit +*/ +import "C"