OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / shared / cplusplus / Symbols.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
33 //
34 // Permission is hereby granted, free of charge, to any person obtaining a copy
35 // of this software and associated documentation files (the "Software"), to deal
36 // in the Software without restriction, including without limitation the rights
37 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38 // copies of the Software, and to permit persons to whom the Software is
39 // furnished to do so, subject to the following conditions:
40 //
41 // The above copyright notice and this permission notice shall be included in
42 // all copies or substantial portions of the Software.
43 //
44 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
50 // THE SOFTWARE.
51
52 #ifndef CPLUSPLUS_SYMBOLS_H
53 #define CPLUSPLUS_SYMBOLS_H
54
55 #include "CPlusPlusForwardDeclarations.h"
56 #include "Symbol.h"
57 #include "Type.h"
58 #include "FullySpecifiedType.h"
59 #include "Scope.h"
60 #include <vector>
61
62 namespace CPlusPlus {
63
64 class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
65 {
66 public:
67     UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
68     virtual ~UsingNamespaceDirective();
69
70     // Symbol's interface
71     virtual FullySpecifiedType type() const;
72
73     virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const
74     { return this; }
75
76     virtual UsingNamespaceDirective *asUsingNamespaceDirective()
77     { return this; }
78
79 protected:
80     virtual void visitSymbol0(SymbolVisitor *visitor);
81 };
82
83 class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
84 {
85 public:
86     UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
87     virtual ~UsingDeclaration();
88
89     // Symbol's interface
90     virtual FullySpecifiedType type() const;
91
92     virtual const UsingDeclaration *asUsingDeclaration() const
93     { return this; }
94
95     virtual UsingDeclaration *asUsingDeclaration()
96     { return this; }
97
98 protected:
99     virtual void visitSymbol0(SymbolVisitor *visitor);
100 };
101
102 class CPLUSPLUS_EXPORT NamespaceAlias: public Symbol
103 {
104 public:
105     NamespaceAlias(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
106     virtual ~NamespaceAlias();
107
108     const Name *namespaceName() const;
109     void setNamespaceName(const Name *namespaceName);
110
111     // Symbol's interface
112     virtual FullySpecifiedType type() const;
113
114     virtual const NamespaceAlias *asNamespaceAlias() const
115     { return this; }
116
117     virtual NamespaceAlias *asNamespaceAlias()
118     { return this; }
119
120 protected:
121     virtual void visitSymbol0(SymbolVisitor *visitor);
122
123 private:
124     const Name *_namespaceName;
125 };
126
127 class CPLUSPLUS_EXPORT Declaration: public Symbol
128 {
129 public:
130     Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
131     virtual ~Declaration();
132
133     void setType(const FullySpecifiedType &type);
134
135     // Symbol's interface
136     virtual FullySpecifiedType type() const;
137
138     virtual const Declaration *asDeclaration() const
139     { return this; }
140
141     virtual Declaration *asDeclaration()
142     { return this; }
143
144 protected:
145     virtual void visitSymbol0(SymbolVisitor *visitor);
146
147 private:
148     FullySpecifiedType _type;
149 };
150
151 class CPLUSPLUS_EXPORT Argument: public Symbol
152 {
153 public:
154     Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
155     virtual ~Argument();
156
157     void setType(const FullySpecifiedType &type);
158
159     bool hasInitializer() const;
160
161     const StringLiteral *initializer() const;
162     void setInitializer(const StringLiteral *initializer);
163
164     // Symbol's interface
165     virtual FullySpecifiedType type() const;
166
167     virtual const Argument *asArgument() const
168     { return this; }
169
170     virtual Argument *asArgument()
171     { return this; }
172
173 protected:
174     virtual void visitSymbol0(SymbolVisitor *visitor);
175
176 private:
177     const StringLiteral *_initializer;
178     FullySpecifiedType _type;
179 };
180
181 class CPLUSPLUS_EXPORT TypenameArgument: public Symbol
182 {
183 public:
184     TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
185     virtual ~TypenameArgument();
186
187     void setType(const FullySpecifiedType &type);
188
189     // Symbol's interface
190     virtual FullySpecifiedType type() const;
191
192     virtual const TypenameArgument *asTypenameArgument() const
193     { return this; }
194
195     virtual TypenameArgument *asTypenameArgument()
196     { return this; }
197
198 protected:
199     virtual void visitSymbol0(SymbolVisitor *visitor);
200
201 private:
202     FullySpecifiedType _type;
203 };
204
205 class CPLUSPLUS_EXPORT Block: public Scope
206 {
207 public:
208     Block(TranslationUnit *translationUnit, unsigned sourceLocation);
209     virtual ~Block();
210
211     // Symbol's interface
212     virtual FullySpecifiedType type() const;
213
214     virtual const Block *asBlock() const
215     { return this; }
216
217     virtual Block *asBlock()
218     { return this; }
219
220 protected:
221     virtual void visitSymbol0(SymbolVisitor *visitor);
222 };
223
224 class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
225 {
226 public:
227     ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
228     virtual ~ForwardClassDeclaration();
229
230     virtual FullySpecifiedType type() const;
231
232     virtual bool isEqualTo(const Type *other) const;
233
234     virtual const ForwardClassDeclaration *asForwardClassDeclaration() const
235     { return this; }
236
237     virtual ForwardClassDeclaration *asForwardClassDeclaration()
238     { return this; }
239
240     virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const
241     { return this; }
242
243     virtual ForwardClassDeclaration *asForwardClassDeclarationType()
244     { return this; }
245
246 protected:
247     virtual void visitSymbol0(SymbolVisitor *visitor);
248     virtual void accept0(TypeVisitor *visitor);
249     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
250 };
251
252 class CPLUSPLUS_EXPORT Enum: public Scope, public Type
253 {
254 public:
255     Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
256     virtual ~Enum();
257
258     // Symbol's interface
259     virtual FullySpecifiedType type() const;
260
261     // Type's interface
262     virtual bool isEqualTo(const Type *other) const;
263
264     virtual const Enum *asEnum() const
265     { return this; }
266
267     virtual Enum *asEnum()
268     { return this; }
269
270     virtual const Enum *asEnumType() const
271     { return this; }
272
273     virtual Enum *asEnumType()
274     { return this; }
275
276 protected:
277     virtual void visitSymbol0(SymbolVisitor *visitor);
278     virtual void accept0(TypeVisitor *visitor);
279     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
280 };
281
282 class CPLUSPLUS_EXPORT Function: public Scope, public Type
283 {
284 public:
285     enum MethodKey {
286         NormalMethod,
287         SlotMethod,
288         SignalMethod,
289         InvokableMethod
290     };
291
292 public:
293     Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
294     virtual ~Function();
295
296     bool isNormal() const;
297     bool isSignal() const;
298     bool isSlot() const;
299     bool isInvokable() const;
300     int methodKey() const;
301     void setMethodKey(int key);
302
303     FullySpecifiedType returnType() const;
304     void setReturnType(const FullySpecifiedType &returnType);
305
306     /** Convenience function that returns whether the function returns something (including void). */
307     bool hasReturnType() const;
308
309     unsigned argumentCount() const;
310     Symbol *argumentAt(unsigned index) const;
311
312     /** Convenience function that returns whether the function receives any arguments. */
313     bool hasArguments() const;
314     unsigned minimumArgumentCount() const;
315
316     bool isVirtual() const;
317     void setVirtual(bool isVirtual);
318
319     bool isVariadic() const;
320     void setVariadic(bool isVariadic);
321
322     bool isConst() const;
323     void setConst(bool isConst);
324
325     bool isVolatile() const;
326     void setVolatile(bool isVolatile);
327
328     bool isPureVirtual() const;
329     void setPureVirtual(bool isPureVirtual);
330
331 #ifdef ICHECK_BUILD
332     bool isEqualTo(const Function* fct, bool ignoreName = false) const;
333 #endif
334
335     // Symbol's interface
336     virtual FullySpecifiedType type() const;
337
338     // Type's interface
339     virtual bool isEqualTo(const Type *other) const;
340
341     virtual const Function *asFunction() const
342     { return this; }
343
344     virtual Function *asFunction()
345     { return this; }
346
347     virtual const Function *asFunctionType() const
348     { return this; }
349
350     virtual Function *asFunctionType()
351     { return this; }
352
353     bool isAmbiguous() const; // internal
354     void setAmbiguous(bool isAmbiguous); // internal
355
356     bool maybeValidPrototype(unsigned actualArgumentCount) const;
357
358 protected:
359     virtual void visitSymbol0(SymbolVisitor *visitor);
360     virtual void accept0(TypeVisitor *visitor);
361     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
362
363 private:
364     FullySpecifiedType _returnType;
365     struct Flags {
366         unsigned _isVirtual: 1;
367         unsigned _isVariadic: 1;
368         unsigned _isPureVirtual: 1;
369         unsigned _isConst: 1;
370         unsigned _isVolatile: 1;
371         unsigned _isAmbiguous: 1;
372         unsigned _methodKey: 3;
373     };
374     union {
375         unsigned _flags;
376         Flags f;
377     };
378 };
379
380 class CPLUSPLUS_EXPORT Template: public Scope, public Type
381 {
382 public:
383     Template(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
384     virtual ~Template();
385
386     unsigned templateParameterCount() const;
387     Symbol *templateParameterAt(unsigned index) const;
388     Symbol *declaration() const;
389
390     // Symbol's interface
391     virtual FullySpecifiedType type() const;
392
393     // Type's interface
394     virtual bool isEqualTo(const Type *other) const;
395
396     virtual const Template *asTemplate() const
397     { return this; }
398
399     virtual Template *asTemplate()
400     { return this; }
401
402     virtual const Template *asTemplateType() const
403     { return this; }
404
405     virtual Template *asTemplateType()
406     { return this; }
407
408 protected:
409     virtual void visitSymbol0(SymbolVisitor *visitor);
410     virtual void accept0(TypeVisitor *visitor);
411     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
412 };
413
414
415 class CPLUSPLUS_EXPORT Namespace: public Scope, public Type
416 {
417 public:
418     Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
419     virtual ~Namespace();
420
421     // Symbol's interface
422     virtual FullySpecifiedType type() const;
423
424     // Type's interface
425     virtual bool isEqualTo(const Type *other) const;
426
427     virtual const Namespace *asNamespace() const
428     { return this; }
429
430     virtual Namespace *asNamespace()
431     { return this; }
432
433     virtual const Namespace *asNamespaceType() const
434     { return this; }
435
436     virtual Namespace *asNamespaceType()
437     { return this; }
438
439 protected:
440     virtual void visitSymbol0(SymbolVisitor *visitor);
441     virtual void accept0(TypeVisitor *visitor);
442     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
443 };
444
445 class CPLUSPLUS_EXPORT BaseClass: public Symbol
446 {
447 public:
448     BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
449     virtual ~BaseClass();
450
451     bool isVirtual() const;
452     void setVirtual(bool isVirtual);
453
454     // Symbol's interface
455     virtual FullySpecifiedType type() const;
456     void setType(const FullySpecifiedType &type);
457
458     virtual const BaseClass *asBaseClass() const
459     { return this; }
460
461     virtual BaseClass *asBaseClass()
462     { return this; }
463
464 protected:
465     virtual void visitSymbol0(SymbolVisitor *visitor);
466
467 private:
468     bool _isVirtual;
469     FullySpecifiedType _type;
470 };
471
472 class CPLUSPLUS_EXPORT Class: public Scope, public Type
473 {
474 public:
475     Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
476     virtual ~Class();
477
478     enum Key {
479         ClassKey,
480         StructKey,
481         UnionKey
482     };
483
484     bool isClass() const;
485     bool isStruct() const;
486     bool isUnion() const;
487     Key classKey() const;
488     void setClassKey(Key key);
489
490     unsigned baseClassCount() const;
491     BaseClass *baseClassAt(unsigned index) const;
492     void addBaseClass(BaseClass *baseClass);
493
494     // Symbol's interface
495     virtual FullySpecifiedType type() const;
496
497     // Type's interface
498     virtual bool isEqualTo(const Type *other) const;
499
500     virtual const Class *asClass() const
501     { return this; }
502
503     virtual Class *asClass()
504     { return this; }
505
506     virtual const Class *asClassType() const
507     { return this; }
508
509     virtual Class *asClassType()
510     { return this; }
511
512 protected:
513     virtual void visitSymbol0(SymbolVisitor *visitor);
514     virtual void accept0(TypeVisitor *visitor);
515     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
516
517 private:
518     Key _key;
519     std::vector<BaseClass *> _baseClasses;
520 };
521
522 class CPLUSPLUS_EXPORT QtPropertyDeclaration: public Symbol
523 {
524 public:
525     enum Flag {
526         NoFlags = 0,
527         ReadFunction = 1 << 0,
528         WriteFunction = 1 << 1,
529         ResetFunction = 1 << 2,
530         NotifyFunction = 1 << 3,
531         DesignableFlag = 1 << 4,
532         DesignableFunction = 1 << 5,
533         ScriptableFlag = 1 << 6,
534         ScriptableFunction = 1 << 7,
535         StoredFlag = 1 << 8,
536         StoredFunction = 1 << 9,
537         UserFlag = 1 << 10,
538         UserFunction = 1 << 11,
539         ConstantFlag = 1 << 12,
540         FinalFlag = 1 << 13,
541     };
542
543 public:
544     QtPropertyDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
545     virtual ~QtPropertyDeclaration();
546
547     void setType(const FullySpecifiedType &type);
548
549     void setFlags(int flags);
550     int flags() const;
551
552     // Symbol's interface
553     virtual FullySpecifiedType type() const;
554
555     virtual const QtPropertyDeclaration *asQtPropertyDeclaration() const
556     { return this; }
557
558     virtual QtPropertyDeclaration *asQtPropertyDeclaration()
559     { return this; }
560
561 protected:
562     virtual void visitSymbol0(SymbolVisitor *visitor);
563
564 private:
565     FullySpecifiedType _type;
566     int _flags;
567 };
568
569 class CPLUSPLUS_EXPORT QtEnum: public Symbol
570 {
571 public:
572     QtEnum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
573     virtual ~QtEnum();
574
575     // Symbol's interface
576     virtual FullySpecifiedType type() const;
577
578     virtual const QtEnum *asQtEnum() const
579     { return this; }
580
581     virtual QtEnum *asQtEnum()
582     { return this; }
583
584 protected:
585     virtual void visitSymbol0(SymbolVisitor *visitor);
586 };
587
588 class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
589 {
590 public:
591     ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
592     virtual ~ObjCBaseClass();
593
594     // Symbol's interface
595     virtual FullySpecifiedType type() const;
596
597     virtual const ObjCBaseClass *asObjCBaseClass() const
598     { return this; }
599
600     virtual ObjCBaseClass *asObjCBaseClass()
601     { return this; }
602
603 protected:
604     virtual void visitSymbol0(SymbolVisitor *visitor);
605 };
606
607 class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
608 {
609 public:
610     ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
611     virtual ~ObjCBaseProtocol();
612
613     // Symbol's interface
614     virtual FullySpecifiedType type() const;
615
616     virtual const ObjCBaseProtocol *asObjCBaseProtocol() const
617     { return this; }
618
619     virtual ObjCBaseProtocol *asObjCBaseProtocol()
620     { return this; }
621
622 protected:
623     virtual void visitSymbol0(SymbolVisitor *visitor);
624 };
625
626 class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
627 {
628 public:
629     ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
630     virtual ~ObjCForwardProtocolDeclaration();
631
632     virtual FullySpecifiedType type() const;
633
634     virtual bool isEqualTo(const Type *other) const;
635
636     virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const
637     { return this; }
638
639     virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration()
640     { return this; }
641
642     virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const
643     { return this; }
644
645     virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType()
646     { return this; }
647
648 protected:
649     virtual void visitSymbol0(SymbolVisitor *visitor);
650     virtual void accept0(TypeVisitor *visitor);
651     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
652 };
653
654 class CPLUSPLUS_EXPORT ObjCProtocol: public Scope, public Type
655 {
656 public:
657     ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
658     virtual ~ObjCProtocol();
659
660     unsigned protocolCount() const;
661     ObjCBaseProtocol *protocolAt(unsigned index) const;
662     void addProtocol(ObjCBaseProtocol *protocol);
663
664     // Symbol's interface
665     virtual FullySpecifiedType type() const;
666
667     // Type's interface
668     virtual bool isEqualTo(const Type *other) const;
669
670     virtual const ObjCProtocol *asObjCProtocol() const
671     { return this; }
672
673     virtual ObjCProtocol *asObjCProtocol()
674     { return this; }
675
676     virtual const ObjCProtocol *asObjCProtocolType() const
677     { return this; }
678
679     virtual ObjCProtocol *asObjCProtocolType()
680     { return this; }
681
682 protected:
683     virtual void visitSymbol0(SymbolVisitor *visitor);
684     virtual void accept0(TypeVisitor *visitor);
685     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
686
687 private:
688     std::vector<ObjCBaseProtocol *> _protocols;
689 };
690
691 class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
692 {
693 public:
694     ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
695     virtual ~ObjCForwardClassDeclaration();
696
697     virtual FullySpecifiedType type() const;
698
699     virtual bool isEqualTo(const Type *other) const;
700
701     virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const
702     { return this; }
703
704     virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration()
705     { return this; }
706
707     virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const
708     { return this; }
709
710     virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType()
711     { return this; }
712
713 protected:
714     virtual void visitSymbol0(SymbolVisitor *visitor);
715     virtual void accept0(TypeVisitor *visitor);
716     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
717 };
718
719 class CPLUSPLUS_EXPORT ObjCClass: public Scope, public Type
720 {
721 public:
722     ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
723     virtual ~ObjCClass();
724
725     bool isInterface() const;
726     void setInterface(bool isInterface);
727
728     bool isCategory() const;
729     const Name *categoryName() const;
730     void setCategoryName(const Name *categoryName);
731
732     ObjCBaseClass *baseClass() const;
733     void setBaseClass(ObjCBaseClass *baseClass);
734
735     unsigned protocolCount() const;
736     ObjCBaseProtocol *protocolAt(unsigned index) const;
737     void addProtocol(ObjCBaseProtocol *protocol);
738
739     // Symbol's interface
740     virtual FullySpecifiedType type() const;
741
742     // Type's interface
743     virtual bool isEqualTo(const Type *other) const;
744
745     virtual const ObjCClass *asObjCClass() const
746     { return this; }
747
748     virtual ObjCClass *asObjCClass()
749     { return this; }
750
751     virtual const ObjCClass *asObjCClassType() const
752     { return this; }
753
754     virtual ObjCClass *asObjCClassType()
755     { return this; }
756
757 protected:
758     virtual void visitSymbol0(SymbolVisitor *visitor);
759     virtual void accept0(TypeVisitor *visitor);
760     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
761
762 private:
763     const Name *_categoryName;
764     ObjCBaseClass * _baseClass;
765     std::vector<ObjCBaseProtocol *> _protocols;
766     bool _isInterface;
767 };
768
769 class CPLUSPLUS_EXPORT ObjCMethod: public Scope, public Type
770 {
771 public:
772     ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
773     virtual ~ObjCMethod();
774
775     FullySpecifiedType returnType() const;
776     void setReturnType(const FullySpecifiedType &returnType);
777
778     /** Convenience function that returns whether the function returns something (including void). */
779     bool hasReturnType() const;
780
781     unsigned argumentCount() const;
782     Symbol *argumentAt(unsigned index) const;
783
784     /** Convenience function that returns whether the function receives any arguments. */
785     bool hasArguments() const;
786
787     bool isVariadic() const;
788     void setVariadic(bool isVariadic);
789
790     // Symbol's interface
791     virtual FullySpecifiedType type() const;
792
793     // Type's interface
794     virtual bool isEqualTo(const Type *other) const;
795
796     virtual const ObjCMethod *asObjCMethod() const
797     { return this; }
798
799     virtual ObjCMethod *asObjCMethod()
800     { return this; }
801
802     virtual const ObjCMethod *asObjCMethodType() const
803     { return this; }
804
805     virtual ObjCMethod *asObjCMethodType()
806     { return this; }
807
808 protected:
809     virtual void visitSymbol0(SymbolVisitor *visitor);
810     virtual void accept0(TypeVisitor *visitor);
811     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
812
813 private:
814     FullySpecifiedType _returnType;
815     struct Flags {
816         unsigned _isVariadic: 1;
817     };
818     union {
819         unsigned _flags;
820         Flags f;
821     };
822 };
823
824 class CPLUSPLUS_EXPORT ObjCPropertyDeclaration: public Symbol
825 {
826 public:
827     enum PropertyAttributes {
828         None = 0,
829         Assign = 1 << 0,
830         Retain = 1 << 1,
831         Copy = 1 << 2,
832         ReadOnly = 1 << 3,
833         ReadWrite = 1 << 4,
834         Getter = 1 << 5,
835         Setter = 1 << 6,
836         NonAtomic = 1 << 7,
837
838         WritabilityMask = ReadOnly | ReadWrite,
839         SetterSemanticsMask = Assign | Retain | Copy
840     };
841
842 public:
843     ObjCPropertyDeclaration(TranslationUnit *translationUnit,
844                             unsigned sourceLocation,
845                             const Name *name);
846     virtual ~ObjCPropertyDeclaration();
847
848     bool hasAttribute(int attribute) const;
849     void setAttributes(int attributes);
850
851     bool hasGetter() const;
852     bool hasSetter() const;
853
854     const Name *getterName() const;
855
856     void setGetterName(const Name *getterName);
857
858     const Name *setterName() const;
859     void setSetterName(const Name *setterName);
860
861     void setType(const FullySpecifiedType &type);
862
863     // Symbol's interface
864     virtual FullySpecifiedType type() const;
865
866     virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const
867     { return this; }
868
869     virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration()
870     { return this; }
871
872 protected:
873     virtual void visitSymbol0(SymbolVisitor *visitor);
874
875 private:
876     const Name *_getterName;
877     const Name *_setterName;
878     FullySpecifiedType _type;
879     int _propertyAttributes;
880 };
881
882 } // namespace CPlusPlus
883
884
885 #endif // CPLUSPLUS_SYMBOLS_H