Skip to content

Commit

Permalink
Simplifies DelegateProxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzaher committed Sep 16, 2017
1 parent f61ecc7 commit d1bc89b
Show file tree
Hide file tree
Showing 24 changed files with 232 additions and 327 deletions.
10 changes: 0 additions & 10 deletions Rx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,6 @@
D2138C881BB9BEBE00339B5C /* DelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093E8B1B8A732E0088E94D /* DelegateProxy.swift */; };
D2138C891BB9BEBE00339B5C /* DelegateProxyType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093E8C1B8A732E0088E94D /* DelegateProxyType.swift */; };
D2138C991BB9BEEE00339B5C /* RxTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093E9C1B8A732E0088E94D /* RxTarget.swift */; };
D29E23191EF4B93D006E295D /* DelegateProxyFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */; };
D29E231A1EF4B93E006E295D /* DelegateProxyFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */; };
D29E231B1EF4B93E006E295D /* DelegateProxyFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */; };
D29E231C1EF4B93F006E295D /* DelegateProxyFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */; };
D2EBEADC1BB9B697003A27DC /* Cancelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C491B8A72BE0088E94D /* Cancelable.swift */; };
D2EBEADD1BB9B697003A27DC /* ConnectableObservableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C4D1B8A72BE0088E94D /* ConnectableObservableType.swift */; };
D2EBEADE1BB9B697003A27DC /* Disposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C521B8A72BE0088E94D /* Disposable.swift */; };
Expand Down Expand Up @@ -2198,7 +2194,6 @@
CB883B441BE256D4000AC2EE /* BooleanDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BooleanDisposable.swift; sourceTree = "<group>"; };
CDDEF1691D4FB40000CA8546 /* Disposables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disposables.swift; sourceTree = "<group>"; };
D2138C751BB9BE9800339B5C /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelegateProxyFactory.swift; sourceTree = "<group>"; };
D2EA280C1BB9B5A200880ED3 /* RxSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D2EBEB811BB9B99D003A27DC /* RxBlocking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxBlocking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D9080ACD1EA05A16002B433B /* RxNavigationControllerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxNavigationControllerDelegateProxy.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2585,7 +2580,6 @@
C80D338E1B91EF9E0014629D /* Observable+Bind.swift */,
C8093E8B1B8A732E0088E94D /* DelegateProxy.swift */,
C8093E8C1B8A732E0088E94D /* DelegateProxyType.swift */,
D29E23171EF4B92E006E295D /* DelegateProxyFactory.swift */,
C8093E9C1B8A732E0088E94D /* RxTarget.swift */,
C89AB1711DAAC1680065FBE6 /* ControlTarget.swift */,
C8BCD3F31C14B6D1005F1280 /* NSLayoutConstraint+Rx.swift */,
Expand Down Expand Up @@ -4141,7 +4135,6 @@
C882542B1B8A752B00B02D69 /* UIDatePicker+Rx.swift in Sources */,
C88254221B8A752B00B02D69 /* RxTableViewDataSourceProxy.swift in Sources */,
C8BCD3F41C14B6D1005F1280 /* NSLayoutConstraint+Rx.swift in Sources */,
D29E23191EF4B93D006E295D /* DelegateProxyFactory.swift in Sources */,
C882542C1B8A752B00B02D69 /* UIGestureRecognizer+Rx.swift in Sources */,
C89AB1D21DAAC3350065FBE6 /* ControlProperty+Driver.swift in Sources */,
C8093EE11B8A732E0088E94D /* DelegateProxy.swift in Sources */,
Expand Down Expand Up @@ -4216,7 +4209,6 @@
C8B0F71A1F530FE400548EBE /* PublishRelay.swift in Sources */,
C86781A61DB823B500B2029A /* NSSlider+Rx.swift in Sources */,
C89AB2231DAAC3350065FBE6 /* URLSession+Rx.swift in Sources */,
D29E231A1EF4B93E006E295D /* DelegateProxyFactory.swift in Sources */,
C86781A11DB823B500B2029A /* NSImageView+Rx.swift in Sources */,
C89AB2281DAAC33F0065FBE6 /* RxCocoa.swift in Sources */,
C8D132451C42D15E00B59FFF /* SectionedViewDataSourceType.swift in Sources */,
Expand Down Expand Up @@ -5367,7 +5359,6 @@
C8F0C03B1BBBFBB9001B112F /* UISearchBar+Rx.swift in Sources */,
C89AB2431DAAC3A60065FBE6 /* _RXDelegateProxy.m in Sources */,
C8F0C03C1BBBFBB9001B112F /* ItemEvents.swift in Sources */,
D29E231C1EF4B93F006E295D /* DelegateProxyFactory.swift in Sources */,
7EDBAEBF1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */,
C8F0C03D1BBBFBB9001B112F /* RxTableViewDataSourceType.swift in Sources */,
);
Expand Down Expand Up @@ -5431,7 +5422,6 @@
C89AB1751DAAC1680065FBE6 /* ControlTarget.swift in Sources */,
D203C4FB1BB9C53700D02D00 /* RxCollectionViewDelegateProxy.swift in Sources */,
D203C5031BB9C53E00D02D00 /* UIBarButtonItem+Rx.swift in Sources */,
D29E231B1EF4B93E006E295D /* DelegateProxyFactory.swift in Sources */,
C89AB1EC1DAAC3350065FBE6 /* SharedSequence+Operators+arity.swift in Sources */,
C85E6FC01F53025700C5681E /* SchedulerType+SharedSequence.swift in Sources */,
D203C4FC1BB9C53700D02D00 /* RxScrollViewDelegateProxy.swift in Sources */,
Expand Down
30 changes: 1 addition & 29 deletions RxCocoa/Common/DelegateProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#endif
#endif

let delegateAssociatedTag: UnsafeRawPointer = UnsafeRawPointer(UnsafeMutablePointer<UInt8>.allocate(capacity: 1))
let dataSourceAssociatedTag: UnsafeRawPointer = UnsafeRawPointer(UnsafeMutablePointer<UInt8>.allocate(capacity: 1))

/// Base class for `DelegateProxyType` protocol.
///
/// This implementation is not thread safe and can be used only from one thread (Main thread).
Expand All @@ -34,7 +31,7 @@ open class DelegateProxy<P: AnyObject, D: NSObjectProtocol>: _RXDelegateProxy {
/// Initializes new instance.
///
/// - parameter parentObject: Optional parent object that owns `DelegateProxy` as associated object.
public required init(parentObject: ParentObject) {
public init(parentObject: ParentObject) {
self.parentObject = parentObject

MainScheduler.ensureExecutingOnScheduler()
Expand Down Expand Up @@ -183,31 +180,6 @@ open class DelegateProxy<P: AnyObject, D: NSObjectProtocol>: _RXDelegateProxy {
methodInvokedForSelector[selector]?.on(.next(arguments))
}

/// Returns tag used to identify associated object.
///
/// - returns: Associated object tag.
open class func delegateAssociatedObjectTag() -> UnsafeRawPointer {
return delegateAssociatedTag
}

/// Returns assigned proxy for object.
///
/// - parameter object: Object that can have assigned delegate proxy.
/// - returns: Assigned delegate proxy or `nil` if no delegate proxy is assigned.
open class func assignedProxy(for object: ParentObject) -> Delegate? {
let maybeDelegate = objc_getAssociatedObject(object, self.delegateAssociatedObjectTag())
return castOptionalOrFatalError(maybeDelegate.map { $0 as AnyObject })
}

/// Assigns proxy to object.
///
/// - parameter object: Object that can have assigned delegate proxy.
/// - parameter proxy: Delegate proxy object to assign to `object`.
open class func assignProxy(_ proxy: Delegate, toObject object: ParentObject) {
objc_setAssociatedObject(object, self.delegateAssociatedObjectTag(), proxy, .OBJC_ASSOCIATION_RETAIN)
}


/// Returns designated delegate property for object.
///
/// Objects can have multiple delegate properties.
Expand Down
100 changes: 0 additions & 100 deletions RxCocoa/Common/DelegateProxyFactory.swift

This file was deleted.

Loading

0 comments on commit d1bc89b

Please sign in to comment.