| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
| |
In JavaScript we have a number of extra conversions not covered by
qvariant_cast. Therefore, add a method to perform a QVariant conversion
in JavaScript semantics to QJSEngine, and use that in the compiler.
Fixes: QTBUG-100883
Change-Id: I8b0bfa0974bc6b339d2601fb373859bc710788c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
(cherry picked from commit d0f4e0c037cf61eb5bb559755ee7c9ce6cf6b7dc)
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we pass in a const pointer, we're not allowed to modify the object,
so the create==true case does not make sense there. We therefore provide
now two versions of the function: One taking only a const pointer, and
one taking a non-const pointer and a bool. The latter no longer provides
a default parameter to encourage usage of the the const version wherever
possible.
Change-Id: Ifb5a7e0605127de429403982b31f754e154b8048
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was a plain QProperty before. Given that the property is exposed in
the global Qt object in the engine, this could be problematic as with
the QProperty it is possible to change the value without emitting the
uiLanguageChanged signal. By using QObjectBindableProperty, we ensure
that the signal is always emitted.
Pick-to: 6.2
Change-Id: I0f771a4e4d752704f469de27617835260b261052
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The toScriptValue function template called the exported create function.
Thus, we can not change the signature of create, even though it was
private. To avoid the BIC break, we keep the old version (and ifdef it
so that it will go away in Qt 7).
Task-number: QTBUG-94407
Pick-to: 6.2
Change-Id: I5b07f978dca156f52bdb529d3e15aea8c0c3c97e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
| |
It is shorter and encapsulates the exception handling a bit.
Change-Id: I8e2dc0eb3b930e222b8cb4852b73d99ca18a0379
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
| |
Also explictily mention again that objects with JS ownership won't be
deleted as long as they have a parent.
Pick-to: 6.2 6.1
Change-Id: I1eeb5bc8183b6621f24f3751b8152b36acf2eeae
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
* Comment out \instantiates referring to an internal class
* Remove duplicate module page for Qt QML
* Fix various linking problems
Task-number: QTBUG-91875
Change-Id: I7675f8a253e0b0e0a031d8a3642b3d2786b75149
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
This way it actually generates interesting data about the JavaScript
types, for example the functions of the String prototype. Add a helper
method to create a symbol to QJSEngine. This should be generally useful.
Change-Id: I6c7b253b9d6cdb61602ceeae0955aed8d942c139
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Task-number: QTBUG-82931
Change-Id: I7b663c5f774ef3edbb19d5f2ef53cfe623a8e4cf
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
| |
Fixes: QTBUG-89956
Change-Id: I96439433b1f172e933c6c56daae639be7e18b931
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It makes little sense that you can construct an error object but not
throw it. The test was definitely meant to actually throw the error
object, not return it.
[ChangeLog][QtQml] QJSEngine has gained an additional overload to the
throwError() method, with the effect that calling throwError() with a
character literal as argument is now ambiguous. You should explicitly
construct a QString instead.
Change-Id: I90c6c9edf10509daa142a86581d6a3f7ff45af2c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A QJSManagedValue is a view on a QJSValue which always knows the engine
the value belongs to. This allows us to implement the JavaScript
semantics of the various QJSValue methods in a much more rigorous way.
[ChangeLog][QtQml] The new QJSManagedValue should be used instead of
QJSValue for manipulating properties and prototypes of JavaScript
values, as well as for calling JavaScript functions.
Change-Id: I9d445ffcf68dfa72dba9bae0818e83c80665ad66
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
| |
As you can manually throw an error, you should be able to catch it
again, too.
Change-Id: I82475df1969a1fd76f4cf5fc0a8d921dfafaef89
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
|
|
|
|
|
|
| |
Task-number: QTBUG-88156
Change-Id: Ic6127c6128b4c7736cb4b5ab8ce51629388b59ca
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
|
|
|
|
|
|
| |
Change-Id: Ie0e6d975079e4cbedad2dd4f17d3efe8aee553bc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
|
|
|
|
|
|
|
|
|
|
|
| |
[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>
|
|
|
|
|
|
|
|
|
| |
[ChangeLog][QJSEngine] The deprecated installTranslatorFunctions() has
been removed.
Use installExtensions() with TranslationExtension instead.
Change-Id: I58345793ea154ec37d0c64f13c958193e6fa461b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
[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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
[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>
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| | |
Change-Id: I59f738402d51e39188bbbca2ef1fbc8a61612372
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|/
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Change-Id: I19545953bde10d4ccc2f37843dcda2569dc77df4
Reviewed-by: Martin Smith <martin.smith@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is quite common in JavaScript to use exceptions for error handling, but
there was no way to generate an exception from C++ context, i.e. when
the JS run-time invoked a C++ method or a slot.
This patch adds an naive way to report run-time errors to QJSEngine from
CPP context. The user may set a custom error message, but the location
points always to the caller context in JavaScript.
[ChangeLog][QtQml][QJSEngine] Added API to throw run-time errors.
Task-number: QTBUG-39041
Change-Id: If59627b83d50351eb225adde63187fc251aa349e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|
|
|
|
|
|
|
|
| |
And make it an enum class. The new name fits better, as it's mainly
used to determine the type of the context when parsing. Also already
added the 'Block' value that will be needed.
Change-Id: I70d963b6a0b22db1a3c607cce6bdd2054b29e000
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4internalclass.cpp
src/qml/parser/qqmljslexer.cpp
src/qml/qml/v8/qv8engine.cpp
src/qml/util/qqmladaptormodel_p.h
src/quick/items/qquickanimatedsprite.cpp
tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.
Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).
Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|\|
| |
| |
| | |
Change-Id: I2d4c012c8ca578f90d7eb56dbc6b306ac7cbb841
|
| |\
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Conflicts:
src/imports/shapes/qquickshape.cpp
src/imports/shapes/qquickshape_p_p.h
src/qml/compiler/qqmlpropertycachecreator_p.h
src/qml/jsruntime/qv4value_p.h
src/quick/items/qquickloader_p.h
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
tools/qmlprofiler/qmlprofilerapplication.cpp
Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69
|
| | |
| | |
| | |
| | |
| | |
| | | |
Task-number: QTBUG-62007
Change-Id: I63d5a57163b36bc8629930e1cda8d5afa1e77d15
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|\| |
| | |
| | |
| | | |
Change-Id: Ib297817e2fd9b6790d9bc8ee522c32f5b3422574
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Several \fn commands needed template parameters added, and several
static functions that were not accessible were documented but should
not have been documented. The template texts were added and the qdoc
comments of the static functions were changed to non-qdoc comments.
Change-Id: Icc44e243fbec2023865f47b7c73dc15d241d5b4d
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
|
|/ /
| |
| |
| |
| |
| |
| | |
The only engine we ever ask for QJSEngine is QV4::ExecutionEngine.
Change-Id: Ia1354e552bddac72177b7aa62de5a7a502089841
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
As QJSEngine's handle() method is internal, we can redefine it to return
a pointer to an ExecutionEngine. That makes many things easier.
Change-Id: Ie3df99e0bad5f00ad4fe73182896cd135fa82994
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The compilation mode used in the evaluate method was changed to eval,
breaking existing uses. This patch fixes that.
Task-number: QTBUG-65167
Change-Id: I645ad50be36884eb10bf86ecf060b2b62b50f122
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
|