Revision: 3439
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3439&view=rev
Author:   hofman
Date:     2008-02-24 17:08:03 -0800 (Sun, 24 Feb 2008)

Log Message:
-----------
Return old implementation in our version of method_setImplementation.

Modified Paths:
--------------
    trunk/OBUtilities.m

Modified: trunk/OBUtilities.m
===================================================================
--- trunk/OBUtilities.m 2008-02-24 14:04:44 UTC (rev 3438)
+++ trunk/OBUtilities.m 2008-02-25 01:08:03 UTC (rev 3439)
@@ -24,12 +24,15 @@
     return method_getImplementation != NULL ? 
method_getImplementation(aMethod) : aMethod->method_imp;
 } 
 
-static void SK_method_setImplementation(Method aMethod, IMP anImp)
+static IMP SK_method_setImplementation(Method aMethod, IMP anImp)
 {
     if (method_setImplementation != NULL)
-        method_setImplementation(aMethod, anImp);
-    else
+        return method_setImplementation(aMethod, anImp);
+    } else {
+        IMP oldImp = aMethod->method_imp;
         aMethod->method_imp = anImp;
+        return oldImp;
+    }
 } 
 
 static const char *SK_method_getTypeEncoding(Method aMethod)
@@ -81,20 +84,21 @@
     extern void _objc_flush_caches(Class);
     
     if ((localMethod = class_getInstanceMethod(aClass, oldSelector))) {
-        oldImp = SK_method_getImplementation(localMethod);
         if (superCls = SK_class_getSuperclass(aClass))
             superMethod = class_getInstanceMethod(superCls, oldSelector);
         
         if (superMethod == localMethod) {
             // We are inheriting this method from the superclass.  We do *not* 
want to clobber the superclass's Method structure as that would replace the 
implementation on a greater scope than the caller wanted.  In this case, 
install a new method at this class and return the superclass's implementation 
as the old implementation (which it is).
+            oldImp = SK_method_getImplementation(localMethod);
             SK_class_addMethod(aClass, oldSelector, newImp, 
SK_method_getTypeEncoding(localMethod));
         } else {
             // Replace the method in place
-            SK_method_setImplementation(localMethod, newImp);
+            oldImp = SK_method_setImplementation(localMethod, newImp);
         }
         
-        // Flush the method cache
-        _objc_flush_caches(aClass);
+        // Flush the method cache, deprecated on 10.5
+        if (_objc_flush_caches != NULL)
+            _objc_flush_caches(aClass);
     }
     
     return oldImp;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to