Fixed #2271 (Tokenizer: simplify Qt signals and slots)
This commit is contained in:
parent
2cd8bc74cc
commit
b29568c81d
|
@ -8745,16 +8745,17 @@ void Tokenizer::simplifyQtSignalsSlots()
|
|||
{
|
||||
tok2->deleteNext();
|
||||
}
|
||||
else if (Token::Match(tok2->next(), "public|protected|private slots :"))
|
||||
else if (Token::Match(tok2->next(), "public|protected|private slots|Q_SLOTS :"))
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
tok2->str(tok2->str() + ":");
|
||||
tok2->deleteNext();
|
||||
tok2->deleteNext();
|
||||
}
|
||||
else if (Token::simpleMatch(tok2->next(), "signals :"))
|
||||
else if (Token::Match(tok2->next(), "signals|Q_SIGNALS :"))
|
||||
{
|
||||
tok2->deleteNext();
|
||||
tok2 = tok2->next();
|
||||
tok2->str("protected:");
|
||||
tok2->deleteNext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4774,33 +4774,63 @@ private:
|
|||
|
||||
void Qt()
|
||||
{
|
||||
const char code[] = "class Counter : public QObject "
|
||||
"{ "
|
||||
" Q_OBJECT "
|
||||
"public: "
|
||||
" Counter() { m_value = 0; } "
|
||||
" int value() const { return m_value; } "
|
||||
"public slots: "
|
||||
" void setValue(int value); "
|
||||
"signals: "
|
||||
" void valueChanged(int newValue); "
|
||||
"private: "
|
||||
" int m_value; "
|
||||
"};";
|
||||
const char code1[] = "class Counter : public QObject "
|
||||
"{ "
|
||||
" Q_OBJECT "
|
||||
"public: "
|
||||
" Counter() { m_value = 0; } "
|
||||
" int value() const { return m_value; } "
|
||||
"public slots: "
|
||||
" void setValue(int value); "
|
||||
"signals: "
|
||||
" void valueChanged(int newValue); "
|
||||
"private: "
|
||||
" int m_value; "
|
||||
"};";
|
||||
|
||||
const char result [] = "class Counter : public QObject "
|
||||
"{ "
|
||||
"public: "
|
||||
"Counter ( ) { m_value = 0 ; } "
|
||||
"int value ( ) const { return m_value ; } "
|
||||
"public: "
|
||||
"void setValue ( int value ) ; "
|
||||
"void valueChanged ( int newValue ) ; "
|
||||
"private: "
|
||||
"int m_value ; "
|
||||
"} ;";
|
||||
const char result1 [] = "class Counter : public QObject "
|
||||
"{ "
|
||||
"public: "
|
||||
"Counter ( ) { m_value = 0 ; } "
|
||||
"int value ( ) const { return m_value ; } "
|
||||
"public: "
|
||||
"void setValue ( int value ) ; "
|
||||
"protected: "
|
||||
"void valueChanged ( int newValue ) ; "
|
||||
"private: "
|
||||
"int m_value ; "
|
||||
"} ;";
|
||||
|
||||
ASSERT_EQUALS(result, tokenizeAndStringify(code,false));
|
||||
ASSERT_EQUALS(result1, tokenizeAndStringify(code1,false));
|
||||
|
||||
const char code2[] = "class Counter : public QObject "
|
||||
"{ "
|
||||
" Q_OBJECT "
|
||||
"public: "
|
||||
" Counter() { m_value = 0; } "
|
||||
" int value() const { return m_value; } "
|
||||
"public Q_SLOTS: "
|
||||
" void setValue(int value); "
|
||||
"Q_SIGNALS: "
|
||||
" void valueChanged(int newValue); "
|
||||
"private: "
|
||||
" int m_value; "
|
||||
"};";
|
||||
|
||||
const char result2 [] = "class Counter : public QObject "
|
||||
"{ "
|
||||
"public: "
|
||||
"Counter ( ) { m_value = 0 ; } "
|
||||
"int value ( ) const { return m_value ; } "
|
||||
"public: "
|
||||
"void setValue ( int value ) ; "
|
||||
"protected: "
|
||||
"void valueChanged ( int newValue ) ; "
|
||||
"private: "
|
||||
"int m_value ; "
|
||||
"} ;";
|
||||
|
||||
ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false));
|
||||
}
|
||||
|
||||
void sql()
|
||||
|
|
Loading…
Reference in New Issue