aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/apiextractorresult.h
blob: 88a2093f1f8b9ed8ceb21c45da9893b356e77f8f (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef APIEXTRACTORRESULT_H
#define APIEXTRACTORRESULT_H

#include "apiextractorflags.h"
#include "abstractmetatype.h"
#include "abstractmetalang_typedefs.h"
#include "typesystem_typedefs.h"

#include <QtCore/QHash>
#include <QtCore/QMultiHash>

#include <optional>

class ApiExtractorResultData;

struct InstantiatedSmartPointer
{
    AbstractMetaClassCPtr smartPointer; // Template class
    AbstractMetaClassCPtr specialized; // Specialized for type
    AbstractMetaType type;
};

using InstantiatedSmartPointers = QList<InstantiatedSmartPointer>;

/// Result of an ApiExtractor run.
class ApiExtractorResult
{
public:
    ApiExtractorResult();
    ApiExtractorResult(const ApiExtractorResult &);
    ApiExtractorResult &operator=(const ApiExtractorResult &);
    ApiExtractorResult(ApiExtractorResult &&) noexcept;
    ApiExtractorResult &operator=(ApiExtractorResult &&) noexcept;
    ~ApiExtractorResult();

    const AbstractMetaEnumList &globalEnums() const;
    const AbstractMetaFunctionCList &globalFunctions() const;
    const AbstractMetaClassCList &classes() const;
    const AbstractMetaClassCList &smartPointers() const;

    const AbstractMetaTypeList &instantiatedContainers() const;
    const InstantiatedSmartPointers &instantiatedSmartPointers() const;

    const QMultiHash<QString, QString> &typedefTargetToName() const;

    // Query functions for the generators
    std::optional<AbstractMetaEnum>
        findAbstractMetaEnum(TypeEntryCPtr typeEntry) const;

    /// Retrieves a list of constructors used in implicit conversions
    /// available on the given type. The TypeEntry must be a value-type
    /// or else it will return an empty list.
    ///  \param type a TypeEntry that is expected to be a value-type
    /// \return a list of constructors that could be used as implicit converters
    AbstractMetaFunctionCList implicitConversions(const TypeEntryCPtr &type) const;
    AbstractMetaFunctionCList implicitConversions(const AbstractMetaType &metaType) const;

    ApiExtractorFlags flags() const;
    void setFlags(ApiExtractorFlags f);

private:
    AbstractMetaClassCList m_metaClasses;
    AbstractMetaClassCList m_smartPointers;
    AbstractMetaFunctionCList m_globalFunctions;
    AbstractMetaEnumList m_globalEnums;
    AbstractMetaTypeList m_instantiatedContainers;
    InstantiatedSmartPointers m_instantiatedSmartPointers;
    QHash<TypeEntryCPtr, AbstractMetaEnum> m_enums;
    QMultiHash<QString, QString> m_typedefTargetToName;
    ApiExtractorFlags m_flags;

    friend class ApiExtractor;
};

#endif // APIEXTRACTORRESULT_H