summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/QtContextKeywords.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2010-02-06 11:05:43 +0100
committerErik Verbruggen <erik.verbruggen@nokia.com>2010-02-07 10:49:03 +0100
commit8d8b05da5a93bcd8f45a2d1b796ff1e4b1102ff5 (patch)
tree4aa3c52c3c3d428ccb2da1a68ad54ce698b7a282 /src/shared/cplusplus/QtContextKeywords.cpp
parent6ca5f5f5f886449f88d1ff7085f640c46bbc8fb2 (diff)
downloadqt-creator-8d8b05da5a93bcd8f45a2d1b796ff1e4b1102ff5.tar.gz
Reworked parts of the QtPropertyDeclaration parsing and handling.
Diffstat (limited to 'src/shared/cplusplus/QtContextKeywords.cpp')
-rw-r--r--src/shared/cplusplus/QtContextKeywords.cpp199
1 files changed, 199 insertions, 0 deletions
diff --git a/src/shared/cplusplus/QtContextKeywords.cpp b/src/shared/cplusplus/QtContextKeywords.cpp
new file mode 100644
index 0000000000..1b1ff8bb8c
--- /dev/null
+++ b/src/shared/cplusplus/QtContextKeywords.cpp
@@ -0,0 +1,199 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "QtContextKeywords.h"
+
+using namespace CPlusPlus;
+
+static inline int classify4(const char *s) {
+ if (s[0] == 'R') {
+ if (s[1] == 'E') {
+ if (s[2] == 'A') {
+ if (s[3] == 'D') {
+ return Token_READ;
+ }
+ }
+ }
+ }
+ else if (s[0] == 'U') {
+ if (s[1] == 'S') {
+ if (s[2] == 'E') {
+ if (s[3] == 'R') {
+ return Token_USER;
+ }
+ }
+ }
+ }
+ return Token_not_Qt_context_keyword;
+}
+
+static inline int classify5(const char *s) {
+ if (s[0] == 'F') {
+ if (s[1] == 'I') {
+ if (s[2] == 'N') {
+ if (s[3] == 'A') {
+ if (s[4] == 'L') {
+ return Token_FINAL;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0] == 'R') {
+ if (s[1] == 'E') {
+ if (s[2] == 'S') {
+ if (s[3] == 'E') {
+ if (s[4] == 'T') {
+ return Token_RESET;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0] == 'W') {
+ if (s[1] == 'R') {
+ if (s[2] == 'I') {
+ if (s[3] == 'T') {
+ if (s[4] == 'E') {
+ return Token_WRITE;
+ }
+ }
+ }
+ }
+ }
+ return Token_not_Qt_context_keyword;
+}
+
+static inline int classify6(const char *s) {
+ if (s[0] == 'N') {
+ if (s[1] == 'O') {
+ if (s[2] == 'T') {
+ if (s[3] == 'I') {
+ if (s[4] == 'F') {
+ if (s[5] == 'Y') {
+ return Token_NOTIFY;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0] == 'S') {
+ if (s[1] == 'T') {
+ if (s[2] == 'O') {
+ if (s[3] == 'R') {
+ if (s[4] == 'E') {
+ if (s[5] == 'D') {
+ return Token_STORED;
+ }
+ }
+ }
+ }
+ }
+ }
+ return Token_not_Qt_context_keyword;
+}
+
+static inline int classify8(const char *s) {
+ if (s[0] == 'C') {
+ if (s[1] == 'O') {
+ if (s[2] == 'N') {
+ if (s[3] == 'S') {
+ if (s[4] == 'T') {
+ if (s[5] == 'A') {
+ if (s[6] == 'N') {
+ if (s[7] == 'T') {
+ return Token_CONSTANT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Token_not_Qt_context_keyword;
+}
+
+static inline int classify10(const char *s) {
+ if (s[0] == 'D') {
+ if (s[1] == 'E') {
+ if (s[2] == 'S') {
+ if (s[3] == 'I') {
+ if (s[4] == 'G') {
+ if (s[0] == 'N') {
+ if (s[1] == 'A') {
+ if (s[2] == 'B') {
+ if (s[3] == 'L') {
+ if (s[4] == 'E') {
+ return Token_DESIGNABLE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0] == 'S') {
+ if (s[1] == 'C') {
+ if (s[2] == 'R') {
+ if (s[3] == 'I') {
+ if (s[4] == 'P') {
+ if (s[0] == 'T') {
+ if (s[1] == 'A') {
+ if (s[2] == 'B') {
+ if (s[3] == 'L') {
+ if (s[4] == 'E') {
+ return Token_SCRIPTABLE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Token_not_Qt_context_keyword;
+}
+
+int CPlusPlus::classifyQtContextKeyword(const char *s, int n) {
+ switch (n) {
+ case 4: return classify4(s);
+ case 5: return classify5(s);
+ case 6: return classify6(s);
+ case 8: return classify8(s);
+ case 10: return classify10(s);
+ default: return Token_not_Qt_context_keyword;
+ } // switch
+}