mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-26 03:11:14 +01:00
Merge branch 'develop' into prototype/concurrency
This commit is contained in:
@@ -1215,8 +1215,14 @@ extension NSAttributeType: CoreStoreDebugStringConvertible {
|
||||
case .objectIDAttributeType: return ".objectIDAttributeType"
|
||||
case .UUIDAttributeType: return ".UUIDAttributeType"
|
||||
case .URIAttributeType: return ".URIAttributeType"
|
||||
|
||||
#if swift(>=5.9) // Xcode 15 (iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0)
|
||||
case .compositeAttributeType: return ".compositeAttributeType"
|
||||
|
||||
#endif
|
||||
|
||||
@unknown default:
|
||||
fatalError()
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +114,15 @@ extension NSManagedObject: DynamicObject {
|
||||
}
|
||||
|
||||
public class func cs_fromRaw(object: NSManagedObject) -> Self {
|
||||
|
||||
|
||||
#if swift(>=5.9)
|
||||
return unsafeDowncast(object, to: self)
|
||||
|
||||
#else
|
||||
// unsafeDowncast fails debug assertion starting Swift 5.2
|
||||
return _unsafeUncheckedDowncast(object, to: self)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
public static func cs_matches(object: NSManagedObject) -> Bool {
|
||||
|
||||
@@ -48,7 +48,7 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
var elementUpdated: [ElementPath]
|
||||
var elementMoved: [(source: ElementPath, target: ElementPath)]
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
init(
|
||||
data: C,
|
||||
sectionDeleted: [Int] = [],
|
||||
|
||||
@@ -190,7 +190,7 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
internal init(
|
||||
deleted: [Index] = [],
|
||||
inserted: [Index] = [],
|
||||
@@ -213,18 +213,18 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
|
||||
// Implementation based on https://github.com/ra1028/DifferenceKit
|
||||
@usableFromInline
|
||||
internal struct Trace<Index> {
|
||||
|
||||
internal struct Trace<I> {
|
||||
|
||||
@usableFromInline
|
||||
internal var reference: Index?
|
||||
|
||||
internal var reference: I?
|
||||
|
||||
@usableFromInline
|
||||
internal var deleteOffset = 0
|
||||
|
||||
@usableFromInline
|
||||
internal var isTracked = false
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
init() {}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
@usableFromInline
|
||||
internal var position = 0
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
internal init(_ indices: ContiguousArray<Int>) {
|
||||
|
||||
self.indices = indices
|
||||
@@ -292,7 +292,7 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
@usableFromInline
|
||||
internal let pointer: UnsafePointer<T>
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
internal init(pointer: UnsafePointer<T>) {
|
||||
|
||||
self.pointeeHashValue = pointer.pointee.hashValue
|
||||
|
||||
@@ -40,7 +40,7 @@ extension Internals.DiffableDataUIDispatcher {
|
||||
@usableFromInline
|
||||
var changesets: ContiguousArray<Changeset<C>>
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
init<S: Sequence>(_ changesets: S) where S.Element == Changeset<C> {
|
||||
|
||||
self.changesets = ContiguousArray(changesets)
|
||||
|
||||
@@ -221,7 +221,7 @@ extension Internals {
|
||||
@usableFromInline
|
||||
var section: Int
|
||||
|
||||
@inlinable
|
||||
@usableFromInline
|
||||
init(element: Int, section: Int) {
|
||||
|
||||
self.element = element
|
||||
|
||||
@@ -74,7 +74,7 @@ extension Internals {
|
||||
default:
|
||||
Internals.abort("\(Internals.typeName(DynamicObject.self)) is not meant to be implemented by external types.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal init(_ entityDescription: NSEntityDescription) {
|
||||
|
||||
|
||||
47
Sources/Operators.swift
Normal file
47
Sources/Operators.swift
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Operators.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2023 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
|
||||
infix operator &&? : LogicalConjunctionPrecedence
|
||||
infix operator ||? : LogicalConjunctionPrecedence
|
||||
|
||||
|
||||
// MARK: - ~
|
||||
|
||||
/**
|
||||
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
|
||||
```
|
||||
let owner = dataStack.fetchOne(
|
||||
From<Pet>().where(
|
||||
(\.master ~ \.name) == "John"
|
||||
)
|
||||
)
|
||||
```
|
||||
*/
|
||||
infix operator ~ : AdditionPrecedence
|
||||
@@ -371,9 +371,6 @@ extension RelationshipContainer.ToManyOrdered: RandomAccessCollection {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension RelationshipContainer.ToManyOrdered {
|
||||
|
||||
/**
|
||||
|
||||
@@ -364,9 +364,6 @@ extension RelationshipContainer.ToManyUnordered: Sequence {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension RelationshipContainer.ToManyUnordered {
|
||||
|
||||
/**
|
||||
|
||||
@@ -304,10 +304,6 @@ extension RelationshipContainer {
|
||||
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension RelationshipContainer.ToOne {
|
||||
|
||||
/**
|
||||
|
||||
@@ -503,8 +503,8 @@ public struct Select<O: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
|
||||
// MARK: Equatable
|
||||
|
||||
public static func == <T, U>(lhs: Select<O, T>, rhs: Select<O, U>) -> Bool {
|
||||
|
||||
public static func == <T1, T2>(lhs: Select<O, T1>, rhs: Select<O, T2>) -> Bool {
|
||||
|
||||
return lhs.selectTerms == rhs.selectTerms
|
||||
}
|
||||
|
||||
|
||||
@@ -251,9 +251,6 @@ extension TransformableContainer {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension TransformableContainer.Optional {
|
||||
|
||||
/**
|
||||
|
||||
@@ -254,9 +254,6 @@ extension TransformableContainer {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension TransformableContainer.Required {
|
||||
|
||||
/**
|
||||
|
||||
@@ -252,9 +252,6 @@ extension ValueContainer {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension ValueContainer.Optional {
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,9 +250,6 @@ extension ValueContainer {
|
||||
|
||||
// MARK: - Operations
|
||||
|
||||
infix operator .= : AssignmentPrecedence
|
||||
infix operator .== : ComparisonPrecedence
|
||||
|
||||
extension ValueContainer.Required {
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,21 +27,6 @@ import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - ~
|
||||
|
||||
/**
|
||||
Connects multiple `KeyPathStringConvertible`s to create a type-safe chain usable in query/fetch expressions
|
||||
```
|
||||
let owner = dataStack.fetchOne(
|
||||
From<Pet>().where(
|
||||
(\.master ~ \.name) == "John"
|
||||
)
|
||||
)
|
||||
```
|
||||
*/
|
||||
infix operator ~ : AdditionPrecedence
|
||||
|
||||
|
||||
// MARK: - WhereExpressionTrait
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,10 +27,6 @@ import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
infix operator &&? : LogicalConjunctionPrecedence
|
||||
infix operator ||? : LogicalConjunctionPrecedence
|
||||
|
||||
|
||||
// MARK: - Where
|
||||
|
||||
/**
|
||||
@@ -250,8 +246,8 @@ public struct Where<O: DynamicObject>: WhereClauseType, FetchClause, QueryClause
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter object: the arguments for the `==` operator
|
||||
*/
|
||||
public init<O: DynamicObject>(_ keyPath: KeyPathString, isEqualTo object: O?) {
|
||||
|
||||
public init<Other: DynamicObject>(_ keyPath: KeyPathString, isEqualTo object: Other?) {
|
||||
|
||||
switch object {
|
||||
|
||||
case nil:
|
||||
|
||||
Reference in New Issue
Block a user