⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codemodel.h

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.** Copyright (C) 2001-2004 Roberto Raggi**** This file is part of the qt3to4 porting application of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.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.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef CODEMODEL_H#define CODEMODEL_H#include "smallobject.h"#include "tokenengine.h"#include <QByteArray>#include <QList>#include <QMap>#include <QHash>namespace CodeModel{// typesstruct Type;struct EnumType;struct EnumeratorType;struct ClassType;struct BuiltinType;struct PointerType;struct ReferenceType;struct GenericType;struct AliasType;struct FunctionType;struct UnknownType;// Scopes contain child scopes, members and types.struct Scope;struct ClassScope;struct NamespaceScope;struct BlockScope;// Members introduces names into scopes, and are also linked to a specific// token in a source file.struct Member;struct FunctionMember;struct VariableMember;struct UsingDeclarationMember;struct NamespaceMember;struct TypeMember;// Name uses links uses of a name to its declaration (a Member), and also to a// token in a source file.struct NameUse;struct Argument;struct UsingDirectiveLink;template <typename CollectedType>class Collection: public QMultiHash<QByteArray, CollectedType *>{public:     void add(CollectedType *collectedItem)    { insert(collectedItem->name(), collectedItem); }};typedef Collection<Scope> ScopeCollection;typedef Collection<Member> MemberCollection;typedef Collection<Type> TypeCollection;typedef Collection<NameUse> NameUseCollection;typedef Collection<Argument> ArgumentCollection;struct SemanticInfo{    CodeModel::NamespaceScope *codeModel;    // tokenindex -> NameUse* map. Use map here bacause we expect name uses to    // be sparesly distributed among the tokens.    QMap<int, NameUse*> nameUses;};struct Item{    Item()  {}    virtual ~Item() {}    virtual QByteArray name() const = 0;};struct Type: public Item{    virtual QByteArray name() const =0;    virtual EnumType *toEnumType() const    { return 0; }    virtual ClassType *toClassType() const    { return 0; }    virtual UnknownType *toUnknownType() const    { return 0; }    virtual BuiltinType *toBuiltinType() const    { return 0; }    virtual PointerType *toPointerType() const    { return 0; }    virtual ReferenceType *toReferenceType() const    { return 0; }    virtual GenericType *toGenericType() const    { return 0; }    virtual AliasType *toAliasType() const    { return 0; }};struct Scope: public Item{    Scope()     : m_parent(0) {}    void setParent(Scope *parent)    { m_parent = parent; }    Scope *parent() const    { return m_parent; }    QByteArray name() const    { return m_name; }    void setName(const QByteArray &name)    { m_name=name; }    virtual NamespaceScope *toNamespaceScope() const    { return 0; }    virtual ClassScope *toClassScope() const    { return 0; }    virtual BlockScope *toBlockScope() const    { return 0; }    const Collection<Scope> scopes() const    { return m_scopes; }    const Collection<Type> types() const    { return m_types; }    const Collection<Member> members() const    { return m_members; }    const Collection<NameUse> nameUses() const    { return m_nameUses; }    void addScope(Scope *scope);    void addType(Type *type);    void addMember(Member *member);    void addNameUse(NameUse *nameUse);private:    Scope *m_parent;    QByteArray m_name;    Collection<Scope> m_scopes;    Collection<Type> m_types;    Collection<Member> m_members;    Collection<NameUse> m_nameUses;};struct Member: public Item{    enum Binding // ### not used yet    {        Static,        Instance    };    enum Access // ### not used yet    {        Public,        Protected,        Private    };    Member()        : m_binding(Static), m_access(Public),        m_parent(0), m_constant(0), m_static(0)   {}    QByteArray name() const    { return m_name; }    void setName(const QByteArray &name)    { m_name = name; }    TokenEngine::TokenRef nameToken() const    { return m_nameToken; }    void setNameToken(TokenEngine::TokenRef nameToken)    { m_nameToken = nameToken; }    Binding binding() const    { return m_binding; }    void setBinding(Binding binding)    { m_binding = binding; }    Access access() const    { return m_access; }    void setAccess(Access access)    { m_access = access; }    bool isConstant() const    { return m_constant; }    void setConstant(bool b)    { m_constant = b; }    bool isStatic() const    { return m_static; }    void setStatic(bool b)    { m_static = b; }    Scope *parent() const    { return m_parent; }    void setParent(Scope *parent)    { m_parent = parent; }    virtual FunctionMember *toFunctionMember() const    { return 0; }    virtual VariableMember *toVariableMember() const    { return 0; }    virtual UsingDeclarationMember *toUsingDeclarationMember() const    { return 0; }    virtual NamespaceMember *toNamespaceMember() const    { return 0; }    virtual TypeMember *toTypeMember() const    { return 0; } private:     Binding m_binding;     Access m_access;     Scope *m_parent;     QByteArray m_name;     TokenEngine::TokenRef m_nameToken;     uint m_constant : 1;     uint m_static : 1;};struct ClassScope: public Scope{    const Collection<Type> baseClasses() const    { return m_baseClasses; }    void addBaseClass(Type *baseClass)    {        Q_ASSERT(baseClass->toClassType());        m_baseClasses.add(baseClass);    }    virtual ClassScope *toClassScope() const    { return const_cast<ClassScope*>(this); }private:    Collection<Type> m_baseClasses;};struct UsingDirectiveLinkable : public Scope{    const QList<UsingDirectiveLink *> usingDirectiveLinks() const    { return m_usingDirectiveLinks; }    void addUsingDirectiveLink(UsingDirectiveLink *usingDirectiveLink)    { m_usingDirectiveLinks.append(usingDirectiveLink); }private:    QList<UsingDirectiveLink *> m_usingDirectiveLinks;};struct NamespaceScope: public UsingDirectiveLinkable{    NamespaceScope() {}    virtual NamespaceScope *toNamespaceScope() const    { return const_cast<NamespaceScope*>(this); }};struct BlockScope: public UsingDirectiveLinkable{    BlockScope() {}    virtual BlockScope *toBlockScope() const    { return const_cast<BlockScope*>(this); }};struct EnumType: public Type{    EnumType()        : m_parent(0) {}    QByteArray name() const    { return m_name; }    void setName(const QByteArray &name)    { m_name = name; }    Scope *parent() const    { return m_parent; }    void setParent(Scope *parent)    { m_parent = parent; }    virtual EnumType *toEnumType() const    { return const_cast<EnumType*>(this); }private:    Scope *m_parent;    QByteArray m_name;};struct UnknownType: public Type{    UnknownType()        : m_parent(0) {}    QByteArray name() const    { return m_name; }    void setName(const QByteArray &name)    { m_name = name; }    Scope *parent() const    { return m_parent; }    void setParent(Scope *parent)    { m_parent = parent; }    virtual UnknownType *toUnknownType() const    { return const_cast<UnknownType*>(this); }private:    Scope *m_parent;    QByteArray m_name;};struct ClassType: public Type{    ClassType()        : m_scope(0) {}    ClassScope *scope() const    { return m_scope; }    void setScope(ClassScope *scope)    { m_scope = scope; }    QByteArray name() const    { return m_scope ? m_scope->name() : /*anonymous*/ QByteArray(); }    Scope *parent() const    { return m_parent; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -