diff options
Diffstat (limited to 'libobjc/Protocol.m')
-rw-r--r-- | libobjc/Protocol.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/libobjc/Protocol.m b/libobjc/Protocol.m index 06a25ac..a18d544 100644 --- a/libobjc/Protocol.m +++ b/libobjc/Protocol.m @@ -1,5 +1,5 @@ /* This file contains the implementation of class Protocol. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 2004 Free Software Foundation, Inc. This file is part of GCC. @@ -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; @@ -129,4 +132,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 |