aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideqml/pysideqmltypeinfo_p.h
blob: 465299833d521a549ace68ca5ee6040302c0b3a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef PYSIDEQMLTYPEINFO_P_H
#define PYSIDEQMLTYPEINFO_P_H

#include <sbkpython.h>

#include <QtCore/QFlags>
#include <QtCore/QSharedPointer>

#include <string>

QT_FORWARD_DECLARE_CLASS(QDebug)
QT_FORWARD_DECLARE_CLASS(QObject)
QT_FORWARD_DECLARE_STRUCT(QMetaObject)

namespace PySide::Qml {

enum class QmlTypeFlag
{
    Singleton = 0x1,
    Uncreatable = 0x2
};

Q_DECLARE_FLAGS(QmlTypeFlags, QmlTypeFlag)
Q_DECLARE_OPERATORS_FOR_FLAGS(QmlTypeFlags)

// Type information associated with QML type objects
struct QmlTypeInfo
{
    QmlTypeFlags flags;
    std::string noCreationReason;
    PyTypeObject *foreignType = nullptr;
    PyTypeObject *attachedType = nullptr;
    PyTypeObject *extensionType = nullptr;
};

using QmlTypeInfoPtr = QSharedPointer<QmlTypeInfo>;

QmlTypeInfoPtr ensureQmlTypeInfo(const PyObject *o);
void insertQmlTypeInfoAlias(const PyObject *o, const QmlTypeInfoPtr &value);
QmlTypeInfoPtr qmlTypeInfo(const PyObject *o);

// Meta Object and factory function for QmlExtended/QmlAttached
struct QmlExtensionInfo
{
    using Factory = QObject *(*)(QObject *);

    Factory factory;
    const QMetaObject *metaObject;
};

#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const QmlTypeInfo &);
QDebug operator<<(QDebug d, const QmlExtensionInfo &);
#endif

} // namespace PySide::Qml

#endif // PYSIDEQMLTYPEINFO_P_H