Fixed pre-processor handling for Q_PROPERTY, Q_ENUMS and Q_FLAGS.

This commit is contained in:
Erik Verbruggen
2010-02-22 13:11:09 +01:00
parent 41e2b885b8
commit 72c3ba791e
2 changed files with 27 additions and 28 deletions

View File

@@ -766,34 +766,27 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
expandBuiltinMacro(identifierToken, spell); expandBuiltinMacro(identifierToken, spell);
else { else {
if (spell != "Q_PROPERTY" if (Macro *m = env->resolve(spell)) {
&& spell != "Q_INVOKABLE" if (! m->isFunctionLike()) {
&& spell != "Q_ENUMS" if (0 == (m = processObjectLikeMacro(identifierToken, spell, m)))
&& spell != "Q_FLAGS") { continue;
// ### FIXME: shouldn't this be T_Q_PROPERTY & friends? // the macro expansion generated something that looks like
// a function-like macro.
}
if (Macro *m = env->resolve(spell)) { // `m' is function-like macro.
if (! m->isFunctionLike()) { if (_dot->is(T_LPAREN)) {
if (0 == (m = processObjectLikeMacro(identifierToken, spell, m))) QVector<MacroArgumentReference> actuals;
continue; collectActualArguments(&actuals);
// the macro expansion generated something that looks like if (_dot->is(T_RPAREN)) {
// a function-like macro. expandFunctionLikeMacro(identifierToken, m, actuals);
} continue;
// `m' is function-like macro.
if (_dot->is(T_LPAREN)) {
QVector<MacroArgumentReference> actuals;
collectActualArguments(&actuals);
if (_dot->is(T_RPAREN)) {
expandFunctionLikeMacro(identifierToken, m, actuals);
continue;
}
} }
} }
} }
// it's not a function or object-like macro. // it's not a function or object-like macro.
out(spell); out(spell);
} }
@@ -1390,6 +1383,12 @@ bool Preprocessor::isQtReservedWord(const QByteArray &macroId) const
return true; return true;
else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_Q") else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_Q")
return true; return true;
else if (size == 10 && macroId.at(0) == 'Q' && macroId == "Q_PROPERTY")
return true;
else if (size == 7 && macroId.at(0) == 'Q' && macroId == "Q_ENUMS")
return true;
else if (size == 7 && macroId.at(0) == 'Q' && macroId == "Q_FLAGS")
return true;
else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL") else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL")
return true; return true;
else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT") else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT")

View File

@@ -745,7 +745,7 @@ static inline int classify7(const char *s, bool q) {
return T_IDENTIFIER; return T_IDENTIFIER;
} }
static inline int classify8(const char *s, bool) { static inline int classify8(const char *s, bool q) {
if (s[0] == '_') { if (s[0] == '_') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'i') { if (s[2] == 'i') {
@@ -910,7 +910,7 @@ static inline int classify8(const char *s, bool) {
} }
} }
} }
else if (s[0] == 'Q') { else if (q && s[0] == 'Q') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'S') { if (s[2] == 'S') {
if (s[3] == 'I') { if (s[3] == 'I') {
@@ -1024,7 +1024,7 @@ static inline int classify9(const char *s, bool q) {
return T_IDENTIFIER; return T_IDENTIFIER;
} }
static inline int classify10(const char *s, bool) { static inline int classify10(const char *s, bool q) {
if (s[0] == '_') { if (s[0] == '_') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'i') { if (s[2] == 'i') {
@@ -1101,7 +1101,7 @@ static inline int classify10(const char *s, bool) {
} }
} }
} }
else if (s[0] == 'Q') { else if (q && s[0] == 'Q') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'P') { if (s[2] == 'P') {
if (s[3] == 'R') { if (s[3] == 'R') {
@@ -1125,7 +1125,7 @@ static inline int classify10(const char *s, bool) {
return T_IDENTIFIER; return T_IDENTIFIER;
} }
static inline int classify11(const char *s, bool) { static inline int classify11(const char *s, bool q) {
if (s[0] == '_') { if (s[0] == '_') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'a') { if (s[2] == 'a') {
@@ -1172,7 +1172,7 @@ static inline int classify11(const char *s, bool) {
} }
} }
} }
else if (s[0] == 'Q') { else if (q && s[0] == 'Q') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'I') { if (s[2] == 'I') {
if (s[3] == 'N') { if (s[3] == 'N') {