Support typed errors. Misc formatting

This commit is contained in:
John Estropia
2024-09-10 11:14:39 +09:00
parent c9e091a6a4
commit 5dcf29011a
74 changed files with 3987 additions and 1441 deletions

View File

@@ -116,8 +116,19 @@ extension FieldContainer {
_ keyPath: KeyPathString,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
customGetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>
) -> V
)? = nil,
customSetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>,
_ newValue: V
) -> Void
)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
) {
@@ -157,8 +168,19 @@ extension FieldContainer {
_ keyPath: KeyPathString,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
customGetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>
) -> V
)? = nil,
customSetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>,
_ newValue: V
) -> Void
)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = [],
dynamicInitialValue: @escaping () -> V
) {
@@ -255,7 +277,10 @@ extension FieldContainer {
return ObjectType.self
}
internal static func read(field: FieldProtocol, for rawObject: CoreStoreManagedObject) -> Any? {
internal static func read(
field: FieldProtocol,
for rawObject: CoreStoreManagedObject
) -> Any? {
let field = field as! Self
if let customGetter = field.customGetter {
@@ -276,7 +301,10 @@ extension FieldContainer {
}
}
internal static func modify(field: FieldProtocol, for rawObject: CoreStoreManagedObject, newValue: Any?) {
internal static func modify(
field: FieldProtocol,
for rawObject: CoreStoreManagedObject, newValue: Any?
) {
Internals.assert(
rawObject.isEditableInContext() == true,
@@ -379,7 +407,8 @@ extension FieldContainer {
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)?,
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)?,
dynamicInitialValue: (() -> V)?,
affectedByKeyPaths: @escaping () -> Set<KeyPathString>) {
affectedByKeyPaths: @escaping () -> Set<KeyPathString>
) {
self.keyPath = keyPath
self.entityDescriptionValues = {
@@ -403,8 +432,19 @@ extension FieldContainer {
// MARK: Private
private let customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)?
private let customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)?
private let customGetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>
) -> V
)?
private let customSetter: (
(
_ object: ObjectProxy<O>,
_ field: ObjectProxy<O>.FieldProxy<V>,
_ newValue: V
) -> Void
)?
private let dynamicInitialValue: (() -> V)?
}
}