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