~ubuntu-branches/ubuntu/wily/qtdeclarative-opensource-src/wily-proposed

« back to all changes in this revision

Viewing changes to src/qml/qml/qqmltypeloader_p.h

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Ricardo Salveti de Araujo, Timo Jyrinki
  • Date: 2014-06-19 02:39:21 UTC
  • mfrom: (0.1.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140619023921-yb2oasnuetz9b0fc
Tags: 5.3.0-3ubuntu4
[ Ricardo Salveti de Araujo ]
* debian/control:
  - Updating dependencies as we now also have libqt5quickwidgets5-gles
* libqt5quickwidgets5.symbols: updating to allow gles variant

[ Timo Jyrinki ]
* Update libqt5quickparticles5.symbols from build logs

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#include <QtQml/qqmlabstracturlinterceptor.h>
63
63
 
64
64
#include <private/qhashedstring_p.h>
65
 
#include <private/qqmlscript_p.h>
66
65
#include <private/qqmlimport_p.h>
67
66
#include <private/qqmlcleanup_p.h>
68
67
#include <private/qqmldirparser_p.h>
69
68
#include <private/qqmlbundle_p.h>
70
69
#include <private/qflagpointer_p.h>
 
70
#include <private/qqmlirbuilder_p.h>
71
71
 
72
 
#include <private/qv4value_p.h>
 
72
#include <private/qv4value_inl_p.h>
73
73
#include <private/qv4script_p.h>
74
74
 
75
75
QT_BEGIN_NAMESPACE
84
84
class QQmlDataLoader;
85
85
class QQmlExtensionInterface;
86
86
 
87
 
namespace QtQml {
88
 
struct ParsedQML;
 
87
namespace QmlIR {
 
88
struct Document;
89
89
}
90
90
 
91
91
class Q_QML_PRIVATE_EXPORT QQmlDataBlob : public QQmlRefCount
155
155
 
156
156
    // Callbacks made in load thread
157
157
    virtual void dataReceived(const Data &) = 0;
 
158
    virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) = 0;
158
159
    virtual void done();
159
160
    virtual void networkError(QNetworkReply::NetworkError);
160
161
    virtual void dependencyError(QQmlDataBlob *);
189
190
 
190
191
    // m_errors should *always* be written before the status is set to Error.
191
192
    // We use the status change as a memory fence around m_errors so that locking
192
 
    // isn't required.  Once the status is set to Error (or Complete), m_errors 
 
193
    // isn't required.  Once the status is set to Error (or Complete), m_errors
193
194
    // cannot be changed.
194
195
    QList<QQmlError> m_errors;
195
196
 
228
229
 
229
230
    void load(QQmlDataBlob *, Mode = PreferSynchronous);
230
231
    void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous);
 
232
    void loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
231
233
 
232
234
    QQmlEngine *engine() const;
233
235
    void initializeEngine(QQmlExtensionInterface *, const char *);
242
244
 
243
245
    void loadThread(QQmlDataBlob *);
244
246
    void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
 
247
    void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
245
248
    void networkReplyFinished(QNetworkReply *);
246
249
    void networkReplyProgress(QNetworkReply *, qint64, qint64);
247
 
    
 
250
 
248
251
    typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies;
249
252
 
250
253
    void setData(QQmlDataBlob *, const QByteArray &);
251
254
    void setData(QQmlDataBlob *, QQmlFile *);
252
255
    void setData(QQmlDataBlob *, const QQmlDataBlob::Data &);
 
256
    void setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
253
257
 
254
258
    QQmlEngine *m_engine;
255
259
    QQmlDataLoaderThread *m_thread;
264
268
    QString fileName;
265
269
};
266
270
 
267
 
class QQmlTypeLoader : public QQmlDataLoader
 
271
class Q_AUTOTEST_EXPORT QQmlTypeLoader : public QQmlDataLoader
268
272
{
269
273
    Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader)
270
274
public:
275
279
        ~Blob();
276
280
 
277
281
        QQmlTypeLoader *typeLoader() const { return m_typeLoader; }
278
 
        const QQmlImports &imports() const { return m_imports; }
 
282
        const QQmlImports &imports() const { return m_importCache; }
279
283
 
280
284
    protected:
281
 
        bool addImport(const QQmlScript::Import &import, QList<QQmlError> *errors);
282
 
        bool addPragma(const QQmlScript::Pragma &pragma, QList<QQmlError> *errors);
 
285
        bool addImport(const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
 
286
        bool addPragma(const QmlIR::Pragma &pragma, QList<QQmlError> *errors);
283
287
 
284
 
        bool fetchQmldir(const QUrl &url, const QQmlScript::Import *import, int priority, QList<QQmlError> *errors);
285
 
        bool updateQmldir(QQmlQmldirData *data, const QQmlScript::Import *import, QList<QQmlError> *errors);
 
288
        bool fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors);
 
289
        bool updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
286
290
 
287
291
    private:
288
292
        virtual bool qmldirDataAvailable(QQmlQmldirData *, QList<QQmlError> *);
289
293
 
290
 
        virtual void scriptImported(QQmlScriptBlob *, const QQmlScript::Location &, const QString &, const QString &) {}
 
294
        virtual void scriptImported(QQmlScriptBlob *, const QV4::CompiledData::Location &, const QString &, const QString &) {}
291
295
 
292
296
        virtual void dependencyError(QQmlDataBlob *);
293
297
        virtual void dependencyComplete(QQmlDataBlob *);
294
298
 
295
299
    protected:
 
300
        virtual QString stringAt(int) const { return QString(); }
 
301
 
296
302
        QQmlTypeLoader *m_typeLoader;
297
 
        QQmlImports m_imports;
 
303
        QQmlImports m_importCache;
298
304
        bool m_isSingleton;
299
 
        QHash<const QQmlScript::Import *, int> m_unresolvedImports;
 
305
        QHash<const QV4::CompiledData::Import*, int> m_unresolvedImports;
300
306
        QList<QQmlQmldirData *> m_qmldirs;
301
307
    };
302
308
 
396
402
public:
397
403
    struct TypeReference
398
404
    {
399
 
        TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0) {}
 
405
        TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0), needsCreation(true) {}
400
406
 
401
 
        QQmlScript::Location location;
 
407
        QV4::CompiledData::Location location;
402
408
        QQmlType *type;
403
409
        int majorVersion;
404
410
        int minorVersion;
405
411
        QQmlTypeData *typeData;
406
412
        QString prefix; // used by CompositeSingleton types
 
413
        bool needsCreation;
407
414
    };
408
415
 
409
416
    struct ScriptReference
410
417
    {
411
418
        ScriptReference() : script(0) {}
412
419
 
413
 
        QQmlScript::Location location;
 
420
        QV4::CompiledData::Location location;
414
421
        QString qualifier;
415
422
        QQmlScriptBlob *script;
416
423
    };
423
430
public:
424
431
    ~QQmlTypeData();
425
432
 
426
 
    const QQmlScript::Parser &parser() const;
 
433
    const QHash<int, TypeReference> &resolvedTypeRefs() const { return m_resolvedTypes; }
427
434
 
428
 
    const QList<TypeReference> &resolvedTypes() const;
429
435
    const QList<ScriptReference> &resolvedScripts() const;
430
436
    const QSet<QString> &namespaces() const;
431
437
    const QList<TypeReference> &compositeSingletons() const;
445
451
    virtual void done();
446
452
    virtual void completed();
447
453
    virtual void dataReceived(const Data &);
 
454
    virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
448
455
    virtual void allDependenciesDone();
449
456
    virtual void downloadProgressChanged(qreal);
450
457
 
 
458
    virtual QString stringAt(int index) const;
 
459
 
451
460
private:
 
461
    void continueLoadFromIR();
452
462
    void resolveTypes();
453
463
    void compile();
454
 
    bool resolveType(const QQmlScript::TypeReference *parserRef, int &majorVersion, int &minorVersion, TypeReference &ref);
455
 
 
456
 
    virtual void scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &nameSpace);
457
 
 
458
 
    // --- old compiler
459
 
    QQmlScript::Parser scriptParser;
460
 
    // --- new compiler
461
 
    QScopedPointer<QtQml::ParsedQML> parsedQML;
462
 
    QList<QQmlScript::Import> m_newImports;
463
 
    QList<QQmlScript::Pragma> m_newPragmas;
464
 
    // ---
 
464
    bool resolveType(const QString &typeName, int &majorVersion, int &minorVersion, TypeReference &ref);
 
465
 
 
466
    virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
 
467
 
 
468
    QScopedPointer<QmlIR::Document> m_document;
465
469
 
466
470
    QList<ScriptReference> m_scripts;
467
471
 
468
472
    QSet<QString> m_namespaces;
469
473
    QList<TypeReference> m_compositeSingletons;
470
474
 
471
 
    // --- old compiler
472
 
    QList<TypeReference> m_types;
473
 
    // --- new compiler
474
475
    // map from name index to resolved type
475
476
    QHash<int, TypeReference> m_resolvedTypes;
476
 
    // ---
477
477
    bool m_typesResolved:1;
478
 
    bool m_useNewCompiler:1;
479
478
 
480
479
    QQmlCompiledData *m_compiledData;
481
480
 
482
481
    QList<TypeDataCallback *> m_callbacks;
483
482
 
484
 
    QQmlScript::Import *m_implicitImport;
 
483
    QV4::CompiledData::Import *m_implicitImport;
485
484
    bool m_implicitImportLoaded;
486
485
    bool loadImplicitImport();
487
486
};
488
487
 
489
 
// QQmlScriptData instances are created, uninitialized, by the loader in the 
 
488
// QQmlScriptData instances are created, uninitialized, by the loader in the
490
489
// load thread.  The first time they are used by the VME, they are initialized which
491
490
// creates their v8 objects and they are referenced and added to the  engine's cleanup
492
 
// list.  During QQmlCleanup::clear() all v8 resources are destroyed, and the 
 
491
// list.  During QQmlCleanup::clear() all v8 resources are destroyed, and the
493
492
// reference that was created is released but final deletion only occurs once all the
494
493
// references as released.  This is all intended to ensure that the v8 resources are
495
494
// only created and destroyed in the main thread :)
507
506
    QString urlString;
508
507
    QQmlTypeNameCache *importCache;
509
508
    QList<QQmlScriptBlob *> scripts;
510
 
    QQmlScript::Object::ScriptBlock::Pragmas pragmas;
511
509
 
512
510
    QV4::PersistentValue scriptValueForContext(QQmlContextData *parentCtxt);
513
511
 
515
513
    virtual void clear(); // From QQmlCleanup
516
514
 
517
515
private:
518
 
    friend class QQmlVME;
519
516
    friend class QQmlScriptBlob;
520
517
 
521
518
    void initialize(QQmlEngine *);
540
537
    {
541
538
        ScriptReference() : script(0) {}
542
539
 
543
 
        QQmlScript::Location location;
 
540
        QV4::CompiledData::Location location;
544
541
        QString qualifier;
545
542
        QString nameSpace;
546
543
        QQmlScriptBlob *script;
547
544
    };
548
545
 
549
 
    QQmlScript::Object::ScriptBlock::Pragmas pragmas() const;
550
 
 
551
546
    QQmlScriptData *scriptData() const;
552
547
 
553
548
protected:
554
549
    virtual void dataReceived(const Data &);
 
550
    virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
555
551
    virtual void done();
556
552
 
 
553
    virtual QString stringAt(int index) const;
 
554
 
557
555
private:
558
 
    virtual void scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &nameSpace);
559
 
 
560
 
    QString m_source;
561
 
    QQmlScript::Parser::JavaScriptMetaData m_metadata;
 
556
    virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
 
557
    void initializeFromCompilationUnit(QV4::CompiledData::CompilationUnit *unit);
562
558
 
563
559
    QList<ScriptReference> m_scripts;
564
560
    QQmlScriptData *m_scriptData;
574
570
public:
575
571
    const QString &content() const;
576
572
 
577
 
    const QQmlScript::Import *import() const;
578
 
    void setImport(const QQmlScript::Import *);
 
573
    const QV4::CompiledData::Import *import() const;
 
574
    void setImport(const QV4::CompiledData::Import *);
579
575
 
580
576
    int priority() const;
581
577
    void setPriority(int);
582
578
 
583
579
protected:
584
580
    virtual void dataReceived(const Data &);
 
581
    virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*);
585
582
 
586
583
private:
587
584
    QString m_content;
588
 
    const QQmlScript::Import *m_import;
 
585
    const QV4::CompiledData::Import *m_import;
589
586
    int m_priority;
590
587
};
591
588