Commit Graph

5 Commits

Author SHA1 Message Date
Maximilian Goldstein d8e73b588a qmllint: Properly handle JavaScript functions with variable arguments
Previously calling a JavaScript function with variable arguments could
cause the linting process to error out because of a lack of matching
function arguments.

This is now handled by defaulting to a JavaScript method if no matching
function signature can be found.

Fixes: QTBUG-98299
Change-Id: I748a60839106243a12bffd8d715b48cbc53d7f57
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 21:23:08 +01:00
Ulf Hermann d98bc001f9 qmljsrootgen: Try properties on instances if not available on prototypes
This gives us type information for a few extra properties, among which
is ArrayBuffer. We also declare ArrayBuffer as extension to QByteArray,
which we can now test with qmllint.

Change-Id: Ibb3da5e8b8a9e839dc6365fbeabe8418022d1346
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-05 12:53:14 +02:00
Ulf Hermann 478d0d5d33 Amend JS root with more precise type information
Methods on the "Math" object preferably deal with numbers, and if we
pass them numbers, they also return numbers. Model this as overrides of
the generic methods.

Change-Id: I419093630577c371846e5c8ac153f90ed6ffa87e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-05 12:53:14 +02:00
Ulf Hermann 16b30313ad Rework qmljsrootgen
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>
2021-04-16 14:29:55 +02:00
Maximilian Goldstein 5851195c4f Add qmltypes for JavaScript root object
This change adds jsroot.qmltypes which represents QJSEngine's global / root object and a tool to generate it (qmlsjrootgen).

If you wish to regenerate jsroot.qmltypes run the following commands:

qmljsrootgen jsroot.json
qmltyperegistrar jsroot.json --generate-qmltypes src/imports/builtins/jsroot.qmltypes --import-name QJSEngine --major-version 1 --minor-version 0

Fixes: QTBUG-90807
Change-Id: I5ba0a048586d2dd945009d65c2b51be8ead85feb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-19 14:57:46 +01:00