[cfe-commits] r41985 - /cfe/trunk/include/clang/AST/Decl.h
Fariborz Jahanian
fjahanian at apple.com
Sat Sep 15 11:27:26 PDT 2007
Author: fjahanian
Date: Sat Sep 15 13:27:26 2007
New Revision: 41985
URL: http://llvm.org/viewvc/llvm-project?rev=41985&view=rev
Log:
Couple of new classes for objective-c's @protocol typings.
Modified:
cfe/trunk/include/clang/AST/Decl.h
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=41985&r1=41984&r2=41985&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Sep 15 13:27:26 2007
@@ -26,6 +26,7 @@
class ObjcIvarDecl;
class ObjcMethodDecl;
class AttributeList;
+class ObjcProtoMethodDecl;
/// Decl - This represents one declaration (or definition), e.g. a variable,
@@ -38,6 +39,7 @@
Function, BlockVariable, FileVariable, ParmVariable, EnumConstant,
// Concrete sub-classes of TypeDecl
Typedef, Struct, Union, Class, Enum, ObjcInterface, ObjcClass, ObjcMethod,
+ ObjcProtoMethod, ObjcProtocol,
// Concrete sub-class of Decl
Field, ObjcIvar
};
@@ -619,6 +621,14 @@
ParamInfo(paramInfo), NumMethodParams(numParams),
MethodAttrs(M), IsInstance(isInstance) {}
+ ObjcMethodDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
+ ParmVarDecl **paramInfo = 0, int numParams=-1,
+ AttributeList *M = 0, bool isInstance = true,
+ Decl *PrevDecl = 0)
+ : Decl(DK), MethodDeclType(T),
+ ParamInfo(paramInfo), NumMethodParams(numParams),
+ MethodAttrs(M), IsInstance(isInstance) {}
+
virtual ~ObjcMethodDecl();
QualType getMethodType() const { return MethodDeclType; }
unsigned getNumMethodParams() const { return NumMethodParams; }
@@ -632,7 +642,10 @@
bool isInstance() const { return IsInstance; }
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) { return D->getKind() == ObjcMethod; }
+ static bool classof(const Decl *D) {
+ return D->getKind() == ObjcMethod
+ || D->getKind() == ObjcProtoMethod;
+ }
static bool classof(const ObjcMethodDecl *D) { return true; }
private:
@@ -650,5 +663,57 @@
bool IsInstance : 1;
};
+/// ObjcProtoMethodDecl - Each instance represents a method declared
+/// in a protocol.
+///
+class ObjcProtoMethodDecl : ObjcMethodDecl {
+public:
+ ObjcProtoMethodDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
+ ParmVarDecl **paramInfo = 0, int numParams=-1,
+ AttributeList *M = 0, bool isInstance = true,
+ Decl *PrevDecl = 0) :
+ ObjcMethodDecl(ObjcProtoMethod, L, Id, T, paramInfo, numParams,
+ M, isInstance, PrevDecl) {}
+
+ enum ImplementationControl { None, Required, Optional };
+
+ void setDeclImplementation(ImplementationControl ic)
+ { DeclImplementation = ic; }
+ ImplementationControl getImplementationControl() const
+ { return DeclImplementation; }
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Decl *D) { return D->getKind() == ObjcProtoMethod; }
+ static bool classof(const ObjcMethodDecl *D) { return true; }
+
+private:
+ ImplementationControl DeclImplementation : 2;
+};
+
+class ObjcProtocolDecl : public TypeDecl {
+ /// protocol instance methods
+ ObjcProtoMethodDecl **ProtoInsMethods; // Null if not defined
+ int NumProtoInsMethods; // -1 if not defined
+
+ /// protocol class methods
+ ObjcProtoMethodDecl **ProtoClsMethods; // Null if not defined
+ int NumProtoClsMethods; // -1 if not defined
+
+ bool isForwardProtoDecl; // declared with @protocol.
+public:
+ ObjcProtocolDecl(SourceLocation L, IdentifierInfo *Id, bool FD = false)
+ : TypeDecl(ObjcProtocol, L, Id, 0),
+ ProtoInsMethods(0), NumProtoInsMethods(-1),
+ ProtoClsMethods(0), NumProtoClsMethods(-1),
+ isForwardProtoDecl(FD) { }
+
+ void ObjcAddProtoMethods(ObjcProtoMethodDecl **insMethods, unsigned numInsMembers,
+ ObjcProtoMethodDecl **clsMethods, unsigned numClsMembers);
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == ObjcProtocol;
+ }
+ static bool classof(const ObjcProtocolDecl *D) { return true; }
+};
+
} // end namespace clang
#endif
More information about the cfe-commits
mailing list