diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-10-01 14:55:12 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-10-02 11:15:36 +0200 |
| commit | 7afdba8fa948efcaa8f1537af19eb1513736c146 (patch) | |
| tree | 4615b9d0a935d5b53b8d11cafe7b6badc5ee9a90 | |
| parent | 9893580be85a9113a2c7b1dc874bee9d2aed0399 (diff) | |
shiboken6: Fix clazy warnings about too-large underlying types of enumerations
Use the types suggested by clang-tidy.
Change-Id: I0bc80d00e75305423caa4254b1383979e89128ec
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
45 files changed, 96 insertions, 94 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index 9807e1ea6..d67d0f599 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -2067,7 +2067,7 @@ void AbstractMetaBuilderPrivate::rejectFunction(const FunctionModelItem &functio } // Check for special Qt argument types which should be ignored. -enum class QtSpecialArgument +enum class QtSpecialArgument : std::uint8_t { None, PrivateSignal, diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h index 67dc82802..465255e97 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h @@ -31,7 +31,7 @@ class AbstractMetaBuilder public: Q_DISABLE_COPY_MOVE(AbstractMetaBuilder) - enum RejectReason { + enum RejectReason : std::uint8_t { NotInTypeSystem, GenerationDisabled, RedefinedToNotClass, @@ -78,7 +78,7 @@ public: void setApiExtractorFlags(ApiExtractorFlags flags); - enum TranslateTypeFlag { + enum TranslateTypeFlag : std::uint8_t { DontResolveType = 0x1, TemplateArgument = 0x2, NoClassScopeLookup = 0x4 diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.h b/sources/shiboken6/ApiExtractor/abstractmetafunction.h index 6b36ed496..63a5f9c14 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetafunction.h +++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.h @@ -34,7 +34,7 @@ class AbstractMetaFunction public: Q_DISABLE_COPY_MOVE(AbstractMetaFunction) - enum FunctionType { + enum FunctionType : std::uint8_t { ConstructorFunction, CopyConstructorFunction, MoveConstructorFunction, @@ -66,13 +66,13 @@ public: }; Q_ENUM(FunctionType) - enum ComparisonOperatorType { + enum ComparisonOperatorType : std::uint8_t { OperatorEqual, OperatorNotEqual, OperatorLess, OperatorLessEqual, OperatorGreater, OperatorGreaterEqual }; Q_ENUM(ComparisonOperatorType) - enum CompareResultFlag { + enum CompareResultFlag : std::uint16_t { EqualName = 0x0001, EqualModifiedName = 0x0002, EqualVirtual = 0x0004, @@ -120,7 +120,7 @@ public: void setCppAttributes(FunctionAttributes a); void setCppAttribute(FunctionAttribute a, bool on = true); - enum class Flag { // Internal flags not relevant for comparing functions + enum class Flag : std::uint8_t { // Internal flags not relevant for comparing functions // Binary operator whose leading/trailing argument was removed by metabuilder OperatorLeadingClassArgumentRemoved = 0x1, OperatorTrailingClassArgumentRemoved = 0x2, diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.h b/sources/shiboken6/ApiExtractor/abstractmetalang.h index 4816299b6..98725af7e 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.h @@ -15,7 +15,7 @@ QT_FORWARD_DECLARE_CLASS(QDebug) -enum class Access; +enum class Access : std::uint8_t; class AbstractMetaClassPrivate; class ComplexTypeEntry; class Documentation; @@ -30,14 +30,14 @@ class AbstractMetaClass : public EnclosingClassMixin public: Q_DISABLE_COPY_MOVE(AbstractMetaClass) - enum CppWrapperFlag { + enum CppWrapperFlag : std::uint8_t { NoCppWrapper = 0x0, CppProtectedHackWrapper = 0x1,// Make protected functions accessible CppVirtualMethodWrapper = 0x2 // Need C++ wrapper for calling Python overrides }; Q_DECLARE_FLAGS(CppWrapper, CppWrapperFlag) - enum Attribute { + enum Attribute : std::uint16_t { None = 0x00000000, Abstract = 0x00000001, @@ -272,7 +272,7 @@ public: void setPropertyDocumentation(const QString &name, const Documentation &doc); // Helpers to search whether a functions is a property setter/getter/reset - enum class PropertyFunction + enum class PropertyFunction : std::uint8_t { Read, Write, diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang_enums.h b/sources/shiboken6/ApiExtractor/abstractmetalang_enums.h index d8606ecc2..b7f113795 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang_enums.h +++ b/sources/shiboken6/ApiExtractor/abstractmetalang_enums.h @@ -6,7 +6,7 @@ #include <QtCore/qflags.h> -enum class FunctionQueryOption { +enum class FunctionQueryOption : std::uint32_t { AnyConstructor = 0x0000001, // Any constructor (copy/move) Constructors = 0x0000002, // Constructors except copy/move DefaultConstructor = 0x0000004, // Only Default constructors @@ -33,7 +33,7 @@ enum class FunctionQueryOption { Q_DECLARE_FLAGS(FunctionQueryOptions, FunctionQueryOption) Q_DECLARE_OPERATORS_FOR_FLAGS(FunctionQueryOptions) -enum class OperatorQueryOption { +enum class OperatorQueryOption : std::uint16_t { ArithmeticOp = 0x01, // Arithmetic: +, -, *, /, %, +=, -=, *=, /=, %=, unary+, unary- IncDecrementOp = 0x02, // ++, -- BitwiseOp = 0x04, // Bitwise: <<, <<=, >>, >>=, ~, &, &=, |, |=, ^, ^= diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.h b/sources/shiboken6/ApiExtractor/abstractmetatype.h index 9dd2f09be..9c9c54502 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetatype.h +++ b/sources/shiboken6/ApiExtractor/abstractmetatype.h @@ -29,7 +29,7 @@ class AbstractMetaType public: using Indirections = QList<Indirection>; - enum TypeUsagePattern { + enum TypeUsagePattern : std::uint8_t { PrimitivePattern, FlagsPattern, EnumPattern, diff --git a/sources/shiboken6/ApiExtractor/addedfunction.h b/sources/shiboken6/ApiExtractor/addedfunction.h index 6eadc337b..a16a4e583 100644 --- a/sources/shiboken6/ApiExtractor/addedfunction.h +++ b/sources/shiboken6/ApiExtractor/addedfunction.h @@ -23,7 +23,7 @@ struct AddedFunction using AddedFunctionPtr = std::shared_ptr<AddedFunction>; /// Function access types. - enum Access { + enum Access : std::uint8_t { Protected = 0x1, Public = 0x2 }; diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index cc2924287..fd7566c12 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -112,7 +112,7 @@ class BuilderPrivate { public: Q_DISABLE_COPY_MOVE(BuilderPrivate) - enum class SpecialSystemHeader { + enum class SpecialSystemHeader : std::uint8_t { None, Types, OpenGL, diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangparser.h b/sources/shiboken6/ApiExtractor/clangparser/clangparser.h index d7667eaa3..79dc855e2 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangparser.h +++ b/sources/shiboken6/ApiExtractor/clangparser/clangparser.h @@ -14,7 +14,7 @@ #include <string_view> #include <utility> -enum class LanguageLevel; +enum class LanguageLevel : std::uint8_t; namespace clang { @@ -33,7 +33,7 @@ private: FileNameCache m_fileNameCache; }; -enum class LocationType +enum class LocationType : std::uint8_t { Main, // Main header parsed for bindings Other, // A header parsed for bindings @@ -46,7 +46,7 @@ class BaseVisitor { public: using Diagnostics = QList<Diagnostic>; - enum StartTokenResult { Error, Skip, Recurse }; + enum StartTokenResult : std::uint8_t { Error, Skip, Recurse }; BaseVisitor(); virtual ~BaseVisitor(); diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h index 575bb9f07..bb819e61f 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h +++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h @@ -68,7 +68,7 @@ CXString getFileNameFromLocation(const CXSourceLocation &location); SourceRange getCursorRange(const CXCursor &cursor); struct Diagnostic { - enum Source { Clang, Other }; + enum Source : std::uint8_t { Clang, Other }; Diagnostic() = default; // Clang diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index a482c3a60..1f67a143b 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -31,7 +31,7 @@ using namespace Qt::StringLiterals; namespace clang { // The command line options set -enum OptionSetFlag : unsigned +enum OptionSetFlag : std::uint8_t { CompilerOption = 0x1, CompilerPathOption = 0x2, diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h index 84395d28f..f8aa5b2d7 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h @@ -9,7 +9,7 @@ QT_FORWARD_DECLARE_CLASS(QString) -enum class LanguageLevel { +enum class LanguageLevel : std::uint8_t { Default, Cpp11, Cpp14, @@ -18,13 +18,13 @@ enum class LanguageLevel { Cpp1Z }; -enum class Compiler { +enum class Compiler : std::uint8_t { Msvc, Gpp, Clang }; -enum class Platform { +enum class Platform : std::uint8_t { Unix, Linux, Windows, @@ -33,7 +33,7 @@ enum class Platform { iOS }; -enum class Architecture { +enum class Architecture : std::uint8_t { Other, X64, X86, diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.cpp b/sources/shiboken6/ApiExtractor/classdocumentation.cpp index ccc7b29d2..6f7159845 100644 --- a/sources/shiboken6/ApiExtractor/classdocumentation.cpp +++ b/sources/shiboken6/ApiExtractor/classdocumentation.cpp @@ -81,7 +81,7 @@ qsizetype ClassDocumentation::indexOfProperty(const QString &name) const return -1; } -enum class WebXmlCodeTag +enum class WebXmlCodeTag : std::uint8_t { Class, Description, Enum, Function, Header, Parameter, Property, Typedef, Other }; diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.h b/sources/shiboken6/ApiExtractor/classdocumentation.h index fc1c4fdd9..7ed5c02f5 100644 --- a/sources/shiboken6/ApiExtractor/classdocumentation.h +++ b/sources/shiboken6/ApiExtractor/classdocumentation.h @@ -47,7 +47,7 @@ using FunctionDocumentationList = QList<FunctionDocumentation>; /// A WebXML/doxygen document struct ClassDocumentation { - enum Type { + enum Type : std::uint8_t { Class, // <class>, class/namespace Header // <header>, grouped global functions/enums }; diff --git a/sources/shiboken6/ApiExtractor/conditionalstreamreader.h b/sources/shiboken6/ApiExtractor/conditionalstreamreader.h index d9af5dc1e..9ce8262e0 100644 --- a/sources/shiboken6/ApiExtractor/conditionalstreamreader.h +++ b/sources/shiboken6/ApiExtractor/conditionalstreamreader.h @@ -70,7 +70,7 @@ public: void setConditions(const QStringList &newConditions); private: - enum class PiTokens { None, If, Endif, EntityDefinition }; + enum class PiTokens : std::uint8_t { None, If, Endif, EntityDefinition }; using ExtendedToken = std::pair<TokenType, PiTokens>; ExtendedToken readNextInternal(); diff --git a/sources/shiboken6/ApiExtractor/fileout.cpp b/sources/shiboken6/ApiExtractor/fileout.cpp index 2aa7a5497..9bf33f94f 100644 --- a/sources/shiboken6/ApiExtractor/fileout.cpp +++ b/sources/shiboken6/ApiExtractor/fileout.cpp @@ -61,7 +61,7 @@ static QList<qsizetype> lcsLength(const QByteArrayList &a, const QByteArrayList return res; } -enum Type { +enum Type : std::uint8_t { Add, Delete, Unchanged diff --git a/sources/shiboken6/ApiExtractor/fileout.h b/sources/shiboken6/ApiExtractor/fileout.h index b11ad1e20..4c2aac661 100644 --- a/sources/shiboken6/ApiExtractor/fileout.h +++ b/sources/shiboken6/ApiExtractor/fileout.h @@ -16,7 +16,7 @@ class FileOut public: Q_DISABLE_COPY_MOVE(FileOut) - enum State { Unchanged, Success }; + enum State : std::uint8_t { Unchanged, Success }; explicit FileOut(QString name); ~FileOut(); diff --git a/sources/shiboken6/ApiExtractor/include.h b/sources/shiboken6/ApiExtractor/include.h index 1bba39a09..d2b6e0435 100644 --- a/sources/shiboken6/ApiExtractor/include.h +++ b/sources/shiboken6/ApiExtractor/include.h @@ -18,7 +18,7 @@ class TextStream; class Include { public: - enum IncludeType { + enum IncludeType : std::uint8_t { IncludePath, LocalPath, TargetLangImport diff --git a/sources/shiboken6/ApiExtractor/modifications.h b/sources/shiboken6/ApiExtractor/modifications.h index ca130104e..740f38f56 100644 --- a/sources/shiboken6/ApiExtractor/modifications.h +++ b/sources/shiboken6/ApiExtractor/modifications.h @@ -49,12 +49,12 @@ struct ReferenceCount struct ArgumentOwner { - enum Action { + enum Action : std::uint8_t { Invalid = 0x00, Add = 0x01, Remove = 0x02 }; - enum { + enum : std::int8_t { InvalidIndex = -2, ThisIndex = -1, ReturnIndex = 0, diff --git a/sources/shiboken6/ApiExtractor/optionsparser.h b/sources/shiboken6/ApiExtractor/optionsparser.h index 122887bb6..7ae7c1d7c 100644 --- a/sources/shiboken6/ApiExtractor/optionsparser.h +++ b/sources/shiboken6/ApiExtractor/optionsparser.h @@ -11,7 +11,7 @@ QT_FORWARD_DECLARE_CLASS(QTextStream) -enum class OptionSource +enum class OptionSource : std::uint8_t { CommandLine, // "--option" CommandLineSingleDash, // "-o" diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.h b/sources/shiboken6/ApiExtractor/parser/codemodel.h index 77082efa5..3e5b63377 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.h @@ -33,7 +33,7 @@ class CodeModel public: Q_DISABLE_COPY_MOVE(CodeModel) - enum FunctionType { + enum FunctionType : std::uint8_t { Normal, Constructor, CopyConstructor, @@ -60,7 +60,7 @@ public: }; Q_ENUM(FunctionType) - enum ClassType { + enum ClassType : std::uint8_t { Class, Struct, Union @@ -94,7 +94,7 @@ class _CodeModelItem public: Q_DISABLE_COPY_MOVE(_CodeModelItem) - enum Kind { + enum Kind : std::uint16_t { /* These are bit-flags resembling inheritance */ Kind_Scope = 0x1, Kind_Namespace = 0x2 | Kind_Scope, diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel_enums.h b/sources/shiboken6/ApiExtractor/parser/codemodel_enums.h index c3bb10e5f..358195799 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel_enums.h +++ b/sources/shiboken6/ApiExtractor/parser/codemodel_enums.h @@ -6,46 +6,46 @@ #include <QtCore/qflags.h> -enum ReferenceType { +enum ReferenceType : std::uint8_t { NoReference, LValueReference, RValueReference }; -enum EnumKind { +enum EnumKind : std::uint8_t { CEnum, // Standard C: enum Foo { value1, value2 } AnonymousEnum, // enum { value1, value2 } EnumClass // C++ 11 : enum class Foo { value1, value2 } }; -enum class Indirection +enum class Indirection : std::uint8_t { Pointer, // int * ConstPointer // int *const }; -enum class ExceptionSpecification +enum class ExceptionSpecification : std::uint8_t { Unknown, NoExcept, Throws }; -enum class NamespaceType +enum class NamespaceType : std::uint8_t { Default, Anonymous, Inline }; -enum class Access +enum class Access : std::uint8_t { Private, Protected, Public }; -enum class FunctionAttribute { +enum class FunctionAttribute : std::uint8_t { Abstract = 0x00000001, Static = 0x00000002, Virtual = 0x00000004, diff --git a/sources/shiboken6/ApiExtractor/parser/enumvalue.h b/sources/shiboken6/ApiExtractor/parser/enumvalue.h index bad2c0e58..e4346ce7f 100644 --- a/sources/shiboken6/ApiExtractor/parser/enumvalue.h +++ b/sources/shiboken6/ApiExtractor/parser/enumvalue.h @@ -15,7 +15,7 @@ QT_FORWARD_DECLARE_CLASS(QTextStream) class EnumValue { public: - enum Type + enum Type : std::uint8_t { Signed, Unsigned diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp index 158d9f627..1cbf7149f 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.cpp +++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp @@ -189,7 +189,7 @@ void QPropertySpec::setGenerateGetSetDef(bool generateGetSetDef) TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString &declarationIn, QString *errorMessage) { - enum class PropertyToken { None, Read, Write, Designable, Reset, Notify, Member }; + enum class PropertyToken : std::uint8_t { None, Read, Write, Designable, Reset, Notify, Member }; static const QHash<QString, PropertyToken> tokenLookup = { {"READ"_L1, PropertyToken::Read}, diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp index a9b76d32c..af1781b9a 100644 --- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp @@ -34,7 +34,7 @@ using namespace Qt::StringLiterals; -enum { debugFunctionSearch = 0 }; +enum : std::uint8_t { debugFunctionSearch = 0 }; constexpr auto briefStartElement = "<brief>"_L1; constexpr auto briefEndElement = "</brief>"_L1; diff --git a/sources/shiboken6/ApiExtractor/reporthandler.h b/sources/shiboken6/ApiExtractor/reporthandler.h index 3562ab43a..523ab81ab 100644 --- a/sources/shiboken6/ApiExtractor/reporthandler.h +++ b/sources/shiboken6/ApiExtractor/reporthandler.h @@ -13,7 +13,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcShibokenDoc) class ReportHandler { public: - enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug }; + enum DebugLevel : std::uint8_t { NoDebug, SparseDebug, MediumDebug, FullDebug }; static void install(); static void startTimer(); diff --git a/sources/shiboken6/ApiExtractor/textstream.h b/sources/shiboken6/ApiExtractor/textstream.h index 3cf6d0716..5999e8b55 100644 --- a/sources/shiboken6/ApiExtractor/textstream.h +++ b/sources/shiboken6/ApiExtractor/textstream.h @@ -15,12 +15,12 @@ public: using ManipulatorFunc = void(TextStream &); - enum class Language + enum class Language : std::uint8_t { None, Cpp }; - enum class CharClass + enum class CharClass : std::uint8_t { Other, NewLine, Space, Hash, BackSlash }; diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp index 2e1f345cf..93480e775 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp @@ -358,7 +358,7 @@ static const IntTypeNormalizationEntries &intTypeNormalizationEntries() } // Normalization helpers -enum CharCategory { Space, Identifier, Other }; +enum CharCategory : std::uint8_t { Space, Identifier, Other }; static CharCategory charCategory(QChar c) { diff --git a/sources/shiboken6/ApiExtractor/typedatabase.h b/sources/shiboken6/ApiExtractor/typedatabase.h index ad3285e5c..08454d298 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.h +++ b/sources/shiboken6/ApiExtractor/typedatabase.h @@ -39,7 +39,7 @@ struct VersionRange struct TypeRejection { - enum MatchType + enum MatchType : std::uint8_t { ExcludeClass, // Match className only Function, // Match className and function name diff --git a/sources/shiboken6/ApiExtractor/typeparser.cpp b/sources/shiboken6/ApiExtractor/typeparser.cpp index 4dd5994da..2668a4828 100644 --- a/sources/shiboken6/ApiExtractor/typeparser.cpp +++ b/sources/shiboken6/ApiExtractor/typeparser.cpp @@ -13,7 +13,7 @@ using namespace Qt::StringLiterals; class Scanner { public: - enum Token { + enum Token : std::uint8_t { StarToken, AmpersandToken, LessThanToken, diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h index b34d860b0..116069c91 100644 --- a/sources/shiboken6/ApiExtractor/typesystem.h +++ b/sources/shiboken6/ApiExtractor/typesystem.h @@ -30,7 +30,7 @@ class TypeEntry public: Q_DISABLE_COPY_MOVE(TypeEntry) - enum Type { + enum Type : std::uint8_t { PrimitiveType, VoidType, VarargsType, @@ -53,7 +53,7 @@ public: }; Q_ENUM(Type) - enum CodeGeneration { + enum CodeGeneration : std::uint8_t { GenerateNothing, // Rejection, private type, ConstantValueTypeEntry or similar GenerationDisabled, // generate='no' in type system GenerateCode, // Generate code diff --git a/sources/shiboken6/ApiExtractor/typesystem_enums.h b/sources/shiboken6/ApiExtractor/typesystem_enums.h index 2b876efc4..bb2b5cd6f 100644 --- a/sources/shiboken6/ApiExtractor/typesystem_enums.h +++ b/sources/shiboken6/ApiExtractor/typesystem_enums.h @@ -4,9 +4,11 @@ #ifndef TYPESYSTEM_ENUMS_H #define TYPESYSTEM_ENUMS_H +#include <cstdint> + namespace TypeSystem { -enum Language { +enum Language : std::uint8_t { TargetLangCode = 0x0001, NativeCode = 0x0002, ShellCode = 0x0004, @@ -17,21 +19,21 @@ enum Language { TargetLangAndNativeCode = TargetLangCode | NativeCode }; -enum class AllowThread { +enum class AllowThread : std::uint8_t { Unspecified, Allow, Disallow, Auto }; -enum Ownership { +enum Ownership : std::uint8_t { UnspecifiedOwnership, DefaultOwnership, TargetLangOwnership, CppOwnership }; -enum CodeSnipPosition { +enum CodeSnipPosition : std::uint8_t { CodeSnipPositionBeginning, CodeSnipPositionEnd, CodeSnipPositionDeclaration, @@ -40,19 +42,19 @@ enum CodeSnipPosition { CodeSnipPositionAny }; -enum DocModificationMode { +enum DocModificationMode : std::uint8_t { DocModificationAppend, DocModificationPrepend, DocModificationReplace, DocModificationXPathReplace }; -enum class DocMode { +enum class DocMode : std::uint8_t { Nested, Flat }; -enum class ExceptionHandling { +enum class ExceptionHandling : std::uint8_t { Unspecified, Off, AutoDefaultToOff, @@ -60,27 +62,27 @@ enum class ExceptionHandling { On }; -enum class SnakeCase { +enum class SnakeCase : std::uint8_t { Unspecified, Disabled, Enabled, Both }; -enum Visibility { // For namespaces +enum Visibility : std::uint8_t { // For namespaces Unspecified, Visible, Invisible, Auto }; -enum class BoolCast { // Generate nb_bool (overriding command line) +enum class BoolCast : std::uint8_t { // Generate nb_bool (overriding command line) Unspecified, Disabled, Enabled }; -enum class CPythonType +enum class CPythonType : std::uint8_t { Bool, Float, @@ -89,7 +91,7 @@ enum class CPythonType Other }; -enum class QtMetaTypeRegistration +enum class QtMetaTypeRegistration : std::uint8_t { Unspecified, Enabled, @@ -97,14 +99,14 @@ enum class QtMetaTypeRegistration Disabled }; -enum class SmartPointerType { +enum class SmartPointerType : std::uint8_t { Shared, Unique, Handle, ValueHandle }; -enum class PythonEnumType { +enum class PythonEnumType : std::uint8_t { Unspecified, Enum, IntEnum, diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp index 53b455b2a..9a8611589 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp @@ -648,7 +648,7 @@ QString TypeSystemEntityResolver::resolveUndeclaredEntity(const QString &name) } // State depending on element stack -enum class ParserState +enum class ParserState : std::uint8_t { None, PrimitiveTypeNativeToTargetConversion, diff --git a/sources/shiboken6/ApiExtractor/typesystemparser_p.h b/sources/shiboken6/ApiExtractor/typesystemparser_p.h index b5f77bebf..071a1dc30 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser_p.h +++ b/sources/shiboken6/ApiExtractor/typesystemparser_p.h @@ -31,9 +31,9 @@ class TypeSystemTypeEntry; class ValueTypeEntry; class EnumTypeEntry; -enum class ParserState; +enum class ParserState : std::uint8_t; -enum class StackElement { +enum class StackElement : std::uint8_t { None, // Type tags diff --git a/sources/shiboken6/generator/defaultvalue.h b/sources/shiboken6/generator/defaultvalue.h index c07b78868..9bef7d2e7 100644 --- a/sources/shiboken6/generator/defaultvalue.h +++ b/sources/shiboken6/generator/defaultvalue.h @@ -11,7 +11,7 @@ QT_FORWARD_DECLARE_CLASS(QDebug); class DefaultValue { public: - enum Type + enum Type : std::uint8_t { Boolean, CppScalar, // A C++ scalar type (int,..) specified by value() diff --git a/sources/shiboken6/generator/generator.h b/sources/shiboken6/generator/generator.h index 3a1c0dc1d..514801f5b 100644 --- a/sources/shiboken6/generator/generator.h +++ b/sources/shiboken6/generator/generator.h @@ -35,7 +35,7 @@ public: Q_DISABLE_COPY_MOVE(Generator) /// Options used around the generator code - enum Option { + enum Option : std::uint16_t { NoOption = 0x00000000, ExcludeConst = 0x00000001, ExcludeReference = 0x00000002, @@ -51,13 +51,13 @@ public: }; Q_DECLARE_FLAGS(Options, Option) - enum FileNameFlag { + enum FileNameFlag : std::uint8_t { UnqualifiedName = 0x1, KeepCase = 0x2 }; Q_DECLARE_FLAGS(FileNameFlags, FileNameFlag) - enum CodeOptimizationFlag { + enum CodeOptimizationFlag : std::uint8_t { RemoveFullnameField = 0x00000001, CompressSignatureStrings = 0x00000002, FoldCommonTailCode = 0x00000004, diff --git a/sources/shiboken6/generator/generatorcontext.h b/sources/shiboken6/generator/generatorcontext.h index 80c37df7c..7730cd6d9 100644 --- a/sources/shiboken6/generator/generatorcontext.h +++ b/sources/shiboken6/generator/generatorcontext.h @@ -27,7 +27,7 @@ class GeneratorContext { friend class ShibokenGenerator; friend class Generator; public: - enum Type { Class, WrappedClass, SmartPointer, + enum Type : std::uint8_t { Class, WrappedClass, SmartPointer, GlobalFunction // No class contained }; diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index 87e01f35b..9a1a28ef2 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -507,7 +507,7 @@ void QtDocGenerator::writeDetailedDescription(TextStream &s, parsedImages); } -enum ClassDescriptionMode +enum ClassDescriptionMode : std::uint8_t { NoDescription, BriefOnly, diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp index bddf2f511..e135cd0a7 100644 --- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp +++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp @@ -193,7 +193,7 @@ TextStream &operator<<(TextStream &str, const QtXmlToSphinxLink &linkContext) return str; } -enum class WebXmlTag { +enum class WebXmlTag : std::uint8_t { Unknown, heading, brief, para, italic, bold, see_also, snippet, dots, codeline, table, header, row, item, argument, teletype, link, inlineimage, image, @@ -566,7 +566,7 @@ static QString resolveFile(const QStringList &locations, const QString &path) return {}; } -enum class SnippetType +enum class SnippetType : std::uint8_t { Other, // .qdoc, .qml,... CppSource, CppHeader // Potentially converted to Python @@ -1041,7 +1041,7 @@ void QtXmlToSphinx::handleRowTag(QXmlStreamReader& reader) m_tables.back().appendRow({}); } -enum ListType { BulletList, OrderedList, EnumeratedList }; +enum ListType : std::uint8_t { BulletList, OrderedList, EnumeratedList }; static inline ListType webXmlListType(QStringView t) { diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h index 757013925..d657890a8 100644 --- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h +++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h @@ -22,7 +22,7 @@ struct QtXmlToSphinxParameters; struct QtXmlToSphinxLink; struct QtXmlToSphinxImage; -enum class WebXmlTag; +enum class WebXmlTag : std::uint8_t; class QtXmlToSphinx { @@ -185,7 +185,7 @@ private: struct Snippet { - enum Result { + enum Result : std::uint8_t { Converted, // C++ converted to Python Resolved, // Otherwise resolved in snippet paths Fallback, // Fallback from XML diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 6882a1039..371af6a65 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -152,7 +152,7 @@ static constexpr auto converterVar = "converter"_L1; class registerConverterName { public: - enum Flag + enum Flag : std::uint8_t { Indirections = 0x1, // Also register "Type*", "Type&" PartiallyQualifiedAliases = 0x2, // Also register "B" when passed "A::B" @@ -6065,7 +6065,7 @@ void CppGenerator::writeStaticFieldInitialization(TextStream &s, s << "return type;\n" << outdent << "}\n"; } -enum class QtRegisterMetaType +enum class QtRegisterMetaType : std::uint8_t { None, Pointer, Value }; diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.h b/sources/shiboken6/generator/shiboken/cppgenerator.h index baa876468..50afe3594 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.h +++ b/sources/shiboken6/generator/shiboken/cppgenerator.h @@ -25,7 +25,7 @@ struct PyMethodDefEntry; class CppGenerator : public ShibokenGenerator { public: - enum class ErrorReturn { + enum class ErrorReturn : std::uint8_t { Default, // "{}" Zero, MinusOne, @@ -33,7 +33,7 @@ public: Void }; - enum CppSelfDefinitionFlag { + enum CppSelfDefinitionFlag : std::uint8_t { HasStaticOverload = 0x1, HasClassMethodOverload = 0x2, CppSelfAsReference = 0x4 diff --git a/sources/shiboken6/generator/shiboken/cppgenerator_container.cpp b/sources/shiboken6/generator/shiboken/cppgenerator_container.cpp index 826ad89af..5fde6699d 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator_container.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator_container.cpp @@ -56,7 +56,7 @@ static void writeSlot(TextStream &s, const QString &privateObjType, // Write creation function from C++ reference, used by field accessors // and getters which are within extern "C" -enum ContainerCreationFlag +enum ContainerCreationFlag : std::uint8_t { None = 0, Const = 0x1, diff --git a/sources/shiboken6/generator/shiboken/generatorargument.h b/sources/shiboken6/generator/shiboken/generatorargument.h index a5dee8087..d42872973 100644 --- a/sources/shiboken6/generator/shiboken/generatorargument.h +++ b/sources/shiboken6/generator/shiboken/generatorargument.h @@ -17,7 +17,7 @@ struct GeneratorArgument Q_GADGET public: - enum class Type { + enum class Type : std::uint8_t { Other, Primitive, Enum, @@ -27,7 +27,7 @@ public: }; Q_ENUM(Type) - enum class Conversion { + enum class Conversion : std::uint8_t { Default, CppPrimitiveArray, // Similar to Default except default values Pointer, @@ -35,7 +35,7 @@ public: }; Q_ENUM(Conversion) - enum class Flag { + enum class Flag : std::uint8_t { TreatAsPointer = 0x1, PointerOrObjectType = 0x2, MayHaveImplicitConversion = 0x4, diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h index c0f388871..d988a065d 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.h +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h @@ -50,7 +50,7 @@ public: /// Besides the actual bindings (see AbstractMetaFunction::generateBinding(), /// some functions need to be generated into the wrapper class /// (virtual method/avoid protected hack expose). - enum class FunctionGenerationFlag + enum class FunctionGenerationFlag : std::uint8_t { None = 0x0, /// Virtual method overridable in Python @@ -68,7 +68,7 @@ public: }; Q_DECLARE_FLAGS(FunctionGeneration, FunctionGenerationFlag); - enum class AttroCheckFlag + enum class AttroCheckFlag : std::uint8_t { None = 0x0, GetattroOverloads = 0x01, @@ -450,7 +450,7 @@ private: TypeSystem::CodeSnipPosition position, TypeSystem::Language language); - enum TypeSystemConverterVariable { + enum TypeSystemConverterVariable : std::uint8_t { TypeSystemCheckFunction = 0, TypeSystemIsConvertibleFunction, TypeSystemToCppFunction, |
