This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libobjc-branch] More merging in from GNUStep's libobjc


Just some misc. patches from the GNUStep people.
There will be one more merge patch, libobjc.def which I have to do mainly by hand.



Thanks, Andrew Pinski

ChangeLog:

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.

Patch:

Index: Protocol.m
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/Protocol.m,v
retrieving revision 1.5
diff -u -p -r1.5 Protocol.m
--- Protocol.m	1 Dec 2003 23:29:59 -0000	1.5
+++ Protocol.m	28 Jan 2004 07:54:59 -0000
@@ -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
Index: hash.c
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/hash.c,v
retrieving revision 1.4
diff -u -p -r1.4 hash.c
--- hash.c	23 May 2003 20:25:39 -0000	1.4
+++ hash.c	28 Jan 2004 07:54:59 -0000
@@ -154,7 +154,7 @@ hash_add (cache_ptr *cachep, const void
 			      (*cachep)->compare_func);

     DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n",
-		  *cachep, (*cachep)->size, new->size);
+		  (int) *cachep, (*cachep)->size, new->size);

     /* Copy the nodes from the first hash table to the new one.  */
     while ((node1 = hash_next (*cachep, node1)))
Index: sarray.c
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/sarray.c,v
retrieving revision 1.8
diff -u -p -r1.8 sarray.c
--- sarray.c	10 Jan 2004 05:47:42 -0000	1.8
+++ sarray.c	28 Jan 2004 07:55:00 -0000
@@ -459,7 +459,9 @@ sarray_free (struct sarray *array) {

#endif

- /* If this is a copy, go ahead and decrement/deallocate the original */
+ /* If this is a copy of another array, we free it (which might just
+ * decrement its reference count so it will be freed when no longer in use).
+ */
if (array->is_copy_of)
sarray_free (array->is_copy_of);


Index: selector.c
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/selector.c,v
retrieving revision 1.7.4.1
diff -u -p -r1.7.4.1 selector.c
--- selector.c	27 Jan 2004 22:56:50 -0000	1.7.4.1
+++ selector.c	28 Jan 2004 07:55:00 -0000
@@ -435,7 +435,7 @@ __sel_register_typed_name (const char *n
     }

   DEBUG_PRINTF ("Record selector %s[%s] as: %ld\n", name, types,
-		soffset_decode (i));
+		(long) soffset_decode (i));

   {
     int is_new = (l == 0);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]