tools/icheck/parser/src/shared/cplusplus/Control.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
       
    42 //
       
    43 // Permission is hereby granted, free of charge, to any person obtaining a copy
       
    44 // of this software and associated documentation files (the "Software"), to deal
       
    45 // in the Software without restriction, including without limitation the rights
       
    46 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       
    47 // copies of the Software, and to permit persons to whom the Software is
       
    48 // furnished to do so, subject to the following conditions:
       
    49 //
       
    50 // The above copyright notice and this permission notice shall be included in
       
    51 // all copies or substantial portions of the Software.
       
    52 //
       
    53 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
       
    54 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       
    55 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
       
    56 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       
    57 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
       
    58 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
       
    59 // THE SOFTWARE.
       
    60 
       
    61 #ifndef CPLUSPLUS_CONTROL_H
       
    62 #define CPLUSPLUS_CONTROL_H
       
    63 
       
    64 #include "CPlusPlusForwardDeclarations.h"
       
    65 
       
    66 namespace CPlusPlus {
       
    67 
       
    68 class CPLUSPLUS_EXPORT Control
       
    69 {
       
    70 public:
       
    71     Control();
       
    72     ~Control();
       
    73 
       
    74     TranslationUnit *translationUnit() const;
       
    75     TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
       
    76 
       
    77     DiagnosticClient *diagnosticClient() const;
       
    78     void setDiagnosticClient(DiagnosticClient *diagnosticClient);
       
    79 
       
    80     /// Returns the canonical name id.
       
    81     const NameId *nameId(const Identifier *id);
       
    82 
       
    83     /// Returns the canonical template name id.
       
    84     const TemplateNameId *templateNameId(const Identifier *id,
       
    85                                          const FullySpecifiedType *const args = 0,
       
    86                                          unsigned argc = 0);
       
    87 
       
    88     /// Returns the canonical destructor name id.
       
    89     const DestructorNameId *destructorNameId(const Identifier *id);
       
    90 
       
    91     /// Returns the canonical operator name id.
       
    92     const OperatorNameId *operatorNameId(int operatorId);
       
    93 
       
    94     /// Returns the canonical conversion name id.
       
    95     const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
       
    96 
       
    97     /// Returns the canonical qualified name id.
       
    98     const QualifiedNameId *qualifiedNameId(const Name *const *names,
       
    99                                            unsigned nameCount,
       
   100                                            bool isGlobal = false);
       
   101 
       
   102     const SelectorNameId *selectorNameId(const Name *const *names,
       
   103                                          unsigned nameCount,
       
   104                                          bool hasArguments);
       
   105 
       
   106     /// Returns a Type object of type VoidType.
       
   107     VoidType *voidType();
       
   108 
       
   109     /// Returns a Type object of type IntegerType.
       
   110     IntegerType *integerType(int integerId);
       
   111 
       
   112     /// Returns a Type object of type FloatType.
       
   113     FloatType *floatType(int floatId);
       
   114 
       
   115     /// Returns a Type object of type PointertoMemberType.
       
   116     PointerToMemberType *pointerToMemberType(const Name *memberName,
       
   117                                              const FullySpecifiedType &elementType);
       
   118 
       
   119     /// Returns a Type object of type PointerType.
       
   120     PointerType *pointerType(const FullySpecifiedType &elementType);
       
   121 
       
   122     /// Returns a Type object of type ReferenceType.
       
   123     ReferenceType *referenceType(const FullySpecifiedType &elementType);
       
   124 
       
   125     /// Retruns a Type object of type ArrayType.
       
   126     ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
       
   127 
       
   128     /// Returns a Type object of type NamedType.
       
   129     NamedType *namedType(const Name *name);
       
   130 
       
   131     /// Creates a new Declaration symbol.
       
   132     Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
       
   133 
       
   134     /// Creates a new Argument symbol.
       
   135     Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
       
   136 
       
   137     /// Creates a new Argument symbol.
       
   138     TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name = 0);
       
   139 
       
   140     /// Creates a new Function symbol.
       
   141     Function *newFunction(unsigned sourceLocation, const Name *name = 0);
       
   142 
       
   143     /// Creates a new Namespace symbol.
       
   144     Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0);
       
   145 
       
   146     /// Creates a new BaseClass symbol.
       
   147     BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
       
   148 
       
   149     /// Creates a new Class symbol.
       
   150     Class *newClass(unsigned sourceLocation, const Name *name = 0);
       
   151 
       
   152     /// Creates a new Enum symbol.
       
   153     Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
       
   154 
       
   155     /// Creates a new Block symbol.
       
   156     Block *newBlock(unsigned sourceLocation);
       
   157 
       
   158     /// Creates a new UsingNamespaceDirective symbol.
       
   159     UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0);
       
   160 
       
   161     /// Creates a new UsingDeclaration symbol.
       
   162     UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
       
   163 
       
   164     /// Creates a new ForwardClassDeclaration symbol.
       
   165     ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
       
   166 
       
   167     ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
       
   168     ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
       
   169 
       
   170     /// Creates a new Objective-C class symbol.
       
   171     ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
       
   172 
       
   173     /// Creates a new Objective-C class forward declaration symbol.
       
   174     ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
       
   175 
       
   176     /// Creates a new Objective-C protocol symbol.
       
   177     ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0);
       
   178 
       
   179     /// Creates a new Objective-C protocol forward declaration symbol.
       
   180     ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
       
   181 
       
   182     /// Creates a new Objective-C method symbol.
       
   183     ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0);
       
   184 
       
   185     /// Creates a new Objective-C @property declaration symbol.
       
   186     ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
       
   187 
       
   188     // Objective-C specific context keywords.
       
   189     const Identifier *objcGetterId() const;
       
   190     const Identifier *objcSetterId() const;
       
   191     const Identifier *objcReadwriteId() const;
       
   192     const Identifier *objcReadonlyId() const;
       
   193     const Identifier *objcAssignId() const;
       
   194     const Identifier *objcRetainId() const;
       
   195     const Identifier *objcCopyId() const;
       
   196     const Identifier *objcNonatomicId() const;
       
   197 
       
   198     const Identifier *findIdentifier(const char *chars, unsigned size) const;
       
   199     const Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
       
   200     const Identifier *findOrInsertIdentifier(const char *chars);
       
   201 
       
   202     typedef const Identifier *const *IdentifierIterator;
       
   203     typedef const StringLiteral *const *StringLiteralIterator;
       
   204     typedef const NumericLiteral *const *NumericLiteralIterator;
       
   205 
       
   206     IdentifierIterator firstIdentifier() const;
       
   207     IdentifierIterator lastIdentifier() const;
       
   208 
       
   209     StringLiteralIterator firstStringLiteral() const;
       
   210     StringLiteralIterator lastStringLiteral() const;
       
   211 
       
   212     NumericLiteralIterator firstNumericLiteral() const;
       
   213     NumericLiteralIterator lastNumericLiteral() const;
       
   214 
       
   215     const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
       
   216     const StringLiteral *findOrInsertStringLiteral(const char *chars);
       
   217 
       
   218     const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
       
   219     const NumericLiteral *findOrInsertNumericLiteral(const char *chars);
       
   220 
       
   221 private:
       
   222     class Data;
       
   223     friend class Data;
       
   224     Data *d;
       
   225 };
       
   226 
       
   227 } // end of namespace CPlusPlus
       
   228 
       
   229 
       
   230 #endif // CPLUSPLUS_CONTROL_H