Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlmetaobject.cpp
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#include "qqmlmetaobject_p.h"
5
6#include <private/qqmlengine_p.h>
7#include <private/qqmlpropertycachemethodarguments_p.h>
8
10
12{
13 int offset;
14
15 switch (type) {
19 offset = (*metaObject)->propertyOffset();
20 while (*index < offset) {
21 *metaObject = (*metaObject)->superClass();
22 offset = (*metaObject)->propertyOffset();
23 }
24 break;
26 offset = (*metaObject)->methodOffset();
27 while (*index < offset) {
28 *metaObject = (*metaObject)->superClass();
29 offset = (*metaObject)->methodOffset();
30 }
31 break;
32 default:
33 offset = 0;
35 offset = INT_MAX;
36 }
37
38 *index -= offset;
39}
40
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(data.coreIndex()).returnMetaType();
49 }
50 if (type.flags().testFlag(QMetaType::IsEnumeration))
52 if (type.isValid())
53 return type;
54 else if (unknownTypeError)
55 *unknownTypeError = _m->method(data.coreIndex()).typeName();
56 return QMetaType();
57}
58
60 QByteArray *unknownTypeError) const
61{
62 Q_ASSERT(_m && index >= 0);
63
65 return methodParameterTypes(m, argStorage, unknownTypeError);
66}
67
69 QByteArray *unknownTypeError) const
70{
72 return methodParameterTypes(m, dummy, unknownTypeError);
73}
74
76 QByteArray *unknownTypeError)
77{
78 Q_ASSERT(argStorage);
79
80 int argc = m.parameterCount();
81 argStorage->resize(argc);
82 for (int ii = 0; ii < argc; ++ii) {
83 QMetaType type = m.parameterMetaType(ii);
84 // we treat enumerations as int
85 if (type.flags().testFlag(QMetaType::IsEnumeration))
87 if (!type.isValid()) {
88 if (unknownTypeError)
89 *unknownTypeError = m.parameterTypeName(ii);
90 return false;
91 }
92 argStorage->operator[](ii) = type;
93 }
94 return true;
95}
96
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qmetaobject.h:18
const char * typeName() const
Returns the return type name of this method.
QMetaType returnMetaType() const
\inmodule QtCore
Definition qmetatype.h:320
QMetaType underlyingType() const
@ IsEnumeration
Definition qmetatype.h:386
bool constructorParameterTypes(int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError) const
QMetaType methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const
const QMetaObject * metaObject() const
static void resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, const QMetaObject **metaObject, int *index)
const QMetaObject * _m
bool methodParameterTypes(int index, ArgTypeStorage *argStorage, QByteArray *unknownTypeError) const
void resize(qsizetype sz)
Combined button and popup list for selecting options.
const GLfloat * m
GLuint index
[2]
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_UNIMPLEMENTED()
obj metaObject() -> className()
\inmodule QtCore
QMetaMethod constructor(int index) const
int methodOffset() const
Returns the method offset for this class; i.e.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or \nullptr if there is no such object.
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
int propertyOffset() const
Returns the property offset for this class; i.e.