mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 18:31:17 +01:00
swift 3.1 support
This commit is contained in:
@@ -168,5 +168,8 @@ extension AsynchronousDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSAsynchronousDataTransaction
|
||||
public var bridgeToObjectiveC: CSAsynchronousDataTransaction {
|
||||
|
||||
return CSAsynchronousDataTransaction(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,13 +294,3 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
private let swiftTransaction: BaseDataTransaction
|
||||
}
|
||||
|
||||
|
||||
//// MARK: - BaseDataTransaction
|
||||
//
|
||||
//extension BaseDataTransaction: CoreStoreSwiftType {
|
||||
//
|
||||
// // MARK: CoreStoreSwiftType
|
||||
//
|
||||
// public typealias ObjectiveCType = CSBaseDataTransaction
|
||||
//}
|
||||
|
||||
@@ -277,5 +277,8 @@ extension DataStack: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSDataStack
|
||||
public var bridgeToObjectiveC: CSDataStack {
|
||||
|
||||
return CSDataStack(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
public init<T: NSManagedObject>(_ swiftValue: From<T>) {
|
||||
|
||||
self.bridgeToSwift = swiftValue.upcast()
|
||||
self.bridgeToSwift = swiftValue.downcast()
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,5 +118,8 @@ extension GroupBy: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSGroupBy
|
||||
public var bridgeToObjectiveC: CSGroupBy {
|
||||
|
||||
return CSGroupBy(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,5 +125,8 @@ extension InMemoryStore: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSInMemoryStore
|
||||
public var bridgeToObjectiveC: CSInMemoryStore {
|
||||
|
||||
return CSInMemoryStore(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class CSInto: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
public required init<T: NSManagedObject>(_ swiftValue: Into<T>) {
|
||||
|
||||
self.bridgeToSwift = swiftValue.upcast()
|
||||
self.bridgeToSwift = swiftValue.downcast()
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
@nonobjc
|
||||
public required init<T: NSManagedObject>(_ swiftValue: ListMonitor<T>) {
|
||||
|
||||
self.bridgeToSwift = swiftValue.upcast()
|
||||
self.bridgeToSwift = swiftValue.downcast()
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,5 +177,8 @@ extension MigrationResult: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSMigrationResult
|
||||
public var bridgeToObjectiveC: CSMigrationResult {
|
||||
|
||||
return CSMigrationResult(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,5 +123,8 @@ extension MigrationType: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSMigrationType
|
||||
public var bridgeToObjectiveC: CSMigrationType {
|
||||
|
||||
return CSMigrationType(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
@nonobjc
|
||||
public required init<T: NSManagedObject>(_ swiftValue: ObjectMonitor<T>) {
|
||||
|
||||
self.bridgeToSwift = swiftValue.upcast()
|
||||
self.bridgeToSwift = swiftValue.downcast()
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,5 +126,8 @@ extension OrderBy: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSOrderBy
|
||||
public var bridgeToObjectiveC: CSOrderBy {
|
||||
|
||||
return CSOrderBy(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,5 +203,8 @@ extension SQLiteStore: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSQLiteStore
|
||||
public var bridgeToObjectiveC: CSSQLiteStore {
|
||||
|
||||
return CSSQLiteStore(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,5 +177,8 @@ extension SaveResult: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSaveResult
|
||||
public var bridgeToObjectiveC: CSSaveResult {
|
||||
|
||||
return CSSaveResult(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,10 @@ extension SectionBy: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSectionBy
|
||||
public var bridgeToObjectiveC: CSSectionBy {
|
||||
|
||||
return CSSectionBy(self)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -192,7 +192,10 @@ extension SelectTerm: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSelectTerm
|
||||
public var bridgeToObjectiveC: CSSelectTerm {
|
||||
|
||||
return CSSelectTerm(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -181,8 +181,6 @@ extension SetupResult where T: CoreStoreSwiftType, T.ObjectiveCType: CSStorageIn
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSetupResult
|
||||
|
||||
public var bridgeToObjectiveC: CSSetupResult {
|
||||
|
||||
return CSSetupResult(self)
|
||||
|
||||
@@ -167,5 +167,8 @@ extension SynchronousDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSSynchronousDataTransaction
|
||||
public var bridgeToObjectiveC: CSSynchronousDataTransaction {
|
||||
|
||||
return CSSynchronousDataTransaction(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,5 +94,8 @@ extension Tweak: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSTweak
|
||||
public var bridgeToObjectiveC: CSTweak {
|
||||
|
||||
return CSTweak(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,5 +197,8 @@ extension UnsafeDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSUnsafeDataTransaction
|
||||
public var bridgeToObjectiveC: CSUnsafeDataTransaction {
|
||||
|
||||
return CSUnsafeDataTransaction(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,5 +163,8 @@ extension Where: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSWhere
|
||||
public var bridgeToObjectiveC: CSWhere {
|
||||
|
||||
return CSWhere(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,28 +68,20 @@ public protocol CoreStoreSwiftType {
|
||||
var bridgeToObjectiveC: ObjectiveCType { get }
|
||||
}
|
||||
|
||||
public extension CoreStoreSwiftType where ObjectiveCType: CoreStoreObjectiveCType, Self == ObjectiveCType.SwiftType {
|
||||
|
||||
public var bridgeToObjectiveC: ObjectiveCType {
|
||||
|
||||
return ObjectiveCType(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Internal
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () -> T) -> T.ObjectiveCType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () -> T) -> T.ObjectiveCType {
|
||||
|
||||
return closure().bridgeToObjectiveC
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () -> T?) -> T.ObjectiveCType? where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () -> T?) -> T.ObjectiveCType? {
|
||||
|
||||
return closure()?.bridgeToObjectiveC
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () throws -> T) throws -> T.ObjectiveCType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ closure: () throws -> T) throws -> T.ObjectiveCType {
|
||||
|
||||
do {
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ fileprivate func createFRC(fromContext context: NSManagedObjectContext, from: CS
|
||||
let controller = CoreStoreFetchedResultsController(
|
||||
context: context,
|
||||
fetchRequest: CoreStoreFetchRequest().dynamicCast(),
|
||||
from: from?.bridgeToSwift.upcast(),
|
||||
from: from?.bridgeToSwift.downcast(),
|
||||
sectionBy: sectionBy?.bridgeToSwift,
|
||||
applyFetchClauses: { (fetchRequest) in
|
||||
|
||||
|
||||
Reference in New Issue
Block a user