/************************************************************************** ** ** This file is part of Qt Creator ** ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). ** ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** No Commercial Usage ** ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. ** ** 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. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** **************************************************************************/ /* ** Description: ** ** The ParseManager parses and compares to different header files ** of its metadata. This can be used for checking if an Interface ** is implemented complete. ** ** How to use it: ** ** //Parse the interface header ** ParseManager* iParseManager = new ParseManager(); ** iParseManager->setIncludePath(iIncludepathlist); ** iParseManager->parse(iFilelist); ** ** //Parse the header that needs to be compared against the interface header ** ParseManager* chParseManager = new ParseManager(); ** chIncludepathlist << getQTIncludePath(); * chParseManager->setIncludePath(chIncludepathlist); ** chParseManager->parse(chFilelist); ** ** if(!chParseManager->checkAllMetadatas(iParseManager)){ ** cout << "Following interface items are missing:" << endl; ** QStringList errorlist = chParseManager->getErrorMsg(); ** foreach(QString msg, errorlist){ ** cout << (const char *)msg.toLatin1() << endl; ** } ** return -1; ** } ** else ** cout << "Interface is full defined."; */ #ifndef PARSEMANAGER_H #define PARSEMANAGER_H #include "cplusplus/CppDocument.h" #include "ASTfwd.h" #include "FullySpecifiedType.h" #include #include #include #include #include namespace CppTools{ namespace Internal{ class CppPreprocessor; } } namespace CPlusPlus { class CLASSLISTITEM { public: CPlusPlus::TranslationUnit* trlUnit; ClassSpecifierAST* classspec; }; class CLASSTREE { public: CLASSLISTITEM* highestlevelclass; QList classlist; }; class FUNCTIONITEM { public: const CLASSLISTITEM* highestlevelclass; CPlusPlus::TranslationUnit* trlUnit; ClassSpecifierAST* classAst; QStringList classWichIsNotFound; CPlusPlus::Function* function; bool isEqualTo(FUNCTIONITEM* cpfct, bool ignoreName = true); FUNCTIONITEM() { highestlevelclass = 0; trlUnit = 0; classAst = 0; function = 0; } }; class PROPERTYITEM { public: const CLASSLISTITEM* highestlevelclass; QStringList classWichIsNotFound; QtPropertyDeclarationAST *ast; CPlusPlus::TranslationUnit* trlUnit; FullySpecifiedType type; ExpressionAST *readAst; FUNCTIONITEM *readFct; ExpressionAST *writeAst; FUNCTIONITEM *writeFct; ExpressionAST *resetAst; FUNCTIONITEM *resetFct; ExpressionAST *notifyAst; FUNCTIONITEM *notifyFct; bool foundalldefinedfct; bool isEqualTo(PROPERTYITEM* cpppt); PROPERTYITEM() { highestlevelclass = 0; ast = 0; trlUnit = 0; readAst = 0; readFct = 0; writeAst = 0; writeFct = 0; resetAst = 0; resetFct = 0; notifyAst = 0; notifyFct = 0; foundalldefinedfct = false; } static PROPERTYITEM *create(QtPropertyDeclarationAST *ast, const CLASSLISTITEM *clazz); }; class QENUMITEM { public: const CLASSLISTITEM* highestlevelclass; QStringList classWichIsNotFound; QString name; //an item in this list will be shown like: //EnumName.EnumItemName.Value //ConnectionState.disconnected.0 QStringList values; bool foundallenums; bool isEqualTo(QENUMITEM *cpenum); QENUMITEM() { highestlevelclass = 0; values.clear(); foundallenums = true; } }; class ENUMITEM { public: const CLASSLISTITEM* highestlevelclass; CPlusPlus::TranslationUnit* trlUnit; QStringList classWichIsNotFound; EnumSpecifierAST* ast; ENUMITEM() { highestlevelclass = 0; trlUnit = 0; ast = 0; } }; class QFLAGITEM { public: const CLASSLISTITEM* highestlevelclass; const Name *name; QStringList classWichIsNotFound; QStringList enumvalues; bool foundallenums; bool isEqualTo(QFLAGITEM *cpflag); QFLAGITEM() { highestlevelclass = 0; enumvalues.clear(); foundallenums = true; } }; class QDECLAREFLAGSITEM { public: const CLASSLISTITEM* highestlevelclass; CPlusPlus::TranslationUnit* trlUnit; QStringList classWichIsNotFound; QtFlagsDeclarationAST* ast; QDECLAREFLAGSITEM() { highestlevelclass = 0; trlUnit = 0; ast = 0; } }; static QFile* m_resultFile = 0; class ParseManager : public QObject { Q_OBJECT public: ParseManager(); virtual ~ParseManager(); void setIncludePath(const QStringList &includePath); void parse(const QStringList &sourceFiles); bool checkAllMetadatas(ParseManager* pInterfaceParserManager, QString resultfile); CppTools::Internal::CppPreprocessor *getPreProcessor() { return pCppPreprocessor; } QList CreateClassLists(bool isInterfaceHeader); QStringList getErrorMsg() { return m_errormsgs; } private: void parse(CppTools::Internal::CppPreprocessor *preproc, const QStringList &files); void Trace(QString value); inline QString getTraceFuntionString(const FUNCTIONITEM* fctitem, const QString& classname); void getBaseClasses(const CLASSLISTITEM* pclass , QList &baseclasslist , const QList &allclasslist , int level , bool isInterfaceHeader); void getElements(QList &functionlist , QList &propertylist , QList &qenumlist , QList &enumlist , QList &qflaglist , QList &qdeclareflaglist , const QList classitems , const CLASSLISTITEM* highestlevelclass); //<--- for Metadata functions checks QList checkMetadataFunctions(const QList > &classfctlist, const QList > &iclassfctlist); bool isMetaObjFunction(FUNCTIONITEM* fct); QList containsAllMetadataFunction(const QList &classfctlist, const QList &iclassfctlist); QStringList getErrorMessage(FUNCTIONITEM* fct); //---> //<--- for Q_PROPERTY functions checks QList checkMetadataProperties(const QList > &classproplist , const QList > &classfctlist , const QList > &iclassproplist , const QList > &iclassfctlist); void assignPropertyFunctions(PROPERTYITEM* prop, const QList > &fctlookuplist); QList containsAllPropertyFunction(const QList &classproplist, const QList &iclassproplist); QStringList getErrorMessage(PROPERTYITEM* ppt); //---> //<--- for Q_ENUMS checks QList checkMetadataEnums(const QList > &classqenumlist , const QList > &classenumlist , const QList > &iclassqenumlist , const QList > &iclassenumlist); QStringList getEnumValueStringList(ENUMITEM *penum, QString mappedenumname = ""); void assignEnumValues(QENUMITEM* qenum, const QList > &enumlookuplist); QList containsAllEnums(const QList &classqenumlist, const QList &iclassqenumlist); QStringList getErrorMessage(QENUMITEM* qenum); //---> //<--- for QFlags checks ---> QList checkMetadataFlags(const QList > &classqflaglist , const QList > &classqdeclareflaglist , const QList > &classenumlist , const QList > &iclassqflaglist , const QList > &iclassqdeclareflaglist , const QList > &iclassenumlist); void assignFlagValues(QFLAGITEM* qflags, const QList > &qdeclareflagslookuplist, const QList > &enumlookuplist); QList containsAllFlags(const QList &classqflaglist, const QList &iclassqflaglist); QStringList getErrorMessage(QFLAGITEM* pfg); //---> private: // cache QStringList m_includePaths; QStringList m_frameworkPaths; QByteArray m_definedMacros; CppTools::Internal::CppPreprocessor* pCppPreprocessor; QString m_strHeaderFile; QStringList m_errormsgs; }; } #endif // PARSEMANAGER_H