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
qqmlscriptdata_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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 QQMLSCRIPTDATA_P_H
5#define QQMLSCRIPTDATA_P_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 <private/qqmlrefcount_p.h>
19#include <private/qv4value_p.h>
20#include <private/qv4persistent_p.h>
21#include <private/qv4compileddata_p.h>
22#include <private/qv4scopedvalue_p.h>
23
24#include <QtCore/qurl.h>
25
26QT_BEGIN_NAMESPACE
27
28class QQmlTypeNameCache;
29class QQmlContextData;
30
31class Q_AUTOTEST_EXPORT QQmlScriptData final : public QQmlRefCounted<QQmlScriptData>
32{
33private:
34 friend class QQmlTypeLoader;
35
36 QQmlScriptData() = default;
37
38public:
39 QUrl url;
40 QString urlString;
41 QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
42 QVector<QQmlRefPointer<QQmlScriptData>> scripts;
43
44 QV4::ReturnedValue scriptValueForContext(const QQmlRefPointer<QQmlContextData> &parentCtxt);
45
46 QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit() const
47 {
48 return m_precompiledScript;
49 }
50
51private:
52 friend class QQmlScriptBlob;
53 friend struct QV4::ExecutionEngine;
54
55 QQmlRefPointer<QQmlContextData> qmlContextDataForContext(
56 const QQmlRefPointer<QQmlContextData> &parentQmlContextData);
57
58 template<typename WithExecutableCU>
59 QV4::ReturnedValue handleOwnScriptValueOrExecutableCU(
60 QV4::ExecutionEngine *v4,
61 WithExecutableCU &&withExecutableCU) const
62 {
63 QV4::Scope scope(v4);
64
65 if (!m_precompiledScript)
66 return QV4::Value::emptyValue().asReturnedValue();
67
68 return withExecutableCU(v4->executableCompilationUnit(
69 QQmlRefPointer<QV4::CompiledData::CompilationUnit>(m_precompiledScript)));
70 }
71
72 QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_precompiledScript;
73};
74
75QT_END_NAMESPACE
76
77#endif // QQMLSCRIPTDATA_P_H