1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | #ifndef QQMLPROPERTYVALIDATOR_P_H |
4 | #define QQMLPROPERTYVALIDATOR_P_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is not part of the Qt API. It exists purely as an |
11 | // implementation detail. This header file may change from version to |
12 | // version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | |
17 | #include <private/qqmlengine_p.h> |
18 | #include <private/qqmlimport_p.h> |
19 | #include <private/qqmljsdiagnosticmessage_p.h> |
20 | #include <private/qqmlpropertycache_p.h> |
21 | #include <private/qv4compileddata_p.h> |
22 | |
23 | #include <QtCore/qcoreapplication.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QQmlPropertyValidator |
28 | { |
29 | Q_DECLARE_TR_FUNCTIONS(QQmlPropertyValidator) |
30 | public: |
31 | QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports *imports, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit); |
32 | |
33 | QVector<QQmlError> validate(); |
34 | |
35 | QQmlPropertyCache::ConstPtr rootPropertyCache() const { return propertyCaches.at(index: 0); } |
36 | QUrl documentSourceUrl() const { return compilationUnit->url(); } |
37 | |
38 | private: |
39 | QVector<QQmlError> validateObject( |
40 | int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, |
41 | bool populatingValueTypeGroupProperty = false) const; |
42 | QQmlError validateLiteralBinding( |
43 | const QQmlPropertyCache::ConstPtr &propertyCache, const QQmlPropertyData *property, |
44 | const QV4::CompiledData::Binding *binding) const; |
45 | QQmlError validateObjectBinding( |
46 | const QQmlPropertyData *property, const QString &propertyName, |
47 | const QV4::CompiledData::Binding *binding) const; |
48 | |
49 | bool canCoerce(QMetaType to, QQmlPropertyCache::ConstPtr fromMo) const; |
50 | |
51 | Q_REQUIRED_RESULT QVector<QQmlError> recordError( |
52 | const QV4::CompiledData::Location &location, const QString &description) const; |
53 | Q_REQUIRED_RESULT QVector<QQmlError> recordError(const QQmlError &error) const; |
54 | QString stringAt(int index) const { return compilationUnit->stringAt(index); } |
55 | QV4::ResolvedTypeReference *resolvedType(int id) const |
56 | { |
57 | return compilationUnit->resolvedType(id); |
58 | } |
59 | |
60 | QQmlEnginePrivate *enginePrivate; |
61 | QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; |
62 | const QQmlImports *imports; |
63 | const QV4::CompiledData::Unit *qmlUnit; |
64 | const QQmlPropertyCacheVector &propertyCaches; |
65 | |
66 | QVector<QV4::BindingPropertyData> * const bindingPropertyDataPerObject; |
67 | }; |
68 | |
69 | QT_END_NAMESPACE |
70 | |
71 | #endif // QQMLPROPERTYVALIDATOR_P_H |
72 | |