diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/customconversion.h')
-rw-r--r-- | sources/shiboken6/ApiExtractor/customconversion.h | 97 |
1 files changed, 57 insertions, 40 deletions
diff --git a/sources/shiboken6/ApiExtractor/customconversion.h b/sources/shiboken6/ApiExtractor/customconversion.h index 172600d48..fd0a67759 100644 --- a/sources/shiboken6/ApiExtractor/customconversion.h +++ b/sources/shiboken6/ApiExtractor/customconversion.h @@ -4,61 +4,78 @@ #ifndef CUSTOMCONVERSION_H #define CUSTOMCONVERSION_H -#include "typesystem_enums.h" +#include "customconversion_typedefs.h" +#include "typesystem_typedefs.h" #include <QtCore/QList> #include <QtCore/QString> +QT_FORWARD_DECLARE_CLASS(QDebug) + class TypeEntry; +class TargetToNativeConversion +{ +public: + explicit TargetToNativeConversion(const QString &sourceTypeName, + const QString &sourceTypeCheck, + const QString &conversion = {}); + + TypeEntryCPtr sourceType() const; + void setSourceType(const TypeEntryCPtr &sourceType); + bool isCustomType() const; + QString sourceTypeName() const; + QString sourceTypeCheck() const; + QString conversion() const; + void setConversion(const QString &conversion); + + void formatDebug(QDebug &d) const; + +private: + TypeEntryCPtr m_sourceType; + QString m_sourceTypeName; + QString m_sourceTypeCheck; + QString m_conversion; +}; + +using TargetToNativeConversions = QList<TargetToNativeConversion>; + class CustomConversion { public: - CustomConversion(TypeEntry* ownerType); - ~CustomConversion(); + explicit CustomConversion(const TypeEntryCPtr &ownerType); - const TypeEntry* ownerType() const; + TypeEntryCPtr ownerType() const; QString nativeToTargetConversion() const; - void setNativeToTargetConversion(const QString& nativeToTargetConversion); - - class TargetToNativeConversion - { - public: - TargetToNativeConversion(const QString& sourceTypeName, - const QString& sourceTypeCheck, - const QString& conversion = QString()); - ~TargetToNativeConversion(); - - const TypeEntry* sourceType() const; - void setSourceType(const TypeEntry* sourceType); - bool isCustomType() const; - QString sourceTypeName() const; - QString sourceTypeCheck() const; - QString conversion() const; - void setConversion(const QString& conversion); - private: - struct TargetToNativeConversionPrivate; - TargetToNativeConversionPrivate* m_d; - }; - - /** - * Returns true if the target to C++ custom conversions should - * replace the original existing ones, and false if the custom - * conversions should be added to the original. - */ + void setNativeToTargetConversion(const QString &nativeToTargetConversion); + + /// Returns true if the target to C++ custom conversions should + /// replace the original existing ones, and false if the custom + /// conversions should be added to the original. bool replaceOriginalTargetToNativeConversions() const; - void setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions); + void setReplaceOriginalTargetToNativeConversions(bool r); - using TargetToNativeConversions = QList<TargetToNativeConversion *>; bool hasTargetToNativeConversions() const; - TargetToNativeConversions& targetToNativeConversions(); - const TargetToNativeConversions& targetToNativeConversions() const; - void addTargetToNativeConversion(const QString& sourceTypeName, - const QString& sourceTypeCheck, - const QString& conversion = QString()); + TargetToNativeConversions &targetToNativeConversions(); + const TargetToNativeConversions &targetToNativeConversions() const; + void addTargetToNativeConversion(const QString &sourceTypeName, + const QString &sourceTypeCheck, + const QString &conversion = QString()); + + /// Return the custom conversion of a type; helper for type system parser + static CustomConversionPtr getCustomConversion(const TypeEntryCPtr &type); + + void formatDebug(QDebug &debug) const; + private: - struct CustomConversionPrivate; - CustomConversionPrivate* m_d; + TypeEntryCPtr m_ownerType; + QString m_nativeToTargetConversion; + TargetToNativeConversions m_targetToNativeConversions; + bool m_replaceOriginalTargetToNativeConversions = false; }; +QDebug operator<<(QDebug debug, const TargetToNativeConversion &t); +QDebug operator<<(QDebug debug, const CustomConversion &c); +QDebug operator<<(QDebug debug, const CustomConversionPtr &cptr); + #endif // CUSTOMCONVERSION_H |