File tree Expand file tree Collapse file tree
Sources/InterposeKit/Hooks Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import Foundation
1+ import ObjectiveC
22
33/// A runtime hook that interposes a single instance method on a class or object.
44public final class Hook {
@@ -39,7 +39,7 @@ public final class Hook {
3939 func makeStrategy( _ hook: Hook ) throws -> HookStrategy {
4040 let hookProxy = HookProxy (
4141 selector: selector,
42- originalProvider : {
42+ getOriginal : {
4343 unsafeBitCast (
4444 self . originalIMP,
4545 to: MethodSignature . self
@@ -169,6 +169,51 @@ extension Hook {
169169 }
170170}
171171
172+ public typealias HookBuilder < MethodSignature, HookSignature> = ( HookProxy < MethodSignature > ) -> HookSignature
173+
174+ public final class HookProxy < MethodSignature> {
175+
176+ internal init (
177+ selector: Selector ,
178+ getOriginal: @escaping ( ) -> MethodSignature
179+ ) {
180+ self . selector = selector
181+ self . _getOriginal = getOriginal
182+ }
183+
184+ public let selector : Selector
185+
186+ private let _getOriginal : ( ) -> MethodSignature
187+
188+ public var original : MethodSignature {
189+ self . _getOriginal ( )
190+ }
191+
192+ }
193+
194+ public enum HookScope {
195+
196+ /// The scope that targets all instances of the class.
197+ case `class`
198+
199+ /// The scope that targets a specific instance of the class.
200+ case object( AnyObject )
201+
202+ }
203+
204+ public enum HookState : Equatable {
205+
206+ /// The hook is ready to be applied.
207+ case pending
208+
209+ /// The hook has been successfully applied.
210+ case active
211+
212+ /// The hook failed to apply.
213+ case failed
214+
215+ }
216+
172217fileprivate enum HookTarget {
173218 case `class`( AnyClass )
174219 case object( AnyObject )
You can’t perform that action at this time.
0 commit comments