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#include "qqmlmetaobject_p.h"
5
6#include <private/qqmlengine_p.h>
7#include <private/qqmlpropertycachemethodarguments_p.h>
8
9QT_BEGIN_NAMESPACE
10
11void QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, const QMetaObject **metaObject, int *index)
12{
13 int offset;
14
15 switch (type) {
16 case QMetaObject::ReadProperty:
17 case QMetaObject::WriteProperty:
18 case QMetaObject::ResetProperty:
19 offset = (*metaObject)->propertyOffset();
20 while (*index < offset) {
21 *metaObject = (*metaObject)->superClass();
22 offset = (*metaObject)->propertyOffset();
23 }
24 break;
25 case QMetaObject::InvokeMetaMethod:
26 offset = (*metaObject)->methodOffset();
27 while (*index < offset) {
28 *metaObject = (*metaObject)->superClass();
29 offset = (*metaObject)->methodOffset();
30 }
31 break;
32 default:
33 offset = 0;
34 Q_UNIMPLEMENTED();
35 offset = INT_MAX;
36 }
37
38 *index -= offset;
39}
40
41QMetaType QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const
42{
43 Q_ASSERT(_m && data.coreIndex() >= 0);
44
45 QMetaType type = data.propType();
46 if (!type.isValid()) {
47 // Find the return type name from the method info
48 type = _m->method(index: data.coreIndex()).returnMetaType();
49 }
50 if (type.flags().testFlag(flag: QMetaType::IsEnumeration))
51 type = type.underlyingType();
52 if (type.isValid())
53 return type;
54 else if (unknownTypeError)
55 *unknownTypeError = _m->method(index: data.coreIndex()).typeName();
56 return QMetaType();
57}
58
59QT_END_NAMESPACE
60

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/qml/qml/qqmlmetaobject.cpp