Revision: 14895
http://sourceforge.net/p/skim-app/code/14895
Author: hofman
Date: 2025-01-28 15:30:34 +0000 (Tue, 28 Jan 2025)
Log Message:
-----------
Implement adding a method implementation directly using class_addMethod.
Simplify functions to replace method implementations.
Modified Paths:
--------------
trunk/PDFDocumentView_SKExtensions.m
trunk/SKRuntime.h
trunk/SKRuntime.m
Modified: trunk/PDFDocumentView_SKExtensions.m
===================================================================
--- trunk/PDFDocumentView_SKExtensions.m 2025-01-28 10:36:19 UTC (rev
14894)
+++ trunk/PDFDocumentView_SKExtensions.m 2025-01-28 15:30:34 UTC (rev
14895)
@@ -157,9 +157,9 @@
if ([PDFDocumentViewClass instancesRespondToSelector:@selector(pdfView)]
== NO) {
if (class_getInstanceVariable(PDFDocumentViewClass, "_private"))
- SKAddInstanceMethodImplementation(PDFDocumentViewClass,
@selector(pdfView), (IMP)fallback_ivar_pdfView, "@@:");
+ class_addMethod(PDFDocumentViewClass, @selector(pdfView),
(IMP)fallback_ivar_pdfView, "@@:");
else
- SKAddInstanceMethodImplementation(PDFDocumentViewClass,
@selector(pdfView), (IMP)fallback_pdfView, "@@:");
+ class_addMethod(PDFDocumentViewClass, @selector(pdfView),
(IMP)fallback_pdfView, "@@:");
}
original_updateTrackingAreas = (void (*)(id,
SEL))SKReplaceInstanceMethodImplementation(PDFDocumentViewClass,
@selector(updateTrackingAreas), (IMP)replacement_updateTrackingAreas);
Modified: trunk/SKRuntime.h
===================================================================
--- trunk/SKRuntime.h 2025-01-28 10:36:19 UTC (rev 14894)
+++ trunk/SKRuntime.h 2025-01-28 15:30:34 UTC (rev 14895)
@@ -41,15 +41,11 @@
NS_ASSUME_NONNULL_BEGIN
extern IMP _Nullable SKReplaceInstanceMethodImplementation(Class aClass, SEL
aSelector, IMP anImp);
-extern void SKAddInstanceMethodImplementation(Class aClass, SEL aSelector, IMP
anImp, const char *types);
extern IMP _Nullable SKReplaceInstanceMethodImplementationFromSelector(Class
aClass, SEL aSelector, SEL impSelector);
-extern void SKAddInstanceMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector);
extern IMP _Nullable SKReplaceClassMethodImplementation(Class aClass, SEL
aSelector, IMP anImp);
-extern void SKAddClassMethodImplementation(Class aClass, SEL aSelector, IMP
anImp, const char *types);
extern IMP _Nullable SKReplaceClassMethodImplementationFromSelector(Class
aClass, SEL aSelector, SEL impSelector);
-extern void SKAddClassMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector);
NS_ASSUME_NONNULL_END
Modified: trunk/SKRuntime.m
===================================================================
--- trunk/SKRuntime.m 2025-01-28 10:36:19 UTC (rev 14894)
+++ trunk/SKRuntime.m 2025-01-28 15:30:34 UTC (rev 14895)
@@ -42,54 +42,27 @@
enum { SKAddOrReplace, SKReplaceOnly, SKAddOnly };
// this is essentially class_replaceMethod, but returns any inherited
implementation, and can get the types from an inherited implementation
-IMP SKSetMethodImplementation(Class aClass, SEL aSelector, IMP anImp, const
char *types, NSInteger options) {
+IMP SKReplaceInstanceMethodImplementation(Class aClass, SEL aSelector, IMP
anImp) {
IMP imp = NULL;
if (anImp) {
Method method = class_getInstanceMethod(aClass, aSelector);
if (method) {
imp = method_getImplementation(method);
- if (types == NULL)
- types = method_getTypeEncoding(method);
+ class_replaceMethod(aClass, aSelector, anImp,
method_getTypeEncoding(method));
}
- if (types != NULL && (options != SKAddOnly || imp == NULL) && (options
!= SKReplaceOnly || imp != NULL))
- class_replaceMethod(aClass, aSelector, anImp, types);
}
return imp;
}
-IMP SKSetMethodImplementationFromSelector(Class aClass, SEL aSelector, SEL
impSelector, NSInteger options) {
+IMP SKReeplaceInstanceMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector) {
Method method = class_getInstanceMethod(aClass, impSelector);
- return method ? SKSetMethodImplementation(aClass, aSelector,
method_getImplementation(method), method_getTypeEncoding(method), options) :
NULL;
+ return method ? SKReplaceInstanceMethodImplementation(aClass, aSelector,
method_getImplementation(method)) : NULL;
}
-IMP SKReplaceInstanceMethodImplementation(Class aClass, SEL aSelector, IMP
anImp) {
- return SKSetMethodImplementation(aClass, aSelector, anImp, NULL,
SKReplaceOnly);
-}
-
-void SKAddInstanceMethodImplementation(Class aClass, SEL aSelector, IMP anImp,
const char *types) {
- SKSetMethodImplementation(aClass, aSelector, anImp, types, SKAddOnly);
-}
-
-IMP SKReplaceInstanceMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector) {
- return SKSetMethodImplementationFromSelector(aClass, aSelector,
impSelector, SKReplaceOnly);
-}
-
-void SKAddInstanceMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector) {
- SKSetMethodImplementationFromSelector(aClass, aSelector, impSelector,
SKAddOnly);
-}
-
IMP SKReplaceClassMethodImplementation(Class aClass, SEL aSelector, IMP anImp)
{
- return SKSetMethodImplementation(object_getClass(aClass), aSelector,
anImp, NULL, SKReplaceOnly);
+ return SKReplaceInstanceMethodImplementation(object_getClass(aClass),
aSelector, anImp);
}
-void SKAddClassMethodImplementation(Class aClass, SEL aSelector, IMP anImp,
const char *types) {
- SKSetMethodImplementation(object_getClass(aClass), aSelector, anImp,
types, SKAddOnly);
-}
-
IMP SKReplaceClassMethodImplementationFromSelector(Class aClass, SEL
aSelector, SEL impSelector) {
- return SKSetMethodImplementationFromSelector(object_getClass(aClass),
aSelector, impSelector, SKReplaceOnly);
+ return
SKReplaceInstanceMethodImplementationFromSelector(object_getClass(aClass),
aSelector, impSelector);
}
-
-void SKAddClassMethodImplementationFromSelector(Class aClass, SEL aSelector,
SEL impSelector) {
- SKSetMethodImplementationFromSelector(object_getClass(aClass), aSelector,
impSelector, SKAddOnly);
-}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit