Update outdated pods.

This commit is contained in:
Qiu Yuzhou
2017-03-20 21:26:25 +08:00
parent 5f97493f1d
commit 975b544078
209 changed files with 4395 additions and 2293 deletions

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import Swift
let arrayDictionaryMaxSize = 30
@ -44,6 +43,9 @@ struct Bag<T> : CustomDebugStringConvertible {
var _key0: BagKey? = nil
var _value0: T? = nil
// then fill "array dictionary"
var _pairs = ContiguousArray<Entry>()
// last is sparse dictionary
var _dictionary: [BagKey : T]? = nil
@ -77,6 +79,11 @@ struct Bag<T> : CustomDebugStringConvertible {
return key
}
if _pairs.count < arrayDictionaryMaxSize {
_pairs.append(key: key, value: element)
return key
}
if _dictionary == nil {
_dictionary = [:]
}
@ -89,7 +96,7 @@ struct Bag<T> : CustomDebugStringConvertible {
/// - returns: Number of elements in bag.
var count: Int {
let dictionaryCount: Int = _dictionary?.count ?? 0
return (_value0 != nil ? 1 : 0) + dictionaryCount
return (_value0 != nil ? 1 : 0) + _pairs.count + dictionaryCount
}
/// Removes all elements from bag and clears capacity.
@ -97,6 +104,7 @@ struct Bag<T> : CustomDebugStringConvertible {
_key0 = nil
_value0 = nil
_pairs.removeAll(keepingCapacity: false)
_dictionary?.removeAll(keepingCapacity: false)
}
@ -118,6 +126,14 @@ struct Bag<T> : CustomDebugStringConvertible {
return existingObject
}
for i in 0 ..< _pairs.count {
if _pairs[i].key == key {
let value = _pairs[i].value
_pairs.remove(at: i)
return value
}
}
return nil
}
}
@ -148,6 +164,10 @@ extension Bag {
action(value0)
}
for i in 0 ..< _pairs.count {
action(_pairs[i].value)
}
if dictionary?.count ?? 0 > 0 {
for element in dictionary!.values {
action(element)

View File

@ -6,8 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
/// Sequence that repeats `repeatedValue` infinite number of times.
struct InfiniteSequence<E> : Sequence {
typealias Element = E

View File

@ -6,8 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
struct PriorityQueue<Element> {
private let _hasHigherPriority: (Element, Element) -> Bool
private let _isEqual: (Element, Element) -> Bool

View File

@ -6,8 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
/**
Data structure that represents queue.

View File

@ -6,7 +6,6 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
import Dispatch
extension DispatchQueue {

View File

@ -9,17 +9,34 @@
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
import Darwin
import Foundation
import class Foundation.Thread
import func Foundation.OSAtomicCompareAndSwap32Barrier
import func Foundation.OSAtomicIncrement32Barrier
import func Foundation.OSAtomicDecrement32Barrier
import protocol Foundation.NSCopying
typealias AtomicInt = Int32
fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer<Int32>) -> UnsafeMutablePointer<UInt32> {
let raw = UnsafeMutableRawPointer(pointer)
return raw.assumingMemoryBound(to: UInt32.self)
}
let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier
let AtomicIncrement = OSAtomicIncrement32Barrier
let AtomicDecrement = OSAtomicDecrement32Barrier
func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer<Int32>) -> Int32 {
return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue))
}
func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer<Int32>) -> Bool {
// just used to create a barrier
OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue))
return (theValue.pointee & Int32(mask)) != 0
}
extension Thread {
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: String
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: NSCopying
) {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary
@ -32,7 +49,7 @@
}
}
static func getThreadLocalStorageValueForKey<T>(_ key: String) -> T? {
static func getThreadLocalStorageValueForKey<T>(_ key: NSCopying) -> T? {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary

View File

@ -7,20 +7,16 @@
//
#if os(Linux)
////////////////////////////////////////////////////////////////////////////////
// This is not the greatest API in the world, this is just a tribute.
// !!! Proof of concept until libdispatch becomes operational. !!!
////////////////////////////////////////////////////////////////////////////////
import Foundation
import XCTest
import Glibc
import SwiftShims
import class Foundation.Thread
final class AtomicInt {
typealias IntegerLiteralType = Int
fileprivate var value: Int32 = 0
fileprivate var _lock = NSRecursiveLock()
fileprivate var _lock = RecursiveLock()
func lock() {
_lock.lock()
@ -48,6 +44,18 @@
return lhs.value == rhs
}
func AtomicFlagSet(_ mask: UInt32, _ atomic: inout AtomicInt) -> Bool {
atomic.lock(); defer { atomic.unlock() }
return (atomic.value & Int32(mask)) != 0
}
func AtomicOr(_ mask: UInt32, _ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
let value = atomic.value
atomic.value |= Int32(mask)
return value
}
func AtomicIncrement(_ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
atomic.value += 1

View File

@ -0,0 +1,34 @@
//
// RecursiveLock.swift
// Platform
//
// Created by Krunoslav Zaher on 12/18/16.
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if TRACE_RESOURCES
class RecursiveLock: NSRecursiveLock {
override init() {
_ = Resources.incrementTotal()
super.init()
}
override func lock() {
super.lock()
_ = Resources.incrementTotal()
}
override func unlock() {
super.unlock()
_ = Resources.decrementTotal()
}
deinit {
_ = Resources.decrementTotal()
}
}
#else
typealias RecursiveLock = NSRecursiveLock
#endif

16
Pods/RxCocoa/README.md generated
View File

@ -45,7 +45,7 @@ KVO observing, async operations and streams are all unified under [abstraction o
###### ... interact
* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences. <br />[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://rxswift-slack.herokuapp.com)
* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences. <br />[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://rxswift-slack.herokuapp.com/) [Join Slack Channel](http://rxswift-slack.herokuapp.com)
* Report a problem using the library. [Open an Issue With Bug Template](.github/ISSUE_TEMPLATE.md)
* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md)
@ -102,7 +102,7 @@ searchResults
cell.textLabel?.text = repository.name
cell.detailTextLabel?.text = repository.url
}
.addDisposableTo(disposeBag)</pre></div></td>
.disposed(by: disposeBag)</pre></div></td>
</tr>
</table>
@ -126,7 +126,7 @@ Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build ever
**Tested with `pod --version`: `1.1.1`**
```
```ruby
# Podfile
use_frameworks!
@ -144,7 +144,7 @@ end
Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type:
```
```bash
$ pod install
```
@ -158,7 +158,7 @@ Add this to `Cartfile`
github "ReactiveX/RxSwift" ~> 3.0
```
```
```bash
$ carthage update
```
@ -168,7 +168,7 @@ $ carthage update
Create a `Package.swift` file.
```
```swift
import PackageDescription
let package = Package(
@ -180,7 +180,7 @@ let package = Package(
)
```
```
```bash
$ swift build
```
@ -188,7 +188,7 @@ $ swift build
* Add RxSwift as a submodule
```
```bash
$ git submodule add git@github.com:ReactiveX/RxSwift.git
```

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
@ -72,6 +71,8 @@ public func driveOnScheduler(_ scheduler: SchedulerType, action: () -> ()) {
#if os(Linux)
import Glibc
#else
import func Foundation.arc4random
#endif
func _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(_ scheduler: SchedulerType) {

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -7,7 +7,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
@ -217,8 +216,51 @@ extension SharedSequenceConvertibleType {
}
// MARK: merge
extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy {
extension SharedSequenceConvertibleType {
/**
Merges elements from all observable sequences from collection into a single observable sequence.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of observable sequences to merge.
- returns: The observable sequence that merges the elements of the observable sequences.
*/
public static func merge<C: Collection>(_ sources: C) -> SharedSequence<SharingStrategy, E>
where C.Iterator.Element == SharedSequence<SharingStrategy, E> {
let source = Observable.merge(sources.map { $0.asObservable() })
return SharedSequence<SharingStrategy, E>(source)
}
/**
Merges elements from all observable sequences from array into a single observable sequence.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Array of observable sequences to merge.
- returns: The observable sequence that merges the elements of the observable sequences.
*/
public static func merge(_ sources: [SharedSequence<SharingStrategy, E>]) -> SharedSequence<SharingStrategy, E> {
let source = Observable.merge(sources.map { $0.asObservable() })
return SharedSequence<SharingStrategy, E>(source)
}
/**
Merges elements from all observable sequences into a single observable sequence.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of observable sequences to merge.
- returns: The observable sequence that merges the elements of the observable sequences.
*/
public static func merge(_ sources: SharedSequence<SharingStrategy, E>...) -> SharedSequence<SharingStrategy, E> {
let source = Observable.merge(sources.map { $0.asObservable() })
return SharedSequence<SharingStrategy, E>(source)
}
}
// MARK: merge
extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy {
/**
Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
@ -109,7 +108,7 @@ extension SharedSequence {
- returns: An observable sequence with no elements.
*/
public static func empty() -> SharedSequence<S, E> {
return SharedSequence(Observable.empty().subscribeOn(S.scheduler))
return SharedSequence(raw: Observable.empty().subscribeOn(S.scheduler))
}
/**
@ -118,7 +117,7 @@ extension SharedSequence {
- returns: An observable sequence whose observers will never get called.
*/
public static func never() -> SharedSequence<S, E> {
return SharedSequence(Observable.never())
return SharedSequence(raw: Observable.never())
}
/**
@ -128,7 +127,7 @@ extension SharedSequence {
- returns: An observable sequence containing the single specified element.
*/
public static func just(_ element: E) -> SharedSequence<S, E> {
return SharedSequence(Observable.just(element).subscribeOn(S.scheduler))
return SharedSequence(raw: Observable.just(element).subscribeOn(S.scheduler))
}
/**

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
import Dispatch
#if !RX_NO_MODULE
import RxSwift
@ -22,7 +21,7 @@ Observer that enforces interface binding rules:
In case event binding is attempted from non main dispatch queue, event binding will be dispatched async to main dispatch
queue.
*/
public class UIBindingObserver<UIElementType, Value> : ObserverType where UIElementType: AnyObject {
public final class UIBindingObserver<UIElementType, Value> : ObserverType where UIElementType: AnyObject {
public typealias E = Value
weak var UIElement: UIElementType?

View File

@ -8,7 +8,6 @@
#if os(iOS) || os(tvOS) || os(macOS)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
@ -25,7 +24,7 @@ import RxSwift
#endif
// This should be only used from `MainScheduler`
class ControlTarget: RxTarget {
final class ControlTarget: RxTarget {
typealias Callback = (Control) -> Void
let selector: Selector = #selector(ControlTarget.eventHandler(_:))

View File

@ -8,7 +8,6 @@
#if !os(Linux)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#if SWIFT_PACKAGE && !os(Linux)
@ -16,16 +15,16 @@ import Foundation
#endif
#endif
var delegateAssociatedTag: UInt8 = 0
var dataSourceAssociatedTag: UInt8 = 0
var delegateAssociatedTag: UnsafeRawPointer = UnsafeRawPointer(UnsafeMutablePointer<UInt8>.allocate(capacity: 1))
var 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).
open class DelegateProxy : _RXDelegateProxy {
private var sentMessageForSelector = [Selector: PublishSubject<[Any]>]()
private var methodInvokedForSelector = [Selector: PublishSubject<[Any]>]()
private var sentMessageForSelector = [Selector: MessageDispatcher]()
private var methodInvokedForSelector = [Selector: MessageDispatcher]()
/// Parent object associated with delegate proxy.
weak private(set) var parentObject: AnyObject?
@ -86,17 +85,18 @@ open class DelegateProxy : _RXDelegateProxy {
- returns: Observable sequence of arguments passed to `selector` method.
*/
open func sentMessage(_ selector: Selector) -> Observable<[Any]> {
MainScheduler.ensureExecutingOnScheduler()
checkSelectorIsObservable(selector)
let subject = sentMessageForSelector[selector]
if let subject = subject {
return subject
return subject.asObservable()
}
else {
let subject = PublishSubject<[Any]>()
let subject = MessageDispatcher(delegateProxy: self)
sentMessageForSelector[selector] = subject
return subject
return subject.asObservable()
}
}
@ -143,17 +143,18 @@ open class DelegateProxy : _RXDelegateProxy {
- returns: Observable sequence of arguments passed to `selector` method.
*/
open func methodInvoked(_ selector: Selector) -> Observable<[Any]> {
MainScheduler.ensureExecutingOnScheduler()
checkSelectorIsObservable(selector)
let subject = methodInvokedForSelector[selector]
if let subject = subject {
return subject
return subject.asObservable()
}
else {
let subject = PublishSubject<[Any]>()
let subject = MessageDispatcher(delegateProxy: self)
methodInvokedForSelector[selector] = subject
return subject
return subject.asObservable()
}
}
@ -162,15 +163,10 @@ open class DelegateProxy : _RXDelegateProxy {
if hasWiredImplementation(for: selector) {
print("Delegate proxy is already implementing `\(selector)`, a more performant way of registering might exist.")
return
}
// It's important to see if super class reponds to selector and not self,
// because super class (_RxDelegateProxy) returns all methods delegate proxy
// can respond to.
// Because of https://github.com/ReactiveX/RxSwift/issues/907 , and possibly
// some other reasons, subclasses could overrride `responds(to:)`, but it shouldn't matter
// for this case.
if !super.responds(to: selector) {
guard (self.forwardToDelegate()?.responds(to: selector) ?? false) || voidDelegateMethodsContain(selector) else {
rxFatalError("This class doesn't respond to selector \(selector)")
}
}
@ -189,7 +185,7 @@ open class DelegateProxy : _RXDelegateProxy {
///
/// - returns: Associated object tag.
open class func delegateAssociatedObjectTag() -> UnsafeRawPointer {
return _pointer(&delegateAssociatedTag)
return delegateAssociatedTag
}
/// Initializes new instance of delegate proxy.
@ -224,7 +220,11 @@ open class DelegateProxy : _RXDelegateProxy {
/// - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`.
/// - parameter retainDelegate: Should `self` retain `forwardToDelegate`.
open func setForwardToDelegate(_ delegate: AnyObject?, retainDelegate: Bool) {
#if DEBUG // 4.0 all configurations
MainScheduler.ensureExecutingOnScheduler()
#endif
self._setForward(toDelegate: delegate, retainDelegate: retainDelegate)
self.reset()
}
/// Returns reference of normal delegate that receives all forwarded messages
@ -234,7 +234,36 @@ open class DelegateProxy : _RXDelegateProxy {
open func forwardToDelegate() -> AnyObject? {
return self._forwardToDelegate
}
private func hasObservers(selector: Selector) -> Bool {
return (sentMessageForSelector[selector]?.hasObservers ?? false)
|| (methodInvokedForSelector[selector]?.hasObservers ?? false)
}
override open func responds(to aSelector: Selector!) -> Bool {
return super.responds(to: aSelector)
|| (self._forwardToDelegate?.responds(to: aSelector) ?? false)
|| (self.voidDelegateMethodsContain(aSelector) && self.hasObservers(selector: aSelector))
}
internal func reset() {
guard let delegateProxySelf = self as? DelegateProxyType else {
rxFatalErrorInDebug("\(self) doesn't implement delegate proxy type.")
return
}
guard let parentObject = self.parentObject else { return }
let selfType = type(of: delegateProxySelf)
let maybeCurrentDelegate = selfType.currentDelegateFor(parentObject)
if maybeCurrentDelegate === self {
selfType.setCurrentDelegate(nil, toObject: parentObject)
selfType.setCurrentDelegate(self, toObject: parentObject)
}
}
deinit {
for v in sentMessageForSelector.values {
v.on(.completed)
@ -246,13 +275,37 @@ open class DelegateProxy : _RXDelegateProxy {
_ = Resources.decrementTotal()
#endif
}
// MARK: Pointer
class func _pointer(_ p: UnsafeRawPointer) -> UnsafeRawPointer {
return p
}
}
#endif
fileprivate let mainScheduler = MainScheduler()
fileprivate final class MessageDispatcher {
private let dispatcher: PublishSubject<[Any]>
private let result: Observable<[Any]>
init(delegateProxy _delegateProxy: DelegateProxy) {
weak var weakDelegateProxy = _delegateProxy
let dispatcher = PublishSubject<[Any]>()
self.dispatcher = dispatcher
self.result = dispatcher
.do(onSubscribed: { weakDelegateProxy?.reset() }, onDispose: { weakDelegateProxy?.reset() })
.share()
.subscribeOn(mainScheduler)
}
var on: (Event<[Any]>) -> () {
return self.dispatcher.on
}
var hasObservers: Bool {
return self.dispatcher.hasObservers
}
func asObservable() -> Observable<[Any]> {
return self.result
}
}
#endif

View File

@ -8,7 +8,6 @@
#if !os(Linux)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
@ -177,7 +176,7 @@ extension DelegateProxyType {
assert(Self.currentDelegateFor(object) === proxy)
assert(proxy.forwardToDelegate() === currentDelegate)
}
return proxy
}
@ -201,19 +200,12 @@ extension DelegateProxyType {
proxy.setForwardToDelegate(forwardDelegate, retainDelegate: retainDelegate)
// refresh properties after delegate is set
// some views like UITableView cache `respondsToSelector`
Self.setCurrentDelegate(nil, toObject: object)
Self.setCurrentDelegate(proxy, toObject: object)
assert(proxy.forwardToDelegate() === forwardDelegate, "Setting of delegate failed:\ncurrent:\n\(proxy.forwardToDelegate())\nexpected:\n\(forwardDelegate)")
return Disposables.create {
MainScheduler.ensureExecutingOnScheduler()
let delegate: AnyObject? = weakForwardDelegate
assert(delegate == nil || proxy.forwardToDelegate() === delegate, "Delegate was changed from time it was first set. Current \(proxy.forwardToDelegate()), and it should have been \(proxy)")
assert(delegate == nil || proxy.forwardToDelegate() === delegate, "Delegate was changed from time it was first set. Current \(String(describing: proxy.forwardToDelegate())), and it should have been \(proxy)")
proxy.setForwardToDelegate(nil, retainDelegate: retainDelegate)
}
@ -243,7 +235,7 @@ extension DelegateProxyType {
.subscribe { [weak object] (event: Event<E>) in
if let object = object {
assert(proxy === P.currentDelegateFor(object), "Proxy changed from the time it was first set.\nOriginal: \(proxy)\nExisting: \(P.currentDelegateFor(object))")
assert(proxy === P.currentDelegateFor(object), "Proxy changed from the time it was first set.\nOriginal: \(proxy)\nExisting: \(String(describing: P.currentDelegateFor(object)))")
}
binding(proxy, event)

View File

@ -8,8 +8,6 @@
#if !os(Linux)
import Foundation
#if os(macOS)
import Cocoa
#else

View File

@ -6,7 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,6 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
#if SWIFT_PACKAGE && !DISABLE_SWIZZLING && !os(Linux)
import RxCocoaRuntime

View File

@ -6,7 +6,8 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import class Foundation.NSObject
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,7 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
import struct Foundation.IndexPath
/// Data source with access to underlying sectioned model.
public protocol SectionedViewDataSourceType {

View File

@ -6,8 +6,6 @@
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -8,11 +8,12 @@
#if !os(Linux)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
import CoreGraphics
import CoreGraphics
import class Foundation.NSValue
#if arch(x86_64) || arch(arm64)
let CGRectType = "{CGRect={CGPoint=dd}{CGSize=dd}}"

View File

@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import class Foundation.NSNumber
extension Int : KVORepresentable {
public typealias KVOType = NSNumber

View File

@ -6,8 +6,6 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
/// Type that is KVO representable (KVO mechanism can be used to observe it).
public protocol KVORepresentable {
/// Associated KVO type.

View File

@ -6,7 +6,7 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import struct Foundation.URLRequest
/// Simple logging settings for RxCocoa library.
public struct Logging {

View File

@ -312,7 +312,7 @@ extension Reactive where Base: AnyObject {
#endif
fileprivate class DeallocObservable {
fileprivate final class DeallocObservable {
let _subject = ReplaySubject<Void>.create(bufferSize:1)
init() {
@ -335,7 +335,7 @@ fileprivate protocol KVOObservableProtocol {
var options: NSKeyValueObservingOptions { get }
}
fileprivate class KVOObserver
fileprivate final class KVOObserver
: _RXKVOObserver
, Disposable {
typealias Callback = (Any?) -> Void
@ -363,7 +363,7 @@ fileprivate class KVOObserver
}
}
fileprivate class KVOObservable<Element>
fileprivate final class KVOObservable<Element>
: ObservableType
, KVOObservableProtocol {
typealias E = Element?

View File

@ -1,12 +1,14 @@
//
// NSNotificationCenter+Rx.swift
// NotificationCenter+Rx.swift
// RxCocoa
//
// Created by Krunoslav Zaher on 5/2/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import class Foundation.NotificationCenter
import struct Foundation.Notification
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -6,7 +6,24 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import struct Foundation.URL
import struct Foundation.URLRequest
import struct Foundation.Data
import struct Foundation.Date
import struct Foundation.TimeInterval
import class Foundation.HTTPURLResponse
import class Foundation.URLSession
import class Foundation.URLResponse
import class Foundation.JSONSerialization
import class Foundation.NSError
import var Foundation.NSURLErrorCancelled
import var Foundation.NSURLErrorDomain
#if os(Linux)
// don't know why
import Foundation
#endif
#if !RX_NO_MODULE
import RxSwift
#endif
@ -71,7 +88,7 @@ fileprivate func convertURLRequestToCurlCommand(_ request: URLRequest) -> String
return returnValue
}
fileprivate func convertResponseToString(_ data: Data!, _ response: URLResponse!, _ error: NSError!, _ interval: TimeInterval) -> String {
fileprivate func convertResponseToString(_ response: URLResponse?, _ error: NSError?, _ interval: TimeInterval) -> String {
let ms = Int(interval * 1000)
if let response = response as? HTTPURLResponse {
@ -124,7 +141,7 @@ extension Reactive where Base: URLSession {
if Logging.URLRequests(request) {
let interval = Date().timeIntervalSince(d ?? Date())
print(convertURLRequestToCurlCommand(request))
print(convertResponseToString(data, response, error as NSError!, interval))
print(convertResponseToString(response, error.map { $0 as NSError }, interval))
}
guard let response = response, let data = data else {
@ -141,9 +158,7 @@ extension Reactive where Base: URLSession {
observer.on(.completed)
}
let t = task
t.resume()
task.resume()
return Disposables.create(with: task.cancel)
}

View File

@ -18,11 +18,11 @@
@end
static NSMutableDictionary *forwardableSelectorsPerClass = nil;
static NSMutableDictionary *voidSelectorsPerClass = nil;
@implementation _RXDelegateProxy
+(NSSet*)collectSelectorsForProtocol:(Protocol *)protocol {
+(NSSet*)collectVoidSelectorsForProtocol:(Protocol *)protocol {
NSMutableSet *selectors = [NSMutableSet set];
unsigned int protocolMethodCount = 0;
@ -41,7 +41,7 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil;
Protocol * __unsafe_unretained * pSubprotocols = protocol_copyProtocolList(protocol, &numberOfBaseProtocols);
for (unsigned int i = 0; i < numberOfBaseProtocols; ++i) {
[selectors unionSet:[self collectSelectorsForProtocol:pSubprotocols[i]]];
[selectors unionSet:[self collectVoidSelectorsForProtocol:pSubprotocols[i]]];
}
free(pSubprotocols);
@ -51,11 +51,11 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil;
+(void)initialize {
@synchronized (_RXDelegateProxy.class) {
if (forwardableSelectorsPerClass == nil) {
forwardableSelectorsPerClass = [[NSMutableDictionary alloc] init];
if (voidSelectorsPerClass == nil) {
voidSelectorsPerClass = [[NSMutableDictionary alloc] init];
}
NSMutableSet *allowedSelectors = [NSMutableSet set];
NSMutableSet *voidSelectors = [NSMutableSet set];
#define CLASS_HIERARCHY_MAX_DEPTH 100
@ -70,8 +70,8 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil;
Protocol *__unsafe_unretained *pProtocols = class_copyProtocolList(targetClass, &count);
for (unsigned int i = 0; i < count; i++) {
NSSet *selectorsForProtocol = [self collectSelectorsForProtocol:pProtocols[i]];
[allowedSelectors unionSet:selectorsForProtocol];
NSSet *selectorsForProtocol = [self collectVoidSelectorsForProtocol:pProtocols[i]];
[voidSelectors unionSet:selectorsForProtocol];
}
free(pProtocols);
@ -84,7 +84,7 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil;
#endif
}
forwardableSelectorsPerClass[CLASS_VALUE(self)] = allowedSelectors;
voidSelectorsPerClass[CLASS_VALUE(self)] = voidSelectors;
}
}
@ -106,20 +106,14 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil;
return [super respondsToSelector:selector];
}
-(BOOL)canRespondToSelector:(SEL)selector {
-(BOOL)voidDelegateMethodsContain:(SEL)selector {
@synchronized(_RXDelegateProxy.class) {
NSSet *allowedMethods = forwardableSelectorsPerClass[CLASS_VALUE(self.class)];
NSAssert(allowedMethods != nil, @"Set of allowed methods not initialized");
return [allowedMethods containsObject:SEL_VALUE(selector)];
NSSet *voidSelectors = voidSelectorsPerClass[CLASS_VALUE(self.class)];
NSAssert(voidSelectors != nil, @"Set of allowed methods not initialized");
return [voidSelectors containsObject:SEL_VALUE(selector)];
}
}
-(BOOL)respondsToSelector:(SEL)aSelector {
return [super respondsToSelector:aSelector]
|| [self._forwardToDelegate respondsToSelector:aSelector]
|| [self canRespondToSelector:aSelector];
}
-(void)forwardInvocation:(NSInvocation *)anInvocation {
BOOL isVoid = RX_is_method_signature_void(anInvocation.methodSignature);
NSArray *arguments = nil;

View File

@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate;
-(BOOL)hasWiredImplementationForSelector:(SEL)selector;
-(BOOL)voidDelegateMethodsContain:(SEL)selector;
-(void)_sentMessage:(SEL)selector withArguments:(NSArray*)arguments;
-(void)_methodInvoked:(SEL)selector withArguments:(NSArray*)arguments;

View File

@ -6,7 +6,8 @@
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import class Foundation.NSNull
#if !RX_NO_MODULE
import RxSwift
#endif
@ -72,14 +73,22 @@ func bindingErrorToInterface(_ error: Swift.Error) {
#endif
}
// MARK: Abstract methods
func rxAbstractMethodWithMessage(_ message: String) -> Swift.Never {
rxFatalError(message)
/// Swift does not implement abstract methods. This method is used as a runtime check to ensure that methods which intended to be abstract (i.e., they should be implemented in subclasses) are not called directly on the superclass.
func rxAbstractMethod(message: String = "Abstract method", file: StaticString = #file, line: UInt = #line) -> Swift.Never {
rxFatalError(message, file: file, line: line)
}
func rxAbstractMethod() -> Swift.Never {
rxFatalError("Abstract method")
func rxFatalError(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) -> Swift.Never {
// The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours.
fatalError(lastMessage(), file: file, line: line)
}
func rxFatalErrorInDebug(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) {
#if DEBUG
fatalError(lastMessage(), file: file, line: line)
#else
print("\(file):\(line): \(lastMessage())")
#endif
}
// MARK: casts or fatal error

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
import Cocoa
#if !RX_NO_MODULE
import RxSwift

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
import Cocoa
#if !RX_NO_MODULE
import RxSwift

View File

@ -8,7 +8,6 @@
#if os(macOS)
import Foundation
import Cocoa
#if !RX_NO_MODULE
import RxSwift