aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix error messages when assigning to non-existent properties in new compilerSimon Hausmann2013-09-301-0/+10
| | | | | | | | | Introduce a simple valdator pass early on to catch those assignments. Also fix storing the correct line/col for default property object bindings and remember the minor/major version of an import in the final type reference. Change-Id: Ib2a93dfe1a30fcd9c09b5443fb8199ad11b19769 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix composite type registration in the new compilerSimon Hausmann2013-09-301-0/+17
| | | | | | | | | | | | | | | When setting a property of a composite type like this property MyType foo: MyType {} and MyType.qml defines the new type, we test for assignability of MyType to the property foo. This test happens before MyType is instantiated and it relies on the meta-type in the CompiledData being set. Therefore this patch makes sure that the meta-type and the list meta-type are set accordingly at type compilation time, not instantiation time, similar to how it's done in the VME. Change-Id: Id7231e0a0113fa63ba6508bfbb1565dd554c5e56 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix JS script imports with namespacesSimon Hausmann2013-09-301-0/+4
| | | | | | | | Make sure to add the resolved namespaces to the import cache, before later adding scripts into it. Change-Id: I41537230c49248c2e6c60623bc5a1fe3d50d76cd Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix support for JS imports in QML files in the new compilerSimon Hausmann2013-09-301-0/+133
| | | | | | | | | | | | Remove the v4 value initialization for imported scripts code out of the VME (the method didn't even need any members of the VME class) and into ScriptData, for re-use on the QmlObjectCreator side. Also add the script index setup for the import cache (used by qml context wrapper) to the type loader. Change-Id: Idc3953a48f6fb66d008008e88a2b9b556c775537 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Compile imported scripts in the loader threadSimon Hausmann2013-09-301-3/+21
| | | | | | | | | | | | | | | | | This has the benefit of blocking the GUI thread less and speeding up type creation in the GUI thread (for types that import js libraries). This patch also brings one behavioral change: Due to the parsing at type instantiation type, things like syntax errors for script imports would only generate a run-time warning and the code in the QML file would just see "undefined". Errors in the script now generate real errors at component compilation time, meaning the errors come out earlier and as real errors. This patch implements the separation for the VME only (to keep the size of this patch small). Change-Id: I82f7f3a2d3d4524ea12a7ab62abd8640aba6a47f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge branch 'wip/v4' of qtdeclarative into devSimon Hausmann2013-09-211-7/+4
|\ | | | | | | | | | | Pull in the remaining bits of the new compiler/vme branch. Change-Id: I4706011c5eaf35f893d0733c4e130a31ce0ebb66
| * [new compiler] Fix crash with remote importsSimon Hausmann2013-09-201-7/+4
| | | | | | | | | | | | | | | | | | The import logic keeps pointers to the provided const QQmlImport references, which means we can't pass references to temporaries when using the new code path but for now have to keep the import objcts as member. Change-Id: I75eff8dbe655ed23188f3f62f743a8f987bc709e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Add Singleton support for QMLAntti Piira2013-09-211-41/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces Singleton support for QML (Composite Singleton). For now, the Singleton support is only availabe for QML types in modules or (remote and local) directories with qmldir file. However, in the future this support may be expanded to arbitrary QML file imports without by leaving out the qmldir requirement. You define a QML type as a Singleton with the following two steps: 1. By adding a pragma Singleton to a type's QML file: pragma Singleton The pragma and import statements can be mixed and their order does not matter. Singleton is the only supported pragma for now. Others will generate errors. 2. By specifying a qmldir file for the directory of your imported type and prepending the type with "singleton" keyword as follows: singleton TestTypeSingleton TestTypeSingleton.qml Alternatively you may specify a qmldir file for a module and specify your type as a singleton as follows: singleton TestTypeSingleton 1.0 TestTypeSingleton.qml Composite Singletons may be included in a module and may be used with a local namespace qualifier when imported with: "import xxx as NameSpace" A singleton instance is created at first use and stored into the QmlEngine (one instance per engine) and eventually released by the engine's destructor. CompositeSingletonType has a dual nature and will return true to both isComposite() and isSingleton() calls. In most cases its enough to check for just isComposite() or isSingleton(). However, there is a isCompositeSingleton() available as well. I used "qlalr --no-debug --no-lines --qt qqmljs.g" to generate the qqmljsparser and qqmljsgrammar files from qqmljs.g. Unit tests are included. Change-Id: I91b303612c5e132143b325b9a8f982e9355bc90e Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* | Merge branch 'wip/v4' of qtdeclarative into devSimon Hausmann2013-09-201-31/+256
|\| | | | | | | | | | | | | | | This brings in the infrastructure for the new compilation of QML and JS in the loader thread and the new VME replacement for creating objects in the GUI thread. Change-Id: Ib8127c10f5cb3ad238e57469723d031ab765a79b
| * [new compiler] Initial support for alias propertiesSimon Hausmann2013-09-201-20/+4
| | | | | | | | | | | | | | | | | | Aliases are resolved at "compile time", not rough JS expressions. This is done right after we determined the scope of components in the QML file, which is also where we collect object ids (that aliases use). Change-Id: If5702337f2cca08d17f196c3b2fde3bbdfea5b3c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Implement dependency type availability checkingSimon Hausmann2013-09-201-0/+20
| | | | | | | | | | Change-Id: I9c2c69dbf88574cbce85898b2b54654445cdb552 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Initial support for composite typesSimon Hausmann2013-09-201-2/+13
| | | | | | | | | | Change-Id: I01030814a978d8a52a086b0389fe62af42a4bbba Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Initial support for componentsSimon Hausmann2013-09-201-6/+22
| | | | | | | | | | | | | | | | | | We use a dedicated pass through the objects in QV4::CompiledData::QmlUnit to determine which objects are QQmlComponents. We remember their object indices as well as to which component other objects belong to (if any). Change-Id: I97929c57e2ccb2fd380d612002d128359c4bc253 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Initial support for attached propertiesSimon Hausmann2013-09-201-4/+4
| | | | | | | | | | | | | | | | | | Attached properties are implemented similarly to group properties, except that the object operated on isn't a QQmlValueType from a property (i.e. font) but the QObject that implements the attached properties. Change-Id: If73751162c191c65512ca1bddadd6270e6e33793 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Initial implementation of signal handler supportSimon Hausmann2013-09-201-0/+16
| | | | | | | | | | | | | | | | | | | | Signal handlers start out in the parser as binding expressions. A new SignalHandlerConverter converts the bindings then so that the expression is turned into a function declaration where the function parameters match the parameters of the signal. Change-Id: I3ea5aa3b80a6ee3b095c6841c63c3e3bb0b47e4f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Add support for id propertiesSimon Hausmann2013-09-201-0/+8
| | | | | | | | | | Change-Id: Idb4a0ad06f6cbe5d040da075a8f43d067a27ebc4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * [new compiler] Initial support for group propertiesSimon Hausmann2013-09-201-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements support for "font.pixelSize: 24" for example. The representation in the compile data structure is so that font.pixelSize is short-hand for font { pixelSize: 24 } which means that inside the braces is a complete object initializer. For that initializer we create a dedicated CompiledData::Object, which however has its type name empty. When populating the outer instance then, the "font" property is read as QQmlValueType (a QObject) and instead of creating a new QObject we use that value type as instance to run the rest of the QML object initializer (everything in braces). Change-Id: Ic0a37ac77ab88f582546b9c09a3d06a07726420b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into HEADSimon Hausmann2013-09-201-2/+8
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_masm.cpp src/qml/jsruntime/qv4script.cpp src/qml/qml/qml.pri src/qml/qml/qqmltypeloader_p.h Change-Id: Ia784d855a2131e3289454f12d841ca2c65be15c1
| * | [new compiler] Implement proper type resolutionSimon Hausmann2013-09-131-3/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | Collect all references to unknown types after parsing, re-use the existing code in QQmlTypeLoader to resolve them and finally use the resolved references map in the QQmlObjectCreator instead of the type name cache directly. Change-Id: I8b83af4f8852e79c33985457081c024358bb9622 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | Fix error reporting timingSimon Hausmann2013-09-121-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Errors for example in signal declarations are usually reported in the loader thread, during property cache construction. This patch separates out the property cache population into QQmlPropertyCacheCreator, runs it from the loader thread and reduces the QQmlObjectCreator to merely set the properties/bindings/ functions on the object. This also enables location tracking for signal declarations and their error reporting. Change-Id: Ief1ffbb3113f8279a50d1a12dab8dbe096702a60 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | [new compiler] Fix type name cache creationSimon Hausmann2013-09-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-use the QQmlImports object created already in the type loader, which will take care of importing scripts and others. This gets rid of the "###" in qqmlobjectcreator and also delegates the type name cache population back to the loader thread. (And will allow for passing to the JS code gen, for type resolution and propagation in the future) Change-Id: I21b0dfc853166200b3bc864f6c0644b2f87a4586 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | Free the parsed QML data structure when we're done compiling the typeSimon Hausmann2013-09-081-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | The QQmlTypeData is going to stick around (and keep the important stuff in its m_compiledData member), but the rest of the data we can free. Change-Id: If331504055960145911fef566b309f812dca5337 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | Beginning of a new qml parserSimon Hausmann2013-09-081-9/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to parse QML and JavaScript binding expressions/functions in one go and generate data structures that allow for the parsing to happen in a thread and the instantiation of the object tree in another thread, just reading from the generated data structures. This will replace qqmlcompiler and the VME. This new way of loading QML is currently hidden behind the QML_NEW_COMPILER=1 environment variable. There's lots of work left to fill in the gaps in object construction, Component support, Component.onComplete, error messages, etc. etc. Change-Id: I5e40643cff169f469f0b6ce151584ffee5ca5e90 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | Remove unused script parser optionsSimon Hausmann2013-09-071-21/+6
| | | | | | | | | | | | | | | Change-Id: Ie3aafe924011466ce2677e10cc69ece61a563db3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | Use a handwritten offsetof macroLars Knoll2013-09-201-3/+3
| |/ |/| | | | | | | | | | | | | | | | | clang complains about our usage of offsetof(). What we do is not strictly c++98 compliant, but compliant with c++11. So replace the default offsetof with a handwritten macro to shut up clang until we can switch to c++11 mode for all compilers. Change-Id: Id724adb323ba9724ad5d7d9e0dba5a73b51af24f Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* | Add qmlProtectModuleAlan Alpert2013-09-201-1/+7
| | | | | | | | | | | | | | | | | | A C++ analog to the protected qmldir syntax, this is also a potential performance improvement because we can avoid some file system accesses. Change-Id: I41781a6cc72aa65bd2d397800345ea16ef442e90 Reviewed-by: Antti Piira <apiira@blackberry.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make QQmlAbstractUrlInterceptor publicAlan Alpert2013-09-191-1/+1
|/ | | | | | | | | | | A supporting class for file selectors and qml import control, it allows redirecting local file paths (use a QNAM for remote paths). All work was done previously for Qt 5.1, including tests. This is just making it public for Qt 5.2. Change-Id: Icb319cc23200541c8e4088b2d400e9af94f3eee5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge "Merge branch 'stable' into dev" into refs/staging/devSergio Ahumada2013-08-061-16/+2
|\
| * Always use QDir::exists() for checking if something existsAndy Shaw2013-07-251-16/+2
| | | | | | | | | | | | | | | | | | | | | | If there is a custom file engine in use by the application then it will not be able to tell if the file exists if the system stat() call is used. Therefore we let it use QDir::exists() on all platforms to ensure that this is taken care of. Change-Id: I0c93cfdad1e71b40512bcf1766de6a705a76bd9c Reviewed-by: Marcus Tillmanns <maddimax@gmail.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* | Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into ↵Simon Hausmann2013-06-241-11/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wip/v4 Conflicts: src/imports/qtquick2/plugins.qmltypes src/qml/debugger/qv8debugservice.cpp src/qml/qml/qml.pri src/qml/qml/qqmlcompiler.cpp src/qml/qml/qqmlcomponent.cpp src/qml/qml/qqmlcontext.cpp src/qml/qml/qqmldata_p.h src/qml/qml/qqmlengine_p.h src/qml/qml/qqmljavascriptexpression.cpp src/qml/qml/qqmlxmlhttprequest.cpp src/qml/qml/v4/qv4bindings.cpp src/qml/qml/v4/qv4irbuilder.cpp src/qml/qml/v4/qv4jsonobject_p.h src/qml/qml/v8/qqmlbuiltinfunctions.cpp src/qml/qml/v8/qv8bindings.cpp src/qml/qml/v8/qv8contextwrapper.cpp src/qml/qml/v8/qv8listwrapper.cpp src/qml/qml/v8/qv8qobjectwrapper.cpp src/qml/qml/v8/qv8qobjectwrapper_p.h src/qml/qml/v8/qv8sequencewrapper_p_p.h src/qml/qml/v8/qv8typewrapper.cpp src/qml/qml/v8/qv8valuetypewrapper.cpp src/qml/types/qqmldelegatemodel.cpp src/quick/items/context2d/qquickcanvasitem.cpp src/quick/items/context2d/qquickcontext2d.cpp sync.profile tests/auto/qml/qjsengine/tst_qjsengine.cpp tests/benchmarks/qml/animation/animation.pro tools/qmlprofiler/qmlprofiler.pro Change-Id: I18a76b8a81d87523247fa03a44ca334b1a2360c9
| * Add a URL interceptor to the QML engineAlan Alpert2013-05-071-11/+20
| | | | | | | | | | | | | | | | Allows for custom file handling to a greater extent than the QNetworkAccessManager. Change-Id: Ifd3946bf33530c40ca2edeeb9f441f712e4941f6 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
* | Replace usage of v8::Script and qmlModeCompile with QV4::ScriptLars Knoll2013-05-221-1/+2
| | | | | | | | | | Change-Id: I114a0b7faed39be313cde5617a0ce4a06dece7e2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Convert qqmltypeloader to use QV4::PersistentValueLars Knoll2013-05-081-3/+0
|/ | | | | Change-Id: Ifc4e2aea870a3a8ab37cd4d0674c672f0850f98f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Android: Support implicit import paths for assets:/ urlsEskil Abrahamsen Blomfeldt2013-04-051-1/+16
| | | | | | | | | | | | | | The assets: scheme is not handled by QNetworkAccessManager, so it needs to be special cased along side the qrc: scheme. We make QML recognize it as a synchronously loaded, local file, and we make the type loader get the correct path and check existence of the directory correctly. This makes it possible to implicitly import the containing directory of QML files that are bundled in the assets directory. Task-number: QTBUG-30510 Change-Id: I048292757e509066a4af342081ec8428e2bd8af3 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Delay loading implicit importAlan Alpert2013-03-271-16/+43
| | | | | | | | As a performance improvement to avoid extra filesystem access, only import "." if it is needed for type resolution. Change-Id: If9be25deb3205f8c81f9f418404d9fb41bebb84f Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
* Work with synchronous replies from a custom QNetworkAccessManagerAlan Alpert2013-03-041-6/+21
| | | | | | | | Forward port of e5783b79887299d094 from QtQuick 1. Task-number: QTBUG-27723 Change-Id: I4332dd72bb9d65167307c1ac5ce24e93b14cff5f Reviewed-by: Peter Hartmann <phartmann@rim.com>
* Add Composite Types to QQmlTypeAlan Alpert2013-02-181-8/+7
| | | | | | | | | When a composite type is loaded from a QML file, it now generates a QQmlType entry in QQmlMetaTypeData. Change-Id: I9b127dff7955456aacb25138fa6ea8efb7bb9221 Reviewed-by: Christopher Adams <chris.adams@jollamobile.com> Reviewed-by: Alan Alpert <aalpert@rim.com>
* Fix lupdate-warnings.Friedemann Kleint2013-02-061-1/+1
| | | | | | | | | qqmlcomponent.cpp:667: Cannot invoke tr() like this qqmltypeloader.cpp:2292: Cannot invoke tr() like this qquickloader.cpp:944: Cannot invoke tr() like this Change-Id: Ifdd1a7b958b6af88f251e7df27eb4d4018301914 Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | Change-Id: I6c3bd7bebe3d62d1cfd0fa6334544c9db8398c76 Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Fixed missing virtual destructors in qtdeclarative.Samuel Rødal2012-09-241-0/+3
| | | | | | Change-Id: I0b0e63b572617a56874e27361479de2690644aa3 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-231-24/+24
| | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Ie7f5d49ed8235d7a7845ab68f99ad1c220e64d5c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* doc: fix some typos in .cpp filesSergio Ahumada2012-09-071-1/+1
| | | | | Change-Id: Ica7685aefde84ec80d8af7a67541af454de4adce Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Refactor singleton type registration codeChris Adams2012-08-281-3/+1
| | | | | | | | | | | Previously each singleton type was registered as an implicit separate import. This commit changes the code so that these types are treated just like any other type in the registration sense. It also ensures that singleton types are instantiated per-engine. Change-Id: I5c81c4ca5bf65210f7125d74a62a282a21838068 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Implement strict mode for qmldir modulesMatthew Vogt2012-07-311-0/+5
| | | | | | | | | | | | | | | Allow a module's qmldir to contain a module directive, which when present specifies 'strict mode' import processing. In strict mode, type registrations are only permitted into the namespace identified in the qmldir file's module directive. In addition, any type registrations to that namespace originating from other modules are treated as error conditions. Task-number: QTBUG-26551 Change-Id: I081bde2d3b83d3f28524440177fb2cd1ccee34ad Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Fix QML import paths in Qt resources.Aaron McCarthy2012-07-271-0/+5
| | | | | | | | | | | | | | | Allow adding qrc: urls as import paths. Store an import path of the form :/import/path as qrc:/import/path which is expected by other parts of the code. Update documentation for QQmlEngine::addImportPath() to explicitly state what types of paths are supported. Add auto tests to check that importing a module from a Qt resource works. Change-Id: If0e75c75078a608b20d7a5c4080bccf6241e97f6 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Support remote import pathsMatthew Vogt2012-07-161-194/+448
| | | | | | | | | | | Probe for installed modules in import path elements which are not local to the machine. Note that all local paths in the import path list will be tried before any remote locations are probed. Task-number: QTBUG-21386 Change-Id: I4f7b9e54e54c1d62a5e7cb7f059ee1e9319ef054 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Improved error messages for malformed .import statementsMatthew Vogt2012-07-111-4/+11
| | | | | | | | | Report errors in .import statements, rather than pass them through to V8 to yield 'Syntax error'. Task-number: QTBUG-24867 Change-Id: I111b3bd3d198e97f42b29591f61753e86295aeb2 Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
* Fix filesystem case sensitivity of QML directory cacheMartin Jones2012-06-061-101/+45
| | | | | | | | Don't attempt to compare file case - if we miss the cache do a stat to determine file existance. Change-Id: Ida79e81c75bc8f4064ba823d11fd0a097bac8b6b Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Lazily create QMetaObjectsAaron Kennedy2012-05-241-10/+4
| | | | | | | | | | For internal QML built types, creating a metaobject each time is just wasteful. Additionally, as the property caches were always created from the intermediate QMetaObject, it was difficult to pass information directly from the compiler to the property cache. Change-Id: I769526b0edaaf16a86883f3065b75618b94e4077 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Optimize qmldir parsingMartin Jones2012-05-241-8/+4
| | | | | | | | From 840K instr to 340K instr for large project. Change-Id: Ib1e4d5ea94001b6650211b96f262db28a05d8260 Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>