diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 1f4621e9703..06655b0960a 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -109,6 +109,7 @@ Document::Document(const QString &fileName) localFileName.size()); _translationUnit = new TranslationUnit(_control, fileId); _translationUnit->setQtMocRunEnabled(true); + _translationUnit->setObjCEnabled(true); (void) _control->switchTranslationUnit(_translationUnit); } diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp index 62ecaa174e8..5efa1f02d8c 100644 --- a/src/libs/cplusplus/SimpleLexer.cpp +++ b/src/libs/cplusplus/SimpleLexer.cpp @@ -59,7 +59,9 @@ SimpleLexer::SimpleLexer() _skipComments(false), _qtMocRunEnabled(true), _objCEnabled(false) -{ } +{ + setObjCEnabled(true); +} SimpleLexer::~SimpleLexer() { } diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index e7d3011a767..974af656a65 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -727,6 +727,7 @@ void Preprocessor::processDirective(TokenIterator firstToken, TokenIterator last case PP_INCLUDE: case PP_INCLUDE_NEXT: + case PP_IMPORT: if (! skipping()) processInclude(d == PP_INCLUDE_NEXT, firstToken, lastToken); break; @@ -1069,6 +1070,8 @@ Preprocessor::PP_DIRECTIVE_TYPE Preprocessor::classifyDirective (const QByteArra case 6: if (__directive[0] == 'i' && __directive == "ifndef") return PP_IFNDEF; + else if (__directive[0] == 'i' && __directive == "import") + return PP_IMPORT; else if (__directive[0] == 'd' && __directive == "define") return PP_DEFINE; break; diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h index 24e1ac13de0..033db4cb933 100644 --- a/src/libs/cplusplus/pp-engine.h +++ b/src/libs/cplusplus/pp-engine.h @@ -150,6 +150,7 @@ namespace CPlusPlus { { PP_UNKNOWN_DIRECTIVE, PP_DEFINE, + PP_IMPORT, PP_INCLUDE, PP_INCLUDE_NEXT, PP_ELIF, diff --git a/src/plugins/bineditor/BinEditor.mimetypes.xml b/src/plugins/bineditor/BinEditor.mimetypes.xml index 4fcd9603652..7791d07203b 100644 --- a/src/plugins/bineditor/BinEditor.mimetypes.xml +++ b/src/plugins/bineditor/BinEditor.mimetypes.xml @@ -2,38 +2,5 @@ unknown - Неизвестен тип - desconegut - Neznámý - Anhysbys - ukendt - unbekannt - αγνωστο - nekonata - desconocido - ezezaguna - tuntematon - inconnu - ismeretlen - Sconosciuto - 不明 - 알 수 없음 - nežinoma - Entah - ukjent - onbekend - ukjend - nieznany typ - desconhecido - Desconhecido - неизвестный - itazwi - nuk njihet - непознато - okänd - невідомо - không rõ - 未知 - 不明 diff --git a/src/plugins/cppeditor/CppEditor.mimetypes.xml b/src/plugins/cppeditor/CppEditor.mimetypes.xml index 0c58890e9b5..04046a28477 100644 --- a/src/plugins/cppeditor/CppEditor.mimetypes.xml +++ b/src/plugins/cppeditor/CppEditor.mimetypes.xml @@ -3,37 +3,6 @@ C Source file - Изходен код на C - codi font en C - Zdrojový kód v C - Ffynhonnell Rhaglen C - C-kildekode - C-Quelltext - πηγαίος κώδικας C - C-fontkodo - código fuente en C - C iturburu-kodea - C-lähdekoodi - code source C - C-forráskód - Codice sorgente C - C ソースコード - C 소스 코드 - C pradinis kodas - Kod sumber C - C-kildekode - C-broncode - C-kjeldekode - Kod źródłowy w C - código fonte C - Código fonte C - программа на языке C - Kod burues C - C изворни ко̂д - C-källkod - Вихідний код на мові C - C 源代码 - C 源代碼 @@ -41,21 +10,6 @@ C Header file - Заглавен файл на C - Hlavička v C - C-Header - cabecera de código fuente en C - C goiburua - C-otsake - en-tête C - C fejléc - Header C - C 헤더 - C-kildekodeheader - C-hovud - Plik nagłówkowy w C - C-huvud - Файл заголовків на C @@ -65,20 +19,6 @@ C++ Header file C++ header - Заглавен файл на C++ - Hlavička v C++ - C++-Header - cabecera de código fuente en C++ - C++ goiburua - C++-otsake - en-tête C++ - C++ fejléc - Header C++ - C++-kildekodeheader - C++-hovud - Plik nagłówkowy w C++ - C++-huvud - Файл заголовків на C++ @@ -97,37 +37,6 @@ C++ Source file C++ source code - Изходен код на C++ - codi font en C++ - Zdrojový kód v C++ - Ffynhonnell Rhaglen C++ - C++-kildekode - C++-Quelltext - πηγαίος κώδικας C++ - C++-fontkodo - código fuente en C++ - C++ iturburu-kodea - C++-lähdekoodi - code source C++ - C++-forráskód - Codice sorgente C++ - C++ ソースコード - C++ 소스 코드 - C++ pradinis kodas - Kod sumber C++ - C++-kildekode - C++-broncode - C++-kjeldekode - Kod źródłowy w C++ - código fonte C++ - Código fonte C++ - программа на языке C++ - Kod burues C++ - C++ изворни ко̂д - C++-källkod - Вихідний код на мові C++ - C++ 源代码 - C++ 源代碼 @@ -135,4 +44,15 @@ + + + Objective-C source code + + + + + + + + diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index f7d12b0add7..511cb56c8b3 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -230,6 +230,8 @@ bool CppHighlighter::isPPKeyword(const QStringRef &text) const case 6: if (text.at(0) == 'i' && text == QLatin1String("ifndef")) return true; + if (text.at(0) == 'i' && text == QLatin1String("import")) + return true; else if (text.at(0) == 'd' && text == QLatin1String("define")) return true; else if (text.at(0) == 'p' && text == QLatin1String("pragma")) diff --git a/src/plugins/cpptools/completionsettingspage.ui b/src/plugins/cpptools/completionsettingspage.ui index c71a2abc821..a044376bc74 100644 --- a/src/plugins/cpptools/completionsettingspage.ui +++ b/src/plugins/cpptools/completionsettingspage.ui @@ -17,11 +17,14 @@ - Completion Settings + Code Completion + + Do a case-sensitive match for completion items. + &Case-sensitive completion @@ -32,6 +35,9 @@ + + Automatically insert (, ) and ; when appropriate. + &Automatically insert braces @@ -42,6 +48,9 @@ + + Insert the common prefix of available completion items. + Autocomplete common &prefix diff --git a/src/plugins/designer/Designer.mimetypes.xml b/src/plugins/designer/Designer.mimetypes.xml index f093afb0e1d..a593f240d12 100644 --- a/src/plugins/designer/Designer.mimetypes.xml +++ b/src/plugins/designer/Designer.mimetypes.xml @@ -4,34 +4,5 @@ Qt Designer file - Файл, формат Qt Designer - fitxer de Qt Designer - Soubor Qt Designeru - Ffeil Qt Designer - Qt Designer-fil - QT Designer-Datei - αρχείο Qt Designer - dosiero de Qt Designer - fichero de Qt Designer - Qt Designer Fitxategia - Qt Designer -tiedosto - fichier Qt Designer - Qt Designer-fájl - File Qt Designer - Qt Designer ファイル - Qt 디자이너 파일 - Qt Designer rinkmena - Fail Qt Designer - Qt Designer-fil - Qt Designer-bestand - Qt Designer-fil - Plik Qt Designera - ficheiro do Qt Designer - Arquivo do Qt Designer - файл Qt Designer - File Qt Designer - Qt Designer датотека - Qt Designer-fil - Файл програми Qt-дизайнер diff --git a/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml b/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml index 45f6c0b00b8..cd600867735 100644 --- a/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml +++ b/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml @@ -5,37 +5,6 @@ Qt Script file - Програма на JavaScript - programa JavaScript - Program v JavaScriptu - JavaScript-program - JavaScript-Programm - πρόγραμμα JavaScript - JavaScript-programo - programa en JavaScript - JavaScript programa - JavaScript-ohjelma - programme JavaScript - JavaScript-program - Programma JavaScript - JavaScript プログラム - 자바스크립트 프로그램 - JavaScript programa - Program JavaScript - JavaScript-program - JavaScript-programma - JavaScript-program - Pogram JavaScript - programa JavaScript - Programa JavaScript - программа JavaScript - program JavaScript - Јаваскрипт програм - JavaScript-program - Програма на мові JavaScript - Chương trình JavaScript - JavaScript 程序 - JavaScript 程式 diff --git a/src/plugins/texteditor/TextEditor.mimetypes.xml b/src/plugins/texteditor/TextEditor.mimetypes.xml index e78754da68d..913b9fe0eba 100644 --- a/src/plugins/texteditor/TextEditor.mimetypes.xml +++ b/src/plugins/texteditor/TextEditor.mimetypes.xml @@ -3,36 +3,6 @@ Plain text document - Документ с неформатиран текст - document de text pla - Prostý textový dokument - ren tekst-dokument - einfaches Textdokument - έγγραφο απλού κειμένου - plata teksta dokumento - documento de texto sencillo - testu soileko dokumentua - perustekstiasiakirja - document plein texte - egyszerű szöveg - Documento in testo semplice - 平文テキストドキュメント - 보통 text 문서 - paprastas tekstinis dokumentas - Dokumen teks jernih - vanlig tekstdokument - platte tekst document - vanleg tekstdokument - zwykły dokument tekstowy - documento em texto simples - Documento somente texto - dokument teksti i thjeshtë - обичан текстуални документ - vanligt textdokument - звичайний текстовий документ - thư nhập thô (văn bản không có kiểu dáng) - 纯文本文档 - 普通文本檔 diff --git a/src/plugins/texteditor/behaviorsettingspage.ui b/src/plugins/texteditor/behaviorsettingspage.ui index e6414918c22..64febb27e5b 100644 --- a/src/plugins/texteditor/behaviorsettingspage.ui +++ b/src/plugins/texteditor/behaviorsettingspage.ui @@ -6,27 +6,144 @@ 0 0 - 484 - 398 + 428 + 384 Form - - + + - Tab/Indent Settings + Storage - - - + + + + + Removes trailing whitespace on saving. + - Enable automatic &indentation + &Clean whitespace + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + false + + + Clean whitespace in entire document instead of only for changed parts. + + + In entire &document + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + false + + + Correct leading whitespace according to tab settings. + + + Clean indentation + + + + + + + + + &Ensure newline at end of file + + + + + + + + + + Interaction + + + + + + + + + Use "vi" style editing + + + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + Tabs and Indentation + + @@ -89,13 +206,6 @@ - - - - Insert &spaces instead of tabs - - - @@ -145,8 +255,11 @@ - + + + Backspace will go back one indentation level instead of one space. + &Backspace follows indentation @@ -168,121 +281,23 @@ - - - - - - - Storage Settings - - - - - - &Clean whitespace - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - false - - - In entire &document - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - false - - - Clean indentation - - - - - - - - - &Ensure newline at end of file - - - - - - - - - - Interaction Settings - - - + - Use "vi" style editing + Insert &spaces instead of tabs + + + + + + + Enable automatic &indentation - - - - Qt::Vertical - - - - 20 - 8 - - - - diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui index 30fdf5cf93b..59c8d676b26 100644 --- a/src/plugins/texteditor/displaysettingspage.ui +++ b/src/plugins/texteditor/displaysettingspage.ui @@ -6,26 +6,86 @@ 0 0 - 514 - 194 + 381 + 279 Form + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + Display + + + + + + Display line &numbers + + + + + + + Display &folding markers + + + + + + + Show tabs and spaces. + + + &Visualize whitespace + + + + + + + Highlight current &line + + + + + + - Display Settings + Text Wrapping - - + + + + + Enable text &wrapping + + + + - Display right &margin at column + Display right &margin at column: @@ -39,59 +99,24 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + - - - - Enable text &wrapping - - - - - - - Display line &numbers - - - - - - - &Visualize whitespace - - - - - - - Display &folding markers - - - - - - - Highlight current &line - - - - - - - Qt::Vertical - - - - 20 - 8 - - - - diff --git a/src/plugins/texteditor/fontsettingspage.ui b/src/plugins/texteditor/fontsettingspage.ui index 770d5e2935c..8aafb751b2f 100644 --- a/src/plugins/texteditor/fontsettingspage.ui +++ b/src/plugins/texteditor/fontsettingspage.ui @@ -23,7 +23,7 @@ - General Font Settings + Font @@ -119,7 +119,7 @@ - Item Specific Settings + Color Scheme diff --git a/src/plugins/vcsbase/VCSBase.mimetypes.xml b/src/plugins/vcsbase/VCSBase.mimetypes.xml index 1c970521748..b5821a75a61 100644 --- a/src/plugins/vcsbase/VCSBase.mimetypes.xml +++ b/src/plugins/vcsbase/VCSBase.mimetypes.xml @@ -3,37 +3,6 @@ Differences between files - Разлики между файлове - diferències entre fitxers - Rozdíly mezi soubory - forskel mellem filer - Unterschied zwischen Dateien - διαφορές μεταξύ αρχείων - diferencoj inter dosieroj - diferencias entre ficheros - fitxategien arteko ezberdintasunak - tiedostojen väliset erot - différences entre fichiers - diff-különbségfájl - Differenze tra file - ファイル間差分 - 파일사이의 바뀐점 - skirtumai tarp rinkmenų - Perbezaan antara fail - forskjeller mellom filer - verschillen tussen bestanden - skilnader mellom filer - różnica pomiędzy plikami - diferenças entre ficheiros - Diferenças entre arquivos - различия между файлами - diferenca midis files - разлике међу датотекама - skillnader mellan filer - різниця між файлами - khác biệt giữa nhiều tập tin - 文件的区别 - 檔案內容差異 diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index 3d710db3669..d0ac090099d 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -611,8 +611,7 @@ AsmDefinitionAST *AsmDefinitionAST::clone(MemoryPool *pool) const { AsmDefinitionAST *ast = new (pool) AsmDefinitionAST; ast->asm_token = asm_token; - if (cv_qualifier_seq) - ast->cv_qualifier_seq = cv_qualifier_seq->clone(pool); + ast->volatile_token = volatile_token; ast->lparen_token = lparen_token; ast->rparen_token = rparen_token; ast->semicolon_token = semicolon_token; @@ -622,9 +621,7 @@ AsmDefinitionAST *AsmDefinitionAST::clone(MemoryPool *pool) const void AsmDefinitionAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { - for (SpecifierAST *spec = cv_qualifier_seq; spec; - spec = spec->next) - accept(spec, visitor); + // ### accept the asm operand list. } } @@ -641,11 +638,8 @@ unsigned AsmDefinitionAST::lastToken() const return rparen_token + 1; else if (lparen_token) return lparen_token + 1; - for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next) { - if (! it->next) - return it->lastToken(); - } - + else if (volatile_token) + return volatile_token + 1; return asm_token + 1; } diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index d7f346c5b0c..1918ee79535 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -397,8 +397,10 @@ class CPLUSPLUS_EXPORT AsmDefinitionAST: public DeclarationAST { public: unsigned asm_token; - SpecifierAST *cv_qualifier_seq; + unsigned volatile_token; unsigned lparen_token; + // ### string literals + // ### asm operand list unsigned rparen_token; unsigned semicolon_token; diff --git a/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp b/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp new file mode 100644 index 00000000000..0bcff3202c9 --- /dev/null +++ b/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp @@ -0,0 +1,124 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "ObjectiveCTypeQualifiers.h" + +CPLUSPLUS_BEGIN_NAMESPACE + +static inline int classify2(const char *s) { + if (s[0] == 'i') { + if (s[1] == 'n') { + return Token_in; + } + } + return Token_identifier; +} + +static inline int classify3(const char *s) { + if (s[0] == 'o') { + if (s[1] == 'u') { + if (s[2] == 't') { + return Token_out; + } + } + } + return Token_identifier; +} + +static inline int classify5(const char *s) { + if (s[0] == 'b') { + if (s[1] == 'y') { + if (s[2] == 'r') { + if (s[3] == 'e') { + if (s[4] == 'f') { + return Token_byref; + } + } + } + } + } + else if (s[0] == 'i') { + if (s[1] == 'n') { + if (s[2] == 'o') { + if (s[3] == 'u') { + if (s[4] == 't') { + return Token_inout; + } + } + } + } + } + return Token_identifier; +} + +static inline int classify6(const char *s) { + if (s[0] == 'b') { + if (s[1] == 'y') { + if (s[2] == 'c') { + if (s[3] == 'o') { + if (s[4] == 'p') { + if (s[5] == 'y') { + return Token_bycopy; + } + } + } + } + } + } + else if (s[0] == 'o') { + if (s[1] == 'n') { + if (s[2] == 'e') { + if (s[3] == 'w') { + if (s[4] == 'a') { + if (s[5] == 'y') { + return Token_oneway; + } + } + } + } + } + } + return Token_identifier; +} + +int classifyObjectiveCTypeQualifiers(const char *s, int n) { + switch (n) { + case 2: return classify2(s); + case 3: return classify3(s); + case 5: return classify5(s); + case 6: return classify6(s); + default: return Token_identifier; + } // switch +} + +CPLUSPLUS_END_NAMESPACE diff --git a/src/shared/cplusplus/ObjectiveCTypeQualifiers.h b/src/shared/cplusplus/ObjectiveCTypeQualifiers.h new file mode 100644 index 00000000000..5dd7a7609ba --- /dev/null +++ b/src/shared/cplusplus/ObjectiveCTypeQualifiers.h @@ -0,0 +1,56 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ +#ifndef CPLUSPLUS_OBJC_TYPEQUALIFIERS_H +#define CPLUSPLUS_OBJC_TYPEQUALIFIERS_H + +#include "CPlusPlusForwardDeclarations.h" + +CPLUSPLUS_BEGIN_HEADER +CPLUSPLUS_BEGIN_NAMESPACE + +enum { + Token_in, + Token_out, + Token_byref, + Token_inout, + Token_bycopy, + Token_oneway, + Token_identifier +}; + +CPLUSPLUS_EXPORT int classifyObjectiveCTypeQualifiers(const char *s, int n); + +CPLUSPLUS_END_NAMESPACE +CPLUSPLUS_END_HEADER + +#endif // CPLUSPLUS_OBJC_TYPEQUALIFIERS_H diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 572c9f6665b..6fb2da600d7 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -56,6 +56,7 @@ #include "Control.h" #include "AST.h" #include "Literals.h" +#include "ObjectiveCTypeQualifiers.h" #include #include #include @@ -627,22 +628,92 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) bool Parser::parseAsmDefinition(DeclarationAST *&node) { - if (LA() == T_ASM) { - AsmDefinitionAST *ast = new (_pool) AsmDefinitionAST; - ast->asm_token = consumeToken(); - parseCvQualifiers(ast->cv_qualifier_seq); - if (LA() == T_LPAREN) { - ast->lparen_token = cursor(); - if (skip(T_LPAREN, T_RPAREN)) - ast->rparen_token = consumeToken(); + if (LA() != T_ASM) + return false; + + AsmDefinitionAST *ast = new (_pool) AsmDefinitionAST; + ast->asm_token = consumeToken(); + + if (LA() == T_VOLATILE) + ast->volatile_token = consumeToken(); + + match(T_LPAREN, &ast->lparen_token); + unsigned string_literal_token = 0; + match(T_STRING_LITERAL, &string_literal_token); + while (LA() == T_STRING_LITERAL) { + consumeToken(); + } + if (LA() == T_COLON) { + consumeToken(); // skip T_COLON + parseAsmOperandList(); + if (LA() == T_COLON) { + consumeToken(); + parseAsmOperandList(); + if (LA() == T_COLON) { + consumeToken(); + parseAsmClobberList(); + } + } else if (LA() == T_COLON_COLON) { + consumeToken(); + parseAsmClobberList(); + } + } else if (LA() == T_COLON_COLON) { + consumeToken(); + parseAsmClobberList(); + } + match(T_RPAREN, &ast->rparen_token); + match(T_SEMICOLON, &ast->semicolon_token); + node = ast; + return true; +} + +bool Parser::parseAsmOperandList() +{ + if (parseAsmOperand()) { + while (LA() == T_COMMA) { + consumeToken(); + parseAsmOperand(); } - match(T_SEMICOLON, &ast->semicolon_token); - node = ast; return true; } return false; } +bool Parser::parseAsmOperand() +{ + unsigned string_literal_token = 0; + match(T_STRING_LITERAL, &string_literal_token); + + if (LA() == T_LBRACKET) { + /*unsigned lbracket_token = */ consumeToken(); + match(T_STRING_LITERAL, &string_literal_token); + unsigned rbracket_token = 0; + match(T_RBRACKET, &rbracket_token); + } + + unsigned lparen_token = 0, rparen_token = 0; + match(T_LPAREN, &lparen_token); + ExpressionAST *expression = 0; + parseExpression(expression); + match(T_RPAREN, &rparen_token); + return true; +} + +bool Parser::parseAsmClobberList() +{ + if (LA() != T_STRING_LITERAL) + return false; + + unsigned string_literal_token = consumeToken(); + + while (LA() == T_COMMA) { + consumeToken(); + match(T_STRING_LITERAL, &string_literal_token); + } + + return true; +} + bool Parser::parseTemplateDeclaration(DeclarationAST *&node) { if (! (LA(1) == T_TEMPLATE || ((LA(1) == T_EXPORT || LA(1) == T_EXTERN) @@ -2556,6 +2627,13 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node) case T_SLOT: return parseQtMethod(node); + case T_LBRACKET: + case T_AT_STRING_LITERAL: + case T_AT_ENCODE: + case T_AT_PROTOCOL: + case T_AT_SELECTOR: + return parseObjCExpression(node); + default: { NameAST *name = 0; if (parseNameId(name)) { @@ -2570,6 +2648,151 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node) return false; } +bool Parser::parseObjCExpression(ExpressionAST *&node) +{ + switch (LA()) { + case T_AT_ENCODE: + return parseObjCEncodeExpression(node); + + case T_AT_PROTOCOL: + return parseObjCProtocolExpression(node); + + case T_AT_SELECTOR: + return parseObjCSelectorExpression(node); + + case T_LBRACKET: + return parseObjCMessageExpression(node); + + case T_AT_STRING_LITERAL: + return parseObjCStringLiteral(node); + + default: + break; + } // switch + return false; +} + +bool Parser::parseObjCStringLiteral(ExpressionAST *&node) +{ + if (LA() != T_AT_STRING_LITERAL) + return false; + + StringLiteralAST **ast = reinterpret_cast (&node); + + while (LA() == T_AT_STRING_LITERAL) { + *ast = new (_pool) StringLiteralAST; + (*ast)->token = consumeToken(); + ast = &(*ast)->next; + } + return true; +} + +bool Parser::parseObjCEncodeExpression(ExpressionAST *&) +{ + if (LA() != T_AT_ENCODE) + return false; + + /*unsigned encode_token = */ consumeToken(); + parseObjCTypeName(); + return true; +} + +bool Parser::parseObjCProtocolExpression(ExpressionAST *&) +{ + if (LA() != T_AT_PROTOCOL) + return false; + + /*unsigned protocol_token = */ consumeToken(); + unsigned lparen_token = 0, identifier_token = 0, rparen_token = 0; + match(T_LPAREN, &lparen_token); + match(T_IDENTIFIER, &identifier_token); + match(T_RPAREN, &rparen_token); + return true; +} + +bool Parser::parseObjCSelectorExpression(ExpressionAST *&) +{ + if (LA() != T_AT_SELECTOR) + return false; + + /*unsigned selector_token = */consumeToken(); + unsigned lparen_token = 0, rparen_token = 0; + match(T_LPAREN, &lparen_token); + parseObjCMethodSignature(); + match(T_RPAREN, &rparen_token); + return true; +} + +bool Parser::parseObjCMessageExpression(ExpressionAST *&) +{ + if (LA() != T_LBRACKET) + return false; + + /*unsigned lbracket_token = */ consumeToken(); + + parseObjCMessageReceiver(); + parseObjCMessageArguments(); + + unsigned rbracket_token = 0; + match(T_RBRACKET, &rbracket_token); + return true; +} + +bool Parser::parseObjCMessageReceiver() +{ + ExpressionAST *expression = 0; + return parseExpression(expression); +} + +bool Parser::parseObjCMessageArguments() +{ + if (LA() == T_RBRACKET) + return false; // nothing to do. + + unsigned start = cursor(); + + if (parseObjCSelectorArgs()) { + while (parseObjCSelectorArgs()) { + // accept the selector args. + } + } else { + rewind(start); + parseObjCSelector(); + } + + while (LA() == T_COMMA) { + consumeToken(); // skip T_COMMA + ExpressionAST *expression = 0; + parseAssignmentExpression(expression); + } + return true; +} + +bool Parser::parseObjCSelectorArgs() +{ + parseObjCSelector(); + if (LA() != T_COLON) + return false; + + /*unsigned colon_token = */consumeToken(); + + ExpressionAST *expression = 0; + parseAssignmentExpression(expression); + return true; +} + +bool Parser::parseObjCMethodSignature() +{ + if (parseObjCSelector()) { + while (LA() == T_COMMA) { + consumeToken(); // skip T_COMMA + parseObjCSelector(); + } + return true; + } + return false; +} + bool Parser::parseNameId(NameAST *&name) { unsigned start = cursor(); @@ -3522,6 +3745,42 @@ bool Parser::parseObjCImplementation(DeclarationAST *&) } parseObjClassInstanceVariables(); + parseObjCMethodDefinitionList(); + return true; +} + +bool Parser::parseObjCMethodDefinitionList() +{ + while (LA() && LA() != T_AT_END) { + unsigned start = cursor(); + + switch (LA()) { + case T_PLUS: + case T_MINUS: + parseObjCMethodDefinition(); + + if (start == cursor()) + consumeToken(); + break; + + default: + // ### warning message + consumeToken(); + break; + } // switch + } + + return true; +} + +bool Parser::parseObjCMethodDefinition() +{ + if (LA() != T_MINUS && LA() != T_PLUS) + return false; + + parseObjCMethodSignature(); + StatementAST *function_body = 0; + parseFunctionBody(function_body); return true; } @@ -3785,16 +4044,11 @@ bool Parser::parseObjCTypeQualifiers() return false; Identifier *id = tok().identifier; - if (! strcmp("in", id->chars()) || - ! strcmp("out", id->chars()) || - ! strcmp("inout", id->chars()) || - ! strcmp("bycopy", id->chars()) || - ! strcmp("byref", id->chars()) || - ! strcmp("oneway", id->chars())) { - consumeToken(); - return true; - } - return false; + const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size()); + if (k == Token_identifier) + return false; + consumeToken(); + return true; } // objc-end: T_AT_END diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index d99d8d27fc0..e6a29d199e2 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -85,6 +85,9 @@ public: bool parseAdditiveExpression(ExpressionAST *&node); bool parseAndExpression(ExpressionAST *&node); bool parseAsmDefinition(DeclarationAST *&node); + bool parseAsmOperandList(); + bool parseAsmOperand(); + bool parseAsmClobberList(); bool parseAssignmentExpression(ExpressionAST *&node); bool parseBaseClause(BaseSpecifierAST *&node); bool parseBaseSpecifier(BaseSpecifierAST *&node); @@ -211,12 +214,25 @@ public: bool parseQtMethod(ExpressionAST *&node); // ObjC++ + bool parseObjCExpression(ExpressionAST *&node); bool parseObjCClassDeclaration(DeclarationAST *&node); bool parseObjCInterface(DeclarationAST *&node, SpecifierAST *attributes = 0); bool parseObjCProtocol(DeclarationAST *&node, SpecifierAST *attributes = 0); + bool parseObjCEncodeExpression(ExpressionAST *&node); + bool parseObjCProtocolExpression(ExpressionAST *&node); + bool parseObjCSelectorExpression(ExpressionAST *&node); + bool parseObjCStringLiteral(ExpressionAST *&node); + bool parseObjCMethodSignature(); + bool parseObjCMessageExpression(ExpressionAST *&node); + bool parseObjCMessageReceiver(); + bool parseObjCMessageArguments(); + bool parseObjCSelectorArgs(); + bool parseObjCMethodDefinitionList(); + bool parseObjCMethodDefinition(); + bool parseObjCProtocolRefs(); bool parseObjClassInstanceVariables(); bool parseObjCInterfaceMemberDeclaration(); diff --git a/src/shared/cplusplus/PrettyPrinter.cpp b/src/shared/cplusplus/PrettyPrinter.cpp index 6acb109dcfb..d6c604c3abb 100644 --- a/src/shared/cplusplus/PrettyPrinter.cpp +++ b/src/shared/cplusplus/PrettyPrinter.cpp @@ -101,10 +101,8 @@ bool PrettyPrinter::visit(ArrayInitializerAST *ast) bool PrettyPrinter::visit(AsmDefinitionAST *ast) { out << spell(ast->asm_token); - for (SpecifierAST *it = ast->cv_qualifier_seq; it; it = it->next) { - out << ' '; - accept(it); - } + if (ast->volatile_token) + out << ' ' << spell(ast->volatile_token) << ' '; out << '('; out << "/* ### implement me */"; out << ");"; diff --git a/src/shared/cplusplus/cplusplus.pri b/src/shared/cplusplus/cplusplus.pri index 041aff67be2..3a62ed6b7da 100644 --- a/src/shared/cplusplus/cplusplus.pri +++ b/src/shared/cplusplus/cplusplus.pri @@ -36,8 +36,8 @@ HEADERS += \ $$PWD/TranslationUnit.h \ $$PWD/Type.h \ $$PWD/TypeVisitor.h \ - $$PWD/PrettyPrinter.h - + $$PWD/PrettyPrinter.h \ + $$PWD/ObjectiveCTypeQualifiers.h SOURCES += \ $$PWD/AST.cpp \ @@ -55,6 +55,7 @@ SOURCES += \ $$PWD/FullySpecifiedType.cpp \ $$PWD/Keywords.cpp \ $$PWD/ObjectiveCAtKeywords.cpp \ + $$PWD/ObjectiveCTypeQualifiers.cpp \ $$PWD/Lexer.cpp \ $$PWD/LiteralTable.cpp \ $$PWD/Literals.cpp \ diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 28a30f2a03b..c54b75a1e2d 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -719,6 +719,7 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value) // The following two blocks fix bug 180128 by making all "interesting" // file name absolute in each .pro file, not just the top most one if (varName == QLatin1String("SOURCES") + || varName == QLatin1String("OBJECTIVE_SOURCES") || varName == QLatin1String("HEADERS") || varName == QLatin1String("INTERFACES") || varName == QLatin1String("FORMS") diff --git a/tests/auto/cplusplus/shared/shared.pri b/tests/auto/cplusplus/shared/shared.pri index 924cda99911..63573f07c69 100644 --- a/tests/auto/cplusplus/shared/shared.pri +++ b/tests/auto/cplusplus/shared/shared.pri @@ -1,5 +1,5 @@ -DEFINES += HAVE_QT CPLUSPLUS_WITH_NAMESPACE +DEFINES += CPLUSPLUS_WITH_NAMESPACE INCLUDEPATH += $$PWD/../../../../src/shared/cplusplus DEPENDPATH += $$INCLUDEPATH . LIBS += -L$$PWD -lCPlusPlusTestSupport diff --git a/tests/auto/cplusplus/shared/shared.pro b/tests/auto/cplusplus/shared/shared.pro index 2f84af560bc..a3746386dfa 100644 --- a/tests/auto/cplusplus/shared/shared.pro +++ b/tests/auto/cplusplus/shared/shared.pro @@ -3,6 +3,7 @@ TEMPLATE = lib TARGET = CPlusPlusTestSupport CONFIG += static QT = core +DESTDIR = $$PWD -DEFINES += HAVE_QT CPLUSPLUS_WITH_NAMESPACE +DEFINES += CPLUSPLUS_WITH_NAMESPACE include($$PWD/../../../../src/shared/cplusplus/cplusplus.pri)