Eneboo - Documentación para desarrolladores
src/qsa/src/kernel/quickclassparser.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: quickclassparser.h  1.1.4   edited 2006-02-23T15:39:57$
00003 **
00004 ** Copyright (C) 2001-2006 Trolltech AS.  All rights reserved.
00005 **
00006 ** This file is part of the Qt Script for Applications framework (QSA).
00007 **
00008 ** This file may be distributed and/or modified under the terms of the
00009 ** GNU General Public License version 2 as published by the Free Software
00010 ** Foundation and appearing in the file LICENSE.GPL included in the
00011 ** packaging of this file.
00012 **
00013 ** Licensees holding a valid Qt Script for Applications license may use
00014 ** this file in accordance with the Qt Script for Applications License
00015 ** Agreement provided with the Software.
00016 **
00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019 **
00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00021 **   information about QSA Commercial License Agreements.
00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00023 **
00024 ** Contact info@trolltech.com if any conditions of this licensing are
00025 ** not clear to you.
00026 **
00027 *****************************************************************************/
00028 
00029 #ifndef QUICKCLASSPARSER_H
00030 #define QUICKCLASSPARSER_H
00031 
00032 #include "dlldefs.h"
00033 #include <qstring.h>
00034 #include <qvaluelist.h>
00035 #include <qstringlist.h>
00036 
00037 struct LanguageInterface {
00038   struct Function {
00039     QString name;
00040     QString body;
00041     QString returnType;
00042     QString comments;
00043     int start;
00044     int end;
00045     QString access;
00046     bool operator==(const Function &f) const {
00047       return (name == f.name &&
00048               body == f.body &&
00049               returnType == f.returnType &&
00050               comments == f.comments);
00051     }
00052   };
00053 
00054   struct Connection {
00055     QString sender;
00056     QString signal;
00057     QString slot;
00058     bool operator==(const Connection &c) const {
00059       return (sender == c.sender &&
00060               signal == c.signal &&
00061               slot == c.slot);
00062     }
00063   };
00064 };
00065 
00066 #if defined(Q_TEMPLATEDLL)
00067 // MOC_SKIP_BEGIN
00068 template class QUICKCORE_EXPORT QValueList<LanguageInterface::Connection>;
00069 template class QUICKCORE_EXPORT QValueList<LanguageInterface::Function>;
00070 // MOC_SKIP_END
00071 #endif
00072 
00073 struct QUICKCORE_EXPORT QuickClass {
00074   enum Type { Global, Class } type;
00075   QValueList<LanguageInterface::Connection> connections;
00076   QValueList<LanguageInterface::Function> functions;
00077   QStringList variables;
00078   QString inherits;
00079   QString access;
00080   QString name;
00081 
00082   bool operator==(const QuickClass &other) const;
00083   QuickClass &operator=(const QuickClass &other) {
00084     connections = other.connections;
00085     functions = other.functions;
00086     variables = other.variables;
00087     name = other.name;
00088     inherits = other.inherits;
00089     access = other.access;
00090     return *this;
00091   }
00092 };
00093 
00094 #if defined(Q_TEMPLATEDLL)
00095 // MOC_SKIP_BEGIN
00096 template class QUICKCORE_EXPORT QValueList<QuickClass>;
00097 // MOC_SKIP_END
00098 #endif
00099 
00100 class QUICKCORE_EXPORT QuickClassParser
00101 {
00102 public:
00103   QuickClassParser();
00104 
00105   void parse(const QString &code);
00106   QValueList<QuickClass> classes() const {
00107     return clsses;
00108   }
00109   void setGlobalName(const QString &n) {
00110     gname = n;
00111   }
00112 
00113 protected:
00114   void parseConnections();
00115   void parseFunction(int functionLength);
00116   void parseVariableDecl(const QString &expr);
00117   void parseClassStart();
00118   void parseCppComment();
00119   void parseCComment();
00120 
00121 private:
00122   QValueList<QuickClass> clsses;
00123   QuickClass *currClass;
00124   QuickClass globalClass;
00125   int pos;
00126   QString formCode;
00127   QString lastAccess;
00128   QString gname;
00129 
00130   static QString legalChars;
00131 };
00132 
00133 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'