Overview
Comment: | Add +[conformsTo:] and -[conformsTo:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5008910e855a19210023262f184961d2 |
User & Date: | js on 2009-06-01 12:20:58 |
Other Links: | manifest | tags |
Context
2009-06-01
| ||
20:36 |
Add objfw.h which includes everything. Only importing what you really need is preferred, though. check-in: f8b652cc27 user: js tags: trunk | |
12:20 | Add +[conformsTo:] and -[conformsTo:]. check-in: 5008910e85 user: js tags: trunk | |
12:02 | Write a warning to stderr if objc_sync_{enter,exit} fails. check-in: 216caca8a0 user: js tags: trunk | |
Changes
Modified src/OFObject.h from [1ae322315c] to [3ce907fa27].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | + (Class)class; /** * \return The name of the class as a C string */ + (const char*)name; /** * Replace a method with a method from another class. * * \param selector The selector of the method to replace * \param class The class from which the new method should be taken * \return The old implementation */ | > > > > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | + (Class)class; /** * \return The name of the class as a C string */ + (const char*)name; /** * \param protocol The protocol which should be checked for conformance * * \return A boolean whether the class conforms to the specified protocol */ + (BOOL)conformsTo: (Protocol*)protocol; /** * Replace a method with a method from another class. * * \param selector The selector of the method to replace * \param class The class from which the new method should be taken * \return The old implementation */ |
︙ | ︙ | |||
89 90 91 92 93 94 95 | * \param class The class whose kind is checked * * \return A boolean whether the object is of the specified kind */ - (BOOL)isKindOf: (Class)class; /** | | > > > > > > > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | * \param class The class whose kind is checked * * \return A boolean whether the object is of the specified kind */ - (BOOL)isKindOf: (Class)class; /** * \param selector The selector which should be checked for respondance * * \return A boolean whether the objects responds to the specified selector */ - (BOOL)respondsTo: (SEL)selector; /** * \param protocol The protocol which should be checked for conformance * * \return A boolean whether the objects conforms to the specified protocol */ - (BOOL)conformsTo: (Protocol*)protocol; /** * \param selector The selector for which the method should be returned * * \return The implementation for the specified selector */ - (IMP)methodFor: (SEL)selector; |
︙ | ︙ |
Modified src/OFObject.m from [4147582b99] to [089ffd7efa].
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | { #ifdef __objc_INCLUDE_GNU return class_get_class_name(self); #else return class_getName(self); #endif } + (IMP)replaceMethod: (SEL)selector withMethodFromClass: (Class)class; { #ifdef __objc_INCLUDE_GNU Method_t method = class_get_instance_method(self, selector); IMP oldimp, newimp; | > > > > > > > > > > > > > > > > > > > > > > > > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | { #ifdef __objc_INCLUDE_GNU return class_get_class_name(self); #else return class_getName(self); #endif } + (BOOL)conformsTo: (Protocol*)protocol { #ifdef __objc_INCLUDE_GNU Class c; struct objc_protocol_list *pl; size_t i; for (c = self; c != Nil; c = class_get_super_class(c)) for (pl = c->protocols; pl != NULL; pl = pl->next) for (i = 0; i < pl->count; i++) if ([pl->list[i] conformsTo: protocol]) return YES; return NO; #else Class c; for (c = self; c != Nil; c = class_getSuperclass(c)) if (class_conformsToProtocol(c, protocol)) return YES; return NO; #endif } + (IMP)replaceMethod: (SEL)selector withMethodFromClass: (Class)class; { #ifdef __objc_INCLUDE_GNU Method_t method = class_get_instance_method(self, selector); IMP oldimp, newimp; |
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 177 178 179 180 181 | return class_get_instance_method(isa, selector) != METHOD_NULL; else return class_get_class_method(isa, selector) != METHOD_NULL; #else return class_respondsToSelector(isa, selector); #endif } - (IMP)methodFor: (SEL)selector { #ifdef __objc_INCLUDE_GNU if (object_is_instance(self)) return method_get_imp(class_get_instance_method(isa, selector)); else | > > > > > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | return class_get_instance_method(isa, selector) != METHOD_NULL; else return class_get_class_method(isa, selector) != METHOD_NULL; #else return class_respondsToSelector(isa, selector); #endif } - (BOOL)conformsTo: (Protocol*)protocol { return [isa conformsTo: protocol]; } - (IMP)methodFor: (SEL)selector { #ifdef __objc_INCLUDE_GNU if (object_is_instance(self)) return method_get_imp(class_get_instance_method(isa, selector)); else |
︙ | ︙ |