Added missing Protocol methods; better check if a protocol is implemented

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/libobjc/trunk@17400 72102866-910b-0410-8b05-ffd578937521
main
nico 23 years ago
parent 1eb05e8a71
commit af66f991cb

@ -1,3 +1,9 @@
Wed Jul 30 17:45:21 2003 Nicola Pero <n.pero@mi.flashnet.it>
* Protocol.m ([-conformsTo:]): If the argument is nil, return NO.
([-hash], [-isEqual:]): New methods.
(Suggestion by Jeremy Bettis <jeremy@deadbeef.com>)
2001-07-04 Richard Frith-Macdonald <rrfm@gnu.org>
* Protocol.m: ([-descriptionForClassMethod:])

@ -56,6 +56,9 @@ struct objc_method_description_list {
size_t i;
struct objc_protocol_list* proto_list;
if (aProtocolObject == nil)
return NO;
if (!strcmp(aProtocolObject->protocol_name, self->protocol_name))
return YES;
@ -133,4 +136,29 @@ struct objc_method_description_list {
return NULL;
}
- (unsigned) hash
{
/* Compute a hash of the protocol_name; use the same hash algorithm
* that we use for class names; protocol names and class names are
* somewhat similar types of string spaces.
*/
int hash = 0, index;
for (index = 0; protocol_name[index] != '\0'; index++)
{
hash = (hash << 4) ^ (hash >> 28) ^ protocol_name[index];
}
hash = (hash ^ (hash >> 10) ^ (hash >> 20));
return hash;
}
- (BOOL) isEqual: (id)obj
{
if (strcmp (protocol_name, [obj name]) == 0)
return YES;
return NO;
}
@end

Loading…
Cancel
Save