Commit 877bf195 by Nicola Pero Committed by Nicola Pero

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

In libobjc/:
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.

From-SVN: r168226
parent eb277bf1
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> 2010-12-24 Alexander Monakov <amonakov@ispras.ru>
PR rtl-optimization/47036 PR rtl-optimization/47036
......
...@@ -42,6 +42,12 @@ ...@@ -42,6 +42,12 @@
- (id) variable { return variable_ivar; } - (id) variable { return variable_ivar; }
@end @end
@interface MyOtherSubClass : MySubClass
@end
@implementation MyOtherSubClass
@end
@interface DifferentClass : MyRootClass @interface DifferentClass : MyRootClass
- (id) myClass; - (id) myClass;
- (id) self; - (id) self;
...@@ -188,6 +194,11 @@ int main () ...@@ -188,6 +194,11 @@ int main ()
if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol))) if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol)))
abort (); 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"; std::cout << "Testing class_copyIvarList ()...\n";
......
...@@ -42,6 +42,12 @@ ...@@ -42,6 +42,12 @@
- (id) variable { return variable_ivar; } - (id) variable { return variable_ivar; }
@end @end
@interface MyOtherSubClass : MySubClass
@end
@implementation MyOtherSubClass
@end
@interface DifferentClass : MyRootClass @interface DifferentClass : MyRootClass
- (id) myClass; - (id) myClass;
- (id) self; - (id) self;
...@@ -188,6 +194,11 @@ int main(int argc, void **args) ...@@ -188,6 +194,11 @@ int main(int argc, void **args)
if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol))) if (!class_conformsToProtocol (objc_getClass ("MySubClass"), @protocol (MyProtocol)))
abort (); 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"); printf ("Testing class_copyIvarList ()...\n");
......
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> 2010-12-23 Nicola Pero <nicola.pero@meta-innovation.com>
* init.c (create_tree_of_subclasses_inherited_from): Updated * init.c (create_tree_of_subclasses_inherited_from): Updated
......
...@@ -768,7 +768,11 @@ objc_EXPORT Protocol **objc_copyProtocolList (unsigned int *numberOfReturnedProt ...@@ -768,7 +768,11 @@ objc_EXPORT Protocol **objc_copyProtocolList (unsigned int *numberOfReturnedProt
objc_EXPORT BOOL class_addProtocol (Class class_, Protocol *protocol); objc_EXPORT BOOL class_addProtocol (Class class_, Protocol *protocol);
/* Return YES if the class 'class_' conforms to 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); objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol);
/* Return all the protocols that the class conforms to. The return /* Return all the protocols that the class conforms to. The return
...@@ -777,7 +781,9 @@ objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol); ...@@ -777,7 +781,9 @@ objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol);
class. It does not include protocols adopted by superclasses. The class. It does not include protocols adopted by superclasses. The
list is terminated by NULL. Optionally, if you pass a non-NULL list is terminated by NULL. Optionally, if you pass a non-NULL
'numberOfReturnedProtocols' pointer, the unsigned int that it '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); objc_EXPORT Protocol **class_copyProtocolList (Class class_, unsigned int *numberOfReturnedProtocols);
/* Return YES if protocol 'protocol' conforms to protocol /* Return YES if protocol 'protocol' conforms to protocol
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment