aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmljsrootgen
Commit message (Collapse)AuthorAgeFilesLines
* Expose XMLHttpRequest to qmltypesFabian Kosmale2025-07-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QML, one can use XMLHttpRequest. Not so with a plain JS engine. The reason for that lies in the fact that a JS engine did not have any network access, because all network functionality was in the type loader, and the type loader was coupled to the QV4::Engine. This has changed in d2bc4a4330254c0c68a0ade51b59a71c4b67b470, but we stil don't expose XMLHttpRequest to a plain QJSEngine. Nevertheless, it conceptually lives in the global object, and we need to collect information about it to enable code completion and linting. Consequently, expose a function in QV4::Engine, which allows us to manually trigger the registration, and call it in qmljsrootgen. Going forward, we should arguably have a QJSEngine::Extension for XMLHttpReuqest, after which we could remove the hack. Note that as before, qmljsrootgen prints a few warnings, because we call functions in contexts in which they must not be called. As before, we ignore this for now. As a side-effect, this adds a few more entries to the qmltypes file for new entries on the global Qt object. Task-number: QTBUG-137075 Pick-to: 6.10 Change-Id: I21e9d62bf075e8d4356db8f357502feb927717e7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Tooling: Use QHash/QMap's constFind() to avoid unnecessary detachesVladimir Belyavsky2024-04-231-4/+4
| | | | | | | | Use QHash/QMap's constFind() instead of non-const find() where applicable to avoid unnecessary detaches. Change-Id: I3906c7ff0601b2b4c336c6e4312319b76fa0c183 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmljsrootgen: port to QCommandLineParserAmanda Hamblin-Trué2023-07-051-5/+14
| | | | | | | Additionally, improved the error message for missing output path. Change-Id: I3885a06157100399c160853b3137dd28aa965c72 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for executablesAlexandru Croitor2022-07-211-1/+1
| | | | | Change-Id: I346ea4eac1dfbfb7fb81609307f5f7c4716bb8d1 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Drop the typed variants of Math methods from jsroot.qmltypesUlf Hermann2022-06-111-28/+0
| | | | | | | | | | | | | They're not needed for the inlining of Math methods in qmlcachegen. qmlcachegen itself detects the Math object and its methods and assumes they shall always deal with numbers. Furthermore, the types in jsroot.qmltypes are actually wrong. Using JS "number" does not help here because we need C++ types. Change-Id: Ibba5c91e8d7ed728c7fe814e43d36b24bb22fcc3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qmllint: Properly handle JavaScript functions with variable argumentsMaximilian Goldstein2021-11-261-0/+1
| | | | | | | | | | | | | Previously calling a JavaScript function with variable arguments could cause the linting process to error out because of a lack of matching function arguments. This is now handled by defaulting to a JavaScript method if no matching function signature can be found. Fixes: QTBUG-98299 Change-Id: I748a60839106243a12bffd8d715b48cbc53d7f57 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Skip unnecessary commands when cross-building toolsJoerg Bornemann2021-10-081-0/+1
| | | | | | | | | | Call qt_internal_return_unless_building_tools() directly after qt_internal_add_tool() to avoid having to special-case code for when this function only creates imported targets in cross-builds. Task-number: QTBUG-85084 Change-Id: I5c8f2ecdf4936cfd15cb530e896bc4e5b5531620 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qmljsrootgen: Try properties on instances if not available on prototypesUlf Hermann2021-10-051-36/+52
| | | | | | | | | This gives us type information for a few extra properties, among which is ArrayBuffer. We also declare ArrayBuffer as extension to QByteArray, which we can now test with qmllint. Change-Id: Ibb3da5e8b8a9e839dc6365fbeabe8418022d1346 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Amend JS root with more precise type informationUlf Hermann2021-10-051-2/+29
| | | | | | | | | Methods on the "Math" object preferably deal with numbers, and if we pass them numbers, they also return numbers. Model this as overrides of the generic methods. Change-Id: I419093630577c371846e5c8ac153f90ed6ffa87e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move tools to libexecKai Köhne2021-05-111-0/+1
| | | | | | | | | | | | | | Move qmlimportscanner, qmltyperegistrar, qmljsrootgen, qmlcachegen to libexec These are internal tools that is not supposed to be run by the user directly. [ChangeLog][Linux] qmlimportscanner, qmltyperegistrar, qmljsrootgen, qmlcachegen tools got moved from QTDIR/bin into QTDIR/libexec directory. Task-number: QTBUG-88791 Change-Id: I2739044e872ec83ef7da7dd857c26395ecfd407d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Rework qmljsrootgenUlf Hermann2021-04-161-160/+241
| | | | | | | | | This way it actually generates interesting data about the JavaScript types, for example the functions of the String prototype. Add a helper method to create a symbol to QJSEngine. This should be generally useful. Change-Id: I6c7b253b9d6cdb61602ceeae0955aed8d942c139 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add qmltypes for JavaScript root objectMaximilian Goldstein2021-03-192-0/+337
This change adds jsroot.qmltypes which represents QJSEngine's global / root object and a tool to generate it (qmlsjrootgen). If you wish to regenerate jsroot.qmltypes run the following commands: qmljsrootgen jsroot.json qmltyperegistrar jsroot.json --generate-qmltypes src/imports/builtins/jsroot.qmltypes --import-name QJSEngine --major-version 1 --minor-version 0 Fixes: QTBUG-90807 Change-Id: I5ba0a048586d2dd945009d65c2b51be8ead85feb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>