aboutsummaryrefslogtreecommitdiff
path: root/libobjc/Protocol.m
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2004-05-25 19:10:54 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2004-05-25 12:10:54 -0700
commit435317e25c1f3571a72d97d089ca085ffd0bf20b (patch)
tree4b71d618aec8fb5c67898b26b6eaab9161fdcf1f /libobjc/Protocol.m
parentf411a73a8caf915d2685c5065de6c918de76daad (diff)
downloadgcc-435317e25c1f3571a72d97d089ca085ffd0bf20b.zip
gcc-435317e25c1f3571a72d97d089ca085ffd0bf20b.tar.gz
gcc-435317e25c1f3571a72d97d089ca085ffd0bf20b.tar.bz2
[multiple changes]
2004-05-25 Andrew Pinski <pinskia@physics.uc.edu> Merge from the libobjc-branch 2004-02-09 Andrew Pinski <pinskia@physics.uc.edu> * Makefile.in (OBJC_H): Change objc-deps.h to objc-decls.h. 2004-02-03 Andrew Pinski <pinskia@physics.uc.edu> * Makefile.in (OBJC_H): Add objc-deps.h. 2004-01-27 Nicola Pero <n.pero@mi.flashnet.it> * Protocol.m ([-conformsTo:]): If the argument is nil, return NO. ([-hash], [-isEqual:]): New methods. 2004-01-27 Richard Frith-Macdonald <rfm@gnu.org> * sarray.c (sarray_free): Add a better comment. 2004-01-27 Adam Fedor <fedor@gnu.org> * hash.c (hash_add): Cast cachep to int. * selector.c (__sel_register_typed_name): Cast soffset_decode to int. 2004-01-27 Alexander Malmberg <alexander@malmberg.org> * selector.c: Rename register_selectors_from_list to __objc_register_selectors_from_list. Update caller. (__objc_register_selectors_from_list): Lock __objc_runtime_mutex while registering selectors. Use __sel_register_typed_name instead of sel_register_typed_name. Check for NULL method_name:s. (pool_alloc_selector): New function. (__sel_register_typed_name): Use pool_alloc_selector to allocate selector structures. * sendmsg.c (class_add_method_list): Use __objc_register_selectors_from_list. * objc/runtime.h: Add __objc_register_selectors_from_list. 2004-01-25 Adam Fedor <fedor@gnu.org> Nicola Pero <n.pero@mi.flashnet.it> Andrew Pinski <pinskia@physics.uc.edu> * objc/objc-decls.h: New file. * objc/objc-api.h (_objc_lookup_class): Mark as export. (_objc_load_callback): Likewise. (_objc_object_alloc): Likewise. (_objc_object_copy): Likewise. (_objc_object_dispose): Likewise. 2004-01-25 Andrew Pinski <pinskia@physics.uc.edu> * archive.c: s/__inline__/inline * sendmsg.c: Likewise. * encoding.c: Remove FIXME about the warning about unused variable. * sendmsg.c: Add a FIXME comment saying that this should be using libffi. * Makefile.in (LIBTOOL): Use @LIBTOOL@ now as it works. From-SVN: r82253
Diffstat (limited to 'libobjc/Protocol.m')
-rw-r--r--libobjc/Protocol.m30
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