diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-14 20:08:20 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-22 02:20:29 +0300 |
commit | 0344332c769db98920c821652c6a6b3fa2502f72 (patch) | |
tree | e15b8cecf92f8c6055ec3ab2b22d31ea686b9557 /src/tools/moc | |
parent | 8726b6a35a7458e33a8dba922ebe659f25694e8d (diff) |
MOC: use methods from QtMiscUtils
Change-Id: I20600357841aff36f68bcc9a81bfb3e96bf6e264
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/generator.cpp | 8 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 18 | ||||
-rw-r--r-- | src/tools/moc/utils.h | 31 |
3 files changed, 19 insertions, 38 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index a39b91e6cd..9740f41255 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -23,6 +23,8 @@ QT_BEGIN_NAMESPACE +using namespace QtMiscUtils; + uint nameToBuiltinType(const QByteArray &name) { if (name.isEmpty()) @@ -80,12 +82,12 @@ static inline qsizetype lengthOfEscapeSequence(const QByteArray &s, qsizetype i) char ch = s.at(i); if (ch == 'x') { ++i; - while (i < s.size() && is_hex_char(s.at(i))) + while (i < s.size() && isHexDigit(s.at(i))) ++i; - } else if (is_octal_char(ch)) { + } else if (isOctalDigit(ch)) { while (i < startPos + 4 && i < s.size() - && is_octal_char(s.at(i))) { + && isOctalDigit(s.at(i))) { ++i; } } else { // single character escape sequence diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index e51a005935..8a0061a9bd 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace QtMiscUtils; + #include "ppkeywords.cpp" #include "keywords.cpp" @@ -212,7 +214,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso data -= 2; break; case DIGIT: - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; if (!*data || *data != '.') { token = INTEGER_LITERAL; @@ -221,7 +223,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso || *data == 'b' || *data == 'B') && *lexem == '0') { ++data; - while (is_hex_char(*data) || *data == '\'') + while (isHexDigit(*data) || *data == '\'') ++data; } break; @@ -230,13 +232,13 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; Q_FALLTHROUGH(); case FLOATING_LITERAL: - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; if (*data == '+' || *data == '-') ++data; if (*data == 'e' || *data == 'E') { ++data; - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; } if (*data == 'f' || *data == 'F' @@ -390,7 +392,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso token = PP_CHARACTER_LITERAL; break; case PP_DIGIT: - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; if (!*data || *data != '.') { token = PP_INTEGER_LITERAL; @@ -398,7 +400,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso (*data == 'x' || *data == 'X') && *lexem == '0') { ++data; - while (is_hex_char(*data) || *data == '\'') + while (isHexDigit(*data) || *data == '\'') ++data; } break; @@ -407,13 +409,13 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; Q_FALLTHROUGH(); case PP_FLOATING_LITERAL: - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; if (*data == '+' || *data == '-') ++data; if (*data == 'e' || *data == 'E') { ++data; - while (is_digit_char(*data) || *data == '\'') + while (isAsciiDigit(*data) || *data == '\'') ++data; } if (*data == 'f' || *data == 'F' diff --git a/src/tools/moc/utils.h b/src/tools/moc/utils.h index cb118fab38..0b0d70f462 100644 --- a/src/tools/moc/utils.h +++ b/src/tools/moc/utils.h @@ -5,6 +5,7 @@ #define UTILS_H #include <QtCore/qglobal.h> +#include <private/qtools_p.h> #include <algorithm> @@ -22,19 +23,13 @@ inline bool is_space(char s) inline bool is_ident_start(char s) { - return ((s >= 'a' && s <= 'z') - || (s >= 'A' && s <= 'Z') - || s == '_' || s == '$' - ); + using namespace QtMiscUtils; + return isAsciiLower(s) || isAsciiUpper(s) || s == '_' || s == '$'; } inline bool is_ident_char(char s) { - return ((s >= 'a' && s <= 'z') - || (s >= 'A' && s <= 'Z') - || (s >= '0' && s <= '9') - || s == '_' || s == '$' - ); + return QtMiscUtils::isAsciiLetterOrNumber(s) || s == '_' || s == '$'; } inline bool is_identifier(const char *s, qsizetype len) @@ -44,24 +39,6 @@ inline bool is_identifier(const char *s, qsizetype len) return std::all_of(s, s + len, is_ident_char); } -inline bool is_digit_char(char s) -{ - return (s >= '0' && s <= '9'); -} - -inline bool is_octal_char(char s) -{ - return (s >= '0' && s <= '7'); -} - -inline bool is_hex_char(char s) -{ - return ((s >= 'a' && s <= 'f') - || (s >= 'A' && s <= 'F') - || (s >= '0' && s <= '9') - ); -} - inline const char *skipQuote(const char *data) { while (*data && (*data != '\"')) { |