bug-gnustep
[Top][All Lists]
Advanced

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

[RFA/base] Replace objc_get_instance/class_method


From: David Ayers
Subject: [RFA/base] Replace objc_get_instance/class_method
Date: Tue, 24 Jun 2003 22:11:55 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507

Hello everyone,

this patch follows up on the new GSGetInstance/ClassMethod patch of GSObjCRuntime. Mainly it replaces all occurances of objc_get_instance_method(class / instance->class_pointer) with GSGetInstanceMethod(class / instance->class_pointers) and objc_get_class_method(class->class_pointer) with GSGetInstanceMethod(class).

Also note that the previous implementation of [NSDistantObject +respondsToSelector] tested against instance methods. This patch also fixes this case.

It would be intersting to know whether the pre-patch version of [NSObject -methodSignatureForSelector:] on a class with a class method worked with the Apple runtime (before I broke it with my last patch to objc-gnu2next.h removing the bogus mapping of objc_get_class_method/objc_getClassMethod :-/ , but which this patch should fix.)

I'd aprreciate it someone with OS X / darwin could test this with the Apple runtime.


   * Source/GSFFCallInvocation.m
   (gs_method_for_receiver_and_selector): Replace usage of
   class_get_instance/class_method with GSGetInstance/ClassMethod and
   Method_t with GSMethod.
   (gs_find_by_receiver_best_typed_sel): Ditto.
   (GSInvocationCallback): Ditto.
   ([GSFFCallInvocation -invokeWithTarget:]): Ditto.
   * Source/GSFFIInvocation.m
   (gs_method_for_receiver_and_selector): Ditto.
   (gs_find_by_receiver_best_typed_sel): Ditto.
   (GSFFIInvocationCallback): Ditto.
   ([GSFFIInvocation -invokeWithTarget:]): Ditto.
   * Source/NSConnection.m
   ([NSConnection -_service_typeForSelector:]): Ditto.
   * Source/NSInvocation.m
   ([NSInvocation -invokeWithTarget:]): Ditto.
   * Source/NSObject.m
   ([NSObject +instanceMethodSignatureForSelector:]): Ditto.
   ([NDObject -methodSignatureForSelector:]): Ditto.
   ([NSObject +descriptionForInstanceMethod:]): Ditto.
   ([NSOnject -descriptionForMethod:]: Ditto.
   * Source/NSProxy.m
   ([NSProxy +methodSignatureForSelector:]): Ditto.
   ([NSProxy -methodSignatureForSelector:]): Ditto.
   * Source/NSDistantObject.m
   ([NSObject -selectorTypeForProxy:]): Ditto.
   ([NSDistantObject +respondsToSelector:]): Ditto. Corrected
   implementation to check class methods instead of instance methods.


OK to commit?

Cheers,
David

Index: Source/GSFFCallInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSFFCallInvocation.m,v
retrieving revision 1.28
diff -u -r1.28 GSFFCallInvocation.m
--- Source/GSFFCallInvocation.m 7 Jun 2003 01:24:40 -0000       1.28
+++ Source/GSFFCallInvocation.m 24 Jun 2003 16:14:40 -0000
@@ -206,20 +206,19 @@
  * we work around it.
  */
 
-static INLINE Method_t
+static INLINE GSMethod
 gs_method_for_receiver_and_selector (id receiver, SEL sel)
 {
   if (receiver)
     {
       if (object_is_instance (receiver))
         {
-          return class_get_instance_method (object_get_class
+          return GSGetInstanceMethod (object_get_class
                                               (receiver), sel);
         }
       else if (object_is_class (receiver))
         {
-          return class_get_class_method (object_get_meta_class
-                                           (receiver), sel);
+          return GSGetClassMethod (receiver, sel);
         }
     }
 
@@ -278,7 +277,7 @@
 
   if (receiver)
     {
-      Method_t method;
+      GSMethod method;
 
       method = gs_method_for_receiver_and_selector (receiver, sel);
       /* CHECKME:  Can we assume that:
@@ -688,10 +687,10 @@
   else
     {
       imp = method_get_imp(object_is_instance(_target) ?
-       class_get_instance_method(
+       GSGetInstanceMethod(
          ((struct objc_class*)_target)->class_pointer, _selector)
-       : class_get_class_method(
-         ((struct objc_class*)_target)->class_pointer, _selector));
+       : GSGetClassMethod(
+         ((struct objc_class*)_target), _selector));
       /*
        * If fast lookup failed, we may be forwarding or something ...
        */
@@ -742,7 +741,7 @@
   NSArgumentInfo       *info;
   GSFFCallInvocation   *invocation;
   NSMethodSignature    *sig;
-  Method_t               fwdInvMethod;
+  GSMethod               fwdInvMethod;
   
     
   typeinfo = (vacallReturnTypeInfo *) callback_data;
@@ -874,7 +873,7 @@
    *
    *   [obj forwardInvocation: invocation];
    *
-   * but we have already the Method_t for forwardInvocation
+   * but we have already the GSMethod for forwardInvocation
    * so the line below is somewhat faster. */
   fwdInvMethod->method_imp (obj, fwdInvMethod->method_name, invocation);
 
Index: Source/GSFFIInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSFFIInvocation.m,v
retrieving revision 1.15
diff -u -r1.15 GSFFIInvocation.m
--- Source/GSFFIInvocation.m    7 Jun 2003 01:24:40 -0000       1.15
+++ Source/GSFFIInvocation.m    24 Jun 2003 16:14:42 -0000
@@ -53,19 +53,19 @@
  * we work around it.
  */
 
-static INLINE Method_t
+static INLINE GSMethod
 gs_method_for_receiver_and_selector (id receiver, SEL sel)
 {
   if (receiver)
     {
       if (object_is_instance (receiver))
         {
-          return class_get_instance_method (object_get_class
+          return GSGetInstanceMethod (object_get_class
                                               (receiver), sel);
         }
       else if (object_is_class (receiver))
         {
-          return class_get_class_method (object_get_meta_class
+          return GSGetClassMethod (object_get_class
                                            (receiver), sel);
         }
     }
@@ -125,7 +125,7 @@
 
   if (receiver)
     {
-      Method_t method;
+      GSMethod method;
 
       method = gs_method_for_receiver_and_selector (receiver, sel);
       /* CHECKME:  Can we assume that:
@@ -320,10 +320,10 @@
   else
     {
       imp = method_get_imp(object_is_instance(_target) ?
-       class_get_instance_method(
+       GSGetInstanceMethod(
          ((struct objc_class*)_target)->class_pointer, _selector)
-       : class_get_class_method(
-         ((struct objc_class*)_target)->class_pointer, _selector));
+       : GSGetClassMethod(
+         (struct objc_class*)_target, _selector));
       /*
        * If fast lookup failed, we may be forwarding or something ...
        */
@@ -359,7 +359,7 @@
   SEL                  selector;
   GSFFIInvocation      *invocation;
   NSMethodSignature    *sig;
-  Method_t              fwdInvMethod;
+  GSMethod              fwdInvMethod;
   
   obj      = *(id *)args[0];
   selector = *(SEL *)args[1];
@@ -405,7 +405,7 @@
    *
    *   [obj forwardInvocation: invocation];
    *
-   * but we have already the Method_t for forwardInvocation
+   * but we have already the GSMethod for forwardInvocation
    * so the line below is somewhat faster. */
   fwdInvMethod->method_imp (obj, fwdInvMethod->method_name, invocation);
 
Index: Source/NSConnection.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSConnection.m,v
retrieving revision 1.112
diff -u -r1.112 NSConnection.m
--- Source/NSConnection.m       7 Jun 2003 01:24:40 -0000       1.112
+++ Source/NSConnection.m       24 Jun 2003 16:14:42 -0000
@@ -2594,7 +2594,7 @@
 
   /* xxx We should make sure that TARGET is a valid object. */
   /* Not actually a Proxy, but we avoid the warnings "id" would have made. */
-  m = class_get_instance_method(((NSDistantObject*)o)->isa, sel);
+  m = GSGetInstanceMethod(((NSDistantObject*)o)->isa, sel);
   /* Perhaps I need to be more careful in the line above to get the
      version of the method types that has the type qualifiers in it.
      Search the protocols list. */
Index: Source/NSDistantObject.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSDistantObject.m,v
retrieving revision 1.43
diff -u -r1.43 NSDistantObject.m
--- Source/NSDistantObject.m    7 Jun 2003 01:24:40 -0000       1.43
+++ Source/NSDistantObject.m    24 Jun 2003 16:14:42 -0000
@@ -114,7 +114,7 @@
 
 + (BOOL) respondsToSelector: (SEL)sel
 {
-  return (IMP)class_get_instance_method(self, sel) != (IMP)0;
+  return GSGetClassMethod(self, sel) != (GSMethod)0;
 }
 
 + (id) initWithCoder: (NSCoder*)aCoder
@@ -1002,7 +1002,7 @@
 {
 #if NeXT_runtime
   {
-    Method m = class_get_instance_method(isa, selector);
+    Method m = GSGetInstanceMethod(isa, selector);
     if (m)
       return m->method_types;
     else
Index: Source/NSInvocation.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSInvocation.m,v
retrieving revision 1.56
diff -u -r1.56 NSInvocation.m
--- Source/NSInvocation.m       7 Jun 2003 01:24:41 -0000       1.56
+++ Source/NSInvocation.m       24 Jun 2003 16:14:42 -0000
@@ -565,10 +565,10 @@
   else
     {
       imp = method_get_imp(object_is_instance(_target) ?
-       class_get_instance_method(
+       GSGetInstanceMethod(
                    ((struct objc_class*)_target)->class_pointer, _selector)
-       : class_get_class_method(
-                   ((struct objc_class*)_target)->class_pointer, _selector));
+       : GSGetClassMethod(
+                   ((struct objc_class*)_target), _selector));
        /*
         * If fast lookup failed, we may be forwarding or something ...
         */
Index: Source/NSObject.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSObject.m,v
retrieving revision 1.178
diff -u -r1.178 NSObject.m
--- Source/NSObject.m   20 Jun 2003 18:53:34 -0000      1.178
+++ Source/NSObject.m   24 Jun 2003 16:14:42 -0000
@@ -1226,7 +1226,7 @@
     [NSException raise: NSInvalidArgumentException
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
-  mth = class_get_instance_method(self, aSelector);
+  mth = GSGetInstanceMethod(self, aSelector);
   return mth ? [NSMethodSignature signatureWithObjCTypes:mth->method_types]
     : nil;
 }
@@ -1246,8 +1246,8 @@
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
   mth = (GSObjCIsInstance(self)
-    ? class_get_instance_method(GSObjCClass(self), aSelector)
-    : class_get_class_method(GSObjCClass(self), aSelector));
+    ? GSGetInstanceMethod(GSObjCClass(self), aSelector)
+    : GSGetClassMethod((Class)self, aSelector));
   if (mth == 0)
     {
       return nil;
@@ -1858,7 +1858,7 @@
     [NSException raise: NSInvalidArgumentException
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
-  mth = class_get_instance_method(self, aSelector);
+  mth = GSGetInstanceMethod(self, aSelector);
   return mth ? [NSMethodSignature signatureWithObjCTypes:mth->method_types]
     : nil;
 }
@@ -2008,7 +2008,7 @@
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
   return ((struct objc_method_description *)
-           class_get_instance_method(self, aSel));
+           GSGetInstanceMethod(self, aSel));
 }
 
 - (struct objc_method_description *) descriptionForMethod: (SEL)aSel
@@ -2019,8 +2019,8 @@
 
   return ((struct objc_method_description *)
            (GSObjCIsInstance(self)
-            ?class_get_instance_method(GSObjCClass(self), aSel)
-            :class_get_class_method(GSObjCClass(self), aSel)));
+            ? GSGetInstanceMethod(GSObjCClass(self), aSel)
+            : GSGetClassMethod((Class)self, aSel)));
 }
 
 /**
Index: Source/NSProxy.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSProxy.m,v
retrieving revision 1.21
diff -u -r1.21 NSProxy.m
--- Source/NSProxy.m    7 Jun 2003 01:24:41 -0000       1.21
+++ Source/NSProxy.m    24 Jun 2003 16:14:42 -0000
@@ -124,7 +124,7 @@
     {
       return nil;
     }
-  mth = class_get_class_method(GSObjCClass(self), aSelector);
+  mth = GSGetClassMethod(self, aSelector);
   if (mth != 0)
     {
       const char       *types = mth->method_types;
@@ -355,7 +355,7 @@
     {
       return nil;
     }
-  mth = class_get_instance_method(GSObjCClass(self), aSelector);
+  mth = GSGetInstanceMethod(GSObjCClass(self), aSelector);
   if (mth != 0)
     {
       const char       *types = mth->method_types;

reply via email to

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