summaryrefslogtreecommitdiff
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* Move ScopedStackFrame into qv4stackframe_p.hUlf Hermann2023-05-1712-122/+144
| | | | | | | | | | | This is where it belongs. We need to apply some tricks to avoid cyclic includes, but that's better than what we have so far. Also, sort and clean up the includes in the affected files. Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* V4: Discern between named builtins and optimizations for common typesUlf Hermann2023-05-162-14/+15
| | | | | | | | | 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-112-4/+4
| | | | | | | | | | | | | | | | | | 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>
* QML: Maintain invariant between QObjectMethod membersUlf Hermann2023-05-111-3/+19
| | | | | | | | | | | | | | | If the methodCount is 0, the methods have to be nullptr. Otherwise they have to point to the actual method(s). This is important for the method resolution to work correctly. In particular when cloning a method we have to check for 0. Amends commit 17bd07cbc5b6cf54716e991765ab3088a710d7b3. Pick-to: 6.5 Fixes: QTBUG-113484 Change-Id: Ic31d6e391c1d74a162820232f242a19379f5e4df Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Properly support lists as method argumentsUlf Hermann2023-05-091-0/+5
| | | | | | | | | | | a, Teach QV4::QObjectWrapper how to convert QQmlListProperty to QObjectList. b, Parse the isList attribute from qmltypes. c, Resolve lists when resolving QQmlJSScope. Change-Id: I70c6d40507de990b45a87eb7d8c7bba279d550e8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Encode "missing" line number as negated address of stack frameUlf Hermann2023-05-094-6/+17
| | | | | | | | | | | | | | | This way we can identify which entry in a stack frame to amend when processing an exception in generated code. However, negative line numbers are also used to signal the position of "Ret" instructions. Since you cannot throw an exception from a "Ret" instruction, those cannot collide, but we cannot qAbs() the line number anymore when saving it in the stack trace. We have to qAbs() it in all the places where it's read. Pick-to: 6.5 Fixes: QTBUG-112946 Change-Id: I24dc4008fb7eab38e4d24e70211c22e46f1b72a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Allow conversion from QV4::Sequence to different iterableUlf Hermann2023-05-091-11/+21
| | | | | | | Pick-to: 6.5 Fixes: QTBUG-112291 Change-Id: Idd47ea8daf9c54759af6c1feba68bd52d1163615 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Don't try to convert objects with prototypes to QVariantUlf Hermann2023-05-091-4/+4
| | | | | | | | | This is likely to lose some properties. Pick-to: 6.5 Fixes: QTBUG-106266 Change-Id: Ib5a2567d61635a5cf7b3abee7cfef0c073d59e63 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Don't crash when monitoring binding removalUlf Hermann2023-05-051-7/+19
| | | | | | | | There are more bindings kinds around. Fixes: QTBUG-113353 Change-Id: If545f56bd61c238431883be3eb013841d96b18bb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Runtime codegen: Avoid memset for zeroingFabian Kosmale2023-05-041-12/+8
| | | | | | | | | We can just use calloc and zero-initialization. Change-Id: I88dc79d5b880253655159ae3b4385b9792a18ec6 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Fix call frame conversion for QVariant return typesUlf Hermann2023-05-041-0/+11
| | | | | | | | | | | The function may return a QVariant in place of the actual type because it cannot express the actual type as-is. This case needs special care because QMetaType::convert() doesn't know what to do with it. Pick-to: 6.5 Fixes: QTBUG-112837 Change-Id: Ibf93a28aa6a60d49c5ab63fa7eed5f5a8e58e163 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Relax shadowing checkUlf Hermann2023-05-023-11/+93
| | | | | | | | | | | | | | | | | If we detect a property or method as potentially shadowed, we don't have to abandon all hope. We can still retrieve it as untyped var. Since there are a number of things we can do with untyped var, this may still be useful. In the same sense, we need to treat function calls as untyped when the function in question can be shadowed. Calling functions with var arguments and return types leads to some more interesting situations in the call frame setup, so we fix that, too. Task-number: QTBUG-112480 Change-Id: I238d1cf04951f390c73e14ed9e299f2aa72b68cb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use actual type of enums, rather than intUlf Hermann2023-04-261-0/+1
| | | | | | | | | | Now that the type is available from qmltypes we can just use it. Task-number: QTBUG-112180 Change-Id: I315372da0925f19c209f676226f450863b0d3ea5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Trace: Convert qtdeclarative to use new tracepoint generationAntti Määttä2023-04-261-0/+3
| | | | | | | Pick-to: 6.5 Change-Id: Ieacfa716b657ac221a75cd5a0dd75d5099962e91 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
* Refactor the usage of icutils::NodeAmir Masoud Abdol2023-04-241-1/+1
| | | | | | | | | | | In Unity Build, on OpenSUSE, for some reason compiler confuses the Node with an `int`. This refactoring resolves the issue by moving the type into the `icutils` namespace. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Id379b9aff21b29115d4503791debd658f034a0cd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Allow some more backing types for enumsFabian Kosmale2023-04-123-5/+5
| | | | | | | | | Task-number: QTBUG-112180 Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Change-Id: I48a2a696d3424ab1d8b9e693a92361a978ad70e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QV4: Sequence/ListWrapper: implement virtualGetLengthFabian Kosmale2023-03-312-0/+9
| | | | | | | | | Both types can provide a natural implementation for virtualGetLength, which is much more efficient than going through the base implementation in QV4::Object. Change-Id: Iefc870451e1ad54c6dbfd6f73f6a5ff9b7552871 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Support more integer typesUlf Hermann2023-03-301-1/+1
| | | | | | | | | | | This adds support for 8- and 16-bit signed and unsigned integer types. The test exposes that the engine fails to correctly convert out of range values when assigning to a 32-bit int property. Fix that as drive-by. Fixes: QTBUG-101634 Change-Id: I0a4177f49ffc062a1f444e30424e94c1f293e70c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Improve handling of CU's sourceFileIndexUlf Hermann2023-03-281-4/+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>
* Models: Straighten out model and modelData propertiesUlf Hermann2023-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | If there is more than one role, just return the whole model item as modelData. This makes sure we can always require modelData. That's a basic precondition for writing delegates that work with any model. The test shows that model and modelData behave quite erratically in the different cases, but much of this cannot be changed anymore. At least they are now both available in all cases. Furthermore, provide modelData as anonymous property of model. This way, if you have a model that can be singular, and a role that will be an empty string if the model is singular, you can just write: SomeDelegate { required property var model someData: model[role] } Task-number: QTBUG-111176 Task-number: QTBUG-110980 Task-number: QTBUG-104752 Change-Id: Ie200be467df2098d817b85b03d2409267722b596 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QV4: Fix formatting options for the search component of UrlObjectOlivier De Cannière2023-03-161-1/+4
| | | | | | | | | | | | | | This fix changes the way the search component of UrlObjects is formatted by passing the correct options to QUrl::query. Namely, the EncodeDelimiters flag is no longer set. This now allows for correct encoding of backslashes in search strings. Amends 6cca731f3e1304ce98f1ec18af42e3bd06001eea. Pick-to: 6.5 Task-number: QTBUG-111014 Change-Id: Iee544dfc7ad6ba374601c8ec4690d11bf07c9b6a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Use qsizetype as index for IndexedBuiltinFunctionUlf Hermann2023-03-151-3/+6
| | | | | | | It's primarily an index into the property roles, which is a QList. Change-Id: Ib3f0000166cae87d3ae0a69db971257e71a0f3e8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Insert aliases in inline components when loading from disk cacheUlf Hermann2023-03-151-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Allow as-casting to value typesUlf Hermann2023-03-032-8/+30
| | | | | | | | | | | | | | | | | | | | | | If the "Addressable" option to ValueTypeBehavior is set, you can use the "as" operator to cast a previously unknown type into either undefined or the given type. We can use this in qmlcachegen to generate efficient code for further operations on the same type. In the generated C++ it in fact only works for GetLookup because: a, We generally don't do SetLookup on value types, yet. b, We generally don't call methods on value types, yet. c, We cannot store a union of undefined and a sequence type, yet. However, getting properties of value types is the most important application of the new casts so this is well worth it. As a side effect we can also look up things in potentially undefined results of other operations now. For example list lookups. Task-number: QTBUG-94807 Change-Id: Ifdf34f1f3f67b7a0a8953b9ed0e947b74638a28c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add an "Addressable" value to ValueTypeBehaviorUlf Hermann2023-03-021-0/+5
| | | | | | | 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: Don't unconditionally invalidate cache if inline component is usedFabian Kosmale2023-03-021-1/+12
| | | | | | | | | | | | | | | | With inline components, we might have the case that an outer components depends on an inline component defined in the same file. In that case, the ResolvedType of the inline component has some very specific characteristics we can recognize when adding to the hash. We don't actually have to add such inline components to the hash since they are just part of the same file. If they change, the file will change, leading to a different timestamp, which is caught earlier. Pick-to: 6.5 6.5.0 6.2 Fixes: QTBUG-111042 Change-Id: I8ae716e55dd783cc8409039bd7baffe051df2b96 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid duplicate value type creationUlf Hermann2023-02-242-9/+9
| | | | | | | | | | | We can actually produce an uninitialized but pre-allocated QVariant using QVariant::Private. Using the new in-place construction support in QMetaObject, we can minimize the amount of copying necessary for value types. Fixes: QTBUG-108789 Change-Id: I6b748794a6adbf6558e1e3086eab80fcfb3154a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Set correct `this` value in JSON.stringify replacer scopeIvan Tkachenko2023-02-221-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long story short, JSON.stringify takes optional second argument which can be a replacer function. It is supposed to be called for each encountered key-value during serialization. While replacer's second argument is already serialized (so you could just return it), just in case you are not satisfied with default serialization — the original value is still passed in together with the whole object as a value of JavaScript `this`. Sadly, there is no test in the whole ECMA test suite to catch this bug. This is quite a breaking change for code which already uses Qt-specific workarounds, so it would be better not to cherry-pick it as a hot-fix onto existing (released) branches. Sample use case: serialize dates as a number of seconds since epoch. function replacer(k, v) { if (this[k] instanceof Date) { return Math.floor(this[k].getTime() / 1000.0); } return v; } const str = JSON.stringify(obj, replacer); [ChangeLog][QML][Important Behavior Changes] Set correct `this` value in JSON.stringify replacer scope, so that the value for current key in current object is no longer pre-stringified, and can actually be used to implement custom object serialization logic. Fixes: QTBUG-95324 Pick-to: 6.5 Change-Id: I618a533e8eba7999d5416aca14f4971093a83f7a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Fix clashes with windows.h definesFriedemann Kleint2023-02-221-2/+2
| | | | | | | Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I92d269c1fa66ee2fe903554f17e3207d51d56b60 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Fix coercion of undefined to float and doubleUlf Hermann2023-02-211-0/+6
| | | | | | | | | | | | | | | | It should result in NaN, not in 0. The typedArray() test exposes that ExecutionEngine::toVariant() also gets this wrong. Fix that, too. [ChangeLog][QtQml][Important Behavior Changes] Converting a JavaScript value to a double or float, for example by inserting it into a typed array, now assumes JavaScript type coercion semantics. In particular, converting a value that is not actually a number now results in NaN where it previously sometimes resulted in 0. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111179 Change-Id: If24444ae9014c8972761c565a6920f06699e485c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove misleading dtor of CompilationUnitMapperUlf Hermann2023-02-142-11/+8
| | | | | | | | | | We actually never want to unmap the CU on destruction. Rather, we want to unmap it if on opening we see that it's not static (which shouldn't happen). Task-number: QTBUG-109314 Change-Id: I06825a043a41d50233b32a1d93625ac864d295df Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Invalidate any existing cache files when saving a CU to diskUlf Hermann2023-02-103-2/+20
| | | | | | | | | | Otherwise we just re-load the old cache file next time. That's clearly not intended. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111078 Change-Id: Ia65b46880eca2b6e8c4792a09f20716125beada3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Disambiguate static variables and methodsFriedemann Kleint2023-02-094-10/+11
| | | | | | | | | They cause clashes in CMake Unity (Jumbo) builds. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I0408c01d3e6f0f4dc74904e12a3036a855cc3225 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* UrlObject: Properly encode the url search componentsOlivier De Cannière2023-02-092-3/+12
| | | | | | | | | | | | The href() and search() functions now return properly encoded search components. Tests were added to tst_urlobject.cpp to verify this. Pick-to: 6.5 Fixes: QTBUG-110454 Change-Id: I3d6485eeeedbd5ba5423cdd42d9c17669ca4bd62 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* UrlObject: Fix setting searchParams not modifying the url's search fieldOlivier De Cannière2023-02-092-3/+37
| | | | | | | | | | | | | | Previously, setting the search params via the searchParams.set() method did not change the url's search field. The searchParams object now has a back pointer to the urlObject it belongs to. Whenever a search param is set, the url search field is also updated. The tst_qv4urlobject test was also added to check proper behavior. Pick-to: 6.5 Task-number: QTBUG-110454 Change-Id: I3b0e843395da8a0e5aedcf71895981f68560d9c6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove superfluous Q_DECLARE_METATYPEFabian Kosmale2023-02-081-2/+0
| | | | | | | | | It breaks unity builds, and declaring metatypes outside of the actual class that uses them is generally a bad idea. Pick-to: 6.5 Change-Id: I0106667f6075aabc2fa3c9e5271d21b64f41e4c1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Treat long and ulong like other numbersUlf Hermann2023-02-071-0/+4
| | | | | | | | | | | | They should either be the same size as int/uint or the same size as longlong/ulonglong, but for some reason we get them as separate types. Pick-to: 6.5 Fixes: QTBUG-110767 Change-Id: I4c5826cfe6108e6f9722e6b3443bde13b2141b04 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QML: Fix interceptors on value types ignoring fast changesUlf Hermann2023-01-251-4/+6
| | | | | | | | | | | | | | | | | | | | | | If a property is changed and reverted in short order, any animation attached to it may not get a chance to take effect in between. In such a case it looks like we don't have to update the interceptor when reverting, but we actually have to. The animation needs to be canceled, after all. We now have to fix the case of writing different properties of a value type sequentially, where one has an animation attached to it, though. If that happens, we cannot drop the animation when a _different_ property is written later on, but we do still have to update the whole value type. So, pass an additional argument in the relevant metacalls that declares the property we intended to change. Pick-to: 6.5 Fixes: QTBUG-54860 Change-Id: I3b6cad2d4707d30312cda98283928fd419c40345 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> 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-202-8/+23
| | | | | | | | | | | 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>
* QJSEngine: Fix potential JS stack overflow cauased by spread operatorFabian Kosmale2023-01-191-0/+5
| | | | | | | | | | | | createSpreadArguments could in theory allocate a (nearly) unbounded number of QV4::Values. Avoid this by checking whether we approach jsStackTop. This fixes CVE-2022-43591. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I01aecb979da47b7261688c9f185dc33a50a579a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Add more overloads to Qt.format{Date|Time|DateTime}()Ulf Hermann2023-01-172-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since JavaScript has no concept of time or date separate from the Date object that contains both, and since we implicitly (via QVariant::convert) or explicitly accept string arguments to all these methods, we should really accept string coercions of Date objects. We should also make all the string overloads explicit. Converting strings to QDateTime is a really obscure feature of the metatype system. We should not rely on it. Furthermore, we need to accept QDateTime, as the native representation of the JavaScript Date object, as argument to formatDate() and formatTime(). Otherwise there are two ambiguous paths to calling formatTime() or formatDate() using a Date object: Either coerce the Date into a string and call the string overload or coerce it into a QTime or QDate and call the QTime or QDate overload. The QML engine special cases this and prefers the QTime/QDate way, but this just needlessly complicates the overload resolution. Interestingly, tst_qqmlqt already tests most of those variants. We just have to add the JS string coercions. Task-number: QTBUG-109380 Change-Id: I880e622256fe115dade32bde880605df2031ff2f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* V4: Unify type conversions for date and time valuesUlf Hermann2023-01-173-22/+22
| | | | | | | | | | We should always use the same conversion to string and we shouldn't duplicate the code for the date conversion. Task-number: QTBUG-109380 Change-Id: I1b1959c8e9b5957ddcf287d252b8143511237565 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QJSEngine: Add efficient conversions for QDateTime and friendsUlf Hermann2023-01-172-0/+28
| | | | | | | | | The JavaScript date and time conversions are different from Qt's. Add them to coerceValue. Task-number: QTBUG-109380 Change-Id: Ic0d7dd8ff51fb8e29d80d9084d4415becaa76259 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix multiplicationFabian Kosmale2023-01-171-0/+3
| | | | | | | | | | | Ensure that negative number times positive zero yields negative zero, not positive zero. Do the same adjustment in QJSPrimitiveValue Fixes: QTBUG-104582 Pick-to: 6.5 Change-Id: I8231bfb051b7d902e5e50bbd282410a572b1628a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow extraction of V4 values from QJSPrimitiveValueUlf Hermann2023-01-161-0/+16
| | | | | | | | | | Since we can produce QJSPrimitiveValue in metaTypeFromJS, we should also handle the other direction. Fixes: QTBUG-109867 Pick-to: 6.5 Change-Id: I2c7598d19eba3e78d071ca3eceb32deda4d0ead8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Fix write back of Date valuesUlf Hermann2023-01-174-58/+272
| | | | | | | | | | A JavaScript Date object can be backed by QDate, QTime or QDateTime. Allow those to be written back. Pick-to: 6.5 Fixes: QTBUG-28981 Change-Id: Ic46b5c4daf75453f03e99470933cf179820e63ef Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-126-138/+88
| | | | | | | | | | | | | | | | | | 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 QT_ASCII_CAST_WARNINGMarc Mutz2023-01-031-1/+4
| | | | | | | | | | | | | | | | | The two arguments to QLatin1StringView::arg() are const char* and QByteArray, both of which are considered "ASCII" for the purposes of QT_ASCII_CAST_WARNING. Fix by wrap them in QLatin1StringView (their contents are actually ASCII (class and method names)). Amends 3fd3a2a9d06505d549cc4a7c18819a17c6622dfd. As a drive-by, use the _L1 UDL for the format string. Pick-to: 6.5 Change-Id: I7f83133f52b6f4ec53a2bfcbca58d91afa9e2ff2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObjectWrapper: Fix calling attached methods on different objectsUlf Hermann2023-01-023-50/+155
| | | | | | | | | | | | | 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>
* QtQml: Allow more fine grained control of the disk cacheUlf Hermann2023-01-024-10/+77
| | | | | | | | | You can now enable and disable the AOT-compiled code and the loading and saving of .qmlc files separately. Fixes: QTBUG-101358 Change-Id: I1305c4f2f75d8cff544a127e956589d1ed1aeb52 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>