Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlcustomparser_p.h
Go to the documentation of this file.
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
4#ifndef QQMLCUSTOMPARSER_H
5#define QQMLCUSTOMPARSER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQml/qqmlerror.h>
19#include <QtQml/private/qqmlbinding_p.h>
20#include <private/qv4compileddata_p.h>
21
22#include <QtCore/qbytearray.h>
23
25
26class QQmlPropertyValidator;
28
29class Q_QML_EXPORT QQmlCustomParser
30{
31public:
32 enum Flag {
33 NoFlag = 0x00000000,
34 AcceptsAttachedProperties = 0x00000001,
35 AcceptsSignalHandlers = 0x00000002
36 };
37 Q_DECLARE_FLAGS(Flags, Flag)
38
39 QQmlCustomParser() : engine(nullptr), validator(nullptr), m_flags(NoFlag) {}
40 QQmlCustomParser(Flags f) : engine(nullptr), validator(nullptr), m_flags(f) {}
41 virtual ~QQmlCustomParser() {}
42
43 void clearErrors();
44 Flags flags() const { return m_flags; }
45
46 virtual void verifyBindings(
47 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &,
48 const QList<const QV4::CompiledData::Binding *> &) = 0;
49 virtual void applyBindings(
50 QObject *, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &,
51 const QList<const QV4::CompiledData::Binding *> &) = 0;
52
53 QVector<QQmlError> errors() const { return exceptions; }
54
55protected:
56 void error(const QV4::CompiledData::Binding *binding, const QString& description)
57 { error(binding->location, description); }
58 void error(const QV4::CompiledData::Object *object, const QString& description)
59 { error(object->location, description); }
60 void error(const QV4::CompiledData::Location &location, const QString& description);
61
62 int evaluateEnum(const QString &, bool *ok) const;
63
64 const QMetaObject *resolveType(const QString&) const;
65 QQmlTypeLoader *typeLoader() const;
66
67private:
68 QVector<QQmlError> exceptions;
69 QQmlEnginePrivate *engine;
70 const QQmlPropertyValidator *validator;
71 Flags m_flags;
72 QBiPointer<const QQmlImports, QQmlTypeNameCache> imports;
73 friend class QQmlPropertyValidator;
74 friend class QQmlObjectCreator;
75};
76Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlCustomParser::Flags)
77
78QT_END_NAMESPACE
79
80#endif
The QQmlCustomParser class allows you to add new arbitrary types to QML.
friend class QQmlEnginePrivate