aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/common
Commit message (Collapse)AuthorAgeFilesLines
...
* QtQml: Move binding, object and parser status counts to base CUUlf Hermann2024-01-132-0/+29
| | | | | Change-Id: Id52e3d50b02649010ebcb2309253aa689a536770 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move inlineComponentId() into base CUUlf Hermann2024-01-131-0/+13
| | | | | Change-Id: Icfc234c0354c27f8ff353f49c16c3d99a14e7ea7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move property caches into base CUUlf Hermann2024-01-131-0/+8
| | | | | Change-Id: I1567c9d3d61312e98200fb0854d7fcf111983948 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move ResolvedTypeReference into base CUUlf Hermann2024-01-132-17/+68
| | | | | Change-Id: I25063457aad3a6d29a8c2a5b236f9a51b56a2f51 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move BindingPropertyData into the base CUUlf Hermann2024-01-131-0/+9
| | | | | Change-Id: I2edcb2c324919a1131ae490bee9c9b1140097b09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move inlineComponentData and icRootName into base CUUlf Hermann2024-01-131-3/+28
| | | | | | Change-Id: I89e44644b083681f069d1d7a385bec68b4bfd80b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-111-3/+3
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Get rid of the module mutexUlf Hermann2024-01-102-4/+44
| | | | | | | | | | | | | It only exists so that the type loader can query pre-compiled and native modules from the loader thread. However, the type loader already has a mutex of its own. We can use that to inject a "native" blob into its script cache for the same effect. We need to get rid of the mutex so that we can use the module map for other compilation units, too. Change-Id: I5a9c266ea36b50f5ea69214110def644f7501674 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Always link executable CU on creationUlf Hermann2024-01-102-0/+122
| | | | | | | | | | | | | | | We don't want floating unlinked executable CUs. They should always be tied to an engine, and the engine should not change. This gives us one definite point where to register them with the engine (to be done in subsequent change). Unfortunately, due to the refcounting, we need to remove the engine from any still-referenced CUs when the engine itself is destructed. We will be able to drop the refcounting and make the engine fully own its executable CUs once we can hold base CUs in most places. Change-Id: I9a53e83d5c4746c2b2bca896b51baa4fe7fee757 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Make base CU a member of ExecutableCompilationUnitUlf Hermann2024-01-101-28/+4
| | | | | | | | | | | | We want to re-use the base compilation unit across engines. For that to work it cannot be a slice of the engine-specific ExecutableCompilationUnit. Since CompiledData::CompilationUnit is refcounted on its own now, make it unmovable. Change-Id: I8418c9754d7a07e5210c1e7a7fc69355e1d57807 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move engine-specific data out of base compilation unitUlf Hermann2024-01-081-55/+9
| | | | | | | | | | We want to re-use the base compilation unit for different engines. To do that, we cannot have data in there that belongs to a specific engine. Pick-to: 6.7 Task-number: QTBUG-120189 Change-Id: I8e43e7ec6c1cd33249dc4ed15fec16babc6d06fb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add pragma syntax to support translation contextLucie Gérard2023-10-261-1/+15
| | | | | | | | | | | | | Translator pragma can be used to set the translation context instead of having the file name used [ChangeLog][qml][translation][Important Behavior Changes] The context for the translation can now be controled in a given file using pragma Translator. Task-number: QTBUG-114528 Change-Id: I6d9d7fb81ea969a90d8637d7277bdbe96c102088 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix compile time qsTranslate with empty contextUlf Hermann2023-10-241-1/+2
| | | | | | | | | | | | | | | | | An empty context is to be passed as-is. We shall not replace it with the file context context. Since the TranslationData struct has a field for the context, we need to invent a "no context" value we use for the methods that don't allow you to set a context (e.g. qsTr, qsTrId). We cannot use 0 because that is the empty string which is a valid context now. Amends commit 9cfc19faf5d1ce2b9626914ab4528998b072385d. Pick-to: 6.6 6.5 Fixes: QTBUG-118469 Change-Id: I160c512f42aba4a8ae2fc8860cdf4e50c53d9d3e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Prevent MSVC 2019 min()/max() macros from triggeringOlivier De Cannière2023-10-161-4/+4
| | | | | | | | | | | | | windows.h defines the min() and max() macros. These get applied when trying to call std::numeric_limits<int>::min(). Add parentheses around the function before its invocation to break the macro. Amends: 9df4293adf7d019b4d3ccaaa2f5d87ddfe0b041b Fixes: QTBUG-118132 Pick-to: 6.6 Change-Id: I96039cd714b042d880bcff6c9163cbeb76fe2f80 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlProperty: Accept badly capitalized signal handler namesUlf Hermann2023-09-052-0/+22
| | | | | | | | | ... but warn about them. Apparently we did accept them prior to 6.4. Fixes: QTBUG-116576 Pick-to: 6.5 6.6 Change-Id: If890db85f5a8d71c0bcdfaf646ee9f01765a0b3c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlSignalNames: Optimize a bitUlf Hermann2023-09-041-26/+32
| | | | | | | | | | | | | We don't have to repeat the strlen("on") and strlen("Changed") because we can phrase them as constexpr statics. The same holds for the actual strings. We can store them as latin-1 so that we don't have to construct temporary QStrings. When calculating the signal name from the handler name, we don't have to check the signal name length twice. And finally, we can reserve() the QString to return when creating a handler name. Change-Id: Ied0c33638d9e72df6360dd04b3f517d72beca21b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Replace signal name manipulations with QQmlSignalNamesSami Shalayel2023-08-152-10/+29
| | | | | | | | | | | | | | | Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: check user-supplied names on renamingSami Shalayel2023-08-102-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the checking of user-supplied names for renaming operations in QmlLSUtils and qqmlrenamesymbolsupport.cpp Add a helper method QQmlLSUtils::isValidEcmaScriptIdentifier that runs the lexer on an identifier. Reject identifiers that do not parse as T_IDENTIFIER, like keywords and invalid unicode escapes, for example. Extend QQmlLSUtilsExpressionType to contain the name of the current object. Drive-by change: fix a off-by-one bug in the lexer, where files (or identifiers, in this case) could not be lexed when they were ending with an unicode-sequence. Also, do not crash on JSIdentifiers without semantic scope in resolveIdentifierExpressionType. Add some tests, and fix a warning about positionAfterOneIndent not being used in tst_qmlls_modules.cpp. Add QQmlLSUtils::isChangedSignalName next to QQmlLSUtils::isChangedHandlerName, and QQmlLSUtils::isHandlerName and add tests for all three. Fixes: QTBUG-114951 Task-number: QTBUG-114788 Change-Id: I0f1a544b70dfb69bca4aef355a8a8658f1d23081 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* UndefinedBehavior: fix some things found with -sanitize undefinedOlivier De Cannière2023-08-013-6/+46
| | | | | | | | | | | | | | | | | | Here are the sorts of things that were found: - Uninitialized variables containing garbage. - Calling member function through nullptr (where this is not actually used inside the function because that would trigger a segfault). - static_cast'ing double to int where the double is either +/-infinity or is outside the range of min and max values for int. Additionally, the uses of QJSNumberCoercion::isInteger() in the code generator have been replaced by QJSNumberCoercion::isArrayIndex() and the former was deprecated as it is no longer being used. Pick-to: 6.5 6.6 Change-Id: I9318671ccbda37e5519f4fcb84a1537585c2103f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlSignalNames: Add implementation for signal name manipulationsSami Shalayel2023-07-212-0/+256
| | | | | | | | | | | | | | | | Add a set of static helper methods in src/qml/common/qqmlsignalnames{_p.h,.cpp} to do signal name manipulations (from signal to signal handler name and back, from property to property changed signal to property changed handler and back). Add tests in tst_qml_common for the helper methods. ToDo in following commit: replace all implementations of signal name manipulations out there with the helpers introduced in this commit. Change-Id: I8e606375839d9eda673da121a60484c5d211f4a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJs::MemoryPool: fix potential UB (pointer overflow)Marc Mutz2023-06-271-6/+4
| | | | | | | | | | | | | | | | A check like (p1 + s op p2) is dangerous, because p1 + s may overflow, and that would be UB, so the compiler can assume it doesn't happen and break the check. Reformulate the expression by subtracting p1 from both sides. Cast the ptrdiff_t to size_t to avoid -Wsign-compare. This is safe because _end is always ≥ _ptr. As a drive-by, remove extra parentheses. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: If240d685fe48196ab5ceb7ff39736b73c8997e30 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Revert the default for enforcing function signaturesUlf Hermann2023-06-261-1/+1
| | | | | | | | | [ChangeLog][QtQml][Important Behavior Changes] Type annotations on function signatures are now enforced, no matter if the code in question is interpreted, JIT-compiled, or AOT-compiled. Previously, only AOT-compiled code enforced the signatures. Therefore you could produce divergent behavior by passing or returning values that violated the type annotations. Fixes: QTBUG-113527 Fixes: QTBUG-109221 Change-Id: Ie573b31f35813db37b75189e747c764d1b9bbe78 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Undeprecate AOTCompiledFunctionUlf Hermann2023-05-231-3/+3
| | | | | | | We're going to call the JavaScript-typed functions a different name. Change-Id: If92c3fb1b16b1b0bd7d009e7dd712ae6405e1232 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Discern between named builtins and optimizations for common typesUlf Hermann2023-05-161-36/+53
| | | | | | | | | The named builtins include void and regexp. The optimizations for other types are useful, but should be a separate enum. Change-Id: I06220cf4a6d3449deca89a26c4f5db0e41d32765 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace {add,sub,mul}_overload with q{Add,Sub,Mul}OverloadMarc Mutz2023-05-111-1/+1
| | | | | | | | | | | | | | | | | | These APIs started out as private APIs in qnumeric_p.h, but have since been made pseudo-public in qnumeric.h. The qnumeric_p.h versions just forward to the qnumeric.h ones, so just use the latter. This is in preparation of removing the {add,sub,mul}_overflow versions, which, despite being defined in the unnamed namespace, don't sport the q prefix, so potentially clash with global symbols. The change is a simple textual search and replace. Picking to 6.5 to avoid cherry-pick conflicts going forward. Pick-to: 6.5 Change-Id: I2525619c14cb8eeadd08e2fa6c35968bcedd5171 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Silence signed vs unsigned warning on 32 bit VS 2022 debug buildJøger Hansegård2023-05-071-1/+1
| | | | | | | | | | | | | | The warning C4018: '<': signed/unsigned mismatch appears in a Q_ASSERT when checking a lookup index against the size of the container. Fixed by changing from unsigned to signed type for the index. Since the index is already implicitly converted to signed type when used, we can use a signed type from the start. We rely on implicit conversion from unsigned instead of static_cast to not hide other warnings in the future. Change-Id: I2b1983bdd40104e2c7135eec849a198ac074517c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtQml: Improve handling of CU's sourceFileIndexUlf Hermann2023-03-281-6/+9
| | | | | | | | | | | | | | In the unlikely case that we get a corrupted CU from a cache file and it still passes the header verification we don't want it to access invalid memory when checking the file name. We also generally want to use uint as index into the string table. A signed integer makes no sense here. Pick-to: 6.5 Coverity-Id: 310389 Change-Id: I12e9b8f39e1d3c68fd701c1ef4f54845ab8c3c12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Insert aliases in inline components when loading from disk cacheUlf Hermann2023-03-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far we did not completely restore aliases in inline components. This was masked by the fact that until recently we failed to load inline components from the disk cache and always loaded them from source instead. To fix this, refactor QQmlComponentAndAliasResolver to work for both, QmlIR and QV4::CompiledData. With QmlIR, it populates the relevant data structures. With QV4::CompiledData, it sanity-checks them. The sanity-checks do incur some overhead, but given recent events, we should err on the side of caution here. Since QQmlComponentAndAliasResolver has received all the fixes we've applied to make inline components work, this should lead to inline components loaded from cache files to work the same way as those compiled from source. In turn, we can drop some methods of QQmlPropertyCacheAliasCreator. Amends commit 131db085a752469e8f19974c2edb3a138d900249 Pick-to: 6.5 Fixes: QTBUG-111766 Fixes: QTBUG-111857 Change-Id: I9cc75e700a5fe5810a866e9aa930b9811368b1b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add an "Addressable" value to ValueTypeBehaviorUlf Hermann2023-03-021-0/+1
| | | | | | | Task-number: QTBUG-94807 Change-Id: I8c78faa99fc4c4b2ffd8c89f1037fc7569212c73 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Add a pragma for value type behaviorUlf Hermann2023-01-201-0/+1
| | | | | | | | | | | Unfortunately value types behave differently when compiled to C++. Document the difference and introduce a pragma to make them behave one way or the other. Pick-to: 6.5 Fixes: QTBUG-109221 Change-Id: Ib2685153c0b4ae209bafbea7a01229377fdb47dd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Do not shift heap pointer bits on arm64 AndroidUlf Hermann2023-01-171-2/+7
| | | | | | | | | | | | | | Memory obtained via mmap() is not subject to heap pointer tagging. We don't need to impose the overhead of shifting the bits around. Amends commit c7722d4ed61d6a887e9f6c403ffa10b2048de2a4. Pick-to: 6.5 Task-number: QTBUG-101686 Task-number: QTBUG-91150 Change-Id: I45dc291c5a1208dd747199f00f819e475d5c0aec Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-121-148/+340
| | | | | | | | | | | | | | | | | | On android and on some other platforms, the upper bits of a pointer are significant. We need to store them in our JS value encoding. Shift the bits around to make this happen. We now can store pointers of up to 57 bits. That's enough for everything we've seen so far. Fixes: QTBUG-101686 Fixes: QTBUG-91150 Pick-to: 6.5 Change-Id: I72e0fe63b27fca94840f82963e4d3936b3581b28 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QObjectWrapper: Fix calling attached methods on different objectsUlf Hermann2023-01-021-0/+1
| | | | | | | | | | | | | You can generally store a method in a value and call it on a different object. However, since we've ignored the thisObject basically forever, we cannot just accept it right away. Add an opt-in mechanism via a pragma that allows you to pass (implicitly via context or explicitly via call()) specific thisObjects to QObject methods. Fixes: QTBUG-109585 Pick-to: 6.5 Change-Id: I4c81b8ecf6317af55104ac9ebb62d98862ff24e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix recognition of builtin list typesUlf Hermann2022-12-151-5/+20
| | | | | | | | | | | | | Previously all list types used as arguments or return types for methods had to be looked up via the imports. However, builtin types are not part of the imports at run time. Therefore, recognize list types already early on, when generating the IR. This is the same way we do it for property types and it allows us to easily identify lists of builtins. Pick-to: 6.5 Fixes: QTBUG-109147 Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: silence -Wextra-semiTim Blechmann2022-11-161-2/+2
| | | | | | | | | silence gcc's -Wextra-semi. the private headers are pulled in via the type compiler Pick-to: 6.4 Change-Id: I5291d007c379f522c2dae9d814c4f4cc6a7d118a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Bump QV4_DATA_STRUCTURE_VERSION after dropping CallElementUlf Hermann2022-11-081-1/+1
| | | | | | | | | | All the instruction numbers have changed. Amends commit 872e91612fd83de6dd1193014b5e2a0f5e8c30af. Task-number: QTBUG-106708 Change-Id: Icd448dd8891edb6e9e8ab9bf0234c0ee0126b86f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Avoid -Wshorten-64-to-32 warnings in a few placesFabian Kosmale2022-10-312-2/+4
| | | | | | | | | | ...by explictily casting to int. Add a few comments explaining why we can get at most INT_MAX many elements, and add Q_ASSERTS to check that the assumptions actually hold. Task-number: QTBUG-105055 Change-Id: I1769318a9c04b51efe45fe0cae9fc0d93cfec45e 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>
* Add option to enforce function signaturesUlf Hermann2022-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | By default, the QML engine does not enforce signatures given as type annotations to functions. By passing different types than the function declares, you can get different behavior between the interpreter/JIT and the AOT-compiled code. In addition, in interpreted or JIT'ed mode, we pass all non-primitive value types as references. This means, if you modify them within the called function, the modifications are propagated back to the place where the value was loaded from. Enforcing the signature prevents all of this, at a run time cost. Since we have to coerce all arguments to the desired types, the function call overhead grows. This change introduces a pragma "FunctionSignatureBehavior" which you can set to "Ignored" or "Enforced" to choose one way or the other as universal way of handling type annotations. Fixes: QTBUG-106819 Change-Id: I50e9b2bd6702907da44974cd9e05b48a96bb609e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Track the statement indices together with line numbersUlf Hermann2022-10-131-13/+33
| | | | | | | | | | We will need the statement indices when tracking value type references. New value type references shall only be written back in the same statement they were created in. Task-number: QTBUG-99766 Change-Id: I83f908df034e7da8ba46ccacaa29bd9d78020d20 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-131-2/+2
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlTranslation: Use std::nullptr_t rather than std::monostateUlf Hermann2022-10-112-5/+8
| | | | | | | | | | | | Wrapping a std::monostate into a std::variant gives the static analyzer all kinds of headaches. std::nullptr_t should have the same effect without the interesting special cases. Coverity-Id: 401041 Coverity-Id: 401042 Coverity-Id: 401046 Change-Id: I786aefbe0392b5f961c99d7de8bd592bdf591143 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-074-6/+6
| | | | | | | | | | | | | | | | | | | | 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>
* V4: Use an enum to categorize functions and rename aotFunctionUlf Hermann2022-09-291-3/+3
| | | | | | | | We want to use the aotFunction member also for typed JavaScript functions. Change-Id: Iad6d12ebed3ad3069832484137ed8e4d9e7a7cf4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Optimize QObject method callsUlf Hermann2022-09-201-6/+15
| | | | | | | | | | | | | | | | | | | | | | So far, for each method call we had to allocate a new QObjectMethod as we didn't have any lookup to cache the methods. Introduce a new lookup for that and use it for all QObject methods. Since QObjectMethod contains a pointer to the concrete QObject the method was retrieved from, some more care has to be taken: If we are going to call the method right away, we don't need the object since we always have a thisObject and any further retrieval of the same method will result in a call again. This enables us to cache the method for any instance of the same class. When storing the method elsewhere, though, we need to hold on to the object since you can defer the call or connect a handler to a signal or similar. For such operations we do need the object. We can still optimize a bit by re-using the method cache we build the first time around. Fixes: QTBUG-95628 Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: translation binding supportSami Shalayel2022-08-252-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Implement and test support for translation bindings in qmltc: * qsTr() * QT_TR_NOOP() * qsTrId() * QT_TRID_NOOP() Not compiled by qmltc, but instead interpreted as script bindings: * combinations like qsTr(qsTr()) * qsTranslate() (as in qmlsc) * QT_TRANSLATE_NOOP() (as in qmlsc) Add the *.qm files directly to the resources as qt_add_translations() is not available from qtdeclarative (the cmake function lives in qttools that depends on qtdeclarative). Fixes: QTBUG-104637 Task-Id: QTBUG-105346 Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-152-0/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmltypecompiler: align runtime function table order to qmlcachegenAndrei Golubev2022-07-221-1/+1
| | | | | | | | | | | | | | | | When we write runtime functions to compilation unit at run time, the order of the functions in the unit (often) differs from the order of functions in the unit produced ahead of time by qmlcachegen and friends. Additionally, the order also differs from what qmltc expects (and qmlcompiler library in general) Fix the order by simplifying the procedure of JS code generation when we create the compilation unit at run time: new logic just goes over the objects in the document linearly, instead of relying on bindings (which are known to be out of order w.r.t. AST) Change-Id: I4070b9d061f03c4c76d03120654ad3f30725493a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Move idIndex into bitfield union of AliasUlf Hermann2022-06-201-10/+18
| | | | | | | | | | | Since we can now add a member that covers the whole storage, we can clean this up a bit. Change-Id: I707f1f3706d68a073d4b0f4937c352bd3df34335 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1111-418/+22
| | | | | | | | | | | | 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>