bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFA/base] GSObjCRuntime cleanups


From: David Ayers
Subject: [RFA/base] GSObjCRuntime cleanups
Date: Fri, 22 Aug 2003 20:44:36 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507

Hello all,

This patch was still siting in my sand box since the header transition. Richard already approved it's predecessor. I was going to wait for the release before applying it to insure it gets some decent testing. But in light of the issues that Manuel has brought up about GSObjCSuper / class_get_super_class / class_superclass_of_class, I would offer to apply this patch (which doesn't deal with this issue directly) and follow up a patch that changes GSObjCSuper class that can deal with unintialized class objects..

I'm not fully convinced that this will not cause any issues. In fact I'd rather not apply this (or the followup) before the release unless I get some feed back from larger projects, that these patches are OK. There are subtle differences in how these function work when the have class / meta class objects as parameters. But this patch should only touch those which are fairly obvious.

So, FWIW, here it is. Adam, you have the say whether this can be commited before/after the release.... but like I said, it can use some testing.

Cheers,
David

       * Headers/Additions/GNUstepBase/GSObjCRuntime.h
       GSObjCClass():  Allow nil values.
       GSObjCIsInstance(): Ditto.
       GSObjCIsClass(): New function.
       GSClassNameFromObject(): Ditto.
       GSObjCIsKindOf():  Use GSObjCSuper() in favor of
       class_get_super_class().

       * Headers/Foundation/NSRange.h
       GS_RANGE_CHECK(), CHECK_INDEX_RANGE_ERROR():
       Use GSNameFromSelector() in favor of sel_get_name().

       * Source/GSFFCallInvocation.m
       gs_method_for_receiver_and_selector(), gs_find_best_typed_sel(),
       -[GSFFCallInvocation invokeWithTarget:], GSInvocationCallback():
       Use GSObjCIsInstance() in favor of object_is_instance,
       GSObjCClass() in favor of object_get_class(),
       GSObjCIsClass() in favor of object_is_class(),
       GSNameFromSelector() in favor of sel_get_name(),
       GSObjCSuper() in favor of class_get_super_class() and
       GSClassNameFromObject() in  favor of object_get_class_name().

       * Source/GSFFIInvocation.m
       gs_method_for_receiver_and_selector(), gs_find_best_typed_sel(),
       -[GSFFIInvocation invokeWithTarget:], GSFFIInvocationCallback():
       Use GSObjCIsInstance() in favor of object_is_instance,
       GSObjCClass() in favor of object_get_class(),
       GSObjCIsClass() in favor of object_is_class(),
       GSNameFromSelector() in favor of sel_get_name(),
       GSObjCSuper() in favor of class_get_super_class() and
       GSClassNameFromObject() in  favor of object_get_class_name().

       * Source/NSConnection.m
       -[NSConnection forwardForProxy:selector:argFrame:],
       -[NSConnection forwardInvocation:forProxy:]:
       Use GSNameFromSelector() in favor of sel_get_name().

       * Source/NSDistantObject.m
       class_is_kind_of(): Use GSObjCSuper in favor of
       class_get_super_class().
       -[NSDistantObject forward::]: Use GSNameFromSelector() in favor of
       sel_get_name().

       * Source/NSInvocation.m
       -[NSInvocation invokeWithTarget:]
       Use GSObjCSuper() in favor of class_get_super_class(),
       GSObjCIsInstance() in favor of object_is_instance()
       -[NSInvocation description]:
       Use GSClassNameFromObject in favor of object_get_class_name().
       Avoid buffer overflow by using snprintf() in favor of sprintf().
       -[NSInvocation initWithSelector:]:
       Use GSNameFromSelector() in favor of sel_get_name().

       * Source/NSObject.m
       GSDescriptionForInstanceMethod(), GSDescriptionForClassMethod(),
       +[NSObject superclass], -[NSObject description],
       -[NSObject doesNotRecognizeSelector:],
       -[NSObject performSelector:],
       -[NSObject performSelector:withObject:],
       +[NSObject setVersion:], -[NSObject error:],
       -[NSObject doesNotRecognize:], -[NSObject isClass],
       -[Object description]:
       Use GSNameFromSelector() in favor of sel_get_name(),
       GSObjCSuper() in favor of class_get_super_class(),
       GSClassNameFromObject() in favor of object_get_class_name() and
       GSObjCIsClass() in favor of object_is_class().

       * Source/NSProxy.m
       +[NSProxy description], -[NSProxy description],
       +[NSProxy superclass], -[NSProxy forwardInvocation:],
       -[NSProxy init], -[NSProxy notImplemented:],
       -[NSProxy performSelector:],
       -[NSProxy performSelector:withObject:],
       -[NSProxy performSelector:withObject:withObject:]:
       Use GSClassNameFromObject() in favor of object_get_class_name(),
       GSObjCSuper() in favor of class_get_super_class() and
       GSNameFromSelector() in favor of sel_get_name().

       * Source/Additions/GSCategories.m
       -[NSObject notImplemented:], -[NSObject shouldNotImplement:],
       -[NSObject subclassResponsibility:]:
       Use GSNameFromSelector() in favor of sel_get_name() and
       GSClassNameFromObject() in favor of object_get_class_name().

       * Source/Additions/GSCompatibility.h
       GS_RANGE_CHECK(): Use GSNameFromSelector() in favor of
       sel_get_name().

       * Source/Additions/GSCompatibility.m
       +[NSObject notImplemented:]:
       Use GSNameFromSelector() in favor of sel_get_name() and
       GSClassNameFromObject() in favor of object_get_class_name().

       * Source/Additions/GSObjCRuntime.m
       GSObjCMethodNames(), GSObjCAddMethods():
       Use GSNameFromSelector() in favor of sel_get_name().

       * Testing/nsbundle.m (main): Update to reflect filesystem change.
       Use GSClassNameFromObject() in favor of object_get_class_name().

       * Testing/nsconnection_server.m
       Use GSNameFromSelector() in favor of sel_get_name().

       * Testing/Makefile.postamble: Build before checking.

Index: Headers/Additions/GNUstepBase/GSObjCRuntime.h
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Headers/Additions/GNUstepBase/GSObjCRuntime.h,v
retrieving revision 1.1
diff -u -r1.1 GSObjCRuntime.h
--- Headers/Additions/GNUstepBase/GSObjCRuntime.h       31 Jul 2003 23:49:29 
-0000      1.1
+++ Headers/Additions/GNUstepBase/GSObjCRuntime.h       22 Aug 2003 16:18:56 
-0000
@@ -125,25 +125,41 @@
 
 /**
  * GSObjCClass() return the class of an instance.
- * The argument to this function must NOT be nil.
+ * Returns a nul pointer if the argument is nil.
  */
 GS_STATIC_INLINE Class
 GSObjCClass(id obj)
 {
+  if (obj == nil)
+    return 0;
   return obj->class_pointer;
 }
 
 /**
  * GSObjCIsInstance() tests to see if an id is an instance.
- * The argument to this function must NOT be nil.
+ * Returns NO if the argument is nil.
  */
 GS_STATIC_INLINE BOOL
 GSObjCIsInstance(id obj)
 {
+  if (obj == nil)
+    return NO;
   return CLS_ISCLASS(obj->class_pointer);
 }
 
 /**
+ * GSObjCIsClass() tests to see if an id is a class.
+ * Returns NO if the argument is nil.
+ */
+GS_STATIC_INLINE BOOL
+GSObjCIsClass(id obj)
+{
+  if (obj == nil)
+    return NO;
+  return CLS_ISCLASS(obj);
+}
+
+/**
  * GSObjCIsKindOf() tests to see if a class inherits from another class
  * The argument to this function must NOT be nil.
  */
@@ -156,7 +172,7 @@
        {
          return YES;
        }
-      this = class_get_super_class(this);
+      this = GSObjCSuper(this);
     }
   return NO;
 }
@@ -184,6 +200,18 @@
   if (this == 0)
     return 0;
   return class_get_class_name(this);
+}
+
+/**
+ * Return the name of the object's class, or a nul pointer if no object
+ * was supplied.
+ */
+GS_STATIC_INLINE const char *
+GSClassNameFromObject(id obj)
+{
+  if (obj == 0)
+    return 0;
+  return object_get_class_name(obj);
 }
 
 /**
Index: Headers/Foundation/NSRange.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Foundation/NSRange.h,v
retrieving revision 1.1
diff -u -r1.1 NSRange.h
--- Headers/Foundation/NSRange.h        31 Jul 2003 23:49:29 -0000      1.1
+++ Headers/Foundation/NSRange.h        22 Aug 2003 16:18:56 -0000
@@ -203,13 +203,13 @@
 #define GS_RANGE_CHECK(RANGE, SIZE) \
   if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
     [NSException raise: NSRangeException \
-                format: @"in %s, range { %u, %u } extends beyond size (%u)", \
-                 sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
+                 format: @"in %s, range { %u, %u } extends beyond size (%u)", \
+                GSNameFromSelector(_cmd), RANGE.location, RANGE.length, SIZE]
 #define CHECK_INDEX_RANGE_ERROR(INDEX, OVER) \
 if (INDEX >= OVER) \
   [NSException raise: NSRangeException \
                format: @"in %s, index %d is out of range", \
-               sel_get_name (_cmd), INDEX]
+               GSNameFromSelector(_cmd), INDEX]
 #endif
 
 #endif /* __NSRange_h_GNUSTEP_BASE_INCLUDE */
Index: Source/GSFFCallInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSFFCallInvocation.m,v
retrieving revision 1.36
diff -u -r1.36 GSFFCallInvocation.m
--- Source/GSFFCallInvocation.m 31 Jul 2003 23:49:30 -0000      1.36
+++ Source/GSFFCallInvocation.m 22 Aug 2003 16:18:56 -0000
@@ -212,14 +212,13 @@
 {
   if (receiver)
     {
-      if (object_is_instance (receiver))
+      if (GSObjCIsInstance(receiver))
         {
-          return GSGetInstanceMethod (object_get_class
-                                              (receiver), sel);
+          return GSGetInstanceMethod(GSObjCClass(receiver), sel);
         }
-      else if (object_is_class (receiver))
+      else if (GSObjCIsClass(receiver))
         {
-          return GSGetClassMethod (receiver, sel);
+          return GSGetClassMethod(receiver, sel);
         }
     }
 
@@ -248,7 +247,7 @@
 {
   if (!sel_get_type (sel))
     {
-      const char *name = sel_get_name (sel);
+      const char *name = GSNameFromSelector(sel);
       
       if (name)
        {
@@ -679,14 +678,14 @@
 
       s.self = _target;
       if (GSObjCIsInstance(_target))
-       s.class = class_get_super_class(GSObjCClass(_target));
+       s.class = GSObjCSuper(GSObjCClass(_target));
       else
-       s.class = class_get_super_class((Class)_target);
+       s.class = GSObjCSuper((Class)_target);
       imp = objc_msg_lookup_super(&s, _selector);
     }
   else
     {
-      imp = method_get_imp(object_is_instance(_target) ?
+      imp = method_get_imp(GSObjCIsInstance(_target) ?
        GSGetInstanceMethod(
          ((struct objc_class*)_target)->class_pointer, _selector)
        : GSGetClassMethod(
@@ -801,9 +800,13 @@
   
   if (!fwdInvMethod)
     {
-      NSCAssert2 (0, @"GSFFCallInvocation: Class '%s' does not respond"
-                  @" to forwardInvocation: for '%s'",
-                  object_get_class_name (obj), sel_get_name(selector));
+      [NSException raise: NSInvalidArgumentException
+                  format: @"GSFFCallInvocation: Class '%s(%s)'"
+                          @" does not respond"
+                          @" to forwardInvocation: for '%s'",
+                  GSClassNameFromObject(obj),
+                  GSObjCIsInstance(obj) ? "instance" : "class",
+                  selector ? GSNameFromSelector(selector) : "(null)"];
     }
   
   sig = nil;
@@ -831,7 +834,7 @@
 
       if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0)
        {
-         const char    *runtimeName = sel_get_name (selector);
+         const char    *runtimeName = GSNameFromSelector(selector);
 
          selector = sel_get_typed_uid (runtimeName, receiverTypes);
          if (selector == 0)
@@ -864,9 +867,9 @@
     {
       [NSException raise: NSInvalidArgumentException
                  format: @"%s(%s) does not recognize %s",
-        object_get_class_name(obj),
+        GSClassNameFromObject(obj),
         GSObjCIsInstance(obj) ? "instance" : "class",
-        selector ? sel_get_name(selector) : "(null)"];
+        selector ? GSNameFromSelector(selector) : "(null)"];
     }
     
   invocation = [[GSFFCallInvocation alloc] initWithMethodSignature: sig];
Index: Source/GSFFIInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSFFIInvocation.m,v
retrieving revision 1.22
diff -u -r1.22 GSFFIInvocation.m
--- Source/GSFFIInvocation.m    31 Jul 2003 23:49:30 -0000      1.22
+++ Source/GSFFIInvocation.m    22 Aug 2003 16:18:56 -0000
@@ -59,15 +59,13 @@
 {
   if (receiver)
     {
-      if (object_is_instance (receiver))
+      if (GSObjCIsInstance(receiver))
         {
-          return GSGetInstanceMethod (object_get_class
-                                              (receiver), sel);
+          return GSGetInstanceMethod(GSObjCClass(receiver), sel);
         }
-      else if (object_is_class (receiver))
+      else if (GSObjCIsClass(receiver))
         {
-          return GSGetClassMethod (object_get_class
-                                           (receiver), sel);
+          return GSGetClassMethod(receiver, sel);
         }
     }
 
@@ -96,7 +94,7 @@
 {
   if (!sel_get_type (sel))
     {
-      const char *name = sel_get_name (sel);
+      const char *name = GSNameFromSelector(sel);
       
       if (name)
        {
@@ -325,14 +323,14 @@
 
       s.self = _target;
       if (GSObjCIsInstance(_target))
-       s.class = class_get_super_class(GSObjCClass(_target));
+       s.class = GSObjCSuper(GSObjCClass(_target));
       else
-       s.class = class_get_super_class((Class)_target);
+       s.class = GSObjCSuper((Class)_target);
       imp = objc_msg_lookup_super(&s, _selector);
     }
   else
     {
-      imp = method_get_imp(object_is_instance(_target) ?
+      imp = method_get_imp(GSObjCIsInstance(_target) ?
        GSGetInstanceMethod(
          ((struct objc_class*)_target)->class_pointer, _selector)
        : GSGetClassMethod(
@@ -420,9 +418,12 @@
   
   if (!fwdInvMethod)
     {
-      NSCAssert2 (0, @"GSFFIInvocation: Class '%s' does not respond"
-                  @" to forwardInvocation: for '%s'",
-                  object_get_class_name (obj), sel_get_name(selector));
+      [NSException raise: NSInvalidArgumentException
+                  format: @"GSFFIInvocation: Class '%s'(%s) does not respond"
+                          @" to forwardInvocation: for '%s'",
+                  GSClassNameFromObject(obj),
+                  GSObjCIsInstance(obj) ? "instance" : "class",
+                  selector ? GSNameFromSelector(selector) : "(null)"];
     }
        
   sig = nil;
@@ -446,7 +447,7 @@
 
       if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0)
        {
-         const char    *runtimeName = sel_get_name (selector);
+         const char    *runtimeName = GSNameFromSelector(selector);
 
          selector = sel_get_typed_uid (runtimeName, receiverTypes);
          if (selector == 0)
@@ -479,9 +480,9 @@
     {
       [NSException raise: NSInvalidArgumentException
                  format: @"%s(%s) does not recognize %s",
-        object_get_class_name(obj),
+        GSClassNameFromObject(obj),
         GSObjCIsInstance(obj) ? "instance" : "class",
-        selector ? sel_get_name(selector) : "(null)"];
+        selector ? GSNameFromSelector(selector) : "(null)"];
     }
     
   invocation = [[GSFFIInvocation alloc] initWithCallback: cif
Index: Source/NSConnection.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSConnection.m,v
retrieving revision 1.120
diff -u -r1.120 NSConnection.m
--- Source/NSConnection.m       31 Jul 2003 23:49:31 -0000      1.120
+++ Source/NSConnection.m       22 Aug 2003 16:18:57 -0000
@@ -1832,7 +1832,7 @@
       type = [[object methodSignatureForSelector: sel] methodType];
       if (type)
        {
-         sel_register_typed_name(sel_get_name(sel), type);
+         sel_register_typed_name(GSNameFromSelector(sel), type);
        }
     }
 #endif
@@ -1885,7 +1885,7 @@
   [self _sendOutRmc: ctxt.encoder type: METHOD_REQUEST];
   ctxt.encoder = nil;
   NSDebugMLLog(@"NSConnection", @"Sent message (%s) to 0x%x",
-    sel_get_name(sel), (gsaddr)self);
+    GSNameFromSelector(sel), (gsaddr)self);
 
   if (needsResponse == NO)
     {
@@ -1952,7 +1952,7 @@
       type = [[object methodSignatureForSelector: [inv selector]] methodType];
       if (type)
        {
-         sel_register_typed_name(sel_get_name([inv selector]), type);
+         sel_register_typed_name(GSNameFromSelector([inv selector]), type);
        }
     }
   NSParameterAssert(type);
Index: Source/NSDistantObject.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSDistantObject.m,v
retrieving revision 1.54
diff -u -r1.54 NSDistantObject.m
--- Source/NSDistantObject.m    15 Aug 2003 13:20:50 -0000      1.54
+++ Source/NSDistantObject.m    22 Aug 2003 16:18:57 -0000
@@ -1007,7 +1007,7 @@
 {
   Class class;
 
-  for (class = self; class!=Nil; class = class_get_super_class(class))
+  for (class = self; class!=Nil; class = GSObjCSuper(class))
     if (class==aClassObject)
       return YES;
   return NO;
@@ -1040,7 +1040,7 @@
 - (id) forward: (SEL)aSel :(arglist_t)frame
 {
   if (debug_proxy)
-    NSLog(@"NSDistantObject forwarding %s\n", sel_get_name(aSel));
+    NSLog(@"NSDistantObject forwarding %s\n", GSNameFromSelector(aSel));
 
   if (![_connection isValid])
     [NSException
Index: Source/NSInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSInvocation.m,v
retrieving revision 1.59
diff -u -r1.59 NSInvocation.m
--- Source/NSInvocation.m       31 Jul 2003 23:49:31 -0000      1.59
+++ Source/NSInvocation.m       22 Aug 2003 16:18:58 -0000
@@ -558,14 +558,14 @@
       s.receiver = _target;
 #endif
       if (GSObjCIsInstance(_target))
-       s.class = class_get_super_class(GSObjCClass(_target));
+       s.class = GSObjCSuper(GSObjCClass(_target));
       else
-       s.class = class_get_super_class((Class)_target);
+       s.class = GSObjCSuper((Class)_target);
       imp = objc_msg_lookup_super(&s, _selector);
     }
   else
     {
-      imp = method_get_imp(object_is_instance(_target) ?
+      imp = method_get_imp(GSObjCIsInstance(_target) ?
        GSGetInstanceMethod(
                    ((struct objc_class*)_target)->class_pointer, _selector)
        : GSGetClassMethod(
@@ -608,14 +608,14 @@
    */
   char buffer[1024];
 
-  sprintf (buffer, "<%s %p selector: %s target: %s>", \
-                (char*)object_get_class_name(self), \
+  snprintf (buffer, 1024, "<%s %p selector: %s target: %s>", \
+                GSClassNameFromObject(self), \
                 self, \
-                _selector ? [NSStringFromSelector(_selector) cString] : "nil", 
\
-                _target ? [NSStringFromClass([_target class]) cString] : "nil" 
\
+                _selector ? GSNameFromSelector(_selector) : "nil", \
+                _target ?   GSNameFromClass([_target class]) : "nil" \
                 );
 
-  return [NSString stringWithCString:buffer];
+  return [NSString stringWithCString: buffer];
 }
 
 - (void) encodeWithCoder: (NSCoder*)aCoder
@@ -761,12 +761,12 @@
   types = sel_get_type(aSelector);
   if (types == 0)
     {
-      types = sel_get_type(sel_get_any_typed_uid(sel_get_name(aSelector)));
+      types = 
sel_get_type(sel_get_any_typed_uid(GSNameFromSelector(aSelector)));
     }
   if (types == 0)
     {
       NSLog(@"Couldn't find encoding type for selector %s.",
-          sel_get_name(aSelector));
+          GSNameFromSelector(aSelector));
       RELEASE(self);
       return nil;
     }
Index: Source/NSObject.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSObject.m,v
retrieving revision 1.186
diff -u -r1.186 NSObject.m
--- Source/NSObject.m   22 Aug 2003 10:31:16 -0000      1.186
+++ Source/NSObject.m   22 Aug 2003 16:18:58 -0000
@@ -701,7 +701,7 @@
 {
   int i;
   struct objc_protocol_list    *p_list;
-  const char                   *name = sel_get_name (aSel);
+  const char                   *name = GSNameFromSelector(aSel);
   struct objc_method_description *result;
 
   if (self->instance_methods != 0)
@@ -732,7 +732,7 @@
 {
   int i;
   struct objc_protocol_list    *p_list;
-  const char                   *name = sel_get_name (aSel);
+  const char                   *name = GSNameFromSelector(aSel);
   struct objc_method_description *result;
 
   if (self->class_methods != 0)
@@ -1184,7 +1184,7 @@
  */
 + (Class) superclass
 {
-  return class_get_super_class (self);
+  return GSObjCSuper(self);
 }
 
 /**
@@ -1404,7 +1404,7 @@
 - (NSString*) description
 {
   return [NSString stringWithFormat: @"<%s: %lx>",
-    object_get_class_name(self), (unsigned long)self];
+    GSClassNameFromObject(self), (unsigned long)self];
 }
 
 /**
@@ -1437,9 +1437,9 @@
 {
   [NSException raise: NSInvalidArgumentException
              format: @"%s(%s) does not recognize %s",
-              object_get_class_name(self), 
+              GSClassNameFromObject(self), 
               GSObjCIsInstance(self) ? "instance" : "class",
-              aSelector ? sel_get_name(aSelector) : "(null)"];
+              aSelector ? GSNameFromSelector(aSelector) : "(null)"];
 }
 
 - (retval_t) forward: (SEL)aSel : (arglist_t)argFrame
@@ -1681,7 +1681,7 @@
   if (!msg)
     {
       [NSException raise: NSGenericException
-                 format: @"invalid selector passed to %s", sel_get_name(_cmd)];
+                 format: @"invalid selector passed to %s", 
GSNameFromSelector(_cmd)];
       return nil;
     }
   return (*msg)(self, aSelector);
@@ -1705,7 +1705,7 @@
   if (!msg)
     {
       [NSException raise: NSGenericException
-                 format: @"invalid selector passed to %s", sel_get_name(_cmd)];
+                 format: @"invalid selector passed to %s", 
GSNameFromSelector(_cmd)];
       return nil;
     }
 
@@ -1732,7 +1732,7 @@
   if (!msg)
     {
       [NSException raise: NSGenericException
-                 format: @"invalid selector passed to %s", sel_get_name(_cmd)];
+                 format: @"invalid selector passed to %s", 
GSNameFromSelector(_cmd)];
       return nil;
     }
 
@@ -1906,7 +1906,7 @@
   if (aVersion < 0)
     [NSException raise: NSInvalidArgumentException
                format: @"%s +setVersion: may not set a negative version",
-                       object_get_class_name(self)];
+                       GSClassNameFromObject(self)];
   class_set_version(self, aVersion);
   return self;
 }
@@ -1921,11 +1921,11 @@
 - (id) error: (const char *)aString, ...
 {
 #define FMT "error: %s (%s)\n%s\n"
-  char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self))
+  char fmt[(strlen((char*)FMT)+strlen((char*)GSClassNameFromObject(self))
             +((aString!=NULL)?strlen((char*)aString):0)+8)];
   va_list ap;
 
-  sprintf(fmt, FMT, object_get_class_name(self),
+  sprintf(fmt, FMT, GSClassNameFromObject(self),
                     GSObjCIsInstance(self)?"instance":"class",
                     (aString!=NULL)?aString:"");
   va_start(ap, aString);
@@ -1939,7 +1939,7 @@
 /*
 - (const char *) name
 {
-  return object_get_class_name(self);
+  return GSClassNameFromObject(self);
 }
 */
 
@@ -2015,9 +2015,9 @@
 {
   [NSException raise: NSGenericException
               format: @"%s(%s) does not recognize %s",
-              object_get_class_name(self), 
+              GSClassNameFromObject(self), 
               GSObjCIsInstance(self) ? "instance" : "class",
-              aSel ? sel_get_name(aSel) : "(null)"];
+              aSel ? GSNameFromSelector(aSel) : "(null)"];
   return nil;
 }
 
@@ -2124,7 +2124,7 @@
 
 - (BOOL) isClass
 {
-  return object_is_class(self);
+  return GSObjCIsClass(self);
 }
 
 - (BOOL) isInstance
@@ -2271,7 +2271,7 @@
 - (NSString*) description
 {
   return [NSString stringWithFormat: @"<%s: %lx>",
-    object_get_class_name(self), (unsigned long)self];
+    GSClassNameFromObject(self), (unsigned long)self];
 }
 - (BOOL) isProxy
 {
Index: Source/NSProxy.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSProxy.m,v
retrieving revision 1.26
diff -u -r1.26 NSProxy.m
--- Source/NSProxy.m    3 Aug 2003 03:57:53 -0000       1.26
+++ Source/NSProxy.m    22 Aug 2003 16:18:58 -0000
@@ -94,7 +94,7 @@
  */
 + (NSString*) description
 {
-  return [NSString stringWithFormat: @"<%s>", object_get_class_name(self)];
+  return [NSString stringWithFormat: @"<%s>", GSClassNameFromObject(self)];
 }
 
 /**
@@ -185,7 +185,7 @@
  */
 + (Class) superclass
 {
-  return class_get_super_class (self);
+  return GSObjCSuper(self);
 }
 
 /**
@@ -249,7 +249,7 @@
 - (NSString*) description
 {
   return [NSString stringWithFormat: @"<%s %lx>",
-       object_get_class_name(self), (unsigned long)self];
+       GSClassNameFromObject(self), (unsigned long)self];
 }
 
 /**
@@ -272,7 +272,7 @@
 {
   [NSException raise: NSInvalidArgumentException
              format: @"NSProxy should not implement '%s'",
-                               sel_get_name(_cmd)];
+                               GSNameFromSelector(_cmd)];
 }
 
 /**
@@ -289,8 +289,8 @@
 - (id) init
 {
   [NSException raise: NSGenericException
-    format: @"subclass %s should override %s", object_get_class_name(self),
-    sel_get_name(_cmd)];
+    format: @"subclass %s should override %s", GSClassNameFromObject(self),
+    GSNameFromSelector(_cmd)];
   return self;
 }
 
@@ -355,7 +355,7 @@
 - (id) notImplemented: (SEL)aSel
 {
   [NSException raise: NSGenericException
-             format: @"NSProxy notImplemented %s", sel_get_name(aSel)];
+             format: @"NSProxy notImplemented %s", GSNameFromSelector(aSel)];
   return self;
 }
 
@@ -394,7 +394,7 @@
     {
       [NSException raise: NSGenericException
                  format: @"invalid selector passed to %s",
-                               sel_get_name(_cmd)];
+                               GSNameFromSelector(_cmd)];
       return nil;
     }
   return (*msg)(self, aSelector);
@@ -409,7 +409,7 @@
     {
       [NSException raise: NSGenericException
                  format: @"invalid selector passed to %s",
-                               sel_get_name(_cmd)];
+                               GSNameFromSelector(_cmd)];
       return nil;
     }
   return (*msg)(self, aSelector, anObject);
@@ -425,7 +425,7 @@
     {
       [NSException raise: NSGenericException
                  format: @"invalid selector passed to %s",
-                               sel_get_name(_cmd)];
+                               GSNameFromSelector(_cmd)];
       return nil;
     }
   return (*msg)(self, aSelector, anObject, anotherObject);
Index: Source/Additions/GSCategories.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/Additions/GSCategories.m,v
retrieving revision 1.12
diff -u -r1.12 GSCategories.m
--- Source/Additions/GSCategories.m     31 Jul 2003 23:49:32 -0000      1.12
+++ Source/Additions/GSCategories.m     22 Aug 2003 16:18:59 -0000
@@ -542,8 +542,8 @@
   [NSException
     raise: NSGenericException
     format: @"method %s not implemented in %s(%s)",
-    aSel ? sel_get_name(aSel) : "(null)", 
-    object_get_class_name(self),
+    aSel ? GSNameFromSelector(aSel) : "(null)", 
+    GSClassNameFromObject(self),
     GSObjCIsInstance(self) ? "instance" : "class"];
   return nil;
 }
@@ -553,9 +553,9 @@
   [NSException
     raise: NSGenericException
     format: @"%s(%s) should not implement %s", 
-    object_get_class_name(self), 
+    GSClassNameFromObject(self), 
     GSObjCIsInstance(self) ? "instance" : "class",
-    aSel ? sel_get_name(aSel) : "(null)"];
+    aSel ? GSNameFromSelector(aSel) : "(null)"];
   return nil;
 }
 
@@ -563,9 +563,9 @@
 {
   [NSException raise: NSGenericException
     format: @"subclass %s(%s) should override %s", 
-              object_get_class_name(self),
+              GSClassNameFromObject(self),
               GSObjCIsInstance(self) ? "instance" : "class",
-              aSel ? sel_get_name(aSel) : "(null)"];
+              aSel ? GSNameFromSelector(aSel) : "(null)"];
   return nil;
 }
 
Index: Source/Additions/GSCompatibility.h
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Source/Additions/GSCompatibility.h,v
retrieving revision 1.12
diff -u -r1.12 GSCompatibility.h
--- Source/Additions/GSCompatibility.h  31 Jul 2003 23:49:32 -0000      1.12
+++ Source/Additions/GSCompatibility.h  22 Aug 2003 16:18:59 -0000
@@ -112,7 +112,7 @@
   if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
     [NSException raise: NSRangeException \
                 format: @"in %s, range { %u, %u } extends beyond size (%u)", \
-                  sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
+                  GSNameFromSelector(_cmd), RANGE.location, RANGE.length, SIZE]
 
 /* Taken from base/Headers/Foundation/NSString.h */
 typedef enum _NSGNUstepStringEncoding
Index: Source/Additions/GSCompatibility.m
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Source/Additions/GSCompatibility.m,v
retrieving revision 1.11
diff -u -r1.11 GSCompatibility.m
--- Source/Additions/GSCompatibility.m  31 Jul 2003 23:49:32 -0000      1.11
+++ Source/Additions/GSCompatibility.m  22 Aug 2003 16:18:59 -0000
@@ -419,17 +419,17 @@
 
 + (id) notImplemented:(SEL)selector
 {
-    [NSException raise: NSGenericException
-                format: @"method %s not implemented in %s(class)",
-selector ? sel_get_name(selector) : "(null)",
-        object_get_class_name(self)];
-    return nil;
+  [NSException raise: NSGenericException
+              format: @"method %s not implemented in %s(class)",
+              selector ? GSNameFromSelector(selector) : "(null)",
+              GSClassNameFromObject(self)];
+  return nil;
 }
 
 // In NSObject.m, category GNU
 - (BOOL) isInstance
 {
-    return GSObjCIsInstance(self);
+  return GSObjCIsInstance(self);
 }
 
 @end
Index: Source/Additions/GSObjCRuntime.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/Additions/GSObjCRuntime.m,v
retrieving revision 1.26
diff -u -r1.26 GSObjCRuntime.m
--- Source/Additions/GSObjCRuntime.m    31 Jul 2003 23:49:32 -0000      1.26
+++ Source/Additions/GSObjCRuntime.m    22 Aug 2003 16:18:59 -0000
@@ -172,7 +172,7 @@
              NSString  *name;
 
              name = [[NSString alloc] initWithUTF8String:
-               sel_get_name(methods->method_list[i].method_name)];
+               GSNameFromSelector(methods->method_list[i].method_name)];
              [set addObject: name];
              RELEASE(name);
            }
@@ -505,7 +505,7 @@
          if (behavior_debug)
            {
              fprintf(stderr, "   processing method [%s] ... ", 
-               sel_get_name(method->method_name));
+               GSNameFromSelector(method->method_name));
            }
 
          if (!search_for_method_in_class(class,method->method_name)
@@ -610,7 +610,7 @@
       while (counter >= 0)
         {
           struct objc_method   *method = &(mlist->method_list[counter]);
-         const char            *name = sel_get_name(method->method_name);
+         const char            *name = GSNameFromSelector(method->method_name);
 
          if (behavior_debug)
            {
Index: Testing/Makefile.postamble
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Testing/Makefile.postamble,v
retrieving revision 1.6
diff -u -r1.6 Makefile.postamble
--- Testing/Makefile.postamble  24 Jun 2003 03:46:13 -0000      1.6
+++ Testing/Makefile.postamble  22 Aug 2003 16:18:59 -0000
@@ -66,7 +66,7 @@
 after-distclean::
        rm -f cstream.dat fref.dat nsarchiver.dat
 
-check::
+check:: all
        for f in $(CHECKABLE_TOOLS); do \
          obj/$$f ; \
        done
Index: Testing/nsbundle.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Testing/nsbundle.m,v
retrieving revision 1.14
diff -u -r1.14 nsbundle.m
--- Testing/nsbundle.m  30 May 2003 02:54:49 -0000      1.14
+++ Testing/nsbundle.m  22 Aug 2003 16:18:59 -0000
@@ -48,9 +48,13 @@
     printf("Looking for LoadMe bundle...\n");
     path = [path stringByDeletingLastPathComponent];
     path = [path stringByDeletingLastPathComponent];
-    path = [path stringByDeletingLastPathComponent];
-    path = [path stringByDeletingLastPathComponent];
-    path = [path stringByDeletingLastPathComponent];
+    if ([[path lastPathComponent] isEqualToString:@"Testing"] == NO)
+      {
+       /* Delete library combo */
+       path = [path stringByDeletingLastPathComponent];
+       path = [path stringByDeletingLastPathComponent];
+       path = [path stringByDeletingLastPathComponent];
+      }
     printf("  Bundle directory is %s\n", [path cString]);
     path = [NSBundle pathForResource:@"LoadMe" ofType:@"bundle"
                      inDirectory: path];
@@ -88,7 +92,7 @@
        printf("* ERROR: Can't find principal class\n");
       }
     else
-      printf("  Principal class is: %s\n", object_get_class_name (object));
+      printf("  Principal class is: %s\n", GSClassNameFromObject(object));
 
     printf("Testing LoadMe bundle classes...\n");
     printf("  This is LoadMe:\n");
Index: Testing/nsconnection_server.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Testing/nsconnection_server.m,v
retrieving revision 1.11
diff -u -r1.11 nsconnection_server.m
--- Testing/nsconnection_server.m       4 Jul 2003 09:33:53 -0000       1.11
+++ Testing/nsconnection_server.m       22 Aug 2003 16:18:59 -0000
@@ -93,7 +93,7 @@
 
 - (BOOL) sendBoolean: (BOOL)b
 {
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), (int)b, (int)(!b));
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), (int)b, 
(int)(!b));
   fflush(stdout);
   return !b;
 }
@@ -102,7 +102,7 @@
 - (void) getBoolean: (BOOL*)bp
 {
   BOOL rbp = !(*bp);
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), 
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), 
         (int)*bp, (int)rbp);
   fflush(stdout);
   *bp = rbp;
@@ -111,7 +111,7 @@
 - (unsigned char) sendUChar: (unsigned char)num
 {
   unsigned char rnum = num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), 
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), 
         (int)num, (int)rnum);
   fflush(stdout);
   return rnum;
@@ -121,7 +121,7 @@
 - (void) getUChar: (unsigned char *)num
 {
   unsigned char rnum = *num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), 
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), 
         (int)(*num), (int)rnum);
   *num = rnum;
   fflush(stdout);
@@ -130,7 +130,7 @@
 - (char) sendChar: (char)num
 {
   char rnum = num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd),
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd),
         (int)num, (int)rnum);
   fflush(stdout);
   return rnum;
@@ -139,7 +139,7 @@
 - (void) getChar: (char *)num
 {
   char rnum = *num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), 
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), 
         (int)(*num), (int)rnum);
   *num = rnum;
   fflush(stdout);
@@ -148,7 +148,7 @@
 - (short) sendShort: (short)num
 {
   short rnum = num + ADD_CONST;
-  printf("(%s) got %hd, returning %hd\n", sel_get_name(_cmd),
+  printf("(%s) got %hd, returning %hd\n", GSNameFromSelector(_cmd),
         num, rnum);
   fflush(stdout);
   return rnum;
@@ -157,7 +157,7 @@
 - (void) getShort: (short *)num
 {
   short rnum = *num + ADD_CONST;
-  printf("(%s) got %hd, returning %hd\n", sel_get_name(_cmd), 
+  printf("(%s) got %hd, returning %hd\n", GSNameFromSelector(_cmd), 
         (*num), rnum);
   *num = rnum;
   fflush(stdout);
@@ -166,7 +166,7 @@
 - (int) sendInt: (int)num
 {
   int rnum = num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), num, rnum);
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), num, rnum);
   fflush(stdout);
   return rnum;
 }
@@ -174,7 +174,7 @@
 - (void) getInt: (int *)num
 {
   int rnum = *num + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *num, rnum);
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), *num, rnum);
   *num = rnum;
   fflush(stdout);
 }
@@ -182,7 +182,7 @@
 - (long) sendLong: (long)num
 {
   long rnum = num + ADD_CONST;
-  printf("(%s) got %ld, returning %ld\n", sel_get_name(_cmd), num, rnum);
+  printf("(%s) got %ld, returning %ld\n", GSNameFromSelector(_cmd), num, rnum);
   fflush(stdout);
   return rnum;
 }
@@ -190,7 +190,7 @@
 - (void) getLong: (long *)num
 {
   long rnum = *num + ADD_CONST;
-  printf("(%s) got %ld, returning %ld\n", sel_get_name(_cmd), *num, rnum);
+  printf("(%s) got %ld, returning %ld\n", GSNameFromSelector(_cmd), *num, 
rnum);
   *num = rnum;
   fflush(stdout);
 }
@@ -198,7 +198,7 @@
 - (float) sendFloat: (float)num
 {
   float rnum = num + ADD_CONST;
-  printf("(%s) got %f, returning %f\n", sel_get_name(_cmd), num, rnum);
+  printf("(%s) got %f, returning %f\n", GSNameFromSelector(_cmd), num, rnum);
   fflush(stdout);
   return rnum;
 }
@@ -206,7 +206,7 @@
 - (void) getFloat: (float *)num
 {
   float rnum = *num + ADD_CONST;
-  printf("(%s) got %f, returning %f\n", sel_get_name(_cmd), *num, rnum);
+  printf("(%s) got %f, returning %f\n", GSNameFromSelector(_cmd), *num, rnum);
   *num = rnum;
   fflush(stdout);
 }
@@ -214,7 +214,7 @@
 - (double) sendDouble: (double)num
 {
   double rnum = num + ADD_CONST;
-  printf("(%s) got %g, returning %g\n", sel_get_name(_cmd), num, rnum);
+  printf("(%s) got %g, returning %g\n", GSNameFromSelector(_cmd), num, rnum);
   fflush(stdout);
   return rnum;
 }
@@ -222,7 +222,7 @@
 - (void) getDouble: (double *)num
 {
   double rnum = *num + ADD_CONST;
-  printf("(%s) got %g, returning %g\n", sel_get_name(_cmd), *num, rnum);
+  printf("(%s) got %g, returning %g\n", GSNameFromSelector(_cmd), *num, rnum);
   *num = rnum;
   fflush(stdout);
 }
@@ -230,7 +230,7 @@
 - (small_struct) sendSmallStruct: (small_struct)str
 {
   char rnum = str.z + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), str.z, rnum);
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), str.z, rnum);
   fflush(stdout);
   str.z = rnum;
   return str;
@@ -239,7 +239,7 @@
 - (void) getSmallStruct: (small_struct *)str
 {
   char rnum = str->z + ADD_CONST;
-  printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), str->z, rnum);
+  printf("(%s) got %d, returning %d\n", GSNameFromSelector(_cmd), str->z, 
rnum);
   fflush(stdout);
   str->z = rnum;
 }
@@ -248,7 +248,7 @@
 {
   foo f2 = {'A', 123.456, 1, "horse", 987654};
   printf("(%s) got c='%c', d=%g, i=%d, s=%s, l=%lu",
-    sel_get_name(_cmd), f.c, f.d, f.i, f.s, f.l);
+    GSNameFromSelector(_cmd), f.c, f.d, f.i, f.s, f.l);
   fflush(stdout);
   printf(" returning c='%c', d=%g, i=%d, s=%s, l=%lu\n",
     f2.c, f2.d, f2.i, f2.s, f2.l);
@@ -260,7 +260,7 @@
 {
   foo f2 = {'A', 123.456, 1, "horse", 987654};
   printf("(%s) got c='%c', d=%g, i=%d, s=%s, l=%lu",
-    sel_get_name(_cmd), f->c, f->d, f->i, f->s, f->l);
+    GSNameFromSelector(_cmd), f->c, f->d, f->i, f->s, f->l);
   fflush(stdout);
   printf(" returning c='%c', d=%g, i=%d, s=%s, l=%lu\n",
     f2.c, f2.d, f2.i, f2.s, f2.l);
@@ -270,22 +270,22 @@
 
 - sendObject: (id)str
 {
-  printf ("(%s) got object (%s)\n", sel_get_name(_cmd), 
-    object_get_class_name (str));
+  printf ("(%s) got object (%s)\n", GSNameFromSelector(_cmd), 
+    GSClassNameFromObject(str));
   fflush(stdout);
   return str;
 }
 
 - (void) getObject: (id *)str
 {
-  printf ("(%s) got object (%s)\n", sel_get_name(_cmd), 
-    object_get_class_name (*str));
+  printf ("(%s) got object (%s)\n", GSNameFromSelector(_cmd), 
+    GSClassNameFromObject(*str));
   fflush(stdout);
 }
 
 - (char *) sendString: (char *)str
 {
-  printf ("(%s) got string (%s)", sel_get_name(_cmd), str);
+  printf ("(%s) got string (%s)", GSNameFromSelector(_cmd), str);
   str[0] = 'N';
   printf(" returning (%s)\n", str);
   fflush(stdout);
@@ -294,7 +294,7 @@
 
 - (void) getString: (char **)str
 {
-  printf ("(%s) got string (%s)", sel_get_name(_cmd), *str);
+  printf ("(%s) got string (%s)", GSNameFromSelector(_cmd), *str);
   (*str)[0] = 'N';
   printf(" returning (%s)\n", *str);
   fflush(stdout);
@@ -302,14 +302,14 @@
 
 - (oneway void) shout
 {
-  printf ("(%s) got it\n", sel_get_name(_cmd));
+  printf ("(%s) got it\n", GSNameFromSelector(_cmd));
   fflush(stdout);
 }
 
 /* sender must also respond to 'bounce:count:' */
 - bounce: sender count: (int)c
 {
-  printf ("(%s) got message %d, bouncing back %d", sel_get_name(_cmd), c, c-1);
+  printf ("(%s) got message %d, bouncing back %d", GSNameFromSelector(_cmd), 
c, c-1);
   fflush(stdout);
   if (--c)
     [sender bounce:self count:c];
@@ -354,21 +354,21 @@
 
 - sendDouble: (double)d andFloat: (float)f
 {
-  printf("(%s) got double %f, float %f\n", sel_get_name(_cmd), d, f);
+  printf("(%s) got double %f, float %f\n", GSNameFromSelector(_cmd), d, f);
   fflush(stdout);
   return self;
 }
 
 - quietBycopy: (bycopy id)o
 {
-  printf("  >> quiet bycopy class is %s\n", object_get_class_name (o));
+  printf("  >> quiet bycopy class is %s\n", GSClassNameFromObject(o));
   fflush(stdout);
   return self;
 }
 
 - sendBycopy: (bycopy id)o
 {
-  printf("  >> bycopy class is %s\n", object_get_class_name (o));
+  printf("  >> bycopy class is %s\n", GSClassNameFromObject(o));
   fflush(stdout);
   return self;
 }
@@ -376,13 +376,13 @@
 #ifdef _F_BYREF
 - sendByref: (byref id)o
 {
-  printf("  >> byref class is %s\n", object_get_class_name (o));
+  printf("  >> byref class is %s\n", GSClassNameFromObject(o));
   fflush(stdout);
   return self;
 }
 - modifyByref: (byref NSMutableString *)o
 {
-  printf("  >> byref class is %s\n", object_get_class_name (o));
+  printf("  >> byref class is %s\n", GSClassNameFromObject(o));
   fflush(stdout);
   [o appendString: @"hello"];
   return self;
@@ -422,7 +422,7 @@
 
 - (NSConnection*) connection: ancestor didConnect: newConn
 {
-  printf("%s\n", sel_get_name(_cmd));
+  printf("%s\n", GSNameFromSelector(_cmd));
   [[NSNotificationCenter defaultCenter]
     addObserver: self
     selector: @selector(connectionBecameInvalid:)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]