Merge branch 'develop' into prototype/Swift_3_2

# Conflicts:
#	Sources/CoreStoreManagedObject.swift
#	Sources/CoreStoreSchema.swift
#	Sources/NSEntityDescription+DynamicModel.swift
#	Sources/Value.swift
This commit is contained in:
John Rommel Estropia
2017-06-11 09:16:34 +09:00
10 changed files with 678 additions and 294 deletions

View File

@@ -13,28 +13,14 @@ import CoreData
@objc internal class CoreStoreManagedObject: NSManagedObject {
@nonobjc
internal class func cs_setKeyPathsForValuesAffectingKeys(_ keyPathsForValuesAffectingKeys: [RawKeyPath: Set<RawKeyPath>], for managedObjectClass: CoreStoreManagedObject.Type) {
Static.queue.sync(flags: .barrier) {
Static.cache[ObjectIdentifier(managedObjectClass)] = keyPathsForValuesAffectingKeys
}
}
internal typealias CustomGetter = @convention(block) (_ rawObject: Any) -> Any?
internal typealias CustomSetter = @convention(block) (_ rawObject: Any, _ newValue: Any?) -> Void
internal typealias CustomGetterSetter = (getter: CustomGetter?, setter: CustomSetter?)
// MARK: NSManagedObject
override class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> {
@nonobjc @inline(__always)
internal static func cs_subclassName(for entity: DynamicEntity, in modelVersion: ModelVersion) -> String {
return Static.queue.sync(flags: .barrier) {
let cacheKey = ObjectIdentifier(self)
if let keyPathsForValuesAffectingKeys = Static.cache[cacheKey] {
return keyPathsForValuesAffectingKeys[key] ?? []
}
return super.keyPathsForValuesAffectingValue(forKey: key)
}
return "_\(NSStringFromClass(CoreStoreManagedObject.self))__\(modelVersion)__\(NSStringFromClass(entity.type))__\(entity.entityName)"
}
}