From 0a297fbfe5f174212b94dbe8c3e17809340d25c7 Mon Sep 17 00:00:00 2001 From: Ruslan Alikhamov Date: Sat, 22 Jun 2024 23:14:54 +0400 Subject: [PATCH] update internal boilerplate code. --- .../Sources/Generated/Coding.generated.swift | 2 +- .../Generated/JSExport.generated.swift | 2 +- .../Sources/Generated/Typed.generated.swift | 2 +- .../SourceryRuntime.content.generated.swift | 16 +- ...rceryRuntime_Linux.content.generated.swift | 166 +++++++++++++++++- .../Models/TypedSpec.generated.swift | 2 +- 6 files changed, 170 insertions(+), 20 deletions(-) diff --git a/SourceryRuntime/Sources/Generated/Coding.generated.swift b/SourceryRuntime/Sources/Generated/Coding.generated.swift index 03014cbd9..da809f3bb 100644 --- a/SourceryRuntime/Sources/Generated/Coding.generated.swift +++ b/SourceryRuntime/Sources/Generated/Coding.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline diff --git a/SourceryRuntime/Sources/Generated/JSExport.generated.swift b/SourceryRuntime/Sources/Generated/JSExport.generated.swift index 361e8e634..b69da4289 100644 --- a/SourceryRuntime/Sources/Generated/JSExport.generated.swift +++ b/SourceryRuntime/Sources/Generated/JSExport.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline diff --git a/SourceryRuntime/Sources/Generated/Typed.generated.swift b/SourceryRuntime/Sources/Generated/Typed.generated.swift index 61a66ea93..6b463bc54 100644 --- a/SourceryRuntime/Sources/Generated/Typed.generated.swift +++ b/SourceryRuntime/Sources/Generated/Typed.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace diff --git a/SourcerySwift/Sources/SourceryRuntime.content.generated.swift b/SourcerySwift/Sources/SourceryRuntime.content.generated.swift index fdd60d854..5285d9ba5 100644 --- a/SourcerySwift/Sources/SourceryRuntime.content.generated.swift +++ b/SourcerySwift/Sources/SourceryRuntime.content.generated.swift @@ -235,7 +235,7 @@ public final class ArrayType: NSObject, SourceryModel, Diffable { /// Returns array as generic type public var asGeneric: GenericType { GenericType(name: "Array", typeParameters: [ - .init(typeName: elementTypeName) + .init(typeName: elementTypeName, type: elementType) ]) } @@ -2610,7 +2610,7 @@ internal struct ParserResultsComposed { if let array = lookupName.array { array.elementType = resolveTypeWithName(array.elementTypeName) - if array.elementTypeName.actualTypeName != nil || retrievedName != nil { + if array.elementTypeName.actualTypeName != nil || retrievedName != nil || array.elementType != nil { let array = ArrayType(name: array.name, elementTypeName: array.elementTypeName, elementType: array.elementType) array.elementTypeName = array.elementTypeName.actualTypeName ?? array.elementTypeName array.elementTypeName.actualTypeName = nil @@ -2898,13 +2898,13 @@ protocol SourceryModel: SourceryModelWithoutDescription, AutoDescription {} import Foundation +#if canImport(ObjectiveC) + /// :nodoc: public typealias SourceryProtocol = Protocol /// Describes Swift protocol -#if canImport(ObjectiveC) @objcMembers -#endif public final class Protocol: Type { // sourcery: skipJSExport @@ -3027,7 +3027,7 @@ public final class Protocol: Type { } // sourcery:end } - +#endif """), .init(name: "ProtocolComposition.swift", content: """ @@ -7714,7 +7714,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document """), .init(name: "Coding.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline @@ -7820,7 +7820,7 @@ extension Variable: NSCoding {} """), .init(name: "JSExport.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline @@ -8558,7 +8558,7 @@ extension Variable: VariableAutoJSExport {} """), .init(name: "Typed.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace diff --git a/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift b/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift index e26cfcf50..e9fe6a81c 100644 --- a/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift +++ b/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift @@ -235,7 +235,7 @@ public final class ArrayType: NSObject, SourceryModel, Diffable { /// Returns array as generic type public var asGeneric: GenericType { GenericType(name: "Array", typeParameters: [ - .init(typeName: elementTypeName) + .init(typeName: elementTypeName, type: elementType) ]) } @@ -2610,7 +2610,7 @@ internal struct ParserResultsComposed { if let array = lookupName.array { array.elementType = resolveTypeWithName(array.elementTypeName) - if array.elementTypeName.actualTypeName != nil || retrievedName != nil { + if array.elementTypeName.actualTypeName != nil || retrievedName != nil || array.elementType != nil { let array = ArrayType(name: array.name, elementTypeName: array.elementTypeName, elementType: array.elementType) array.elementTypeName = array.elementTypeName.actualTypeName ?? array.elementTypeName array.elementTypeName.actualTypeName = nil @@ -2898,13 +2898,13 @@ protocol SourceryModel: SourceryModelWithoutDescription, AutoDescription {} import Foundation +#if canImport(ObjectiveC) + /// :nodoc: public typealias SourceryProtocol = Protocol /// Describes Swift protocol -#if canImport(ObjectiveC) @objcMembers -#endif public final class Protocol: Type { // sourcery: skipJSExport @@ -3027,7 +3027,7 @@ public final class Protocol: Type { } // sourcery:end } - +#endif """), .init(name: "ProtocolComposition.swift", content: """ @@ -5786,6 +5786,156 @@ public extension NSExceptionName { } #endif +"""), + .init(name: "Protocol_Linux.swift", content: +""" +// +// Protocol.swift +// Sourcery +// +// Created by Krzysztof Zablocki on 09/12/2016. +// Copyright © 2016 Pixle. All rights reserved. +// + +import Foundation + +#if !canImport(ObjectiveC) + +/// :nodoc: +public typealias SourceryProtocol = Protocol + +/// Describes Swift protocol +public final class Protocol: Type { + public override subscript(dynamicMember member: String) -> Any? { + switch member { + case "associatedTypes": + return associatedTypes + default: + return super[dynamicMember: member] + } + } + + // sourcery: skipJSExport + public class var kind: String { return "protocol" } + + /// Returns "protocol" + public override var kind: String { Self.kind } + + /// list of all declared associated types with their names as keys + public var associatedTypes: [String: AssociatedType] { + didSet { + isGeneric = !associatedTypes.isEmpty || !genericRequirements.isEmpty + } + } + + // sourcery: skipCoding + /// list of generic requirements + public override var genericRequirements: [GenericRequirement] { + didSet { + isGeneric = !associatedTypes.isEmpty || !genericRequirements.isEmpty + } + } + + /// :nodoc: + public init(name: String = "", + parent: Type? = nil, + accessLevel: AccessLevel = .internal, + isExtension: Bool = false, + variables: [Variable] = [], + methods: [Method] = [], + subscripts: [Subscript] = [], + inheritedTypes: [String] = [], + containedTypes: [Type] = [], + typealiases: [Typealias] = [], + associatedTypes: [String: AssociatedType] = [:], + genericRequirements: [GenericRequirement] = [], + attributes: AttributeList = [:], + modifiers: [SourceryModifier] = [], + annotations: [String: NSObject] = [:], + documentation: [String] = [], + implements: [String: Type] = [:], + kind: String = Protocol.kind) { + self.associatedTypes = associatedTypes + super.init( + name: name, + parent: parent, + accessLevel: accessLevel, + isExtension: isExtension, + variables: variables, + methods: methods, + subscripts: subscripts, + inheritedTypes: inheritedTypes, + containedTypes: containedTypes, + typealiases: typealiases, + genericRequirements: genericRequirements, + attributes: attributes, + modifiers: modifiers, + annotations: annotations, + documentation: documentation, + isGeneric: !associatedTypes.isEmpty || !genericRequirements.isEmpty, + implements: implements, + kind: kind + ) + } + + /// :nodoc: + // sourcery: skipJSExport + override public var description: String { + var string = super.description + string.append(", ") + string.append("kind = \\(String(describing: self.kind)), ") + string.append("associatedTypes = \\(String(describing: self.associatedTypes)), ") + return string + } + + override public func diffAgainst(_ object: Any?) -> DiffableResult { + let results = DiffableResult() + guard let castObject = object as? Protocol else { + results.append("Incorrect type ") + return results + } + results.append(contentsOf: DiffableResult(identifier: "associatedTypes").trackDifference(actual: self.associatedTypes, expected: castObject.associatedTypes)) + results.append(contentsOf: super.diffAgainst(castObject)) + return results + } + + /// :nodoc: + // sourcery: skipJSExport + public override var hash: Int { + var hasher = Hasher() + hasher.combine(self.associatedTypes) + hasher.combine(super.hash) + return hasher.finalize() + } + + /// :nodoc: + public override func isEqual(_ object: Any?) -> Bool { + guard let rhs = object as? Protocol else { return false } + if self.associatedTypes != rhs.associatedTypes { return false } + return super.isEqual(rhs) + } + +// sourcery:inline:Protocol.AutoCoding + + /// :nodoc: + required public init?(coder aDecoder: NSCoder) { + guard let associatedTypes: [String: AssociatedType] = aDecoder.decode(forKey: "associatedTypes") else { + withVaList(["associatedTypes"]) { arguments in + NSException.raise(NSExceptionName.parseErrorException, format: "Key '%@' not found.", arguments: arguments) + } + fatalError() + }; self.associatedTypes = associatedTypes + super.init(coder: aDecoder) + } + + /// :nodoc: + override public func encode(with aCoder: NSCoder) { + super.encode(with: aCoder) + aCoder.encode(self.associatedTypes, forKey: "associatedTypes") + } +// sourcery:end +} +#endif """), .init(name: "Subscript_Linux.swift", content: """ @@ -8147,7 +8297,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document """), .init(name: "Coding.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline @@ -8253,7 +8403,7 @@ extension Variable: NSCoding {} """), .init(name: "JSExport.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline @@ -8991,7 +9141,7 @@ extension Variable: VariableAutoJSExport {} """), .init(name: "Typed.generated.swift", content: """ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace diff --git a/SourceryTests/Models/TypedSpec.generated.swift b/SourceryTests/Models/TypedSpec.generated.swift index fb83a4d70..a45c29fef 100644 --- a/SourceryTests/Models/TypedSpec.generated.swift +++ b/SourceryTests/Models/TypedSpec.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT import Quick import Nimble