Skip to content

Commit b02ae63

Browse files
committed
Minor tweaks to internal ITKSuperBuilder target
1 parent ebd0d6e commit b02ae63

File tree

5 files changed

+14
-26
lines changed

5 files changed

+14
-26
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ let package = Package(
1717
),
1818
],
1919
targets: [
20-
.target(name: "SuperBuilder"),
20+
.target(name: "ITKSuperBuilder"),
2121
.target(
2222
name: "InterposeKit",
23-
dependencies: ["SuperBuilder"]
23+
dependencies: ["ITKSuperBuilder"]
2424
),
2525
.testTarget(
2626
name: "InterposeKitTests",

Sources/SuperBuilder/include/ITKSuperBuilder.h renamed to Sources/ITKSuperBuilder/include/ITKSuperBuilder.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ There are a few important details:
4444
4545
@see https://steipete.com/posts/calling-super-at-runtime/
4646
*/
47-
@interface SuperBuilder : NSObject
47+
@interface ITKSuperBuilder : NSObject
4848

4949
/// Adds an empty super implementation instance method to originalClass.
5050
/// If a method already exists, this will return NO and a descriptive error message.
51-
+ (BOOL)addSuperInstanceMethodToClass:(Class)originalClass selector:(SEL)selector error:(NSError **)error;
51+
+ (BOOL)addSuperInstanceMethodToClass:(Class)originalClass
52+
selector:(SEL)selector
53+
error:(NSError **)error;
5254

5355
/// Check if the instance method in `originalClass` is a super trampoline.
5456
+ (BOOL)isSuperTrampolineForClass:(Class)originalClass selector:(SEL)selector;
@@ -63,9 +65,9 @@ There are a few important details:
6365

6466
@end
6567

66-
NSString *const SuperBuilderErrorDomain;
68+
NSString *const ITKSuperBuilderErrorDomain;
6769

68-
typedef NS_ERROR_ENUM(SuperBuilderErrorDomain, SuperBuilderErrorCode) {
70+
typedef NS_ERROR_ENUM(ITKSuperBuilderErrorDomain, ITKSuperBuilderErrorCode) {
6971
SuperBuilderErrorCodeArchitectureNotSupported,
7072
SuperBuilderErrorCodeNoSuperClass,
7173
SuperBuilderErrorCodeNoDynamicallyDispatchedMethodAvailable,

Sources/SuperBuilder/src/ITKSuperBuilder.m renamed to Sources/ITKSuperBuilder/src/ITKSuperBuilder.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
NS_ASSUME_NONNULL_BEGIN
88

9-
NSString *const SuperBuilderErrorDomain = @"com.steipete.superbuilder";
9+
NSString *const ITKSuperBuilderErrorDomain = @"com.steipete.InterposeKit";
1010

1111
void msgSendSuperTrampoline(void);
1212
void msgSendSuperStretTrampoline(void);
@@ -37,9 +37,9 @@ static IMP ITKGetTrampolineForTypeEncoding(__unused const char *typeEncoding) {
3737
}
3838

3939
#define ERROR_AND_RETURN(CODE, STRING)\
40-
if (error) { *error = [NSError errorWithDomain:SuperBuilderErrorDomain code:CODE userInfo:@{NSLocalizedDescriptionKey: STRING}];} return NO;
40+
if (error) { *error = [NSError errorWithDomain:ITKSuperBuilderErrorDomain code:CODE userInfo:@{NSLocalizedDescriptionKey: STRING}];} return NO;
4141

42-
@implementation SuperBuilder
42+
@implementation ITKSuperBuilder
4343

4444
+ (BOOL)isSupportedArchitecture {
4545
#if defined (__arm64__) || defined (__x86_64__)

Sources/InterposeKit/InterposeKit.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

Sources/InterposeKit/InterposeSubclass.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import SuperBuilder
2+
import ITKSuperBuilder
33

44
class InterposeSubclass {
55

@@ -86,12 +86,12 @@ class InterposeSubclass {
8686
}
8787

8888
class var supportsSuperTrampolines: Bool {
89-
NSClassFromString("SuperBuilder")?.value(forKey: "isSupportedArchitecture") as? Bool ?? false
89+
ITKSuperBuilder.isSupportedArchitecture
9090
}
9191

9292
func addSuperTrampoline(selector: Selector) {
9393
do {
94-
try SuperBuilder.addSuperInstanceMethod(to: dynamicClass, selector: selector)
94+
try ITKSuperBuilder.addSuperInstanceMethod(to: dynamicClass, selector: selector)
9595

9696
let imp = class_getMethodImplementation(dynamicClass, selector)!
9797
Interpose.log("Added super for -[\(dynamicClass).\(selector)]: \(imp)")

0 commit comments

Comments
 (0)