MOC: use methods from QtMiscUtils
Change-Id: I20600357841aff36f68bcc9a81bfb3e96bf6e264 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
8726b6a35a
commit
0344332c76
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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 != '\"')) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue