]> granicus.if.org Git - clang/commitdiff
start cleaning up interfaces for objc bits and pieces by switching to an
authorChris Lattner <sabre@nondot.org>
Wed, 12 Dec 2007 07:30:05 +0000 (07:30 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Dec 2007 07:30:05 +0000 (07:30 +0000)
iterator interface.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44926 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Decl.cpp
include/clang/AST/DeclObjC.h

index 188f3255dee02a02a644febdfdb8c61ac7121c46..c71fbca348b3211e7744d38fbedc6efe502ddb62 100644 (file)
@@ -406,8 +406,8 @@ ObjcIvarDecl *ObjcInterfaceDecl::lookupInstanceVariable(
   return NULL;
 }
 
-// lookupInstanceMethod - This method returns an instance method by looking in
-// the class, it's categories, and it's super classes (using a linear search).
+/// lookupInstanceMethod - This method returns an instance method by looking in
+/// the class, it's categories, and it's super classes (using a linear search).
 ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
   ObjcInterfaceDecl* ClassDecl = this;
   while (ClassDecl != NULL) {
@@ -488,24 +488,20 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) {
   return NULL;
 }
 
-// lookupInstanceMethod - This method returns an instance method by looking in
-// the class implementation. Unlike interfaces, we don't look outside the
-// implementation.
-ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(Selector &Sel) {
-  ObjcMethodDecl *const*methods = getInstanceMethods();
-  int methodCount = getNumInstanceMethods();
-  for (int i = 0; i < methodCount; ++i) {
-    if (methods[i]->getSelector() == Sel) {
-      return methods[i];
-    }
-  }
+/// lookupInstanceMethod - This method returns an instance method by looking in
+/// the class implementation. Unlike interfaces, we don't look outside the
+/// implementation.
+ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(Selector Sel) {
+  for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
+    if ((*I)->getSelector() == Sel)
+      return *I;
   return NULL;
 }
 
-// lookupClassMethod - This method returns an instance method by looking in
-// the class implementation. Unlike interfaces, we don't look outside the
-// implementation.
-ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector &Sel) {
+/// lookupClassMethod - This method returns a class method by looking in
+/// the class implementation. Unlike interfaces, we don't look outside the
+/// implementation.
+ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector Sel) {
   ObjcMethodDecl *const*methods = getClassMethods();
   int methodCount = getNumClassMethods();
   for (int i = 0; i < methodCount; ++i) {
index 4a4bcf10db7efed832239eff8f1a83936129e02a..d9d17b3678ce52c8ec8ced96343a9ab0e9230e7a 100644 (file)
@@ -589,12 +589,34 @@ public:
   }
   int getNumClassMethods() const { return ClassMethods.size(); }
 
-  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
-  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
-  
   ObjcIvarDecl **getImplDeclIVars() const { return Ivars; }
   int getImplDeclNumIvars() const { return NumIvars; }
-    
+  
+  
+  typedef llvm::SmallVector<ObjcMethodDecl*, 32>::const_iterator
+       instmeth_iterator;
+  instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); }
+  instmeth_iterator instmeth_end() const { return InstanceMethods.end(); }
+
+  typedef llvm::SmallVector<ObjcMethodDecl*, 32>::const_iterator
+    classmeth_iterator;
+  classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); }
+  classmeth_iterator classmeth_end() const { return ClassMethods.end(); }
+  
+  /// lookupInstanceMethod - This method returns an instance method by looking
+  /// in the class implementation. Unlike interfaces, we don't look outside the
+  /// implementation.
+  ObjcMethodDecl *lookupInstanceMethod(Selector Sel);
+  
+  /// lookupClassMethod - This method returns a class method by looking in
+  /// the class implementation. Unlike interfaces, we don't look outside the
+  /// implementation.
+  ObjcMethodDecl *lookupClassMethod(Selector Sel);
+  
+  typedef ObjcIvarDecl * const *ivar_iterator;
+  ivar_iterator ivar_begin() const { return Ivars; }
+  ivar_iterator ivar_end() const { return Ivars+NumIvars; }
+  
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcImplementation;
   }