]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/gcc-tumbl.git/commitdiff
In libobjc/:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Dec 2010 15:32:25 +0000 (15:32 +0000)
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Dec 2010 15:32:25 +0000 (15:32 +0000)
2010-12-24  Nicola Pero  <nicola.pero@meta-innovation.com>

* objc/runtime.h (class_conformsToProtocol,
class_copyProtocolList): Updated documentation.

In gcc/testsuite/:
2010-12-24  Nicola Pero  <nicola.pero@meta-innovation.com>

* obj-c.dg/gnu-api-2-class.m: Test that class_conformsToProtocol()
does not check the superclasses.
* obj-c++.dg/gnu-api-2-class.mm: Same change.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168226 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
gcc/testsuite/objc.dg/gnu-api-2-class.m
libobjc/ChangeLog
libobjc/objc/runtime.h

index 2cc045ba7e20c04d49b2aec42d4bf991ee4b5d06..1324aeb83b80ea13c7bf881a983ea97a7710a4c9 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-24  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * obj-c.dg/gnu-api-2-class.m: Test that class_conformsToProtocol()
+       does not check the superclasses.
+       * obj-c++.dg/gnu-api-2-class.mm: Same change.   
+
 2010-12-24  Alexander Monakov  <amonakov@ispras.ru>
 
        PR rtl-optimization/47036
index da25663d171dcf5b6330b64f129b0853de48fd18..b86396f2144aa35bb4d50651f5ee86210a54c9ec 100644 (file)
 - (id) variable { return variable_ivar; }
 @end
 
+@interface MyOtherSubClass : MySubClass
+@end
+
+@implementation MyOtherSubClass
+@end
+
 @interface DifferentClass : MyRootClass
 - (id) myClass;
 - (id) self;
@@ -188,6 +194,11 @@ int main ()
 
     if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol)))
       abort ();
+
+    /* Test that class_conformsToProtocol checks the class, but not
+       superclasses.  */
+    if (class_conformsToProtocol (objc_getClass ("MyOtherSubClass"), @protocol (MyProtocol)))
+      abort ();
   }
 
   std::cout << "Testing class_copyIvarList ()...\n";
index d38d9c253dc3efbb91c1af8bde5a8272d6d61a48..ff0425966cdc5252e62ef58f49333855dbfc25c3 100644 (file)
 - (id) variable { return variable_ivar; }
 @end
 
+@interface MyOtherSubClass : MySubClass
+@end
+
+@implementation MyOtherSubClass
+@end
+
 @interface DifferentClass : MyRootClass
 - (id) myClass;
 - (id) self;
@@ -188,6 +194,11 @@ int main(int argc, void **args)
 
     if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol)))
       abort ();
+
+    /* Test that class_conformsToProtocol checks the class, but not
+       superclasses.  */
+    if (class_conformsToProtocol (objc_getClass ("MyOtherSubClass"), @protocol (MyProtocol)))
+      abort ();
   }
 
   printf ("Testing class_copyIvarList ()...\n");
index fbeaf3fa57167fb2fa6b4696a5faa59c5a966099..78112bdecfe145a076b46e535e55cd8265209a59 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-24  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc/runtime.h (class_conformsToProtocol,
+       class_copyProtocolList): Updated documentation.
+
 2010-12-23  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * init.c (create_tree_of_subclasses_inherited_from): Updated
index 8d380156e41c69e9a500889d56d39e830f91c87b..7ad46dcc6fd073512e28aadf795307203fd23908 100644 (file)
@@ -768,7 +768,11 @@ objc_EXPORT Protocol **objc_copyProtocolList (unsigned int *numberOfReturnedProt
 objc_EXPORT BOOL class_addProtocol (Class class_, Protocol *protocol);
 
 /* Return YES if the class 'class_' conforms to Protocol 'protocol',
-   and NO if not.  */
+   and NO if not.  This function does not check superclasses; if you
+   want to check for superclasses (in the way that [NSObject
+   +conformsToProtocol:] does) you need to iterate over the class
+   hierarchy using class_getSuperclass(), and call
+   class_conformsToProtocol() for each of them.  */
 objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol);
 
 /* Return all the protocols that the class conforms to.  The return
@@ -777,7 +781,9 @@ objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol);
    class.  It does not include protocols adopted by superclasses.  The
    list is terminated by NULL.  Optionally, if you pass a non-NULL
    'numberOfReturnedProtocols' pointer, the unsigned int that it
-   points to will be filled with the number of protocols returned.  */
+   points to will be filled with the number of protocols returned.
+   This function does not return protocols that superclasses conform
+   to.  */
 objc_EXPORT Protocol **class_copyProtocolList (Class class_, unsigned int *numberOfReturnedProtocols);
 
 /* Return YES if protocol 'protocol' conforms to protocol