mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-20 16:43:55 +01:00
code cleanup
This commit is contained in:
@@ -488,12 +488,6 @@ public final class CoreStoreSchema: DynamicSchema {
|
||||
for (attributeName, customGetterSetters) in (customGetterSetterByKeyPaths ?? [:])
|
||||
where customGetterSetters.getter != nil || customGetterSetters.setter != nil {
|
||||
|
||||
var rawAttributes: [objc_property_attribute_t] = [
|
||||
objc_property_attribute_t(name: "T@", value: attributeName),
|
||||
objc_property_attribute_t(name: "N", value: ""),
|
||||
objc_property_attribute_t(name: "C", value: ""),
|
||||
objc_property_attribute_t(name: "&", value: "")
|
||||
]
|
||||
if let getter = customGetterSetters.getter {
|
||||
|
||||
let getterName = "\(attributeName)"
|
||||
@@ -505,7 +499,6 @@ public final class CoreStoreSchema: DynamicSchema {
|
||||
|
||||
CoreStore.abort("Could not dynamically add getter method \"\(getterName)\" to class \(cs_typeName(managedObjectClass))")
|
||||
}
|
||||
rawAttributes.append(objc_property_attribute_t(name: "G", value: getterName))
|
||||
}
|
||||
if let setter = customGetterSetters.setter {
|
||||
|
||||
@@ -518,17 +511,7 @@ public final class CoreStoreSchema: DynamicSchema {
|
||||
|
||||
CoreStore.abort("Could not dynamically add setter method \"\(setterName)\" to class \(cs_typeName(managedObjectClass))")
|
||||
}
|
||||
rawAttributes.append(objc_property_attribute_t(name: "S", value: setterName))
|
||||
}
|
||||
// rawAttributes.append("\(attributeName)".withCString({ objc_property_attribute_t(name: "V", value: $0) }))
|
||||
|
||||
// rawAttributes.withUnsafeBufferPointer { (buffer) in
|
||||
//
|
||||
// guard class_addProperty(managedObjectClass, attributeName, buffer.baseAddress, UInt32(buffer.count)) else {
|
||||
//
|
||||
// CoreStore.abort("Could not dynamically add property \"\(attributeName)\" to class \(cs_typeName(managedObjectClass))")
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
let newSelector = NSSelectorFromString("cs_keyPathsForValuesAffectingValueForKey:")
|
||||
|
||||
@@ -181,7 +181,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
object.rawObject!.isEditableInContext() == true,
|
||||
self.isTransient || object.rawObject!.isEditableInContext() == true,
|
||||
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
|
||||
)
|
||||
let customSetter = (self.customSetter ?? { $1($2) })
|
||||
@@ -222,19 +222,11 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customGetter = self.customGetter else {
|
||||
|
||||
guard let _ = self.customSetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
return rawObject.getValue(forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -253,19 +245,11 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var setter: CoreStoreManagedObject.CustomSetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customSetter = self.customSetter else {
|
||||
|
||||
guard let _ = self.customGetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
rawObject.setValue(newValue, forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -400,7 +384,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
object.rawObject!.isEditableInContext() == true,
|
||||
self.isTransient || object.rawObject!.isEditableInContext() == true,
|
||||
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
|
||||
)
|
||||
let customSetter = (self.customSetter ?? { $1($2) })
|
||||
@@ -440,19 +424,11 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customGetter = self.customGetter else {
|
||||
|
||||
guard let _ = self.customSetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
return rawObject.getValue(forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -471,19 +447,11 @@ public enum ValueContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var setter: CoreStoreManagedObject.CustomSetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customSetter = self.customSetter else {
|
||||
|
||||
guard let _ = self.customGetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
rawObject.setValue(newValue, forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -674,7 +642,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
||||
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
object.rawObject!.isEditableInContext() == true,
|
||||
self.isTransient || object.rawObject!.isEditableInContext() == true,
|
||||
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
|
||||
)
|
||||
let customSetter = (self.customSetter ?? { $1($2) })
|
||||
@@ -714,19 +682,11 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customGetter = self.customGetter else {
|
||||
|
||||
guard let _ = self.customSetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
return rawObject.getValue(forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -739,19 +699,11 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var setter: CoreStoreManagedObject.CustomSetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customSetter = self.customSetter else {
|
||||
|
||||
guard let _ = self.customGetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
rawObject.setValue(newValue, forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any, _ newValue: Any?) -> Void in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
@@ -876,7 +828,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
||||
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
object.rawObject!.isEditableInContext() == true,
|
||||
self.isTransient || object.rawObject!.isEditableInContext() == true,
|
||||
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
|
||||
)
|
||||
let customSetter = (self.customSetter ?? { $1($2) })
|
||||
@@ -916,19 +868,11 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
||||
|
||||
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
|
||||
|
||||
let keyPath = self.keyPath
|
||||
guard let customGetter = self.customGetter else {
|
||||
|
||||
guard let _ = self.customSetter else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
return rawObject.getValue(forKvcKey: keyPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let keyPath = self.keyPath
|
||||
return { (_ id: Any) -> Any? in
|
||||
|
||||
let rawObject = id as! CoreStoreManagedObject
|
||||
|
||||
Reference in New Issue
Block a user