Revision: 28991
          http://sourceforge.net/p/bibdesk/svn/28991
Author:   hofman
Date:     2025-02-06 17:18:51 +0000 (Thu, 06 Feb 2025)
Log Message:
-----------
Need only one method swizzling function, so remove others

Modified Paths:
--------------
    trunk/bibdesk/BDSKRuntime.h
    trunk/bibdesk/BDSKRuntime.m

Modified: trunk/bibdesk/BDSKRuntime.h
===================================================================
--- trunk/bibdesk/BDSKRuntime.h 2025-02-06 16:49:38 UTC (rev 28990)
+++ trunk/bibdesk/BDSKRuntime.h 2025-02-06 17:18:51 UTC (rev 28991)
@@ -38,25 +38,6 @@
 
 #import <Cocoa/Cocoa.h>
 
-enum {
-    BDSKAddOrReplace,
-    BDSKReplaceOnly,
-    BDSKAddOnly
-};
-
-extern IMP BDSKSetMethodImplementation(Class aClass, SEL aSelector, IMP anImp, 
const char *types, BOOL isInstance, NSInteger options);
-extern IMP BDSKSetMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector, BOOL isInstance, NSInteger options);
-
-extern IMP BDSKReplaceInstanceMethodImplementation(Class aClass, SEL 
aSelector, IMP anImp);
-extern void BDSKAddInstanceMethodImplementation(Class aClass, SEL aSelector, 
IMP anImp, const char *types);
-
 extern IMP BDSKReplaceInstanceMethodImplementationFromSelector(Class aClass, 
SEL aSelector, SEL impSelector);
-extern void BDSKAddInstanceMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector);
 
-extern IMP BDSKReplaceClassMethodImplementation(Class aClass, SEL aSelector, 
IMP anImp);
-extern void BDSKAddClassMethodImplementation(Class aClass, SEL aSelector, IMP 
anImp, const char *types);
-
-extern IMP BDSKReplaceClassMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector);
-extern void BDSKAddClassMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector);
-
 extern void BDSKRequestConcreteImplementation(id self, SEL aSelector);

Modified: trunk/bibdesk/BDSKRuntime.m
===================================================================
--- trunk/bibdesk/BDSKRuntime.m 2025-02-06 16:49:38 UTC (rev 28990)
+++ trunk/bibdesk/BDSKRuntime.m 2025-02-06 17:18:51 UTC (rev 28991)
@@ -43,59 +43,17 @@
 
 #pragma mark API
 
-// this is essentially class_replaceMethod, but handles instance/class 
methods, returns any inherited implementation, and can get the types from an 
inherited implementation
-IMP BDSKSetMethodImplementation(Class aClass, SEL aSelector, IMP anImp, const 
char *types, BOOL isInstance, NSInteger options) {
+IMP BDSKReplaceInstanceMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector) {
+    Method method = class_getInstanceMethod(aClass, aSelector);
+    Method impMethod = class_getInstanceMethod(aClass, impSelector);
     IMP imp = NULL;
-    if (anImp) {
-        Method method = isInstance ? class_getInstanceMethod(aClass, 
aSelector) : class_getClassMethod(aClass, aSelector);
-        if (method) {
-            imp = method_getImplementation(method);
-            if (types == NULL)
-                types = method_getTypeEncoding(method);
-        }
-        if (types != NULL && (options != BDSKAddOnly || imp == NULL) && 
(options != BDSKReplaceOnly || imp != NULL))
-            class_replaceMethod(isInstance ? aClass : object_getClass(aClass), 
aSelector, anImp, types);
+    if (method && impMethod) {
+        imp = method_getImplementation(method);
+        class_replaceMethod(aClass, aSelector, 
method_getImplementation(impMethod), method_getTypeEncoding(method));
     }
     return imp;
 }
 
-IMP BDSKSetMethodImplementationFromSelector(Class aClass, SEL aSelector, SEL 
impSelector, BOOL isInstance, NSInteger options) {
-    Method method = isInstance ? class_getInstanceMethod(aClass, impSelector) 
: class_getClassMethod(aClass, impSelector);
-    return method ? BDSKSetMethodImplementation(aClass, aSelector, 
method_getImplementation(method), method_getTypeEncoding(method), isInstance, 
options) : NULL;
-}
-
-IMP BDSKReplaceInstanceMethodImplementation(Class aClass, SEL aSelector, IMP 
anImp) {
-    return BDSKSetMethodImplementation(aClass, aSelector, anImp, NULL, YES, 
BDSKReplaceOnly);
-}
-
-void BDSKAddInstanceMethodImplementation(Class aClass, SEL aSelector, IMP 
anImp, const char *types) {
-    BDSKSetMethodImplementation(aClass, aSelector, anImp, types, YES, 
BDSKAddOnly);
-}
-
-IMP BDSKReplaceInstanceMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector) {
-    return BDSKSetMethodImplementationFromSelector(aClass, aSelector, 
impSelector, YES, BDSKReplaceOnly);
-}
-
-void BDSKAddInstanceMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector) {
-    BDSKSetMethodImplementationFromSelector(aClass, aSelector, impSelector, 
YES, BDSKAddOnly);
-}
-
-IMP BDSKReplaceClassMethodImplementation(Class aClass, SEL aSelector, IMP 
anImp) {
-    return BDSKSetMethodImplementation(aClass, aSelector, anImp, NULL, NO, 
BDSKReplaceOnly);
-}
-
-void BDSKAddClassMethodImplementation(Class aClass, SEL aSelector, IMP anImp, 
const char *types) {
-    BDSKSetMethodImplementation(aClass, aSelector, anImp, types, NO, 
BDSKAddOnly);
-}
-
-IMP BDSKReplaceClassMethodImplementationFromSelector(Class aClass, SEL 
aSelector, SEL impSelector) {
-    return BDSKSetMethodImplementationFromSelector(aClass, aSelector, 
impSelector, NO, BDSKReplaceOnly);
-}
-
-void BDSKAddClassMethodImplementationFromSelector(Class aClass, SEL aSelector, 
SEL impSelector) {
-    BDSKSetMethodImplementationFromSelector(aClass, aSelector, impSelector, 
NO, BDSKAddOnly);
-}
-
 void BDSKRequestConcreteImplementation(id self, SEL aSelector) {
     BDSKASSERT_NOT_REACHED("Concrete implementation needed");
     [NSException raise:BDSKAbstractImplementationException format:@"%@ needs a 
concrete implementation of %@%@", [self class], [self class] == self ? @"+" : 
@"-", NSStringFromSelector(aSelector)];

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to