Skip to content
Permalink
Browse files

Reduce fileprivate usage

  • Loading branch information...
MortyMerr authored and freak4pc committed Jul 1, 2019
1 parent 01f927a commit 6e175add1e9c363ac0315d18574164c7e6174959
Showing with 188 additions and 188 deletions.
  1. +1 −1 Platform/DataStructures/Bag.swift
  2. +1 −1 Platform/DataStructures/PriorityQueue.swift
  3. +2 −2 RxBlocking/BlockingObservable+Operators.swift
  4. +3 −3 RxCocoa/Common/DelegateProxy.swift
  5. +4 −4 RxCocoa/Common/DelegateProxyType.swift
  6. +8 −8 RxCocoa/Foundation/NSObject+Rx.swift
  7. +1 −1 RxCocoa/Foundation/URLSession+Rx.swift
  8. +3 −3 RxCocoa/iOS/Proxies/RxCollectionViewDataSourcePrefetchingProxy.swift
  9. +2 −2 RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift
  10. +2 −2 RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift
  11. +3 −3 RxCocoa/iOS/Proxies/RxTableViewDataSourcePrefetchingProxy.swift
  12. +3 −3 RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift
  13. +1 −1 RxCocoa/iOS/UIBarButtonItem+Rx.swift
  14. +2 −2 RxExample/Extensions/CLLocationManager+Rx.swift
  15. +1 −1 RxExample/Extensions/UIImagePickerController+Rx.swift
  16. +1 −1 RxExample/RxDataSources/Differentiator/Diff.swift
  17. +4 −4 RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift
  18. +2 −2 RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift
  19. +2 −2 RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift
  20. +1 −1 RxExample/RxExample/Feedbacks.swift
  21. +6 −6 RxExample/RxExample/Services/Reachability.swift
  22. +1 −1 RxSwift/Deprecated.swift
  23. +2 −2 RxSwift/Disposables/AnonymousDisposable.swift
  24. +2 −2 RxSwift/Disposables/DisposeBag.swift
  25. +2 −2 RxSwift/Disposables/NopDisposable.swift
  26. +1 −1 RxSwift/Disposables/SingleAssignmentDisposable.swift
  27. +3 −3 RxSwift/ObservableType+Extensions.swift
  28. +2 −2 RxSwift/Observables/Amb.swift
  29. +2 −2 RxSwift/Observables/AsMaybe.swift
  30. +2 −2 RxSwift/Observables/AsSingle.swift
  31. +1 −1 RxSwift/Observables/Create.swift
  32. +3 −3 RxSwift/Observables/Debug.swift
  33. +1 −1 RxSwift/Observables/Dematerialize.swift
  34. +1 −1 RxSwift/Observables/DistinctUntilChanged.swift
  35. +6 −6 RxSwift/Observables/Do.swift
  36. +2 −2 RxSwift/Observables/First.swift
  37. +1 −1 RxSwift/Observables/Map.swift
  38. +1 −1 RxSwift/Observables/Materialize.swift
  39. +7 −7 RxSwift/Observables/Merge.swift
  40. +3 −3 RxSwift/Observables/Multicast.swift
  41. +1 −1 RxSwift/Observables/ObserveOn.swift
  42. +2 −2 RxSwift/Observables/Producer.swift
  43. +1 −1 RxSwift/Observables/Reduce.swift
  44. +6 −6 RxSwift/Observables/RetryWhen.swift
  45. +3 −3 RxSwift/Observables/Sample.swift
  46. +3 −3 RxSwift/Observables/Scan.swift
  47. +5 −5 RxSwift/Observables/ShareReplayScope.swift
  48. +2 −2 RxSwift/Observables/SingleAsync.swift
  49. +2 −2 RxSwift/Observables/Sink.swift
  50. +3 −3 RxSwift/Observables/SkipUntil.swift
  51. +3 −3 RxSwift/Observables/SkipWhile.swift
  52. +9 −9 RxSwift/Observables/Switch.swift
  53. +2 −2 RxSwift/Observables/Take.swift
  54. +1 −1 RxSwift/Observables/TakeLast.swift
  55. +5 −5 RxSwift/Observables/TakeUntil.swift
  56. +3 −3 RxSwift/Observables/TakeWhile.swift
  57. +2 −2 RxSwift/Observables/WithLatestFrom.swift
  58. +1 −1 RxSwift/Rx.swift
  59. +1 −1 RxSwift/Schedulers/CurrentThreadScheduler.swift
  60. +1 −1 RxSwift/Schedulers/VirtualTimeScheduler.swift
  61. +1 −1 RxSwift/Subjects/AsyncSubject.swift
  62. +1 −1 RxSwift/Subjects/BehaviorSubject.swift
  63. +1 −1 RxSwift/Subjects/PublishSubject.swift
  64. +3 −3 RxSwift/Subjects/ReplaySubject.swift
  65. +2 −2 RxTest/TestableObserver.swift
  66. +6 −6 Tests/Microoptimizations/PerformanceTools.swift
  67. +13 −13 Tests/RxCocoaTests/DelegateProxyTest+UIKit.swift
  68. +1 −1 Tests/RxCocoaTests/NSTextField+RxTests.swift
  69. +1 −1 Tests/RxCocoaTests/NSTextView+RxTests.swift
  70. +1 −1 Tests/RxCocoaTests/RuntimeStateSnapshot.swift
  71. +1 −1 Tests/RxCocoaTests/UIControl+RxTests.swift
  72. +1 −1 Tests/RxCocoaTests/UIWebView+RxTests.swift
  73. +1 −1 Tests/RxSwiftTests/AtomicTests.swift
  74. +1 −1 Tests/RxSwiftTests/Observable+MaterializeTests.swift
  75. +1 −1 Tests/RxSwiftTests/RecursiveLockTest.swift
  76. +1 −1 Tests/RxTest.swift
@@ -35,7 +35,7 @@ struct Bag<T> : CustomDebugStringConvertible {

typealias Entry = (key: BagKey, value: T)

fileprivate var _nextKey: BagKey = BagKey(rawValue: 0)
private var _nextKey: BagKey = BagKey(rawValue: 0)

// data
@@ -10,7 +10,7 @@ struct PriorityQueue<Element> {
private let _hasHigherPriority: (Element, Element) -> Bool
private let _isEqual: (Element, Element) -> Bool

fileprivate var _elements = [Element]()
private var _elements = [Element]()

init(hasHigherPriority: @escaping (Element, Element) -> Bool, isEqual: @escaping (Element, Element) -> Bool) {
_hasHigherPriority = hasHigherPriority
@@ -101,7 +101,7 @@ extension BlockingObservable {
}

extension BlockingObservable {
fileprivate func materializeResult(max: Int? = nil, predicate: @escaping (Element) throws -> Bool = { _ in true }) -> MaterializedSequenceResult<Element> {
private func materializeResult(max: Int? = nil, predicate: @escaping (Element) throws -> Bool = { _ in true }) -> MaterializedSequenceResult<Element> {
var elements = [Element]()
var error: Swift.Error?

@@ -159,7 +159,7 @@ extension BlockingObservable {
return MaterializedSequenceResult.completed(elements: elements)
}

fileprivate func elementsOrThrow(_ results: MaterializedSequenceResult<Element>) throws -> [Element] {
private func elementsOrThrow(_ results: MaterializedSequenceResult<Element>) throws -> [Element] {
switch results {
case .failed(_, let error):
throw error
@@ -26,8 +26,8 @@
/// Parent object associated with delegate proxy.
private weak var _parentObject: ParentObject?

fileprivate let _currentDelegateFor: (ParentObject) -> AnyObject?
fileprivate let _setCurrentDelegateTo: (AnyObject?, ParentObject) -> Void
private let _currentDelegateFor: (ParentObject) -> AnyObject?
private let _setCurrentDelegateTo: (AnyObject?, ParentObject) -> Void

/// Initializes new instance.
///
@@ -258,7 +258,7 @@

private let mainScheduler = MainScheduler()

fileprivate final class MessageDispatcher {
private final class MessageDispatcher {
private let dispatcher: PublishSubject<[Any]>
private let result: Observable<[Any]>

@@ -240,18 +240,18 @@ extension DelegateProxyType {
}


// fileprivate extensions
// private extensions
extension DelegateProxyType {
fileprivate static var factory: DelegateProxyFactory {
private static var factory: DelegateProxyFactory {
return DelegateProxyFactory.sharedFactory(for: self)
}

fileprivate static func assignedProxy(for object: ParentObject) -> AnyObject? {
private static func assignedProxy(for object: ParentObject) -> AnyObject? {
let maybeDelegate = objc_getAssociatedObject(object, self.identifier)
return castOptionalOrFatalError(maybeDelegate)
}

fileprivate static func assignProxy(_ proxy: AnyObject, toObject object: ParentObject) {
private static func assignProxy(_ proxy: AnyObject, toObject object: ParentObject) {
objc_setAssociatedObject(object, self.identifier, proxy, .OBJC_ASSOCIATION_RETAIN)
}
}
@@ -202,7 +202,7 @@ extension Reactive where Base: AnyObject {
}
}

fileprivate func registerMessageInterceptor<T: MessageInterceptorSubject>(_ selector: Selector) throws -> T {
private func registerMessageInterceptor<T: MessageInterceptorSubject>(_ selector: Selector) throws -> T {
let rxSelector = RX_selector(selector)
let selectorReference = RX_reference_from_selector(rxSelector)

@@ -251,7 +251,7 @@ extension Reactive where Base: AnyObject {
var targetImplementation: IMP { get set }
}

fileprivate final class DeallocatingProxy
private final class DeallocatingProxy
: MessageInterceptorSubject
, RXDeallocatingObserver {
typealias Element = ()
@@ -276,7 +276,7 @@ extension Reactive where Base: AnyObject {
}
}

fileprivate final class MessageSentProxy
private final class MessageSentProxy
: MessageInterceptorSubject
, RXMessageSentObserver {
typealias Element = [AnyObject]
@@ -310,7 +310,7 @@ extension Reactive where Base: AnyObject {
#endif


fileprivate final class DeallocObservable {
private final class DeallocObservable {
let _subject = ReplaySubject<Void>.create(bufferSize:1)

init() {
@@ -333,7 +333,7 @@ private protocol KVOObservableProtocol {
var options: KeyValueObservingOptions { get }
}

fileprivate final class KVOObserver
private final class KVOObserver
: _RXKVOObserver
, Disposable {
typealias Callback = (Any?) -> Void
@@ -361,7 +361,7 @@ fileprivate final class KVOObserver
}
}

fileprivate final class KVOObservable<Element>
private final class KVOObservable<Element>
: ObservableType
, KVOObservableProtocol {
typealias Element = Element?
@@ -397,7 +397,7 @@ fileprivate final class KVOObservable<Element>

}

fileprivate extension KeyValueObservingOptions {
private extension KeyValueObservingOptions {
var nsOptions: NSKeyValueObservingOptions {
var result: UInt = 0
if self.contains(.new) {
@@ -438,7 +438,7 @@ fileprivate extension KeyValueObservingOptions {
return properyRuntimeInfo.range(of: ",W,") != nil
}

fileprivate extension ObservableType where Element == AnyObject? {
private extension ObservableType where Element == AnyObject? {
func finishWithNilWhenDealloc(_ target: NSObject)
-> Observable<AnyObject?> {
let deallocating = target.rx.deallocating
@@ -60,7 +60,7 @@ private func escapeTerminalString(_ value: String) -> String {
return value.replacingOccurrences(of: "\"", with: "\\\"", options:[], range: nil)
}

fileprivate func convertURLRequestToCurlCommand(_ request: URLRequest) -> String {
private func convertURLRequestToCurlCommand(_ request: URLRequest) -> String {
let method = request.httpMethod ?? "GET"
var returnValue = "curl -X \(method) "

@@ -17,10 +17,10 @@ extension UICollectionView: HasPrefetchDataSource {
}

@available(iOS 10.0, tvOS 10.0, *)
fileprivate let collectionViewPrefetchDataSourceNotSet = CollectionViewPrefetchDataSourceNotSet()
private let collectionViewPrefetchDataSourceNotSet = CollectionViewPrefetchDataSourceNotSet()

@available(iOS 10.0, tvOS 10.0, *)
fileprivate final class CollectionViewPrefetchDataSourceNotSet
private final class CollectionViewPrefetchDataSourceNotSet
: NSObject
, UICollectionViewDataSourcePrefetching {

@@ -48,7 +48,7 @@ open class RxCollectionViewDataSourcePrefetchingProxy
self.register { RxCollectionViewDataSourcePrefetchingProxy(collectionView: $0) }
}

fileprivate var _prefetchItemsPublishSubject: PublishSubject<[IndexPath]>?
private var _prefetchItemsPublishSubject: PublishSubject<[IndexPath]>?

/// Optimized version used for observing prefetch items callbacks.
internal var prefetchItemsPublishSubject: PublishSubject<[IndexPath]> {
@@ -15,9 +15,9 @@ extension UICollectionView: HasDataSource {
public typealias DataSource = UICollectionViewDataSource
}

fileprivate let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()
private let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()

fileprivate final class CollectionViewDataSourceNotSet
private final class CollectionViewDataSourceNotSet
: NSObject
, UICollectionViewDataSource {

@@ -38,8 +38,8 @@ open class RxScrollViewDelegateProxy
self.register { RxTextViewDelegateProxy(textView: $0) }
}

fileprivate var _contentOffsetBehaviorSubject: BehaviorSubject<CGPoint>?
fileprivate var _contentOffsetPublishSubject: PublishSubject<()>?
private var _contentOffsetBehaviorSubject: BehaviorSubject<CGPoint>?
private var _contentOffsetPublishSubject: PublishSubject<()>?

/// Optimized version used for observing content offset changes.
internal var contentOffsetBehaviorSubject: BehaviorSubject<CGPoint> {
@@ -17,10 +17,10 @@ extension UITableView: HasPrefetchDataSource {
}

@available(iOS 10.0, tvOS 10.0, *)
fileprivate let tableViewPrefetchDataSourceNotSet = TableViewPrefetchDataSourceNotSet()
private let tableViewPrefetchDataSourceNotSet = TableViewPrefetchDataSourceNotSet()

@available(iOS 10.0, tvOS 10.0, *)
fileprivate final class TableViewPrefetchDataSourceNotSet
private final class TableViewPrefetchDataSourceNotSet
: NSObject
, UITableViewDataSourcePrefetching {

@@ -48,7 +48,7 @@ open class RxTableViewDataSourcePrefetchingProxy
self.register { RxTableViewDataSourcePrefetchingProxy(tableView: $0) }
}

fileprivate var _prefetchRowsPublishSubject: PublishSubject<[IndexPath]>?
private var _prefetchRowsPublishSubject: PublishSubject<[IndexPath]>?

/// Optimized version used for observing prefetch rows callbacks.
internal var prefetchRowsPublishSubject: PublishSubject<[IndexPath]> {
@@ -15,9 +15,9 @@ extension UITableView: HasDataSource {
public typealias DataSource = UITableViewDataSource
}

fileprivate let tableViewDataSourceNotSet = TableViewDataSourceNotSet()
private let tableViewDataSourceNotSet = TableViewDataSourceNotSet()

fileprivate final class TableViewDataSourceNotSet
private final class TableViewDataSourceNotSet
: NSObject
, UITableViewDataSource {

@@ -50,7 +50,7 @@ open class RxTableViewDataSourceProxy
self.register { RxTableViewDataSourceProxy(tableView: $0) }
}

fileprivate weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet
private weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet

// MARK: delegate
@@ -11,7 +11,7 @@
import UIKit
import RxSwift

fileprivate var rx_tap_key: UInt8 = 0
private var rx_tap_key: UInt8 = 0

extension Reactive where Base: UIBarButtonItem {

@@ -207,15 +207,15 @@ extension Reactive where Base: CLLocationManager {
}


fileprivate func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
private func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
guard let returnValue = object as? T else {
throw RxCocoaError.castingError(object: object, targetType: resultType)
}

return returnValue
}

fileprivate func castOptionalOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T? {
private func castOptionalOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T? {
if NSNull().isEqual(object) {
return nil
}
@@ -39,7 +39,7 @@

#endif

fileprivate func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
private func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
guard let returnValue = object as? T else {
throw RxCocoaError.castingError(object: object, targetType: resultType)
}
@@ -8,7 +8,7 @@
import Foundation

fileprivate extension AnimatableSectionModelType {
private extension AnimatableSectionModelType {
init(safeOriginal: Self, safeItems: [Item]) throws {
self.init(original: safeOriginal, items: safeItems)

@@ -53,7 +53,7 @@ class GitHubSearchRepositoriesAPI {
// *****************************************************************************************
static let sharedAPI = GitHubSearchRepositoriesAPI(reachabilityService: try! DefaultReachabilityService())

fileprivate let _reachabilityService: ReachabilityService
private let _reachabilityService: ReachabilityService

private init(reachabilityService: ReachabilityService) {
_reachabilityService = reachabilityService
@@ -94,7 +94,7 @@ extension GitHubSearchRepositoriesAPI {
private static let parseLinksPattern = "\\s*,?\\s*<([^\\>]*)>\\s*;\\s*rel=\"([^\"]*)\""
private static let linksRegex = try! NSRegularExpression(pattern: parseLinksPattern, options: [.allowCommentsAndWhitespace])

fileprivate static func parseLinks(_ links: String) throws -> [String: String] {
private static func parseLinks(_ links: String) throws -> [String: String] {

let length = (links as NSString).length
let matches = GitHubSearchRepositoriesAPI.linksRegex.matches(in: links, options: NSRegularExpression.MatchingOptions(), range: NSRange(location: 0, length: length))
@@ -119,7 +119,7 @@ extension GitHubSearchRepositoriesAPI {
return result
}

fileprivate static func parseNextURL(_ httpResponse: HTTPURLResponse) throws -> URL? {
private static func parseNextURL(_ httpResponse: HTTPURLResponse) throws -> URL? {
guard let serializedLinks = httpResponse.allHeaderFields["Link"] as? String else {
return nil
}
@@ -137,7 +137,7 @@ extension GitHubSearchRepositoriesAPI {
return nextUrl
}

fileprivate static func parseJSON(_ httpResponse: HTTPURLResponse, data: Data) throws -> AnyObject {
private static func parseJSON(_ httpResponse: HTTPURLResponse, data: Data) throws -> AnyObject {
if !(200 ..< 300 ~= httpResponse.statusCode) {
throw exampleError("Call failed")
}
@@ -10,8 +10,8 @@ import UIKit
import RxSwift
import RxCocoa

fileprivate let minimalUsernameLength = 5
fileprivate let minimalPasswordLength = 5
private let minimalUsernameLength = 5
private let minimalPasswordLength = 5

class SimpleValidationViewController : ViewController {

@@ -72,7 +72,7 @@ public class WikipediaSearchCell: UITableViewCell {

}

fileprivate protocol ReusableView: class {
private protocol ReusableView: class {
var disposeBag: DisposeBag? { get }
func prepareForReuse()
}
@@ -85,7 +85,7 @@ extension CollectionViewImageCell : ReusableView {

}

fileprivate extension ReusableView {
private extension ReusableView {
func installHackBecauseOfAutomationLeaksOnIOS10(firstViewThatDoesntLeak: UIView) {
if #available(iOS 10.0, *) {
if OSApplication.isInUITest {
@@ -281,7 +281,7 @@ extension Observable {
- `events` map events from UI to events of a given system.
*/
public class Bindings<Event>: Disposable {
fileprivate let subscriptions: [Disposable]
private let subscriptions: [Disposable]
fileprivate let events: [Observable<Event>]

/**

0 comments on commit 6e175ad

Please sign in to comment.
You can’t perform that action at this time.