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// Qt-Security score:significant
4
5#ifndef QQMLSCRIPTDATA_P_H
6#define QQMLSCRIPTDATA_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qqmlrefcount_p.h>
20#include <private/qv4value_p.h>
21#include <private/qv4persistent_p.h>
22#include <private/qv4compileddata_p.h>
23#include <private/qv4scopedvalue_p.h>
24
25#include <QtCore/qurl.h>
26
27QT_BEGIN_NAMESPACE
28
29class QQmlTypeNameCache;
30class QQmlContextData;
31
32class Q_AUTOTEST_EXPORT QQmlScriptData final : public QQmlRefCounted<QQmlScriptData>
33{
34private:
35 friend class QQmlTypeLoader;
36
37 QQmlScriptData() = default;
38
39public:
40 QUrl url;
41 QString urlString;
42 QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
43 QList<QQmlRefPointer<QQmlScriptData>> scripts;
44
45 QV4::ReturnedValue scriptValueForContext(const QQmlRefPointer<QQmlContextData> &parentCtxt);
46
47 QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit() const
48 {
49 return m_precompiledScript;
50 }
51
52private:
53 friend class QQmlScriptBlob;
54 friend struct QV4::ExecutionEngine;
55
56 QQmlRefPointer<QQmlContextData> qmlContextDataForContext(
57 const QQmlRefPointer<QQmlContextData> &parentQmlContextData);
58
59 template<typename WithExecutableCU>
60 QV4::ReturnedValue handleOwnScriptValueOrExecutableCU(
61 QV4::ExecutionEngine *v4,
62 WithExecutableCU &&withExecutableCU) const
63 {
64 QV4::Scope scope(v4);
65
66 if (!m_precompiledScript)
67 return QV4::Value::emptyValue().asReturnedValue();
68
69 return withExecutableCU(v4->executableCompilationUnit(
70 QQmlRefPointer<QV4::CompiledData::CompilationUnit>(m_precompiledScript)));
71 }
72
73 QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_precompiledScript;
74};
75
76QT_END_NAMESPACE
77
78#endif // QQMLSCRIPTDATA_P_H