aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary forward declarationAndy Shaw2021-03-241-1/+0
| | | | | | | | | | This ensures that clang-tidy does not report it as a warning when it is used on application code. Change-Id: I5b84759ff87e7a5b9d119ef27650d92c86f9f831 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit c2634e14273b77f8e4cb77585ab9d7eb7880bf34) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qtdeclarative: finish fixing compilation with explicit QChar(int)David Faure2020-11-071-1/+1
| | | | | Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc:: Fix documentation warnings for Qt QMLTopi Reinio2020-11-051-3/+3
| | | | | | Task-number: QTBUG-88156 Change-Id: Ic6127c6128b4c7736cb4b5ab8ce51629388b59ca Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-311-1/+1
| | | | | | | Since we depend on C++17 now, all of these can go. Change-Id: I0484fd4bb99e4367ec211c29146c316453729959 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QJSEngine::evaluete: fix documentationFabian Kosmale2020-09-031-2/+2
| | | | | | Change-Id: Ie0e6d975079e4cbedad2dd4f17d3efe8aee553bc Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QJSEngine: provide a way to check if an exception was thrownFabian Kosmale2020-09-022-6/+28
| | | | | | | | | | | [ChangeLog][QML][QJSEngine] QJSEngine::evaluate gained an optional stackTrace parameter. It can be used to check if the returned QJSValue comes from an uncaught exception, and to retrieve the backtrace of the execution leading to the error. Fixes: QTBUG-54925 Change-Id: I2b5ada1f0c33c335b4b9d0d1268e70ca63a1fad1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix minor typosSze Howe Koh2020-08-301-1/+1
| | | | | | Pick-to: 5.15 Change-Id: I4c51c40697e410d56b6a2d2446ed9f8ae218576d Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* Fix QtQml after QMetaType/QVariant changes in Qt CoreLars Knoll2020-08-282-0/+70
| | | | | Change-Id: I2a983cf8188e88d80d3b7726208d821427eb8f3c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove deprecated function QJSValue::engineFabian Kosmale2020-08-262-22/+0
| | | | | | | | | [ChangeLog][QJSValue] The deprecated function QJSValue::engine() has been removed. Change-Id: I2be35379e0a9e51f5371a2c98b955282955b7147 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove deprecated QJSEngine::installTranslatorFunctions functionFabian Kosmale2020-08-252-38/+0
| | | | | | | | | [ChangeLog][QJSEngine] The deprecated installTranslatorFunctions() has been removed. Use installExtensions() with TranslationExtension instead. Change-Id: I58345793ea154ec37d0c64f13c958193e6fa461b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Adapt to qtbase changesFabian Kosmale2020-08-231-1/+1
| | | | | | | | | | | The internal QVariant constructor taking a QMetaTypeId has been removed. Thus, construct QMetaTypes where necessary from the id, or avoid a QMetaType -> ID -> QMetaType roundtrip where we already have a metatype. Also fix a few missing includse that were previously transitively included. Change-Id: I56ce92281d616108a4ff80fe5052b919d1282357 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Fix race condition in QQmlData::createPropertyCacheFabian Kosmale2020-06-051-6/+6
| | | | | | | | | | | | | | As noted in QJSEnginePrivate::cache, there can be a race between calling addRef on the QQmlPropertyCache and another thread derefing and consequently deleting it. To avoid this, we introduce a doRef flag in QQmlMetaTypeData::propertyCache, which tells it to ref the the cache. This fixes the issue, as the QQmlMetaTypeDataPtr in propertyCache() acts as a mutex. Fixes: QTBUG-84692 Pick-to: 5.15 Change-Id: I962d28cfd22696aad89a660e41c55f63a8791b44 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSEngine: support char16_tFabian Kosmale2020-05-161-0/+3
| | | | | | | | Now that char16_t is used in Qt (for instance in QChar::unicode()), we need to support it. Change-Id: I527a70795524bfd883fc4d729aac714708b51181 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Move object onwership functions from QQmlEngine to QJSEngineFabian Kosmale2020-04-242-0/+70
| | | | | | | | | | | | [ChangeLog][QML] The setObjectOwnership and objectOwnership functions have been moved from QQmlEngine to QJSEngine. This reflects the fact that they have an effect on objects passed not only to a QQmlEngine, but also to a QJSEngine. As QQmlEngine is a subclass of QJSEngine, existing code continues to work. Fixes: QTBUG-83657 Change-Id: Ib29cdb4a9884e1f1b68fcba64d32b1cb2e5a4297 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add support for translation bindings on QProperty based propertiesSimon Hausmann2020-04-021-1/+2
| | | | | Change-Id: I439653123cdc96df97a1801664655c9d28a8b9b5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-186-514/+329
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Being careful, we can now save primitive values inline. We use the heap pointer of QV4::Value as either QString* or QV4::Value* for complex types. We cannot store persistent managed QV4::Value without the double indirection as those need to be allocated in a special place. The generic QVariant case is not supported anymore. The only place where it was actually needed were the stream operators for QJSValue. Those were fundamentally broken: * A managed QJSValue saved and loaded from a stream was converted to a QVariant-type QJSValue * QVariant-type QJSValues were not callable, could not be objects or arrays, or any of the special types. * Cyclic references were forcibly broken when saving to a data stream. In general the support for saving and loading of managed types to/from a data stream was so abysmally bad that we don't lose much by dropping it. [ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a QDataStream only primitive values or strings will be retained. Support for objects and arrays was incomplete and unreliable already before. It cannot work correctly as we don't necessarily have a JavaScript heap when loading a QJSValue from a stream. Therefore, we don't have a proper place to keep any managed values. Using QVariant to keep them instead is a bad idea because QVariant cannot represent everything a QJSValue can contain. Fixes: QTBUG-75174 Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSValue: Make call* const (Qt 6 TODO)Fabian Kosmale2020-03-132-6/+6
| | | | | Change-Id: I3a6c83ffc203bf27121f460ba23d31a39d1493ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-6/+6
| | | | | | | | | | | | | | In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add Qt.uiLanguage and QJSEngine::uiLanguage propertiesSimon Hausmann2020-01-233-8/+38
| | | | | | | | | | | | | | [ChangeLog][QtQml] Added Qt.uiLanguage and QJSEngine::uiLanguage properties These properties mirror the same value in QML and C++ and can be used freely. They also provide API symmetry to Qt for MCUs. QQmlApplicationEngine binds to this property and applies translations accordingly by constructing a QLocale with the value and using QTranslator::load(locale). Change-Id: Id87d6ee64679b07ff3cb47844594e8eeebd8c8b6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Christian Kamm <mail@ckamm.de>
* Replace QVariant::type with QVariant::userTypeOlivier Goffart2020-01-171-6/+6
| | | | | | | | | | | as type is going to be deprecated. This change was done automatically with the help of clazy. In addition, ColumnRoleMetadata was changed to take an int instead of a QVariant::Type Change-Id: Ibc02d7b52e7d931a56c19fdebc4788b5e6df2a39 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-121-1/+3
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine.cpp src/quick/handlers/qquicktaphandler.cpp src/quick/items/qquicktableview.cpp Done-With: Richard Moe Gustavsen <richard.gustavsen@qt.io> Done-With: Ulf Hermann <ulf.hermann@qt.io> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Change-Id: If9558a33f01693ce96420c094e0b57dfff0626cd
| * Doc: Fix documentation warnings for qtdeclarativeTopi Reinio2019-08-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After recent changes to QDoc, it now correctly warns about missing documentation for QML method parameters - fix all of these and also do some minor language editing. Remove duplicated entries for - \qmlmodule Qt.labs.qmlmodels - \group qtjavascript as they were causing issues. Change-Id: I55cd670cc8a0cc6427cdb7945dbd7c28ea94f796 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Port from QMutex::Recursive to QRecursiveMutexMarc Mutz2019-07-311-2/+2
| | | | | | | | | | | | Change-Id: I5bf128b4479971e87d377707f2ebf267ccba1f1d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Port from implicit to explicit atomic operationsMarc Mutz2019-07-022-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | The old code used the implicit conversions from QAtomicPointer<T> to T*, and QAtomicInteger<T> to T, and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixes some users of these APIs before we deprecate them. Change-Id: I892d705c22280f1c6fdc62c1777248b44e9c4329 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-06-141-2/+19
|\| | | | | | | | | | | | | Conflicts: tests/auto/qml/qjsengine/tst_qjsengine.cpp Change-Id: I34df194046a91ee8a076ce28022eb99d68e7f362
| * Allow destroying QJSValues from other threadsUlf Hermann2019-06-111-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QVariants are commonly passed around between threads and QVariants can wrap QJSValues. Therefore we need to allow this. The persistent value is freed immediately if we're still in the same thread. Otherwise a message is passed to the QJSEngine that owns it. If there is no QJSEngine we assume that we can free the value immediately. As such a thing can only happen via private API we can make sure this assumption holds. Fixes: QTBUG-75939 Change-Id: I14c09fd5d6ef7ba689f66656f2bcbb5c88bacf89 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove last traces of QV8EngineUlf Hermann2019-05-081-4/+0
| | | | | | | | | | Change-Id: I59f738402d51e39188bbbca2ef1fbc8a61612372 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Make JavaScript execution interruptibleUlf Hermann2019-04-303-1/+44
| | | | | | | | | | | | | | | | | | | | | | Add an atomic isInterrupted flag to BaseEngine and check that in addition to the hasException flag on checkException(). Add some more exception checks to cover all possible infinite loops. Also, remove the writeBarrierActive member from QV4::EngineBase. It isn't used. Fixes: QTBUG-49080 Change-Id: I86b3114e3e61aff3e5eb9b020749a908ed801c2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-101-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp src/qml/types/qqmlmodelsmodule.cpp Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
| * Doc: Use the \nullptr macro instead of 0Venugopal Shivashankar2019-03-291-1/+1
| | | | | | | | | | | | | | | | This enables overriding the macro so that it translates to 'None' in the Qt for Python context. Change-Id: Ied1ddcb0f9e6e2299d9042e4cc4c2bb6d11a491b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Remove unused includes of qv8engine_p.hUlf Hermann2019-04-091-1/+0
| | | | | | | | | | Change-Id: Ic135a863581d29a3afb9c6c7f070d2630b3913b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-02-251-6/+6
|\| | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp Change-Id: I517c001ea4eb0fdd8e469f9fffe5b7559a5b0795
| * QML: Pass type minor version when creating property dataUlf Hermann2019-02-211-6/+6
| | | | | | | | | | | | | | | | | | Depending on the type minor version recursive properties should be available or not. Check for that when resolving grouped properties. Fixes: QTBUG-33179 Change-Id: Id8f62befdc4a29d879710499e19d3d289bd18775 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | The declarations and usage of runtime functions have seen a number of changes: - we don't use the array of method pointers anymore because we don't use cross-platform AOT JITting - the check if a method can throw a JS exception was invalid, and was not used anymore - value-pointer vs. const-value-ref was inconsistent This patch cleans that up. By fixing the exception checking, we can now use it in the baseline JIT to automatically insert those checks. To make that work correctly, all runtime methods are in a struct, which gets annotated to indicate if that method throws. (The old way of checking which type of engine was used is fragile: some non-throwing methods do not take an engine parameter at all, and those got flagged as throwing). By using a struct, we can also get rid of a bunch of interesting macros. The flags in the struct (as mentioned above) can later be extended to capture more information, e.g. if a method will change the context. Change-Id: I1e0b9ba62a0bf538eb728b4378e2678136e29a64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Documentation: Start using the \nullptr macroFriedemann Kleint2019-01-211-3/+3
| | | | | | Task-number: PYSIDE-903 Change-Id: I0c4640eb20157673eabb131e8834e79cbbf95d5c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix spelling of qjsvalue_cast()Ulf Hermann2018-11-201-1/+1
| | | | | Change-Id: Ic853e8c958b250d87a953942ea944f5d52d456a2 Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
* Clarify documentation about throwError and the specific error typesSimon Hausmann2018-10-312-6/+22
| | | | | | | | | | | | | Elaborate a bit on some specific types, suggest the use of the overload and omit some values that either exist only to complete the enum for API standard purposes (NoError) or exist only for porting purposes but are not relevant in use (EvalError). Change-Id: I4f9cf7a4605305642fc20570a90a16f2c29d8b98 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Richard Weickelt <richard@weickelt.de>
* Add convenience functions for creating and inspecting error objectsAllan Sandfeld Jensen2018-10-304-1/+139
| | | | | | | | | Serves to simplify porting from QtScript by replacing QScriptContext::Error and QScriptContext::throwError(). Change-Id: I4bfe404c358c50aaf3b5469a4304fec97552bf24 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix translation contexts for paths with drive letters on WindowsErik Verbruggen2018-10-151-15/+13
| | | | | | | | | | | | | | | Inside method_qtTr, the filename is assumed to be a (correct) URL. When a (normalized) path with a windows drive letter is passed to QJSEngine::evaluate, the URL will have a scheme that is the drive letter. We cannot correct this in method_qtTr, because at that point we might get in files that do not come from the file system, but through actual URLs. The place where we know for sure that the filename is a real file name and not a URL, is in QJSEngine::evaluate. So at that point, make sure that the filename is a valid URL. Task-number: QTBUG-70425 Change-Id: Ia41859c4024ac46e6f8c3d96057a5dffdecd8f56 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix QDoc warningsPaul Wicking2018-10-011-1/+1
| | | | | Change-Id: I19545953bde10d4ccc2f37843dcda2569dc77df4 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-172-11/+11
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix ownKey iteration over Proxy objectsLars Knoll2018-09-091-1/+1
| | | | | Change-Id: I045a4844c06df9232cc8b04485ab0a39bb990e3f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Provide some more documentation for modules in QJSEngineSimon Hausmann2018-08-161-0/+39
| | | | | | | | A little example goes a long way :) Change-Id: I5aaac011e5a3e1348d7a084b669ec66349d441fa Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add API to QJSEngine for importing ECMAScript modulesSimon Hausmann2018-08-162-0/+51
| | | | | | | | | | | | Now that the standard defines the concept of a module, it makes sense to offer a function in QJSEngine that can read files and load them. [ChangeLog][QtQml][QJSEngine] Added function to import ECMASCript modules from the file system or the Qt resource system. Change-Id: I72f8d49de948872221ac1b54fcfb066404bed9b9 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Implement support for ownKeys in Proxy objectsLars Knoll2018-08-041-2/+2
| | | | | Change-Id: I7edee88e4252e6ed0d2666c3f633bb595cb0e831 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce a new mechanism to iterate over object propertiesLars Knoll2018-08-022-80/+68
| | | | | | | | | | | | | | | | | The old advanceIterator schema was extremely ugly and in addition not flexible enough to support the requirements for Proxy.ownKeys and some of the methods in Object Implemented a new scheme through a OwnPropertyKeys method in the Object VTable that creates and returns an iterator object. Ported QJSValueIterator and for-in to use the new mechanism. There's still many places where we use the old ObjectIterator (that relies on advanceIterator). Those will be ported in subsequent commits. Change-Id: I091a9bea9ff6b2b63630cc336814700757a718be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Encode result of Math.min and Math.max as int when possibleErik Verbruggen2018-07-131-1/+1
| | | | | | | | | | So now Math.max(array1.length, array2.length) won't return a double anymore. This improves the score in the crypto benchmark by ~10% Change-Id: I8453a671d28d7f2a39ba74b18b3155f031d9b12f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the C++ and JS stack frame definitions into it's own fileLars Knoll2018-07-031-0/+1
| | | | | Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up the property key API in StringOrSymbolLars Knoll2018-07-021-16/+4
| | | | | | | | | | | | | | Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-1/+1
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>