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
removed_api.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 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#define QT_QML_BUILD_REMOVED_API
6
7#include "qtqmlglobal.h"
8
9QT_USE_NAMESPACE
10
11#if QT_QML_REMOVED_SINCE(6, 5)
12
13#include <QtQml/qjsengine.h>
14
15QJSValue QJSEngine::create(int typeId, const void *ptr)
16{
17 QMetaType type(typeId);
18 return create(type, ptr);
19}
20
21bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
22{
23 return convertV2(value, QMetaType(type), ptr);
24}
25
26#endif
27
28#if QT_QML_REMOVED_SINCE(6, 6)
29#include <QtQml/qqmlprivate.h>
30#include <QtQml/private/qv4executablecompilationunit_p.h>
31#include <QtQml/private/qv4lookup_p.h>
32
33bool QQmlPrivate::AOTCompiledContext::getEnumLookup(uint index, int *target) const
34{
35 using namespace QQmlPrivate;
36 QV4::Lookup *lookup = compilationUnit->runtimeLookups + index;
37 auto mt = QMetaType(lookup->qmlEnumValueLookup.metaType);
38 QVariant buffer(mt);
39 getEnumLookup(index, buffer.data());
40 *target = buffer.toInt();
41 return true;
42}
43#endif
44
45#if QT_QML_REMOVED_SINCE(6, 9)
46#include <QtQml/qqmlprivate.h>
47#include <QtQml/private/qv4executablecompilationunit_p.h>
48#include <QtQml/private/qv4lookup_p.h>
49#include <QtQml/private/qv4qobjectwrapper_p.h>
50
51bool QQmlPrivate::AOTCompiledContext::callObjectPropertyLookup(
52 uint index, QObject *object, void **args, const QMetaType *types, int argc) const
53{
54 QV4::Lookup *lookup = compilationUnit->runtimeLookups + index;
55 QV4::Scope scope(engine->handle());
56 QV4::ScopedValue thisObject(scope, QV4::QObjectWrapper::wrap(scope.engine, object));
57 QV4::ScopedFunctionObject function(scope, lookup->getter(engine->handle(), thisObject));
58 if (!function) {
59 scope.engine->throwTypeError(
60 QStringLiteral("Property '%1' of object [object Object] is not a function")
61 .arg(compilationUnit->runtimeStrings[lookup->nameIndex]->toQString()));
62 return false;
63 }
64
65 function->call(object, args, types, argc);
66 return !scope.hasException();
67}
68
69void QQmlPrivate::AOTCompiledContext::initCallObjectPropertyLookup(uint index) const
70{
71 Q_UNUSED(index);
72 Q_ASSERT(engine->hasError());
73 engine->handle()->amendException();
74}
75
76bool QQmlPrivate::AOTCompiledContext::callQmlContextPropertyLookup(
77 uint index, void **args, const QMetaType *types, int argc) const
78{
79 QV4::Lookup *lookup = compilationUnit->runtimeLookups + index;
80 QV4::Scope scope(engine->handle());
81 QV4::ScopedValue thisObject(scope);
82 QV4::ScopedFunctionObject function(
83 scope, lookup->contextGetter(scope.engine, thisObject));
84 if (!function) {
85 scope.engine->throwTypeError(
86 QStringLiteral("Property '%1' of object [null] is not a function").arg(
87 compilationUnit->runtimeStrings[lookup->nameIndex]->toQString()));
88 return false;
89 }
90
91 function->call(qmlScopeObject, args, types, argc);
92 return !scope.hasException();
93}
94
95void QQmlPrivate::AOTCompiledContext::initCallQmlContextPropertyLookup(uint index) const
96{
97 Q_UNUSED(index);
98 Q_ASSERT(engine->hasError());
99 engine->handle()->amendException();
100}
101
102bool QQmlPrivate::AOTCompiledContext::loadGlobalLookup(uint index, void *target, QMetaType type) const
103{
104 QV4::Lookup *lookup = compilationUnit->runtimeLookups + index;
105 QV4::Scope scope(engine->handle());
106 QV4::ScopedValue v(scope, lookup->globalGetter(engine->handle()));
107 if (!QV4::ExecutionEngine::metaTypeFromJS(
108 v, type, target)) {
109 engine->handle()->throwTypeError();
110 return false;
111 }
112 return true;
113}
114
115void QQmlPrivate::AOTCompiledContext::initLoadGlobalLookup(uint index) const
116{
117 Q_UNUSED(index);
118 Q_ASSERT(engine->hasError());
119 engine->handle()->amendException();
120}
121
122QVariant QQmlPrivate::AOTCompiledContext::constructValueType(
123 QMetaType resultMetaType, const QMetaObject *resultMetaObject,
124 int ctorIndex, void *ctorArg) const
125{
126 void *args[] = {ctorArg};
127 return QQmlValueTypeProvider::constructValueType(
128 resultMetaType, resultMetaObject, ctorIndex, args);
129}
130
131bool QQmlPrivate::AOTCompiledContext::callGlobalLookup(
132 uint index, void **args, const QMetaType *types, int argc) const
133{
134 QV4::Lookup *lookup = compilationUnit->runtimeLookups + index;
135 QV4::Scope scope(engine->handle());
136 QV4::ScopedFunctionObject function(scope, lookup->globalGetter(scope.engine));
137 if (!function) {
138 scope.engine->throwTypeError(
139 QStringLiteral("Property '%1' of object [null] is not a function")
140 .arg(compilationUnit->runtimeStrings[lookup->nameIndex]->toQString()));
141 return false;
142 }
143
144 function->call(nullptr, args, types, argc);
145 return true;
146}
147
148void QQmlPrivate::AOTCompiledContext::initCallGlobalLookup(uint index) const
149{
150 Q_UNUSED(index);
151 Q_ASSERT(engine->hasError());
152 engine->handle()->amendException();
153}
154
155void QQmlPrivate::AOTCompiledContext::initLoadScopeObjectPropertyLookup(
156 uint index, QMetaType type) const
157{
158 Q_UNUSED(type);
159 return initLoadScopeObjectPropertyLookup(index);
160}
161
162void QQmlPrivate::AOTCompiledContext::initGetObjectLookup(
163 uint index, QObject *object, QMetaType type) const
164{
165 return type == QMetaType::fromType<QVariant>()
166 ? initGetObjectLookupAsVariant(index, object)
167 : initGetObjectLookup(index, object);
168}
169
170void QQmlPrivate::AOTCompiledContext::initSetObjectLookup(
171 uint index, QObject *object, QMetaType type) const
172{
173 return type == QMetaType::fromType<QVariant>()
174 ? initSetObjectLookupAsVariant(index, object)
175 : initSetObjectLookup(index, object);
176}
177
178void QQmlPrivate::AOTCompiledContext::initGetValueLookup(
179 uint index, const QMetaObject *metaObject, QMetaType type) const {
180 Q_UNUSED(type);
181 initGetValueLookup(index, metaObject);
182}
183
184void QQmlPrivate::AOTCompiledContext::initSetValueLookup(
185 uint index, const QMetaObject *metaObject, QMetaType type) const
186{
187 Q_UNUSED(type);
188 initSetValueLookup(index, metaObject);
189}
190
191#endif