aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
Commit message (Collapse)AuthorAgeFilesLines
* Fix build with disable-deprecated-up-to configurationJari Helaakoski14 days1-0/+2
| | | | | Change-Id: I4b2d0e361a2e4fa14c89e1d374bd4244a4b9e0fd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Deprecate QJSValue::isVariantFabian Kosmale2024-03-212-0/+12
| | | | | | | | | | | It returns rather unexpected results, see updated documentation for details. Amends 8704c640946ac852668638e2980d3e2b78aa27ae Pick-to: 6.7 Change-Id: I439ae8dd218aa36fe63ac01953c34e5dff66470d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSEngine: Avoid calling QJSValue::isVariant in qjsvalue_castFabian Kosmale2024-03-211-4/+1
| | | | | | | | | We want to deprecate the function. This will also align the QJSValue overload with the two other overloads we have, and might lead to more conversions succeeding Change-Id: I61aab3568f5dbfc786e54f75036d0b047311cd0c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSEngine: Correctly detect QVariantFabian Kosmale2024-02-081-1/+7
| | | | | | | | | | | | With the introduction of QQmlVarForeign, a QVariant can now be represented as as either a QV4::VariantObject, or as a QQmlValueTypeWrapper wrapping a QVariant. Fix QJSEngine::isVariant to consider the new case, too. Pick-to: 6.7 Fixes: QTBUG-120008 Change-Id: I6aefa64c315b9ed1c7d1e214486f47556ef780fc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-111-1/+1
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add doc for gc()Tasuku Suzuki2024-01-111-1/+5
| | | | | Change-Id: I920acf76846bece462b518239fc4c068a0fad8c1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Always link executable CU on creationUlf Hermann2024-01-101-1/+1
| | | | | | | | | | | | | | | 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>
* Long live incremental garbage collection in QML!Fabian Kosmale2023-12-202-2/+11
| | | | | | | | | | | | | | | | | The design of the garbage collector is described in src/qml/memory/design.md. The gc and gcdone test helpers are adjusted to drive the gc to completion, even when in incremental mode. Parts of tst_qv4mm and tst_qqmlqt need to run with the incremental gc disabled, as they call gc inside QML and assumes that the GC finishes before returning. Initial-patch-by: Rafal Chomentowski <rafal.chomentowski@ge.com> Task-number: QTBUG-119274 Change-Id: I1d94f41bc7a434fad67de0fd46454b6db285f2eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSValue: convert more aggressively to QVariantFabian Kosmale2023-12-191-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Normally, we don't want to convert aggressively between JS objects and QVariant, as that is prone to losing information. However, QJSValue::toVariant is documented to attempt lossy conversions. Restore the behavior of Qt < 6.5.3 for it. This is done by replacing the boolean indicating we should wrap JS objects into QJSValue with an enum instead. That enum introduces a third state ("Aggressive"), which is only used for QJSValue::toVariant. All other users of QJSEngine::toVariant behave as before (post 6.5.3). Function objects are still not converted, as we know that this would be a futile attempt, and more importantly, to keep the behavior that existed before Qt 6.5.3. Amends 43077556550c6b17226a7d393ec844b605c9c678 which introduced the regression and afe96c4d633146df477012975824b8ab65034239 which fixed the issue only partially. Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-119963 Change-Id: I07d9901437812579ac5b873a4dff4de60c8f617e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QJSValue: document that isUrl only returns true for JS URL objectsVolker Hilsheimer2023-12-181-1/+4
| | | | | | | | | | | | It does not return true for a QJSValue that carries a QVariant with a QUrl. However, on the C++ side the caller will want the URL value anyway as a QUrl, and in both cases, going through the QVariant works for that. Fixes: QTBUG-119794 Pick-to: 6.7 6.6 6.5 Change-Id: I90fd4a1a27d4dd4758b1060205ce2aeec730eb72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix \fn template arguments for Qt QmlLuca Di Sera2023-11-301-1/+1
| | | | | | | | | Upcoming changes to QDoc require accurate definition for template arguments in \fn commands. Task-number: QTBUG-118080 Change-Id: Ic61ecace84913f5059fbec21371455741b1bfafe Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QJSEngine: use delegating ctorFabian Kosmale2023-11-221-4/+1
| | | | | Change-Id: Iebb3444a523a5b8bcd3066580968f9d0dccfea87 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML Debugger: Don't crash when looking up values from imported modulesUlf Hermann2023-10-241-2/+5
| | | | | | | | | | We cannot look up the imports from other modules because those are stored in the CU. But we can avoid the crash. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-117479 Change-Id: Ib5660c94dfb7ed20baedf7f71b2f175e6be042b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Implement GetIterator and IteratorNextUlf Hermann2023-09-211-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | Each GetIterator generates * A unique iterator variable that keeps track of the current index * In the case of for...of a copy of reference to the list being iterated The result register holds a pointer to the unique iterator so that it can be loaded and stored without resetting it. In order to do anything meaningful with iterators (in the tests) we also need to allow LoadElement with our "optional" types. That is a conversion of undefined and some other type to QVariant or QJSPrimitiveValue. This follows the same pattern as the other "optional"s we already have. For...of is currently not testable because it requires exception handlers. The tests will be added once we get exception handlers. Task-number: QTBUG-116725 Change-Id: I167fe16b983dc34bf86e1840dfcbf2bf682eecc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qml: replace fromLatin with _L1Anton Kudryavtsev2023-09-151-1/+1
| | | | | | | to improve readability and reduce allocations Change-Id: I1ffe10d6a14fb9cc09dd438cca84f4a1d74b8cb8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix undocumented parameters and broken linksTopi Reinio2023-09-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/qml/jsapi/qjsengine.cpp: (qdoc) warning: Can't link to 'qvariant_cast()' * src/quick/items/qquickrhiitem.cpp: (qdoc) warning: Undocumented parameter 'item' in QQuickRhiItemRenderer::synchronize() (qdoc) warning: Can't link to 'msaaColorBuffer()' (qdoc) warning: Can't link to 'resolveTexture()' * src/quick/scenegraph/util/qsgtextnode.cpp: (qdoc) warning: No such enum item 'Text.NativeRendering' in QSGTextNode::RenderType (qdoc) warning: Undocumented parameter 'color' in QSGTextNode::setColor() (qdoc) warning: Undocumented parameter 'color' in QSGTextNode::setSelectionColor() (qdoc) warning: Undocumented parameter 'viewport' in QSGTextNode::setViewport() * examples/quick/rendercontrol/rendercontrol_rhi/doc/src/ rendercontrol_rhi.qdoc: (qdoc) warning: Can't link to 'QWidget-based' (qdoc) warning: Can't link to 'QAnimationDriver' Mark all documentation modules in qtdeclarative as free of warnings. Change-Id: I97cc059701c351b53cdeeb5fc2feff923c5a76a8 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QmlCompiler: Allow coercing date values to numbersUlf Hermann2023-08-252-0/+12
| | | | | | | | | This is the equivalent of JavaScript's valueOf(). Change-Id: If850519d6dbc7354b447acb6aad8ac04211d059d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Allow construction of Array objectsUlf Hermann2023-08-221-0/+19
| | | | | | | | | | Currently, only the constructor form of the Array function is compiled. We only compile construction of Array objects if we can determine that they are immediately assigned to a typed list. Consequently, we don't have to deal with sparse arrays. Change-Id: I2abd15139eb9a0d530ad49df7313b8dba415ae77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSPrimitiveValue: Fix unreachable-return declarationsUlf Hermann2023-08-161-24/+24
| | | | | | | | | | | MSVC complains about return after Q_UNREACHABLE. We have to use Q_UNREACHABLE_RETURN to avoid it. The workaround for gcc8 can stay as it is. Change-Id: Ia58cba2cf6441572f2ef5a0b64b68b3ab49146f7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QJSEngine::evaluate: Cross-reference QQmlExpressionFabian Kosmale2023-08-151-0/+5
| | | | | | | | | QJSEngine::evaluate is meant for plain JavaScript; guide readers wanting to use it with QML to the correct place. Pick-to: 6.2 6.5 6.6 Change-Id: If8016a4cca2999d95bac47e83159b1e10eb5a0d5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSPrimitiveValue: use Q_UNREACHABLE_RETURN in switch statementsOlivier De Cannière2023-08-111-5/+21
| | | | | | | | | | | | | | | | | | | This patch deals with compiler misbehavior for GCC and MSVC around unreachable return statements in QJSPrimitiveValue. They warn that some code is unreachable or instead that no return statement is present. The solution is to use Q_UNREACHABLE_RETURN. However, GCC 8.x does not treat __builtin_unreachable() as constexpr thus for constexpr functions, a slightly different pattern is needed. See fc7676769251a27cbbc6d40d68f04bfe38511a5b for the introduction of Q_UNREACHABLE_RETURN(). See 6987aab2ab33e9d6d0a01cd04c9c3f8822baa95f in qtbase for the change fixing the issue with Q_UNREACHABLE_RETURN() for MSVC. Change-Id: Ia015a33cad4e35fe511600b005ae6114d5dccc58 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Apply Q_UNREACHABLE-in-constexpr workaround for GCC 8 (QNX)Marc Mutz2023-06-291-4/+24
| | | | | | | | | | | Copied the work-around from QAtomicScopedValueRollback. Amends 53998de985710b5ef5f1a8eddd4550a29841f347. Fixes: QTBUG-114808 Pick-to: 6.6 Change-Id: I08c5a76ed8328628569e854679462dd3b229e1eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Small improvements for ~QQmlEngine, ~QJSEngineKai Köhne2023-06-201-1/+1
| | | | | | Pick-to: 6.5 6.6 Change-Id: I31bfa44ee2a026c2ab0dbdbbd9c349937f2662b2 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* QML: Allow conversion of symbols to QVariantUlf Hermann2023-06-201-1/+2
| | | | | | | | | | | We produce their descriptiveString or simply a QVariant containing a QJSValue, depending on whether we're supposed to convert objects without equivalent C++ type or not. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-113854 Change-Id: I22b6038c936d860fdd8aa227f9dfe704e3265a77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSPrimitiveValue: Drop superfluous constUlf Hermann2023-06-131-1/+1
| | | | | | Pick-to: 6.6 Change-Id: I74cee624b60f97d91e5901691f0b633fec07db9a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add warning comment to qjslist.hUlf Hermann2023-06-131-0/+12
| | | | | | | | | It's only meant to be used by generated code, but for that usage it will be kept compatible. Pick-to: 6.6 Change-Id: I12e4fe6dcd19130e226f80f1b130ab6daa6d90c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Improve argument construction in generated codeUlf Hermann2023-05-112-0/+38
| | | | | | | | | | | | | We don't have to pass types that don't fit if we actually have the correct types in suitable wrappers. This still invokes the internal conversions of the call frame setup if we call with really generic types, for example if the same value is read multiple times with different target types. However, that is acceptable. Fixes: QTBUG-113465 Change-Id: I8ec4afeb39bbe6585e5268c0e9b0cfd2788d761a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Encode "missing" line number as negated address of stack frameUlf Hermann2023-05-091-1/+1
| | | | | | | | | | | | | | | 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>
* QmlCompiler: Inline some array methodsUlf Hermann2023-04-282-0/+300
| | | | | | | | | | | So far we can only deal with methods that don't change the source array and don't use iterators or functions as parameters. We also omit concat() for now. However, indexOf(), lastIndexOf(), includes(), join(), slice() and toString() are possible already now. Task-number: QTBUG-112722 Change-Id: Id19c74e8ad25af876bc954c040c767823b7e3259 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: Fix some conversionsUlf Hermann2023-03-231-2/+11
| | | | | | | | | | | | | | | | The optimization for object-to-string conversion would never trigger because we were checking the wrong metatype for the PointerToQObject flag. Furthermore, we can provide a very simple optimization for the case when we just want a QObject*. Finally, if we have both types, we can use is_base_of_v to optimize cases where we are converting to a base class. Pick-to: 6.5 Task-number: QTBUG-111986 Change-Id: I731fe0398730a2a83222d8c2fdff8aa3d21f7aec Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Fix QJSPrimitiveValue::to() \fn signatureTopi Reinio2023-03-201-2/+3
| | | | | | | | And add \since information. Change-Id: I3634a3b2dbc48e63fac4810cfc0c1a5137e925db Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QJSPrimitiveValue: Add data(), metaType() and a generic coercion methodUlf Hermann2023-03-172-0/+111
| | | | | | | This allows us to do some more specialized lookups in QmlCompiler. Change-Id: I7947c8e7bccfa57aee949b080a531a88fd47c8af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: scope the results of fromData() and fromVariant()Ulf Hermann2023-03-071-2/+7
| | | | | | | | Otherwise the gc might collect them while we're still operating on them. Pick-to: 6.2 6.5 Change-Id: I4644ff7b4b1221f3e58832a245d71215e77bd891 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Remove duplicate words (typos)Andreas Eliasson2023-03-071-2/+2
| | | | | | Pick-to: 6.5 6.4 6.2 Change-Id: Ibd29739b894598e5d7837ed5f9150e08ca07fa35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QML: Treat long and ulong like other numbersUlf Hermann2023-02-071-0/+6
| | | | | | | | | | | | 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>
* QJSEngine: Move old convertV2 to removed_api.cppUlf Hermann2023-01-312-8/+1
| | | | | | Pick-to: 6.5 Change-Id: I7f700d64694c8651769841a0109d32e8f9a839b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSPrimitiveValue: Use operator symbol in lieu of nameFabian Kosmale2023-01-251-1/+1
| | | | | | | Fixes: QTBUG-110585 Pick-to: 6.5 Change-Id: I6acd1ea2a171bd5978bed752f52b8af262936cc2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix minor API problemsUlf Hermann2023-01-182-23/+8
| | | | | | | | | | | Add explicit where appropriate, and use more elegant constructs in inline functions. Introduce removed_api.cpp for QJSEngine::create(int, const void *). Pick-to: 6.5 Change-Id: Ie54b0494fe3c5567f8a5ca361c3a583de3d97dd5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QJSEngine: Add efficient conversions for QDateTime and friendsUlf Hermann2023-01-172-3/+50
| | | | | | | | | 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-1/+5
| | | | | | | | | | | 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/+3
| | | | | | | | | | 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>
* QJSEngine: fix typoUlf Hermann2023-01-171-1/+1
| | | | | | | | Amends commit 0925c51c5988bee7ee96944de2d857b2132ebe65. Pick-to: 6.5 Change-Id: Ia0a42cd32813659a6e3d431e83506e82fac188bd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-122-111/+270
| | | | | | | | | | | | | | | | | | 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>
* QJSEngine: Document new conversion functionsUlf Hermann2023-01-031-6/+38
| | | | | | | | | ... and drop the notes about QMetaType<T>. You can get a metatype for any type these days. Pick-to: 6.5 Change-Id: Iaae53830dfb9cbe81975c3f73cf6cbe33494884a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: Add QJSPrimitiveValue conversionsUlf Hermann2022-12-153-0/+99
| | | | | | | | | | | | We need those in order to get correct results when using the more generic conversions with QJSPrimitiveValue as source or target. Without those extra methods, we frequently get garbage where it would be possible to construct a QJSPrimitiveValue. Pick-to: 6.5 Task-number: QTBUG-109111 Change-Id: I6ceb2a4ed73dae228dd2e5690cd608c58537b95f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix wrapping of numbers in QJSPrimitiveValueUlf Hermann2022-12-151-14/+1
| | | | | | | | | | | | | | | | | | We need to explicitly cast to double if we are wrapping a number type that's not natively accepted by the ctors. As a side effect, correctly run conversions from generic QVariant to QJSPrimitiveValue through the engine now. For that we need another clause in metaTypeFromJS(). Since we are calling methods that return list types in the test, we need to add another clause that converts JS arrays to list types. Otherwise we cannot run that test in interpreted mode. Pick-to: 6.5 6.2 6.4 6.4.2 Task-number: QTBUG-109111 Change-Id: I87f7aafd24371d2c1ffe85569e1f2cd3a1979742 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: Optimize conversion from QObject* to QStringUlf Hermann2022-11-222-0/+19
| | | | | | | | | | | | | | | This is commonly done for logging. With this in place we can have the code generator use coerceType() for such constructs. [ChangeLog][QML][Important Behavior Changes] You can implement custom toString() methods for your QML objects in JavaScript or in C++. Those methods don't actually have to return a string. Previously, whatever return value the method generated was forwarded as-is. Now it is coerced to a string. Change-Id: I4a9721a6948be0c24a36b31d453a74bd747db729 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QJSEngine: Mark convertV2 variant with int parameter as BC-onlyUlf Hermann2022-11-162-1/+5
| | | | | | | We won't need it anymore in Qt7. Change-Id: Iff8bfd5192d80d7603aaa66da8cb00ab23e60f99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: Provide a method to coerce values in JS fashionUlf Hermann2022-11-152-9/+95
| | | | | | | | | | | JavaScript has its own type coercion rules. We already have a methods that coerce QVariants, QJSValues and QJSManagedValues to specific types. The new method is a generalization of all of those and can coerce everything to everything (as far as JavaScript can). Change-Id: I9b6877fb40f67b6f2354781bbd4cf18cf996c7b0 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: add section to QJSValue about converting to JSONMitch Curtis2022-10-261-0/+10
| | | | | | | | | | This is especially useful if you already have serialization code that can perform strict checks on the data, rather than having to rewrite it to work with QJSValue. Pick-to: 6.2 6.4 Change-Id: I5b12aa9806e187586ac1b41995633a46621f76c9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>