aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* V4: Mark InternalClass parents when running GCUlf Hermann2022-08-031-1/+1
| | | | | | | | | | | | | | | | We need to preserve them as they notify us about protoId related changes. In order to avoid wasting heap space in case many properties are added and removed from the same object, we put a mechanism in place to rebuild the InternalClass hierarchy if many redundant transitions are detected. Amends commit 69d76d59cec0dcff4c52eef24e779fbef14beeca. Pick-to: 5.15 6.2 6.3 6.4 Fixes: QTBUG-91687 Task-number: QTBUG-58559 Change-Id: I3238931b5919ed2b98059e0b7f928334284ce7bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Allow conversion from string to QByteArray when setting bindablesUlf Hermann2022-07-251-0/+2
| | | | | | | | | We allow it everywhere else, too. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-105044 Change-Id: I714e5d501a780310791523c5f35a87681c69b1fb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove #include qvariant_p.hThiago Macieira2022-07-251-1/+0
| | | | | | | | It isn't used. Change-Id: I3859764fed084846bcb0fffd1704497a9998d30e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Implement array methods for QQmlListPropertyUlf Hermann2022-07-161-1/+1
| | | | | | | | | | | | | | | | | | The test revealed that the fill() method of JS arrays did not properly range-check its parameters. Fix that, too. [ChangeLog][QtQml][Important Behavior Changes] QQmlListProperty behaves like a JavaScript Array now. You can use map(), reduce(), forEach() etc on it. This also includes a slight change of behavior to the push() method. push() now returns the new list length, and it checks the length to not exceed UINT_MAX. Task-number: QTBUG-58831 Fixes: QTBUG-49613 Fixes: QTBUG-99041 Change-Id: Ia64d73fb704449c280fbbc7ddcf20f4698c82e09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Re-add the Qt namespace enums to the Qt objectUlf Hermann2022-07-051-2/+12
| | | | | | | | | | | They were replaced with an extension to the Qt singleton in Qt6. However, the singleton is only available when QtQml is imported. We can easily provide the enums using the metaobject of the Qt namespace. Pick-to: 6.4 Change-Id: I5f58d30c749c0cb9e531df180a5cbe75c92e1aa6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Allow retrieval of sequences from QJSValueUlf Hermann2022-06-021-20/+25
| | | | | | | | | | | | | | As we can store sequence types in QJSValue, we should be able to retrieve them, too. Move the declaration of the QV4::Sequence struct into a header to make it less of a hassle to identify sequences. Change-Id: I3e45bfe193c669107f90cd6c502765c0c9f60fb0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> 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>
* V4 Engine: Don't try to convert JS functions to other typesUlf Hermann2022-05-091-1/+4
| | | | | | | | | | | When converting a JS value to a variant, if we notice that we get a QJSValue again, there is no point in trying to convert it further. We'll just run into infinite recursion. Pick-to: 6.3 Fixes: QTBUG-102545 Change-Id: I0a40e21287e5460e5e214101aabe8d2b4bf0afad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QQmlEngine resolve closures when executing runtime functionsAndrei Golubev2022-04-271-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QML can create a function which holds a closure in the cases like: onSignal: function() { ... } If the left-hand side is a signal handler (or similar), we want to execute the *inner* function when a signal is called, not the outer one. However, under certain conditions (e.g. we use `this`), the outer function must also be called beforehand to correctly setup the calling scope for the inner function Thus, make the QQmlEnginePrivate::executeRuntimeFunction() do that: always call an outer function first and then the inner one if present. This creates an overhead when dealing with certain signal handlers but we could optimize it later if needed Note that the case `property var prop: function() { return 42; }` where a property contains a callable function is no longer supported by the executeRuntimeFunction() routine (we always call the inner code now). This is fine since qmltc (the main beneficiary of the routine) does not rely on this functionality when dealing with property bindings Given the change, qmltc can be simplified to only work with absolute function indices, ignoring the nesting problem altogether Change-Id: I61f61587b6fe700cb695b3b7a213d9cfab0eb746 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Adapt qv4engine to stack size on AndroidAndreas Buhr2022-04-131-0/+9
| | | | | | | | | | | Adapt maximum stack size to not run into segfaults due to stack overflow. Pick-to: 6.2 6.3 Task-number: QTBUG-102384 Task-number: QTBUG-96788 Change-Id: I4ba3518369c822b1b2d93388817beb7f86d19cdc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ExecutionEngine: Move initialization of statics into separate methodUlf Hermann2022-03-051-60/+79
| | | | | | | | | | ... and do it only for the first engine (ie engineId == 1). The engineId is determined using atomic operations, so this is safe now. Pick-to: 6.3 Task-number: QTBUG-73271 Change-Id: Ife38213fe04e26f35425a29230a2e3b586572dd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adjust default max call depth for QNXUlf Hermann2022-01-251-0/+4
| | | | | | | | | | QNX by default has smaller stacks than other platforms. Pick-to: 5.15 6.2 6.3 Change-Id: Ia83d4e12c0fd24c51069777db2283d456c49800f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
* Remove the qml_sequence_object feature flagUlf Hermann2022-01-151-17/+1
| | | | | | | | | | | | | | | | | | | QML sequences are required for named lists of value types. The original reason for the introduction of this feature was the template code explosion caused by the way the sequence types were registered in Qt5. As we register them differently now, the code size overhead should be smaller. It makes very little sense to switch sequence types off these days. [ChangeLog][QtQml][Important Behavior Changes] The qml_sequence_object feature flag has been removed. Omitting sequences from the QML language does not make much sense now that we use them for lists of value types. The original reason to allow it was that the sequence support took up a lot of space in the binary. This is not the case anymore since 6.0. Change-Id: I2f1d43cdd29ba63853316b06113cb49ed30aa410 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve type conversions from/to QJSValueUlf Hermann2021-10-201-1/+4
| | | | | | | | | We can convert everything into a QJSValue if we have an engine and we can save a binding function in a QVariant by wrapping it into QJSValue. Change-Id: I48e7c13f3f744f1c50bf673b427fe9331250f313 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use value type providers in metaTypeFromJSUlf Hermann2021-09-061-19/+9
| | | | | | | Pick-to: 6.2 Task-number: QTBUG-96144 Change-Id: If12f669ae33bb8ae4768ca79e4ca985f70a2651d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4Engine: Do not use currentContext() when calling JavaScript from C++Andrei Golubev2021-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | This turns out to be not quite valid since context hierarchy is afffected. It was fine before since all the generated classes either had the same context or a dead-simple hierarchy + the tests for comprehensive usage were lacking. The problems arise when contexts are meant to be different for unrelated JS calls e.g. in property bindings with non-trivial cross-context dependencies (e.g. derived property uses both neighbor property and base class property in a binding) As a drive by, simplify QQmlEnginePrivate::executeRuntimeFunction(): * Expect function index to always be valid (in range), it's a very bad otherwise anyway * Use QQmlData::outerContext directly as a context argument for callInContext(). This is what was done anyhow, just through a QQmlContext -> QQmlContextData conversion, which is actually needless Change-Id: I8ac6b181363a5d03e468c2b6f35db2dac188ea8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix conversion of entries to be added to QVariantListsUlf Hermann2021-06-171-4/+6
| | | | | | | | | We should pass the variants themselves, not their constData(). Fixes: QTBUG-94502 Pick-to: 6.1 6.2 Change-Id: I92688348d7b46d74935dc11080b26290f5e8be86 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate JS call frame from metatypes callsUlf Hermann2021-06-101-3/+2
| | | | | | | | If we call an AOT-compiled function we never need the JavaScript call frame. We can just skip its setup and save some overhead. Change-Id: I39dc2ca6eea5b5a66f3b87b642a310534cecf6cd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Pass QMetaType by value rather than by ID in more placesUlf Hermann2021-06-091-10/+9
| | | | | | | | | | This saves us some ping-pong between the IDs and the QMetaTypes, and avoids possible ambiguities if multiple metatypes are registered for the same C++ type. Change-Id: I81cec94a9cd05d69927dc884f65574f0ab2ddc22 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlMetaType::metaObjectForMetaType into metaObjectForValueTypeUlf Hermann2021-06-081-2/+2
| | | | | | | | It really only works for value types and it's not intended to do anythign else. The name should reflect this. Change-Id: Ib73bf7e9655971f7826fe72145e2d2fab363363c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow value type conversion in metaTypeFromJSUlf Hermann2021-06-021-3/+7
| | | | | | | We implicitly do the same when calling toVariant(). Change-Id: I288326125d88bc658dcaf12d3ee623e0e529bb69 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QDate handling consistent in its use of UTCEdward Welbourne2021-05-181-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the quirk of ECMAScript's Date.parse() spec [0] stipulating the use of UTC for date-only strings, in contrast to most other ways of creating a Date using local time, reasonable users get surprised by the behavior of QDate properties initialized from strings. This can't be avoided without breaking other uses of Date, so document the work-around needed to cope with it (use UTC-specific methods to access the Date object). [0] https://tc39.es/ecma262/#sec-date.parse Make conversions back to QDate from Date work round the possibility that the Date, seen as a QDateTime(,, LocalTime), needs to be handled as UTC when extracting the date, and catch two more places that conversion from QDate neglected to use UTC's start of day, for consistency. Revised tests to call UTC-specific methods instead of the local-time ones, where appropriate. Drive-by: some tests were (entirely bogusly) constructing a fresh Date using the UTC-fields of the Date they had, in order to then test the non-UTC fields of this fresh Date; instead, simply test that the UTC fields are as expected. [ChangeLog][QML][Behavior change] Where a QDate is represented in QML's JavaScript as a Date, it is now more consistently associated with the start of the UTC day it describes. Previously cases where it was represented as the start of local time's day could lead to a Date turning into a QDate for the preceding day. Inconsistencies in the specified behavior of Date preclude eliminating such problems entirely, but they should now be limited to cases where (perversely for a date property or parameter) the date is specified with a local time late enough to make it coincide with the start of the next UTC day (in which case that next day's QDate will be its C++ representation). Fixes: QTBUG-92466 Change-Id: I2306dd9ecef0d5c2d59b562762392e51bb6d66ca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlEngine::executeRuntimeFunction: pass return value as input argumentAndrei Golubev2021-05-111-14/+13
| | | | | | | | | Use the newer version of QV4::Function::call() that does not require manual JSCallData setup and is more optimal for AOT function calls Change-Id: I5a5e2d0477c0603b05b7213f1b2adcc34d156bf5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qv4engine: Fix enums getting turned into objects when passed in listsMaximilian Goldstein2021-05-061-0/+4
| | | | | | | | | | | | | Previously passing a QList of a registered enum would result in an array of objects instead of the array of numbers which usually represent enum values in QML. You now get an array of numbers as you would expect. [ChangeLog][QtQml][Important Behavior Changes] QJSEngine::toScriptValue() used to return a QVariant containing an enum, now it returns the enum directly. If you still wish to use valueOf() on the resulting value use QJSEngine::toManagedValue() instead. [ChangeLog][QtQml][Important Behavior Changes] A QList containing enums will now result in an array of numbers instead of an array of objects. Fixes: QTBUG-85861 Change-Id: I5c28f4489dfd02d8256aa818e27b1dd6b7d3113d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add QJSEngine::registerModuleAlex Shaw2021-05-011-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | Some applications that use JavaScript as a scripting language may want to extend JS through C++ code. The current way to do that is with global objects. ES6 provides a better way of encapsulating code: modules. registerModule() allows an application to provide a QJSValue as a named module. Developers familiar with Node.js will find this very easy to use. Example: ```c++ QJSValue num(666); myEngine.registerModule("themarkofthebeast", num); ``` ```js import badnews from "themarkofthebeast"; ``` [ChangeLog][QtQml][QJSEngine] Adds the ability to register QJSValues in C++ as modules for importing in MJS files. Change-Id: I0c98dcb746aa2aa15aa2ab3082129d106413a23b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Support native transformation between UrlObject and QVariant/QUrlUlf Hermann2021-04-221-1/+23
| | | | | | | | | | | | | | URL has become a builtin type. We should support it on the same level as QString/String and QDateTime/Date. In order to continue support for comparing URL properties with the JavaScript equality operators, we still pass URLs as variants when using them in JavaScript. However, we now create proper URL objects for QJSValue and QJSManagedValue, and we allow transforming the URL-carrying variant objects back into QUrls. Change-Id: I78cb2d7d51ac720877217d2d4b4d0ab17cdd2a4b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4::Engine::toVariant: Use metatype instead of metatype idFabian Kosmale2021-03-251-17/+16
| | | | | | | | | | This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Allow creation of QJSValues from QQmlListPropertyUlf Hermann2021-03-251-3/+10
| | | | | | | | This is pretty much the same as creating them from QQmlListReference. Change-Id: I8d873840fc08887655d19a61b028f3eb60eaf938 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Inline retrieval of QML contextsUlf Hermann2021-03-251-18/+3
| | | | | | | | In the good case this is just reading a few members of the relevant classes. No need to call functions for this. Change-Id: I9908cd6437cf9a1ca840f9aa0e524d3976272d67 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QMetaType for ExecutionEngine::metaTypeFromJS()Ulf Hermann2021-03-241-8/+5
| | | | | | | | We should avoid looking up metatypes by ID. That's expensive. Change-Id: I00ce0a7f95ec82b0db6e7eb976e39e50522a7fe4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Avoid qMetaTypeId() in ExecutionEngine::fromData()Ulf Hermann2021-03-231-3/+3
| | | | | | | It's expensive. Change-Id: Ib892027869286772da53e989954063c94505ddbd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support more type conversionsUlf Hermann2021-03-231-3/+15
| | | | | | | | | We need to be able to retrieve QQmlListReference and attached objects from QJSValues. Change-Id: I39679317da4066b054e86f767fc5f723ead2b2e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Avoid string operations on type signatures where possibleUlf Hermann2021-03-231-18/+36
| | | | | | | | Parsing the type from a signature is expensive and we can do better in most cases. Change-Id: Iae85f4dec9ad6b8de60efeb3469a253fd0862672 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize stack frame setup for AOT compiled functionsUlf Hermann2021-03-231-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When called via the metaobject system, parameters and return values are passed as void*, with accompanying type information in the form of QMetaType. The same format is expected when calling an AOT compiled function. Previously, we would first convert all the parameters to QV4::Value, just to convert them back the moment we notice that there is an AOT compiled function. This is wasteful. This change provides a second call infrastructure that accepts void* and QMetaType as parameter and return value format, and passes them as-is all the way to any AOT compiled functions. If there is no AOT compiled function, the conversion is done when detecting this, rather than when initiating the call. This also passes the information "ignore return value" all the way down to the actual function call. If the caller is not interested in the return value, we don't have to marshal it back at all. For now, we only add the extra "callWithMetaTypes" vtable entry to ArrowFunction. However, other callables could also receive variants optimized for calling with void*/int rather than V4 values. This required changing the way how function arguments are stored in the property cache. We squeeze the return type into QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of integers. In turn, we remove some unused bits. Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up JSCallData setupUlf Hermann2021-03-171-2/+2
| | | | | | | | | | | | | | | | | We either have pre-populated arguments and thisObject, then we can just use them and keep them const. Or, we want to allocate and populate the arguments and the thisObject. Then, do allocate them in a separate object, and transform that into JSCallData afterwards if necessary. Furthermore, avoid alloc(0) as that just returns the current stack top. Writing to it will clobber other data. Rather, just use nullptr and crash if it's written to. Also, remove the useless operator-> from JSCallData. That one just confuses the reader. Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't store the scope in JSCallDataUlf Hermann2021-03-171-1/+1
| | | | | | | | | | | We only need it when generating CallData, or when filling in any thisObject or arguments that weren't provided. Provide a constructor that expects thisObject and arguments to be pre-allocated and one that allocates them in a scope passed as argument. Change-Id: Iddfba63f4dbc5b09e2b33fb22a94eea88f515902 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Optimize QML context retrieval for AOT functionsUlf Hermann2021-03-131-8/+6
| | | | | | | | | | We can cache the QQmlContextWrapper rather than retrieving it twice. Inline some things, and do not unnecessarily create and destroy ref pointers. Change-Id: Ife0980f83b7efe1ea9dc56aacbfbccd029ce77c8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize ExecutionEngine::metaTypeToJS()Ulf Hermann2021-03-131-18/+32
| | | | | | | | | | | | | | | | We almost never need to construct a QVariant to do this. Constructing a QVariant is excessively expensive if you have something simple like an integer. This also fixes the unexpected "unwrapping" of variants when we pass them through QJSValue. [ChangeLog][QtQml][Important Behavior Changes] If you create a QJSValue from a nested QVariant (that is, a QVariant containing another QVariant), then, when retrieving its contents again, the outer variant is not unwrapped anymore. Rather, you get exactly the value you've passed in. Change-Id: I8c16eed4f13e8cfdeced0756eef593b3b8e84dd1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4Engine: remove redundant checkFabian Kosmale2021-03-051-6/+1
| | | | | | | | | | | | We already covered the case where the metatype's flag indicate that it is a QObject. That is exactly the same check used in QQmlMetaType::toQObject, so if the test did not succeed before, it won't succeed now either. As a drive-by, avoid useless metatype-id to metatype lookup. Change-Id: Ie36a07587aa2b899d2a932bcb3f4a0b5da8aa282 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Engine: Cleanup method argument passingFabian Kosmale2021-03-041-4/+4
| | | | | | | | | | | | Instead of arguments around as a pointer to [argc, metaTypeId1, metaTypeId12, ...] pass argc and a pointer to [QMetaType1, QMetaType2] around. Moreover, make use of the fact that we now carry the metatype instead of only the id in a few places, to avoid id -> metatype lookups. Task-number: QTBUG-82931 Change-Id: Ib00e4d793727f85f3358a8162d1aac972daab3d3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Handle const QObject pointer correctlyFabian Kosmale2021-03-011-2/+11
| | | | | | | | | | | | | | | | | | | [ChangeLog][QML][Important Behavior Changes] If a QObject pointer is passed to the QML engine and subsequently frozen with Object.freeze, modifying its QObject properties now fails and throws a TypeError. The TypeError is thrown even in non-strict mode. [ChangeLog][QML] It is now possible to pass const QObject derived pointers to QML in properties, and to call Q_INVOKABLE functions which take such pointers as arguments. If the QML engine receives such a pointer, it is treated as if the object was frozen. Fixes: QTBUG-82354 Change-Id: Ib0dbcdfb2370654505936c3cf391d87dd2c9677b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* metaTypeToJS: use QMetaType instead of idFabian Kosmale2021-02-191-3/+3
| | | | | | Task-number: QTBUG-82931 Change-Id: I7b663c5f774ef3edbb19d5f2ef53cfe623a8e4cf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4::populateJSCallArguments: Use v4->metaTypeToJSFabian Kosmale2021-02-191-2/+1
| | | | | | | | | | It appears that nowadays v4->metaTypeToJS handles QVariant and QObject derived classes just fine, and in exactly the same way as the custom code in populateJSCallArguments did. Task-number: QTBUG-82931 Change-Id: Ic5f97dfc3296a409fdd6a1fcb78d3b9bdba5f3a1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSValue: Allow casting integers to enumsUlf Hermann2021-02-191-0/+8
| | | | | | | | You can also cast enums to integers, after all. Pick-to: 6.1 Change-Id: I283d3dd280eeb44ba22bb45ca9be69e5358d5781 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support runtime functions evaluation by index through QQmlEngineAndrei Golubev2021-02-121-0/+28
| | | | | | | | | | | Add execution function that can evaluate runtime functions available in the compilation unit. Private API for now as it's unclear what would be a comprehensive solution to support all existing use cases Task-number: QTBUG-84368 Task-number: QTBUG-91039 Change-Id: Icf755b53484587d7983eaae4821c1aa0111d5c05 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Unregister value types when tearing down QML typesUlf Hermann2021-02-121-2/+2
| | | | | | | | | Move the value type registry into QQmlMetaTypeData. This way we can conveniently drop the relevant entries when unregistering a type. Fixes: QTBUG-86946 Change-Id: Id024a34a8b2b622fd9417fc0e52864b43c66cc01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Respect QML_DISABLE_DISK_CACHE also for caches built into the binaryUlf Hermann2020-12-101-2/+14
| | | | | | | | Previously it would only disable loading of separate cache files. Change-Id: Iae92fc03d2e5566ef7dc44a6730b788b7512fd3d Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QMetaType instead of metatype-id, take 2Fabian Kosmale2020-12-031-5/+6
| | | | | | | | | This time, the ValueTypeFactory gets converted. As a consequence, many callers get touched again. Task-number: QTBUG-88766 Change-Id: I3a8b7d5cfeb7fac85daf1702febba205971d4256 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Mark url as builtin typeUlf Hermann2020-12-021-0/+8
| | | | | | | | | Also, allow conversion from UrlObject and String. We allow the string conversion because we treat string and url as interchangeable in various places. Change-Id: Ib229c6d190e1c5d849ea18798925965b8dbeef7e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4Engine: Fix conversion of char16_tUlf Hermann2020-11-171-1/+1
| | | | | | | | This is a single char16_t, not an array of them. Pick-to: 5.15 Change-Id: I55d23ebb5f2abebd43cd4160a75d373706392ddf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>