mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
d90092d9f1
198 changed files with 25726 additions and 11022 deletions
|
|
@ -96,16 +96,23 @@ private func matchPhoneNumbers(_ lhs: String, _ rhs: String) -> Bool {
|
|||
func matchingCloudContacts(postbox: Postbox, contacts: [MatchingDeviceContact]) -> Signal<[(String, TelegramUser)], NoError> {
|
||||
return postbox.transaction { transaction -> [(String, TelegramUser)] in
|
||||
var result: [(String, TelegramUser)] = []
|
||||
var matchingIds = Set<EnginePeer.Id>()
|
||||
outer: for peerId in transaction.getContactPeerIds() {
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramUser {
|
||||
for contact in contacts {
|
||||
if let contactPeerId = contact.peerId, contactPeerId == peerId {
|
||||
result.append((contact.stableId, peer))
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
continue outer
|
||||
} else if let peerPhoneNumber = peer.phone {
|
||||
for contactPhoneNumber in contact.phoneNumbers {
|
||||
if matchPhoneNumbers(contactPhoneNumber, peerPhoneNumber) {
|
||||
result.append((contact.stableId, peer))
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
|
|
@ -113,6 +120,15 @@ func matchingCloudContacts(postbox: Postbox, contacts: [MatchingDeviceContact])
|
|||
}
|
||||
}
|
||||
}
|
||||
for contact in contacts {
|
||||
if let peerId = contact.peerId, let peer = transaction.getPeer(peerId) as? TelegramUser {
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
build-system/SwiftTL/Package.swift
Normal file
15
build-system/SwiftTL/Package.swift
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// swift-tools-version:5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "SwiftTL",
|
||||
dependencies: [
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "SwiftTL",
|
||||
dependencies: []),
|
||||
]
|
||||
)
|
||||
3
build-system/SwiftTL/README.md
Normal file
3
build-system/SwiftTL/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SwiftTL
|
||||
|
||||
|
||||
986
build-system/SwiftTL/Sources/SwiftTL/CodeGeneration.swift
Normal file
986
build-system/SwiftTL/Sources/SwiftTL/CodeGeneration.swift
Normal file
|
|
@ -0,0 +1,986 @@
|
|||
import Foundation
|
||||
|
||||
private let reservedIdentifiers: [String] = [
|
||||
"protocol",
|
||||
"private"
|
||||
]
|
||||
|
||||
private extension String {
|
||||
var camelCased: String {
|
||||
var result = ""
|
||||
|
||||
var capitalizeNext = false
|
||||
for c in self {
|
||||
if c == "_" {
|
||||
capitalizeNext = true
|
||||
} else {
|
||||
if capitalizeNext {
|
||||
capitalizeNext = false
|
||||
result.append(c.uppercased())
|
||||
} else {
|
||||
result.append(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
var camelCasedAndEscaped: String {
|
||||
var result = self.camelCased
|
||||
|
||||
if reservedIdentifiers.contains(result) {
|
||||
result = "`\(result)`"
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
private struct CodeWriter {
|
||||
private var code: String = ""
|
||||
private var indentLevel: Int = 0
|
||||
private let indentString: String = " "
|
||||
|
||||
private var currentIndent: String {
|
||||
String(repeating: indentString, count: indentLevel)
|
||||
}
|
||||
|
||||
mutating func indent() {
|
||||
indentLevel += 1
|
||||
}
|
||||
|
||||
mutating func dedent() {
|
||||
indentLevel = max(0, indentLevel - 1)
|
||||
}
|
||||
|
||||
mutating func line(_ text: String = "") {
|
||||
if text.isEmpty {
|
||||
code += "\n"
|
||||
} else {
|
||||
code += currentIndent + text + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
mutating func lines(_ text: String) {
|
||||
for line in text.split(separator: "\n", omittingEmptySubsequences: false) {
|
||||
if line.isEmpty {
|
||||
code += "\n"
|
||||
} else {
|
||||
code += currentIndent + line + "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func output() -> String {
|
||||
return code
|
||||
}
|
||||
}
|
||||
|
||||
/*private extension QualifiedName {
|
||||
var camelCased: String {
|
||||
if let namespace = self.namespace {
|
||||
return "\(namespace).\(self.value.camelCased)"
|
||||
} else {
|
||||
return self.value.camelCased
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private func typeReferenceRepresentation(_ type: Resolver.TypeReference) -> String {
|
||||
switch type {
|
||||
case .int32:
|
||||
return "Int32"
|
||||
case .int64:
|
||||
return "Int64"
|
||||
case .int256:
|
||||
return "Int256"
|
||||
case .double:
|
||||
return "Double"
|
||||
case .bytes:
|
||||
return "Buffer"
|
||||
case .string:
|
||||
return "String"
|
||||
case .bool:
|
||||
return "Bool"
|
||||
case .boolTrue:
|
||||
return "bool"
|
||||
case let .bareVector(elementType):
|
||||
return "[\(typeReferenceRepresentation(elementType))]"
|
||||
case let .boxedVector(elementType):
|
||||
return "[\(typeReferenceRepresentation(elementType))]"
|
||||
case let .bareConstructor(typeName, _):
|
||||
return "Api.\(typeName)"
|
||||
case let .boxedType(typeName):
|
||||
return "Api.\(typeName)"
|
||||
}
|
||||
}
|
||||
|
||||
private extension Resolver.SumType {
|
||||
func hasDirectReference(to otherTypes: [Resolver.SumType], typeMap: [QualifiedName: Resolver.SumType]) throws -> Bool {
|
||||
for (_, constructor) in self.constructors {
|
||||
for argument in constructor.arguments {
|
||||
switch argument.type {
|
||||
case .int32:
|
||||
break
|
||||
case .int64:
|
||||
break
|
||||
case .int256:
|
||||
break
|
||||
case .double:
|
||||
break
|
||||
case .bytes:
|
||||
break
|
||||
case .string:
|
||||
break
|
||||
case .bool:
|
||||
break
|
||||
case .boolTrue:
|
||||
break
|
||||
case .bareVector:
|
||||
break
|
||||
case .boxedVector:
|
||||
break
|
||||
case .bareConstructor(let typeName, _), .boxedType(let typeName):
|
||||
for otherType in otherTypes {
|
||||
if typeName == otherType.name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
guard let referencedType = typeMap[typeName] else {
|
||||
throw CodeGenerator.CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
|
||||
var mergedTypes = otherTypes
|
||||
if !mergedTypes.contains(where: { $0.name == self.name }) {
|
||||
mergedTypes.append(self)
|
||||
}
|
||||
|
||||
if try referencedType.hasDirectReference(to: mergedTypes, typeMap: typeMap) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private extension Sequence where Iterator.Element: Hashable {
|
||||
func unique() -> [Iterator.Element] {
|
||||
var seen: Set<Iterator.Element> = []
|
||||
return filter { seen.insert($0).inserted }
|
||||
}
|
||||
}
|
||||
|
||||
enum CodeGenerator {
|
||||
struct CodeGenerationError: Error, CustomStringConvertible {
|
||||
var text: String
|
||||
|
||||
var description: String {
|
||||
return self.text
|
||||
}
|
||||
}
|
||||
|
||||
static func generate(types: [Resolver.SumType], functions: [Resolver.Function], constructorOrder: [(typeName: QualifiedName, constructorName: String)], typeOrder: [(types: [(typeName: QualifiedName, constructorNames: [String])], functions: [QualifiedName])], stubFunctions: Bool = false) throws -> [String: String] {
|
||||
var files: [String: String] = [:]
|
||||
|
||||
var functions = functions
|
||||
functions.append(Resolver.Function(name: QualifiedName(namespace: "help", value: "test"), id: UInt32(bitPattern: -1058929929), arguments: [], result: .boxedType(QualifiedName(namespace: nil, value: "Bool"))))
|
||||
|
||||
files["Api0.swift"] = try generateMainFile(types: types, functions: functions, constructorOrder: constructorOrder)
|
||||
|
||||
for index in 0 ..< typeOrder.count {
|
||||
files["Api\(index + 1).swift"] = try generateImplFile(types: types, functions: functions, typeOrder: typeOrder[index], stubFunctions: stubFunctions)
|
||||
}
|
||||
|
||||
return files
|
||||
}
|
||||
|
||||
private static func generateMainFile(types: [Resolver.SumType], functions: [Resolver.Function], constructorOrder: [(typeName: QualifiedName, constructorName: String)]) throws -> String {
|
||||
var writer = CodeWriter()
|
||||
|
||||
writer.line()
|
||||
|
||||
var namespaces = Set<String>()
|
||||
for type in types {
|
||||
if let namespace = type.name.namespace {
|
||||
namespaces.insert(namespace)
|
||||
}
|
||||
}
|
||||
|
||||
var functionNamespaces = Set<String>()
|
||||
for function in functions {
|
||||
if let namespace = function.name.namespace {
|
||||
functionNamespaces.insert(namespace)
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("public enum Api {")
|
||||
writer.indent()
|
||||
for namespace in namespaces.sorted(by: { $0 < $1 }) {
|
||||
writer.line("public enum \(namespace) {}")
|
||||
}
|
||||
writer.line("public enum functions {")
|
||||
writer.indent()
|
||||
for namespace in functionNamespaces.sorted(by: { $0 < $1 }) {
|
||||
writer.line("public enum \(namespace) {}")
|
||||
}
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
|
||||
var typeMap: [QualifiedName: Resolver.SumType] = [:]
|
||||
for type in types {
|
||||
typeMap[type.name] = type
|
||||
}
|
||||
|
||||
writer.line("fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {")
|
||||
writer.indent()
|
||||
writer.line("var dict: [Int32 : (BufferReader) -> Any?] = [:]")
|
||||
writer.line("dict[-1471112230] = { return $0.readInt32() }")
|
||||
writer.line("dict[570911930] = { return $0.readInt64() }")
|
||||
writer.line("dict[571523412] = { return $0.readDouble() }")
|
||||
writer.line("dict[0x0929C32F] = { return parseInt256($0) }")
|
||||
writer.line("dict[-1255641564] = { return parseString($0) }")
|
||||
|
||||
for (typeName, constructorName) in constructorOrder {
|
||||
guard let type = typeMap[typeName] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
|
||||
var found = false
|
||||
for (_, constructor) in type.constructors {
|
||||
if constructor.name.value == constructorName {
|
||||
found = true
|
||||
writer.line("dict[\(Int32(bitPattern: constructor.id))] = { return Api.\(type.name).parse_\(constructor.name.value)($0) }")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
throw CodeGenerationError(text: "Constructor \(constructorName) not found")
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("return dict")
|
||||
writer.dedent()
|
||||
writer.line("}()")
|
||||
|
||||
writer.line()
|
||||
|
||||
writer.line("public extension Api {")
|
||||
writer.indent()
|
||||
|
||||
writer.line("static func parse(_ buffer: Buffer) -> Any? {")
|
||||
writer.indent()
|
||||
writer.line("let reader = BufferReader(buffer)")
|
||||
writer.line("if let signature = reader.readInt32() {")
|
||||
writer.indent()
|
||||
writer.line("return parse(reader, signature: signature)")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
|
||||
writer.line("static func parse(_ reader: BufferReader, signature: Int32) -> Any? {")
|
||||
writer.indent()
|
||||
writer.line("if let parser = parsers[signature] {")
|
||||
writer.indent()
|
||||
writer.line("return parser(reader)")
|
||||
writer.dedent()
|
||||
writer.line("} else {")
|
||||
writer.indent()
|
||||
writer.line("telegramApiLog(\"Type constructor \\(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found\")")
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
|
||||
writer.line("static func parseVector<T>(_ reader: BufferReader, elementSignature: Int32, elementType: T.Type) -> [T]? {")
|
||||
writer.indent()
|
||||
writer.line("if let count = reader.readInt32() {")
|
||||
writer.indent()
|
||||
writer.line("var array = [T]()")
|
||||
writer.line("var i: Int32 = 0")
|
||||
writer.line("while i < count {")
|
||||
writer.indent()
|
||||
writer.line("var signature = elementSignature")
|
||||
writer.line("if elementSignature == 0 {")
|
||||
writer.indent()
|
||||
writer.line("if let unboxedSignature = reader.readInt32() {")
|
||||
writer.indent()
|
||||
writer.line("signature = unboxedSignature")
|
||||
writer.dedent()
|
||||
writer.line("} else {")
|
||||
writer.indent()
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("if elementType == Buffer.self {")
|
||||
writer.indent()
|
||||
writer.line("if let item = parseBytes(reader) as? T {")
|
||||
writer.indent()
|
||||
writer.line("array.append(item)")
|
||||
writer.dedent()
|
||||
writer.line("} else {")
|
||||
writer.indent()
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("} else {")
|
||||
writer.indent()
|
||||
writer.line("if let item = Api.parse(reader, signature: signature) as? T {")
|
||||
writer.indent()
|
||||
writer.line("array.append(item)")
|
||||
writer.dedent()
|
||||
writer.line("} else {")
|
||||
writer.indent()
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("i += 1")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("return array")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
|
||||
writer.line("static func serializeObject(_ object: Any, buffer: Buffer, boxed: Swift.Bool) {")
|
||||
writer.indent()
|
||||
writer.line("switch object {")
|
||||
|
||||
let typeOrder = constructorOrder.map(\.typeName).unique()
|
||||
|
||||
for typeName in typeOrder {
|
||||
guard let type = typeMap[typeName] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
|
||||
writer.line("case let _1 as Api.\(type.name):")
|
||||
writer.indent()
|
||||
writer.line("_1.serialize(buffer, boxed)")
|
||||
writer.dedent()
|
||||
}
|
||||
|
||||
writer.line("default:")
|
||||
writer.indent()
|
||||
writer.line("break")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
return writer.output()
|
||||
}
|
||||
|
||||
private static func generateImplFile(types: [Resolver.SumType], functions: [Resolver.Function], typeOrder: (types: [(typeName: QualifiedName, constructorNames: [String])], functions: [QualifiedName]), stubFunctions: Bool) throws -> String {
|
||||
var writer = CodeWriter()
|
||||
|
||||
var typeMap: [QualifiedName: Resolver.SumType] = [:]
|
||||
for type in types {
|
||||
typeMap[type.name] = type
|
||||
}
|
||||
|
||||
for (typeName, constructorNames) in typeOrder.types {
|
||||
writer.line("public extension Api\(typeName.namespace.flatMap { "." + $0 } ?? "") {")
|
||||
writer.indent()
|
||||
|
||||
guard let type = typeMap[typeName] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
|
||||
let indirectPrefix = try type.hasDirectReference(to: [type], typeMap: typeMap) ? "indirect " : ""
|
||||
writer.line("\(indirectPrefix)enum \(typeName.value): TypeConstructorDescription {")
|
||||
writer.indent()
|
||||
|
||||
var sortedConstructors: [Resolver.SumType.Constructor] = []
|
||||
for constructorName in constructorNames {
|
||||
var foundConstructor: Resolver.SumType.Constructor?
|
||||
for (_, constructor) in type.constructors {
|
||||
if constructor.name.value == constructorName {
|
||||
foundConstructor = constructor
|
||||
break
|
||||
}
|
||||
}
|
||||
guard let constructor = foundConstructor else {
|
||||
throw CodeGenerationError(text: "Constructor \(constructorName) -> \(typeName) not found")
|
||||
}
|
||||
sortedConstructors.append(constructor)
|
||||
}
|
||||
|
||||
let useStructPattern = true
|
||||
|
||||
if useStructPattern {
|
||||
for constructor in sortedConstructors {
|
||||
var fieldsString = ""
|
||||
var initParamsString = ""
|
||||
var initBodyString = ""
|
||||
var descriptionFieldsString = ""
|
||||
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
let fieldName = argument.name.camelCasedAndEscaped
|
||||
let fieldType = typeReferenceRepresentation(argument.type) + (argument.condition != nil ? "?" : "")
|
||||
|
||||
if !fieldsString.isEmpty {
|
||||
fieldsString.append("\n")
|
||||
}
|
||||
fieldsString.append("public var \(fieldName): \(fieldType)")
|
||||
|
||||
if !initParamsString.isEmpty {
|
||||
initParamsString.append(", ")
|
||||
}
|
||||
initParamsString.append("\(fieldName): \(fieldType)")
|
||||
|
||||
if !initBodyString.isEmpty {
|
||||
initBodyString.append("\n")
|
||||
}
|
||||
initBodyString.append("self.\(fieldName) = \(fieldName)")
|
||||
|
||||
if !descriptionFieldsString.isEmpty {
|
||||
descriptionFieldsString.append(", ")
|
||||
}
|
||||
descriptionFieldsString.append("(\"\(fieldName)\", ConstructorParameterDescription(self.\(fieldName)))")
|
||||
}
|
||||
|
||||
if !fieldsString.isEmpty {
|
||||
writer.line("public class Cons_\(constructor.name.value): TypeConstructorDescription {")
|
||||
writer.indent()
|
||||
writer.lines(fieldsString)
|
||||
writer.line("public init(\(initParamsString)) {")
|
||||
writer.indent()
|
||||
writer.lines(initBodyString)
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {")
|
||||
writer.indent()
|
||||
writer.line("return (\"\(constructor.name.value)\", [\(descriptionFieldsString)])")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for constructor in sortedConstructors {
|
||||
let hasFields = constructor.arguments.contains { if case .boolTrue = $0.type { return false } else { return true } }
|
||||
|
||||
if useStructPattern && hasFields {
|
||||
writer.line("case \(constructor.name.value)(Cons_\(constructor.name.value))")
|
||||
} else {
|
||||
var argumentsString = ""
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if !argumentsString.isEmpty {
|
||||
argumentsString.append(", ")
|
||||
}
|
||||
|
||||
argumentsString.append(argument.name.camelCased)
|
||||
argumentsString.append(": ")
|
||||
argumentsString.append(typeReferenceRepresentation(argument.type))
|
||||
if argument.condition != nil {
|
||||
argumentsString.append("?")
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("case \(constructor.name.value)\(argumentsString.isEmpty ? "" : "(\(argumentsString))")")
|
||||
}
|
||||
}
|
||||
|
||||
writer.line()
|
||||
writer.line("public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {")
|
||||
writer.indent()
|
||||
if stubFunctions {
|
||||
writer.line("#if DEBUG")
|
||||
writer.line("preconditionFailure()")
|
||||
writer.line("#else")
|
||||
writer.line("error")
|
||||
writer.line("#endif")
|
||||
} else {
|
||||
writer.line("switch self {")
|
||||
|
||||
for constructor in sortedConstructors {
|
||||
let hasFields = constructor.arguments.contains { if case .boolTrue = $0.type { return false } else { return true } }
|
||||
|
||||
if useStructPattern && hasFields {
|
||||
writer.line("case .\(constructor.name.value)(let _data):")
|
||||
writer.indent()
|
||||
writer.line("if boxed {")
|
||||
writer.indent()
|
||||
writer.line("buffer.appendInt32(\(Int32(bitPattern: constructor.id)))")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
var argumentAccessor = "_data.\(argument.name.camelCasedAndEscaped)"
|
||||
if let condition = argument.condition {
|
||||
writer.line("if Int(_data.\(condition.fieldName.camelCasedAndEscaped)) & Int(1 << \(condition.bitIndex)) != 0 {")
|
||||
writer.indent()
|
||||
argumentAccessor.append("!")
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
}
|
||||
}
|
||||
writer.line("break")
|
||||
writer.dedent()
|
||||
} else {
|
||||
var argumentsString = ""
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if !argumentsString.isEmpty {
|
||||
argumentsString.append(", ")
|
||||
}
|
||||
|
||||
argumentsString.append("let ")
|
||||
argumentsString.append(argument.name.camelCasedAndEscaped)
|
||||
}
|
||||
|
||||
writer.line("case .\(constructor.name.value)\(argumentsString.isEmpty ? "" : "(\(argumentsString))"):")
|
||||
writer.indent()
|
||||
writer.line("if boxed {")
|
||||
writer.indent()
|
||||
writer.line("buffer.appendInt32(\(Int32(bitPattern: constructor.id)))")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
var argumentAccessor = "\(argument.name.camelCasedAndEscaped)"
|
||||
if let condition = argument.condition {
|
||||
writer.line("if Int(\(condition.fieldName)) & Int(1 << \(condition.bitIndex)) != 0 {")
|
||||
writer.indent()
|
||||
argumentAccessor.append("!")
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
}
|
||||
}
|
||||
writer.line("break")
|
||||
writer.dedent()
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("}")
|
||||
} // end if !stubFunctions
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
writer.line("public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {")
|
||||
writer.indent()
|
||||
if stubFunctions {
|
||||
writer.line("#if DEBUG")
|
||||
writer.line("preconditionFailure()")
|
||||
writer.line("#else")
|
||||
writer.line("error")
|
||||
writer.line("#endif")
|
||||
} else {
|
||||
writer.line("switch self {")
|
||||
|
||||
for constructor in sortedConstructors {
|
||||
let hasFields = constructor.arguments.contains { if case .boolTrue = $0.type { return false } else { return true } }
|
||||
|
||||
if useStructPattern && hasFields {
|
||||
var argumentSerializationString = ""
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if !argumentSerializationString.isEmpty {
|
||||
argumentSerializationString.append(", ")
|
||||
}
|
||||
argumentSerializationString.append("(\"\(argument.name.camelCasedAndEscaped)\", ConstructorParameterDescription(_data.\(argument.name.camelCasedAndEscaped)))")
|
||||
}
|
||||
|
||||
writer.line("case .\(constructor.name.value)(let _data):")
|
||||
writer.indent()
|
||||
writer.line("return (\"\(constructor.name.value)\", [\(argumentSerializationString)])")
|
||||
writer.dedent()
|
||||
} else {
|
||||
var argumentsString = ""
|
||||
var argumentSerializationString = ""
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if !argumentsString.isEmpty {
|
||||
argumentsString.append(", ")
|
||||
}
|
||||
if !argumentSerializationString.isEmpty {
|
||||
argumentSerializationString.append(", ")
|
||||
}
|
||||
|
||||
argumentsString.append("let ")
|
||||
argumentsString.append(argument.name.camelCasedAndEscaped)
|
||||
|
||||
argumentSerializationString.append("(\"\(argument.name.camelCasedAndEscaped)\", \(argument.name.camelCasedAndEscaped) as Any)")
|
||||
}
|
||||
|
||||
writer.line("case .\(constructor.name.value)\(argumentsString.isEmpty ? "" : "(\(argumentsString))"):")
|
||||
writer.indent()
|
||||
writer.line("return (\"\(constructor.name.value)\", [\(argumentSerializationString)])")
|
||||
writer.dedent()
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("}")
|
||||
} // end if !stubFunctions for descriptionFields
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.line()
|
||||
|
||||
for constructor in sortedConstructors {
|
||||
writer.line("public static func parse_\(constructor.name.value)(_ reader: BufferReader) -> \(typeName.value)? {")
|
||||
writer.indent()
|
||||
if stubFunctions {
|
||||
writer.line("#if DEBUG")
|
||||
writer.line("preconditionFailure()")
|
||||
writer.line("#else")
|
||||
writer.line("error")
|
||||
writer.line("#endif")
|
||||
} else {
|
||||
|
||||
if constructor.arguments.contains(where: { if case .boolTrue = $0.type { return false } else { return true } }) {
|
||||
var argumentIndex = 0
|
||||
var argumentCheckString = ""
|
||||
var argumentCollectionString = ""
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
writer.line("var _\(argumentIndex + 1): \(typeReferenceRepresentation(argument.type))?")
|
||||
|
||||
if let condition = argument.condition {
|
||||
guard let fieldIndex = constructor.arguments.filter({ if case .boolTrue = $0.type { return false } else { return true } }).firstIndex(where: { $0.name == condition.fieldName }) else {
|
||||
throw CodeGenerationError(text: "Condition field \(condition.fieldName) not found")
|
||||
}
|
||||
|
||||
writer.line("if Int(_\(fieldIndex + 1)!) & Int(1 << \(condition.bitIndex)) != 0 {")
|
||||
writer.indent()
|
||||
try generateFieldParsing(writer: &writer, typeMap: typeMap, argument: argument, argumentAccessor: "_\(argumentIndex + 1)")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
try generateFieldParsing(writer: &writer, typeMap: typeMap, argument: argument, argumentAccessor: "_\(argumentIndex + 1)")
|
||||
}
|
||||
|
||||
if !argumentCheckString.isEmpty {
|
||||
argumentCheckString.append(" && ")
|
||||
}
|
||||
argumentCheckString.append("_c\(argumentIndex + 1)")
|
||||
|
||||
if !argumentCollectionString.isEmpty {
|
||||
argumentCollectionString.append(", ")
|
||||
}
|
||||
argumentCollectionString.append("\(argument.name.camelCased): _\(argumentIndex + 1)")
|
||||
if argument.condition == nil {
|
||||
argumentCollectionString.append("!")
|
||||
}
|
||||
|
||||
argumentIndex += 1
|
||||
}
|
||||
|
||||
var checkIndex = 0
|
||||
for argument in constructor.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if let condition = argument.condition {
|
||||
guard let fieldIndex = constructor.arguments.filter({ if case .boolTrue = $0.type { return false } else { return true } }).firstIndex(where: { $0.name == condition.fieldName }) else {
|
||||
throw CodeGenerationError(text: "Condition field \(condition.fieldName) not found")
|
||||
}
|
||||
|
||||
writer.line("let _c\(checkIndex + 1) = (Int(_\(fieldIndex + 1)!) & Int(1 << \(condition.bitIndex)) == 0) || _\(checkIndex + 1) != nil")
|
||||
} else {
|
||||
writer.line("let _c\(checkIndex + 1) = _\(checkIndex + 1) != nil")
|
||||
}
|
||||
|
||||
checkIndex += 1
|
||||
}
|
||||
|
||||
writer.line("if \(argumentCheckString) {")
|
||||
writer.indent()
|
||||
if useStructPattern && !argumentCollectionString.isEmpty {
|
||||
writer.line("return Api.\(typeName).\(constructor.name.value)(Cons_\(constructor.name.value)(\(argumentCollectionString)))")
|
||||
} else {
|
||||
writer.line("return Api.\(typeName).\(constructor.name.value)\(argumentCollectionString.isEmpty ? "" : "(\(argumentCollectionString))")")
|
||||
}
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.line("else {")
|
||||
writer.indent()
|
||||
writer.line("return nil")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
writer.line("return Api.\(typeName).\(constructor.name.value)")
|
||||
}
|
||||
|
||||
} // end if !stubFunctions
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
}
|
||||
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
}
|
||||
|
||||
if !typeOrder.functions.isEmpty {
|
||||
for functionName in typeOrder.functions {
|
||||
writer.line("public extension Api.functions\(functionName.namespace.flatMap { "." + $0 } ?? "") {")
|
||||
writer.indent()
|
||||
|
||||
var foundFunction: Resolver.Function?
|
||||
for function in functions {
|
||||
if function.name == functionName {
|
||||
foundFunction = function
|
||||
break
|
||||
}
|
||||
}
|
||||
guard let function = foundFunction else {
|
||||
throw CodeGenerationError(text: "Function \(functionName) not found")
|
||||
}
|
||||
|
||||
var argumentsString = ""
|
||||
for argument in function.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
if !argumentsString.isEmpty {
|
||||
argumentsString.append(", ")
|
||||
}
|
||||
|
||||
argumentsString.append(argument.name.camelCasedAndEscaped)
|
||||
argumentsString.append(": ")
|
||||
argumentsString.append(typeReferenceRepresentation(argument.type))
|
||||
if argument.condition != nil {
|
||||
argumentsString.append("?")
|
||||
}
|
||||
}
|
||||
|
||||
writer.line("static func \(function.name.value)(\(argumentsString)) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<\(typeReferenceRepresentation(function.result))>) {")
|
||||
writer.indent()
|
||||
writer.line("let buffer = Buffer()")
|
||||
writer.line("buffer.appendInt32(\(Int32(bitPattern: function.id)))")
|
||||
|
||||
var argumentSerializationString = ""
|
||||
for argument in function.arguments {
|
||||
if case .boolTrue = argument.type {
|
||||
continue
|
||||
}
|
||||
|
||||
var argumentAccessor = "\(argument.name.camelCasedAndEscaped)"
|
||||
if let condition = argument.condition {
|
||||
guard let _ = function.arguments.filter({ if case .boolTrue = $0.type { return false } else { return true } }).firstIndex(where: { $0.name == condition.fieldName }) else {
|
||||
throw CodeGenerationError(text: "Condition field \(condition.fieldName) not found")
|
||||
}
|
||||
|
||||
writer.line("if Int(\(condition.fieldName)) & Int(1 << \(condition.bitIndex)) != 0 {")
|
||||
writer.indent()
|
||||
argumentAccessor.append("!")
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
generateFieldSerialization(writer: &writer, argument: argument, argumentAccessor: argumentAccessor)
|
||||
}
|
||||
|
||||
if !argumentSerializationString.isEmpty {
|
||||
argumentSerializationString.append(", ")
|
||||
}
|
||||
|
||||
argumentSerializationString.append("(\"\(argument.name.camelCasedAndEscaped)\", ConstructorParameterDescription(\(argument.name.camelCasedAndEscaped)))")
|
||||
}
|
||||
|
||||
writer.line("return (FunctionDescription(name: \"\(function.name)\", parameters: [\(argumentSerializationString)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> \(typeReferenceRepresentation(function.result))? in")
|
||||
writer.indent()
|
||||
writer.line("let reader = BufferReader(buffer)")
|
||||
writer.line("var result: \(typeReferenceRepresentation(function.result))?")
|
||||
|
||||
try generateFieldParsing(writer: &writer, typeMap: typeMap, argument: Resolver.Argument(name: "result", type: function.result, condition: nil), argumentAccessor: "result")
|
||||
|
||||
writer.line("return result")
|
||||
writer.dedent()
|
||||
writer.line("})")
|
||||
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
}
|
||||
}
|
||||
|
||||
return writer.output()
|
||||
}
|
||||
|
||||
private static func generateFieldSerialization(writer: inout CodeWriter, argument: Resolver.Argument, argumentAccessor: String) {
|
||||
switch argument.type {
|
||||
case .int32:
|
||||
writer.line("serializeInt32(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .int64:
|
||||
writer.line("serializeInt64(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .int256:
|
||||
writer.line("serializeInt256(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .double:
|
||||
writer.line("serializeDouble(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .bytes:
|
||||
writer.line("serializeBytes(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .string:
|
||||
writer.line("serializeString(\(argumentAccessor), buffer: buffer, boxed: false)")
|
||||
case .bool:
|
||||
preconditionFailure()
|
||||
case .boolTrue:
|
||||
preconditionFailure()
|
||||
case .bareVector(let elementType), .boxedVector(let elementType):
|
||||
if case .boxedVector = argument.type {
|
||||
writer.line("buffer.appendInt32(481674261)")
|
||||
}
|
||||
writer.line("buffer.appendInt32(Int32(\(argumentAccessor).count))")
|
||||
writer.line("for item in \(argumentAccessor) {")
|
||||
writer.indent()
|
||||
generateFieldSerialization(writer: &writer, argument: Resolver.Argument(name: "item", type: elementType, condition: nil), argumentAccessor: "item")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
case .bareConstructor:
|
||||
writer.line("\(argumentAccessor).serialize(buffer, false)")
|
||||
case .boxedType:
|
||||
writer.line("\(argumentAccessor).serialize(buffer, true)")
|
||||
}
|
||||
}
|
||||
|
||||
private static func generateFieldParsing(writer: inout CodeWriter, typeMap: [QualifiedName: Resolver.SumType], argument: Resolver.Argument, argumentAccessor: String) throws {
|
||||
switch argument.type {
|
||||
case .int32:
|
||||
writer.line("\(argumentAccessor) = reader.readInt32()")
|
||||
case .int64:
|
||||
writer.line("\(argumentAccessor) = reader.readInt64()")
|
||||
case .int256:
|
||||
writer.line("\(argumentAccessor) = parseInt256(reader)")
|
||||
case .double:
|
||||
writer.line("\(argumentAccessor) = reader.readDouble()")
|
||||
case .bytes:
|
||||
writer.line("\(argumentAccessor) = parseBytes(reader)")
|
||||
case .string:
|
||||
writer.line("\(argumentAccessor) = parseString(reader)")
|
||||
case .bool:
|
||||
preconditionFailure()
|
||||
case .boolTrue:
|
||||
preconditionFailure()
|
||||
case .bareVector(let elementType), .boxedVector(let elementType):
|
||||
var elementSignature: Int32 = 0
|
||||
|
||||
switch elementType {
|
||||
case .int32:
|
||||
elementSignature = -1471112230
|
||||
case .int64:
|
||||
elementSignature = 570911930
|
||||
case .int256:
|
||||
elementSignature = 0x0929C32F
|
||||
case .double:
|
||||
elementSignature = 571523412
|
||||
case .bytes:
|
||||
elementSignature = -1255641564
|
||||
case .string:
|
||||
elementSignature = -1255641564
|
||||
case .bool:
|
||||
elementSignature = 0
|
||||
case .boolTrue:
|
||||
elementSignature = 0
|
||||
case .bareVector:
|
||||
elementSignature = 0
|
||||
case .boxedVector:
|
||||
elementSignature = 0
|
||||
case let .bareConstructor(typeName, name):
|
||||
guard let type = typeMap[typeName] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
guard let constructor = type.constructors[name] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
elementSignature = Int32(bitPattern: constructor.id)
|
||||
case .boxedType:
|
||||
elementSignature = 0
|
||||
}
|
||||
|
||||
if case .boxedVector = argument.type {
|
||||
writer.line("if let _ = reader.readInt32() {")
|
||||
writer.indent()
|
||||
writer.line("\(argumentAccessor) = Api.parseVector(reader, elementSignature: \(elementSignature), elementType: \(typeReferenceRepresentation(elementType)).self)")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
} else {
|
||||
writer.line("\(argumentAccessor) = Api.parseVector(reader, elementSignature: \(elementSignature), elementType: \(typeReferenceRepresentation(elementType)).self)")
|
||||
}
|
||||
case let .bareConstructor(typeName, name):
|
||||
guard let type = typeMap[typeName] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
guard let constructor = type.constructors[name] else {
|
||||
throw CodeGenerationError(text: "Type \(typeName) not found")
|
||||
}
|
||||
writer.line("\(argumentAccessor) = Api.parse(reader, signature: \(Int32(bitPattern: constructor.id)) as? \(typeReferenceRepresentation(argument.type))")
|
||||
case .boxedType:
|
||||
writer.line("if let signature = reader.readInt32() {")
|
||||
writer.indent()
|
||||
writer.line("\(argumentAccessor) = Api.parse(reader, signature: signature) as? \(typeReferenceRepresentation(argument.type))")
|
||||
writer.dedent()
|
||||
writer.line("}")
|
||||
}
|
||||
}
|
||||
}
|
||||
228
build-system/SwiftTL/Sources/SwiftTL/DescriptionParsing.swift
Normal file
228
build-system/SwiftTL/Sources/SwiftTL/DescriptionParsing.swift
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
import Foundation
|
||||
|
||||
enum DescriptionParser {
|
||||
enum TypeReferenceDescription {
|
||||
case generic(name: String, argumentType: QualifiedName)
|
||||
case type(name: QualifiedName)
|
||||
}
|
||||
|
||||
struct ArgumentDescription {
|
||||
struct ConditionDescription {
|
||||
var fieldName: String
|
||||
var bitIndex: Int
|
||||
}
|
||||
|
||||
var name: String
|
||||
var type: TypeReferenceDescription
|
||||
var condition: ConditionDescription?
|
||||
}
|
||||
|
||||
struct ConstructorDescription {
|
||||
var name: QualifiedName
|
||||
var explicitId: UInt32?
|
||||
var arguments: [ArgumentDescription]
|
||||
var type: TypeReferenceDescription
|
||||
}
|
||||
|
||||
static func parse(data: String) throws -> (constructors: [ConstructorDescription], functions: [ConstructorDescription]) {
|
||||
let lines = data.components(separatedBy: "\n")
|
||||
|
||||
var typeLines: [String] = []
|
||||
var functionLines: [String] = []
|
||||
|
||||
let skipPrefixes: [String] = [
|
||||
//"boolFalse#bc799737 = Bool;",
|
||||
//"boolTrue#997275b5 = Bool;",
|
||||
"true#3fedd339 = True;",
|
||||
"vector#1cb5c415 {t:Type} # [ t ] = Vector t;",
|
||||
"error#c4b9f9bb code:int text:string = Error;",
|
||||
"null#56730bcc = Null;"
|
||||
]
|
||||
|
||||
let skipContains: [String] = [
|
||||
"{X:Type}"
|
||||
]
|
||||
|
||||
var isParsingFunctions = false
|
||||
loop: for line in lines {
|
||||
if line.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty {
|
||||
// skip
|
||||
} else if line == "---functions---" {
|
||||
isParsingFunctions = true
|
||||
} else {
|
||||
for string in skipPrefixes {
|
||||
if line.hasPrefix(string) {
|
||||
continue loop
|
||||
}
|
||||
}
|
||||
|
||||
for string in skipContains {
|
||||
if line.contains(string) {
|
||||
continue loop
|
||||
}
|
||||
}
|
||||
|
||||
if isParsingFunctions {
|
||||
functionLines.append(line)
|
||||
} else {
|
||||
typeLines.append(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var constructors: [ConstructorDescription] = []
|
||||
var functions: [ConstructorDescription] = []
|
||||
|
||||
for line in typeLines {
|
||||
do {
|
||||
let constructor = try self.parseConstructor(string: line)
|
||||
constructors.append(constructor)
|
||||
} catch let e {
|
||||
print("Error while parsing line:\n\(line)\n")
|
||||
print("\(e)")
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
for line in functionLines {
|
||||
do {
|
||||
let constructor = try parseConstructor(string: line)
|
||||
functions.append(constructor)
|
||||
} catch let e {
|
||||
print("Error while parsing line:\n\(line)\n")
|
||||
print("\(e)")
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
return (constructors, functions)
|
||||
}
|
||||
|
||||
private static func parseConstructor(string: String) throws -> ConstructorDescription {
|
||||
let parseIdentifier = Parse {
|
||||
Prefix<Substring>(minLength: 1, while: { $0.isLetter || $0.isNumber || $0 == "_" })
|
||||
}.map { String($0) }
|
||||
|
||||
let parseConditionDescription = Parse {
|
||||
parseIdentifier
|
||||
"."
|
||||
Int.parser(of: Substring.self)
|
||||
"?"
|
||||
}.map { fieldName, bitIndex -> ArgumentDescription.ConditionDescription in
|
||||
ArgumentDescription.ConditionDescription(fieldName: fieldName, bitIndex: bitIndex)
|
||||
}
|
||||
|
||||
let parseQualifiedName = Parse {
|
||||
parseIdentifier
|
||||
Optionally {
|
||||
"."
|
||||
parseIdentifier
|
||||
}
|
||||
}.map { first, second -> QualifiedName in
|
||||
if let second = second {
|
||||
return QualifiedName(namespace: first, value: second)
|
||||
} else {
|
||||
return QualifiedName(namespace: nil, value: first)
|
||||
}
|
||||
}
|
||||
|
||||
let parseGenericTypeReference = Parse {
|
||||
parseIdentifier
|
||||
"<"
|
||||
parseQualifiedName
|
||||
">"
|
||||
}.map { name, argumentType -> TypeReferenceDescription in
|
||||
return .generic(name: name, argumentType: argumentType)
|
||||
}
|
||||
|
||||
let parseDirectTypeReference = Parse {
|
||||
parseQualifiedName
|
||||
}.map { name -> TypeReferenceDescription in
|
||||
return .type(name: name)
|
||||
}
|
||||
|
||||
let parseFlagsTypeReference = Parse {
|
||||
"#"
|
||||
}.map { () -> TypeReferenceDescription in
|
||||
return .type(name: QualifiedName(namespace: nil, value: "int"))
|
||||
}
|
||||
|
||||
let parseTypeReference = Parse {
|
||||
OneOf {
|
||||
parseFlagsTypeReference
|
||||
parseGenericTypeReference
|
||||
parseDirectTypeReference
|
||||
}
|
||||
}
|
||||
|
||||
let parseArgument = Parse {
|
||||
parseIdentifier
|
||||
":"
|
||||
Optionally {
|
||||
parseConditionDescription
|
||||
}
|
||||
parseTypeReference
|
||||
}.map { name, condition, type -> ArgumentDescription in
|
||||
return ArgumentDescription(name: name, type: type, condition: condition)
|
||||
}
|
||||
|
||||
let parseExplicitId = Parse {
|
||||
"#"
|
||||
Prefix<Substring> { $0.isHexDigit }
|
||||
}.map { UInt32($0, radix: 16)! }
|
||||
|
||||
let optionalExplicitId = Optionally {
|
||||
parseExplicitId
|
||||
}
|
||||
|
||||
let manyArguments = Many {
|
||||
parseArgument
|
||||
} separator: {
|
||||
Whitespace()
|
||||
}
|
||||
|
||||
let nameAndConstructor = Parse {
|
||||
parseQualifiedName
|
||||
optionalExplicitId
|
||||
Whitespace()
|
||||
}.map { name, explicitId, _ -> (name: QualifiedName, explicitId: UInt32?) in
|
||||
return (name, explicitId)
|
||||
}
|
||||
|
||||
let typeSeparator = Parse {
|
||||
Whitespace()
|
||||
"="
|
||||
Whitespace()
|
||||
}
|
||||
|
||||
let trailerParser = Parse {
|
||||
Whitespace()
|
||||
";"
|
||||
Whitespace()
|
||||
End()
|
||||
}.map { _ -> Void in
|
||||
}
|
||||
|
||||
let parseConstructor = Parse {
|
||||
nameAndConstructor
|
||||
manyArguments
|
||||
typeSeparator
|
||||
parseTypeReference
|
||||
trailerParser
|
||||
}.map { nameAndConstructor, arguments, _, type -> ConstructorDescription in
|
||||
return ConstructorDescription(
|
||||
name: nameAndConstructor.name,
|
||||
explicitId: nameAndConstructor.explicitId,
|
||||
arguments: arguments,
|
||||
type: type
|
||||
)
|
||||
}
|
||||
|
||||
var data = string[...]
|
||||
let result = try parseConstructor.parse(&data)
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
128
build-system/SwiftTL/Sources/SwiftTL/LegacyOrderParser.swift
Normal file
128
build-system/SwiftTL/Sources/SwiftTL/LegacyOrderParser.swift
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import Foundation
|
||||
|
||||
enum LegacyOrderParser {
|
||||
struct LegacyOrderParsingError: Error, CustomStringConvertible {
|
||||
var text: String
|
||||
|
||||
var description: String {
|
||||
return self.text
|
||||
}
|
||||
}
|
||||
|
||||
static func parseConstructorOrder(data: String) throws -> [(typeName: QualifiedName, constructorName: String)] {
|
||||
let lines = data.split(separator: "\n")
|
||||
|
||||
var result: [(typeName: QualifiedName, constructorName: String)] = []
|
||||
|
||||
for line in lines {
|
||||
if let startRange = line.range(of: " = { return Api."), let endRange = line.range(of: "($0) }", options: [.backwards], range: nil) {
|
||||
let parseString = line[startRange.upperBound ..< endRange.lowerBound]
|
||||
let components = parseString.components(separatedBy: ".parse_")
|
||||
if components.count != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
result.append((QualifiedName(string: components[0]), components[1]))
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
static func parseTypeOrder(data: String) throws -> (types: [(typeName: QualifiedName, constructorNames: [String])], functions: [QualifiedName]) {
|
||||
var resultTypes: [(typeName: QualifiedName, constructorNames: [String])] = []
|
||||
var resultFunctions: [QualifiedName] = []
|
||||
|
||||
let namespaces = data.components(separatedBy: "public extension Api {\n")
|
||||
|
||||
enum ParseSection {
|
||||
case types
|
||||
case functions
|
||||
}
|
||||
|
||||
for namespaceData in namespaces {
|
||||
if namespaceData.isEmpty {
|
||||
continue
|
||||
}
|
||||
guard let firstNewline = namespaceData.range(of: "\n") else {
|
||||
throw LegacyOrderParsingError(text: "No newline in the beginning of the namespace section")
|
||||
}
|
||||
let namespaceName: String?
|
||||
let namespaceContentData: String
|
||||
let parseSection: ParseSection
|
||||
if let prefixRange = namespaceData.range(of: " public enum ", options: [], range: namespaceData.startIndex ..< firstNewline.lowerBound), prefixRange.lowerBound == namespaceData.startIndex {
|
||||
namespaceName = nil
|
||||
namespaceContentData = namespaceData
|
||||
parseSection = .types
|
||||
} else if let prefixRange = namespaceData.range(of: " indirect public enum ", options: [], range: namespaceData.startIndex ..< firstNewline.lowerBound), prefixRange.lowerBound == namespaceData.startIndex {
|
||||
namespaceName = nil
|
||||
namespaceContentData = namespaceData
|
||||
parseSection = .types
|
||||
} else if let prefixRange = namespaceData.range(of: " public struct functions {", options: [], range: namespaceData.startIndex ..< firstNewline.lowerBound), prefixRange.upperBound == firstNewline.lowerBound {
|
||||
namespaceName = nil
|
||||
namespaceContentData = namespaceData
|
||||
parseSection = .functions
|
||||
} else {
|
||||
guard let prefixRange = namespaceData.range(of: "public struct ", options: [], range: namespaceData.startIndex ..< firstNewline.lowerBound), prefixRange.lowerBound == namespaceData.startIndex else {
|
||||
throw LegacyOrderParsingError(text: "Missing header prefix in the beginning of the namespace section")
|
||||
}
|
||||
guard let trailerRange = namespaceData.range(of: " {", options: [], range: prefixRange.upperBound ..< firstNewline.lowerBound) else {
|
||||
throw LegacyOrderParsingError(text: "Missing trailing suffix in the beginning of the namespace section")
|
||||
}
|
||||
namespaceName = String(namespaceData[prefixRange.upperBound ..< trailerRange.lowerBound])
|
||||
namespaceContentData = String(namespaceData[firstNewline.upperBound...])
|
||||
parseSection = .types
|
||||
}
|
||||
|
||||
let namespaceContentLines = namespaceContentData.split(separator: "\n")
|
||||
|
||||
switch parseSection {
|
||||
case .types:
|
||||
var currentType: (typeName: QualifiedName, constructorNames: [String])?
|
||||
for line in namespaceContentLines {
|
||||
if let typePrefixRange = line.range(of: " public enum "), typePrefixRange.lowerBound == line.startIndex, let typeSuffixRange = line.range(of: ": TypeConstructorDescription {"), typeSuffixRange.upperBound == line.endIndex {
|
||||
let typeName = String(line[typePrefixRange.upperBound ..< typeSuffixRange.lowerBound])
|
||||
if let currentType = currentType {
|
||||
resultTypes.append(currentType)
|
||||
}
|
||||
currentType = (QualifiedName(namespace: namespaceName, value: typeName), [])
|
||||
} else if let typePrefixRange = line.range(of: " indirect public enum "), typePrefixRange.lowerBound == line.startIndex, let typeSuffixRange = line.range(of: ": TypeConstructorDescription {"), typeSuffixRange.upperBound == line.endIndex {
|
||||
let typeName = String(line[typePrefixRange.upperBound ..< typeSuffixRange.lowerBound])
|
||||
if let currentType = currentType {
|
||||
resultTypes.append(currentType)
|
||||
}
|
||||
currentType = (QualifiedName(namespace: namespaceName, value: typeName), [])
|
||||
} else if currentType != nil, let constructorPrefixRange = line.range(of: " case "), constructorPrefixRange.lowerBound == line.startIndex {
|
||||
let constructorName: String
|
||||
if let bracketRange = line.range(of: "(") {
|
||||
constructorName = String(line[constructorPrefixRange.upperBound ..< bracketRange.lowerBound])
|
||||
} else {
|
||||
constructorName = String(line[constructorPrefixRange.upperBound...])
|
||||
}
|
||||
currentType?.constructorNames.append(constructorName)
|
||||
}
|
||||
}
|
||||
if let currentType = currentType {
|
||||
resultTypes.append(currentType)
|
||||
}
|
||||
case .functions:
|
||||
var currentNamespace: String?
|
||||
for line in namespaceContentLines {
|
||||
if let namespacePrefixRange = line.range(of: " public struct "), namespacePrefixRange.lowerBound == line.startIndex, let namespaceSuffixRange = line.range(of: " {"), namespaceSuffixRange.upperBound == line.endIndex {
|
||||
currentNamespace = String(line[namespacePrefixRange.upperBound ..< namespaceSuffixRange.lowerBound])
|
||||
} else if let functionPrefixRange = line.range(of: " public static func "), functionPrefixRange.lowerBound == line.startIndex {
|
||||
let functionName: String
|
||||
if let bracketRange = line.range(of: "(") {
|
||||
functionName = String(line[functionPrefixRange.upperBound ..< bracketRange.lowerBound])
|
||||
} else {
|
||||
functionName = String(line[functionPrefixRange.upperBound...])
|
||||
}
|
||||
resultFunctions.append(QualifiedName(namespace: currentNamespace, value: functionName))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (resultTypes, resultFunctions)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/// A custom parameter attribute that constructs parsers from closures. The constructed parser
|
||||
/// runs each parser in the closure, one after another, till one succeeds with an output.
|
||||
///
|
||||
/// The ``OneOf`` parser acts as an entry point into `@OneOfBuilder` syntax where you can list
|
||||
/// all of the parsers you want to try. For example, to parse a currency symbol into an enum
|
||||
/// of supported currencies:
|
||||
///
|
||||
/// ```swift
|
||||
/// enum Currency { case eur, gbp, usd }
|
||||
/// let currency = OneOf {
|
||||
/// "€".map { Currency.eur }
|
||||
/// "£".map { Currency.gbp }
|
||||
/// "$".map { Currency.usd }
|
||||
/// }
|
||||
/// let money = Parse { currency; Int.parser() }
|
||||
///
|
||||
/// try currency.parse("$100") // (.usd, 100)
|
||||
/// ```
|
||||
@resultBuilder
|
||||
public enum OneOfBuilder {
|
||||
/// Provides support for `for`-`in` loops in ``OneOfBuilder`` blocks.
|
||||
///
|
||||
/// Useful for building up a parser from a dynamic source, like for a case-iterable enum:
|
||||
///
|
||||
/// ```swift
|
||||
/// enum Role: String, CaseIterable {
|
||||
/// case admin
|
||||
/// case guest
|
||||
/// case member
|
||||
/// }
|
||||
///
|
||||
/// let roleParser = Parse {
|
||||
/// for role in Role.allCases {
|
||||
/// status.rawValue.map { role }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildArray<P>(_ parsers: [P]) -> Parsers.OneOfMany<P> {
|
||||
.init(parsers)
|
||||
}
|
||||
|
||||
/// Provides support for specifying a parser in ``OneOfBuilder`` blocks.
|
||||
@inlinable
|
||||
static public func buildBlock<P: Parser>(_ parser: P) -> P {
|
||||
parser
|
||||
}
|
||||
|
||||
/// Provides support for `if`-`else` statements in ``OneOfBuilder`` blocks, producing a
|
||||
/// conditional parser for the `if` branch.
|
||||
///
|
||||
/// ```swift
|
||||
/// OneOf {
|
||||
/// if useLegacyParser {
|
||||
/// LegacyParser()
|
||||
/// } else {
|
||||
/// NewParser()
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildEither<TrueParser, FalseParser>(
|
||||
first parser: TrueParser
|
||||
) -> Parsers.Conditional<TrueParser, FalseParser> {
|
||||
.first(parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if`-`else` statements in ``OneOfBuilder`` blocks, producing a
|
||||
/// conditional parser for the `if` branch.
|
||||
///
|
||||
/// ```swift
|
||||
/// OneOf {
|
||||
/// if useLegacyParser {
|
||||
/// LegacyParser()
|
||||
/// } else {
|
||||
/// NewParser()
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildEither<TrueParser, FalseParser>(
|
||||
second parser: FalseParser
|
||||
) -> Parsers.Conditional<TrueParser, FalseParser> {
|
||||
.second(parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if` statements in ``OneOfBuilder`` blocks, producing an optional parser.
|
||||
///
|
||||
/// ```swift
|
||||
/// let whitespace = OneOf {
|
||||
/// if shouldParseNewlines {
|
||||
/// "\r\n"
|
||||
/// "\r"
|
||||
/// "\n"
|
||||
/// }
|
||||
///
|
||||
/// " "
|
||||
/// "\t"
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildIf<P>(_ parser: P?) -> OptionalOneOf<P> {
|
||||
.init(wrapped: parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if #available` statements in ``OneOfBuilder`` blocks, producing an
|
||||
/// optional parser.
|
||||
@inlinable
|
||||
public static func buildLimitedAvailability<P>(_ parser: P?) -> OptionalOneOf<P> {
|
||||
.init(wrapped: parser)
|
||||
}
|
||||
|
||||
/// A parser that parses output from an optional parser.
|
||||
///
|
||||
/// You won't typically construct this parser directly, but instead will use standard `if`
|
||||
/// statements in a ``OneOfBuilder`` block to automatically build optional parsers:
|
||||
///
|
||||
/// ```swift
|
||||
/// let whitespace = OneOf {
|
||||
/// if shouldParseNewlines {
|
||||
/// "\r\n"
|
||||
/// "\r"
|
||||
/// "\n"
|
||||
/// }
|
||||
///
|
||||
/// " "
|
||||
/// "\t"
|
||||
/// }
|
||||
/// ```
|
||||
public struct OptionalOneOf<Wrapped: Parser>: Parser {
|
||||
@usableFromInline
|
||||
let wrapped: Wrapped?
|
||||
|
||||
@usableFromInline
|
||||
init(wrapped: Wrapped?) {
|
||||
self.wrapped = wrapped
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Wrapped.Input) throws -> Wrapped.Output {
|
||||
guard let wrapped = self.wrapped
|
||||
else { throw ParsingError.manyFailed([], at: input) }
|
||||
return try wrapped.parse(&input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/// A custom parameter attribute that constructs parsers from closures. The constructed parser
|
||||
/// runs a number of parsers, one after the other, and accumulates their outputs.
|
||||
///
|
||||
/// The ``Parse`` parser acts as an entry point into `@ParserBuilder` syntax, where you can list
|
||||
/// all of the parsers you want to run. For example, to parse two comma-separated integers:
|
||||
///
|
||||
/// ```swift
|
||||
/// try Parse {
|
||||
/// Int.parser()
|
||||
/// ","
|
||||
/// Int.parser()
|
||||
/// }
|
||||
/// .parse("123,456") // (123, 456)
|
||||
/// ```
|
||||
@resultBuilder
|
||||
public enum ParserBuilder {
|
||||
/// Provides support for specifying a parser in ``ParserBuilder`` blocks.
|
||||
@inlinable
|
||||
public static func buildBlock<P: Parser>(_ parser: P) -> P {
|
||||
parser
|
||||
}
|
||||
|
||||
/// Provides support for `if`-`else` statements in ``ParserBuilder`` blocks, producing a
|
||||
/// conditional parser for the `if` branch.
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// "Hello"
|
||||
/// if shouldParseComma {
|
||||
/// ", "
|
||||
/// } else {
|
||||
/// " "
|
||||
/// }
|
||||
/// Rest()
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildEither<TrueParser, FalseParser>(
|
||||
first parser: TrueParser
|
||||
) -> Parsers.Conditional<TrueParser, FalseParser> {
|
||||
.first(parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if`-`else` statements in ``ParserBuilder`` blocks, producing a
|
||||
/// conditional parser for the `else` branch.
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// "Hello"
|
||||
/// if shouldParseComma {
|
||||
/// ", "
|
||||
/// } else {
|
||||
/// " "
|
||||
/// }
|
||||
/// Rest()
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildEither<TrueParser, FalseParser>(
|
||||
second parser: FalseParser
|
||||
) -> Parsers.Conditional<TrueParser, FalseParser> {
|
||||
.second(parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if` statements in ``ParserBuilder`` blocks, producing an optional
|
||||
/// parser.
|
||||
@inlinable
|
||||
public static func buildIf<P: Parser>(_ parser: P?) -> P? {
|
||||
parser
|
||||
}
|
||||
|
||||
/// Provides support for `if` statements in ``ParserBuilder`` blocks, producing a void parser for
|
||||
/// a given void parser.
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// "Hello"
|
||||
/// if shouldParseComma {
|
||||
/// ","
|
||||
/// }
|
||||
/// " "
|
||||
/// Rest()
|
||||
/// }
|
||||
/// ```
|
||||
@inlinable
|
||||
public static func buildIf<P>(_ parser: P?) -> Parsers.OptionalVoid<P> {
|
||||
.init(wrapped: parser)
|
||||
}
|
||||
|
||||
/// Provides support for `if #available` statements in ``ParserBuilder`` blocks, producing an
|
||||
/// optional parser.
|
||||
@inlinable
|
||||
public static func buildLimitedAvailability<P: Parser>(_ parser: P?) -> P? {
|
||||
parser
|
||||
}
|
||||
|
||||
/// Provides support for `if #available` statements in ``ParserBuilder`` blocks, producing a void
|
||||
/// parser for a given void parser.
|
||||
@inlinable
|
||||
public static func buildLimitedAvailability<P>(_ parser: P?) -> Parsers.OptionalVoid<P> {
|
||||
.init(wrapped: parser)
|
||||
}
|
||||
}
|
||||
6317
build-system/SwiftTL/Sources/SwiftTL/Parser/Builders/Variadics.swift
Normal file
6317
build-system/SwiftTL/Sources/SwiftTL/Parser/Builders/Variadics.swift
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,132 @@
|
|||
# Backtracking
|
||||
|
||||
Learn what backtracking is, how it affects the performance of your parsers, and how to avoid it when
|
||||
unnecessary.
|
||||
|
||||
## Overview
|
||||
|
||||
Backtracking is the process of restoring an input to its original value when parsing fails. While it
|
||||
can be very useful, backtracking can lead to more complicated parser logic than necessary, and
|
||||
backtracking too often can lead to performance issues. For this reason, most parsers are not
|
||||
required to backtrack, and can therefore fail _and_ still consume from the input.
|
||||
|
||||
The primary way to make use of backtracking in your parsers is through the ``OneOf`` parser, which
|
||||
tries many parsers on an input and chooses the first that succeeds. This allows you to try many
|
||||
parsers on the same input, regardless of how much each parser consumes:
|
||||
|
||||
```swift
|
||||
enum Currency { case eur, gbp, usd }
|
||||
|
||||
let currency = OneOf {
|
||||
"€".map { Currency.eur }
|
||||
"£".map { Currency.gbp }
|
||||
"$".map { Currency.usd }
|
||||
}
|
||||
```
|
||||
|
||||
## When to backtrack in your parsers?
|
||||
|
||||
If you only use the parsers and operators that ship with this library, and in particular you do not
|
||||
create custom conformances to the ``Parser`` protocol, then you never need to worry about explicitly
|
||||
backtracking your input because it will be handled for you automatically. The primary way to allow
|
||||
for backtracking is via the ``OneOf`` parser, but there are a few other parsers that also backtrack
|
||||
internally.
|
||||
|
||||
One such example is the ``Optionally`` parser, which transforms any parser into one that cannot fail
|
||||
by catching any thrown errors and returning `nil`:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
"Hello,"
|
||||
Optionally { " "; Bool.parser() }
|
||||
" world!"
|
||||
}
|
||||
|
||||
try parser.parse("Hello, world!") // nil
|
||||
try parser.parse("Hello, true world!") // true
|
||||
```
|
||||
|
||||
If the parser captured inside ``Optionally`` fails then it backtracks the input to its state before
|
||||
the parser ran. In particular, if the `Bool.parser()` fails then it will make sure to undo
|
||||
consuming the leading space " " so that later parsers can try.
|
||||
|
||||
Another example of a parser that internally backtracks is the ``Parser/replaceError(with:)``
|
||||
operator, which coalesces any error thrown by a parser into a default output value:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
"Hello,"
|
||||
Optionally { " "; Bool.parser() }
|
||||
.replaceError(with: false)
|
||||
" world!"
|
||||
}
|
||||
|
||||
try parser.parse("Hello, world!") // false
|
||||
try parser.parse("Hello, true world!") // true
|
||||
```
|
||||
|
||||
It backtracks the input to its original value when the parser fails so that later parsers can try.
|
||||
|
||||
The only time you need to worry about explicitly backtracking input is when making your own
|
||||
``Parser`` conformances. As a general rule of thumb, if your parser recovers from all failures
|
||||
in the `parse` method then it should backtrack the input to its state before the error was thrown.
|
||||
This is exactly how ``OneOf``, ``Optionally`` and ``Parser/replaceError(with:)`` work.
|
||||
|
||||
## Performance
|
||||
|
||||
If used naively, backtracking can lead to less performant parsing code. For example, if we wanted to
|
||||
parse two integers from a string that were separated by either a dash "-" or slash "/", then we
|
||||
could write this as:
|
||||
|
||||
```swift
|
||||
OneOf {
|
||||
Parse { Int.parser(); "-"; Int.parser() } // 1️⃣
|
||||
Parse { Int.parser(); "/"; Int.parser() } // 2️⃣
|
||||
}
|
||||
```
|
||||
|
||||
However, parsing slash-separated integers is not going to be performant because it will first run
|
||||
the entire 1️⃣ parser until it fails, then backtrack to the beginning, and run the 2️⃣ parser. In
|
||||
particular, the first integer will get parsed twice, unnecessarily repeating that work.
|
||||
|
||||
On the other hand, we can factor out the common work of the parser and localize the backtracking
|
||||
``OneOf`` work to make a much more performant parser:
|
||||
|
||||
```swift
|
||||
Parse {
|
||||
Int.parser()
|
||||
OneOf { "-"; "/" }
|
||||
Int.parser()
|
||||
}
|
||||
```
|
||||
|
||||
We can even write a benchmark to measure the performance difference:
|
||||
|
||||
```swift
|
||||
let first = OneOf {
|
||||
Parse { Int.parser(); "-"; Int.parser() }
|
||||
Parse { Int.parser(); "/"; Int.parser() }
|
||||
}
|
||||
benchmark("First") {
|
||||
precondition(try! first.parse("100/200") == (100, 200))
|
||||
}
|
||||
let second = Parse {
|
||||
Int.parser()
|
||||
OneOf { "-"; "/" }
|
||||
Int.parser()
|
||||
}
|
||||
benchmark("Second") {
|
||||
precondition(try! second.parse("100/200") == (100, 200))
|
||||
}
|
||||
```
|
||||
|
||||
Running this produces the following results:
|
||||
|
||||
```
|
||||
name time std iterations
|
||||
----------------------------------------
|
||||
First 1500.000 ns ± 19.75 % 856753
|
||||
Second 917.000 ns ± 15.89 % 1000000
|
||||
```
|
||||
|
||||
The second parser takes only 60% of the time to run that the first parser does.
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# Design
|
||||
|
||||
Learn how the library is designed, including its use of protocols, result builders and operators.
|
||||
|
||||
## Protocol
|
||||
|
||||
The design of the library is largely inspired by the Swift standard library and Apple's Combine
|
||||
framework. A parser is represented as a protocol that many types conform to, and then parser
|
||||
transformations (also known as "combinators") are methods that return concrete types conforming to
|
||||
the parser protocol.
|
||||
|
||||
For example, to parse all the characters from the beginning of a substring until you encounter a
|
||||
comma you can use the `Prefix` parser:
|
||||
|
||||
```swift
|
||||
let parser = Prefix { $0 != "," }
|
||||
|
||||
var input = "Hello,World"[...]
|
||||
try parser.parse(&input) // "Hello"
|
||||
input // ",World"
|
||||
```
|
||||
|
||||
The type of this parser is:
|
||||
|
||||
```swift
|
||||
Prefix<Substring>
|
||||
```
|
||||
|
||||
We can `.map` on this parser in order to transform its output, which in this case is the string
|
||||
"Hello":
|
||||
|
||||
```swift
|
||||
let parser = Prefix { $0 != "," }
|
||||
.map { $0 + "!!!" }
|
||||
|
||||
var input = "Hello,World"[...]
|
||||
try parser.parse(&input) // "Hello!!!"
|
||||
input // ",World"
|
||||
```
|
||||
|
||||
The type of this parser is now:
|
||||
|
||||
```swift
|
||||
Parsers.Map<Prefix<Substring>, Substring>
|
||||
```
|
||||
|
||||
Notice that the type of the parser encodes the operations that we performed. This adds a bit of
|
||||
complexity when using these types, but comes with some performance benefits because Swift can
|
||||
usually inline and optimize away the creation of those nested types.
|
||||
|
||||
## Result Builders
|
||||
|
||||
The library takes advantage of Swift's `@resultBuilder` feature to make constructing complex parsers
|
||||
as fluent as possible, and should be reminiscent of how views are constructed in SwiftUI. The main
|
||||
entry point into building a parser is the `Parse` builder:
|
||||
|
||||
```swift
|
||||
Parse {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
In this builder block you can specify parsers that will be run one after another. For example, if
|
||||
you wanted to parse an integer, then a comma, and then a boolean from a string, you can simply do:
|
||||
|
||||
```swift
|
||||
Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
```
|
||||
|
||||
Note that the `String` type conforms to the ``Parser`` protocol, and represents a parser that
|
||||
consumes that exact string from the beginning of an input if it matches, and otherwise fails.
|
||||
|
||||
Many of the parsers and operators that come with the library are configured with parser builders
|
||||
to maximize readability of the parsers. For example, to parse accounting syntax of numbers, where
|
||||
parenthesized numbers are negative, we can use the ``OneOf`` parser builder:
|
||||
|
||||
```swift
|
||||
let digits = Prefix { $0 >= "0" && $0 <= "9" }.compactMap(Int.init)
|
||||
|
||||
let accountingNumber = OneOf {
|
||||
digits
|
||||
|
||||
Parse {
|
||||
"("; digits; ")"
|
||||
}
|
||||
.map { -$0 }
|
||||
}
|
||||
|
||||
try accountingNumber.parse("100") // 100
|
||||
try accountingNumber.parse("(100)") // -100
|
||||
```
|
||||
|
||||
## Operators
|
||||
|
||||
Parser operators (also called "combinators") are methods defined on the ``Parser`` protocol that
|
||||
return a parser. For example, the ``Parser/map(_:)`` operator is a method that returns something
|
||||
called a ``Parsers/Map``:
|
||||
|
||||
```swift
|
||||
extension Parser {
|
||||
public func map<NewOutput>(
|
||||
_ transform: @escaping (Output) -> NewOutput
|
||||
) -> Parsers.Map<Self, NewOutput> {
|
||||
.init(upstream: self, transform: transform)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And ``Parsers/Map`` is a dedicated type that implements the logic of the map operation. In
|
||||
particular, in runs the upstream parser and then transforms its output:
|
||||
|
||||
```swift
|
||||
extension Parsers {
|
||||
public struct Map<Upstream: Parser, NewOutput>: Parser {
|
||||
public let upstream: Upstream
|
||||
public let transform: (Upstream.Output) -> NewOutput
|
||||
|
||||
public func parse(_ input: inout Upstream.Input) rethrows -> NewOutput {
|
||||
self.transform(try self.upstream.parse(&input))
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Types that conform to the ``Parser`` protocol but are not constructed directly, and instead are
|
||||
constructed via operators, are housed in the ``Parsers`` type. It's just an empty enum that
|
||||
serves as a namespace for such parsers.
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
# Error messages
|
||||
|
||||
Learn how the library reports parsing errors and how to integrate your own custom error messages
|
||||
into parsers.
|
||||
|
||||
## Overview
|
||||
|
||||
When a parser fails it throws an error containing information about what went wrong. The actual
|
||||
error thrown by the parsers shipped with this library is internal, and so it should be considered
|
||||
opaque. To get a human-readable debug description of the error message you can stringify the error.
|
||||
For example, the following `UInt8` parser fails to parse a string that would cause it to overflow:
|
||||
|
||||
```swift
|
||||
do {
|
||||
var input = "1234 Hello"[...]
|
||||
let number = try UInt8.parser().parse(&input))
|
||||
} catch {
|
||||
print(error)
|
||||
|
||||
// error: failed to process "UInt8"
|
||||
// --> input:1:1-4
|
||||
// 1 | 1234 Hello
|
||||
// | ^^^^ overflowed 255
|
||||
}
|
||||
```
|
||||
|
||||
When the ``OneOf`` parser is used and fails, there are multiple errors that can be shown. ``OneOf``
|
||||
prioritizes the error messages based on which parser got the furthest along. For example, consider
|
||||
a parser that can parse accounting style of numbers, i.e. plain numbers are considered positive
|
||||
and numbers in parentheses are considered negative:
|
||||
|
||||
```swift
|
||||
let digits = Prefix { $0 >= "0" && $0 <= "9" }.compactMap(Int.init)
|
||||
|
||||
let accountingNumber = OneOf {
|
||||
digits
|
||||
|
||||
Parse {
|
||||
"("; digits; ")"
|
||||
}
|
||||
.map { -$0 }
|
||||
}
|
||||
|
||||
try accountingNumber.parse("100") // 100
|
||||
try accountingNumber.parse("(100)") // -100
|
||||
```
|
||||
|
||||
If we try parsing something erroneous, such as "(100]", we get multiple error messages, but the
|
||||
second parser's error shows first since it was able to get the furthest:
|
||||
|
||||
```swift
|
||||
do {
|
||||
try accountingNumber.parse("(100]")
|
||||
} catch {
|
||||
print(error)
|
||||
|
||||
// error: multiple failures occurred
|
||||
//
|
||||
// error: unexpected input
|
||||
// --> input:1:5
|
||||
// 1 | (100]
|
||||
// | ^ expected ")"
|
||||
//
|
||||
// error: unexpected input
|
||||
// --> input:1:1
|
||||
// 1 | (100]
|
||||
// | ^ expected integer
|
||||
}
|
||||
```
|
||||
|
||||
## Improving error messages
|
||||
|
||||
The quality of error messages emitted by a parser can depend on the manner in which the parser was
|
||||
constructed. Some parser operators are powerful and convenient, but can cause the quality of error
|
||||
messaging to degrade.
|
||||
|
||||
For example, we could construct a parser that consumes a single uncommented line from an input
|
||||
(_i.e._, a line that does not begin with "//") by using ``Parser/compactMap(_:)`` to check the line
|
||||
for a prefix:
|
||||
|
||||
```swift
|
||||
let uncommentedLine = Prefix { $0 != "\n" }
|
||||
.compactMap { $0.starts(with: "//") ? nil : $0 }
|
||||
|
||||
try uncommentedLine.parse("// let x = 1")
|
||||
|
||||
// error: failed to process "Substring" from "// let x = 1"
|
||||
// --> input:1:1-12
|
||||
// 1 | // let x = 1
|
||||
// | ^^^^^^^^^^^^
|
||||
```
|
||||
|
||||
However, when this parser fails it can only highlight the entire line as having a problem because
|
||||
it cannot know that the only thing that failed was that the first two characters were slashes.
|
||||
|
||||
We can rewrite this parser in a different, but equivalent, way by using the ``Not`` parser to first
|
||||
confirm that the line does not begin with "//", and then consume the entire line:
|
||||
|
||||
```swift
|
||||
let uncommentedLine = Parse {
|
||||
Not { "//" }
|
||||
Prefix { $0 != "\n" }
|
||||
}
|
||||
|
||||
try uncommentedLine.parse("// let x = 1")
|
||||
|
||||
// error: unexpected input
|
||||
// --> input:1:1-2
|
||||
// 1 | // let x = 1
|
||||
// | ^^ expected not to be processed
|
||||
```
|
||||
|
||||
This provides better error messaging because ``Not`` knows exactly what matched that we did not want
|
||||
to match, and so it can highlight those specific characters.
|
||||
|
||||
When using the `Many` parser you can improve error messaging by supplying a "terminator" parser,
|
||||
which is an optional argument. The terminator parser is run after the element and separator
|
||||
parsers have consumed as much as they can, and allows you to assert on exactly what is left
|
||||
afterwards.
|
||||
|
||||
For example, if a parser is run on an input that has a typo in the last row of data, and a
|
||||
terminator is not specified, the parser will succeed without consuming that last row and we won't
|
||||
know what went wrong:
|
||||
|
||||
```swift
|
||||
struct User {
|
||||
var id: Int
|
||||
var name: String
|
||||
var isAdmin: Bool
|
||||
}
|
||||
|
||||
let user = Parse(User.init(id:name:isAdmin:)) {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }.map(String.init)
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
|
||||
let users = Many {
|
||||
user
|
||||
} separator: {
|
||||
"\n"
|
||||
}
|
||||
|
||||
var input = """
|
||||
1,Blob,true
|
||||
2,Blob Jr.,false
|
||||
3,Blob Sr.,tru
|
||||
"""[...]
|
||||
|
||||
let output = try users.parse(&input)
|
||||
output.count // 2
|
||||
input // "\n3,Blob Sr.,tru"
|
||||
```
|
||||
|
||||
However, by adding a terminator to this `users` parser an error will be throw that points to the
|
||||
exact spot where the typo occurred:
|
||||
|
||||
```swift
|
||||
let users = Many {
|
||||
user
|
||||
} separator: {
|
||||
"\n"
|
||||
} terminator: {
|
||||
End()
|
||||
}
|
||||
|
||||
let output = try users.parse(&input)
|
||||
|
||||
// error: unexpected input
|
||||
// --> input:3:11
|
||||
// 3 | 3,Blob Jr,tru
|
||||
// | ^ expected "true" or "false"
|
||||
```
|
||||
|
||||
## Throwing your own errors
|
||||
|
||||
Although the error type thrown by the parsers that ship in this library is currently internal, and
|
||||
so should be thought of as opaque, it is still possible to throw your own errors. Your errors will
|
||||
automatically be reformatted and contextualized to show exactly where the error occurred.
|
||||
|
||||
For example, suppose we wanted a parser that only parsed the digits 0-9 from the beginning of a
|
||||
string and transformed it into an integer. This is subtly different from `Int.parser()` which
|
||||
supports negative numbers, exponential formatting, and more.
|
||||
|
||||
Constructing a `Digits` parser is easy enough, and we can introduce a custom struct error for
|
||||
customizing the message displayed:
|
||||
|
||||
```swift
|
||||
struct DigitsError: Error {
|
||||
let message = "Expected a prefix of digits 0-9"
|
||||
}
|
||||
|
||||
struct Digits: Parser {
|
||||
func parse(_ input: inout Substring) throws -> Int {
|
||||
let digits = input.prefix { $0 >= "0" && $0 <= "9" }
|
||||
guard let output = Int(digits)
|
||||
else {
|
||||
throw DigitsError()
|
||||
}
|
||||
input.removeFirst(digits.count)
|
||||
return output
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If we swap out the `Int.parser()` for a `Digits` parser in `user`:
|
||||
|
||||
```swift
|
||||
let user = Parse(User.init) {
|
||||
Digits()
|
||||
","
|
||||
Prefix { $0 != "," }.map(String.init)
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
```
|
||||
|
||||
And we introduce an incorrect value into the input:
|
||||
|
||||
```swift
|
||||
let input = """
|
||||
1,Blob,true
|
||||
-2,Blob Jr.,false
|
||||
3,Blob Sr.,true
|
||||
"""[...]
|
||||
```
|
||||
|
||||
Then when running the parser we get a nice error message that shows exactly what went wrong:
|
||||
|
||||
```swift
|
||||
try user.parse(&input)
|
||||
|
||||
// error: DigitsError(message: "Expected a prefix of digits 0-9")
|
||||
// --> input:2:1
|
||||
// 2 | -2,Blob Sr,false
|
||||
// | ^
|
||||
```
|
||||
|
|
@ -0,0 +1,303 @@
|
|||
# Getting Started
|
||||
|
||||
Learn how to integrate Parsing into your project and write your first parser.
|
||||
|
||||
## Adding Parsing as a dependency
|
||||
|
||||
To use the Parsing library in a SwiftPM project, add it to the dependencies of your Package.swift
|
||||
and specify the `Parsing` product in any targets that need access to the library:
|
||||
|
||||
```swift
|
||||
let package = Package(
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.7.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "<target-name>",
|
||||
dependencies: [.product(name: "Parsing", package: "swift-parsing")]
|
||||
)
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Your first parser
|
||||
|
||||
Suppose you have a string that holds some user data that you want to parse into an array of `User`s:
|
||||
|
||||
```swift
|
||||
let input = """
|
||||
1,Blob,true
|
||||
2,Blob Jr.,false
|
||||
3,Blob Sr.,true
|
||||
"""
|
||||
|
||||
struct User {
|
||||
var id: Int
|
||||
var name: String
|
||||
var isAdmin: Bool
|
||||
}
|
||||
```
|
||||
|
||||
A naive approach to this would be a nested use of `.split(separator:)`, and then a little bit of
|
||||
extra work to convert strings into integers and booleans:
|
||||
|
||||
```swift
|
||||
let users = input
|
||||
.split(separator: "\n")
|
||||
.compactMap { row -> User? in
|
||||
let fields = row.split(separator: ",")
|
||||
guard
|
||||
fields.count == 3,
|
||||
let id = Int(fields[0]),
|
||||
let isAdmin = Bool(String(fields[2]))
|
||||
else { return nil }
|
||||
|
||||
return User(id: id, name: String(fields[1]), isAdmin: isAdmin)
|
||||
}
|
||||
```
|
||||
|
||||
Not only is this code a little messy, but it is also inefficient since we are allocating arrays for
|
||||
the `.split` and then just immediately throwing away those values.
|
||||
|
||||
It would be more straightforward and efficient to instead describe how to consume bits from the
|
||||
beginning of the input and convert that into users. This is what this parser library excels at 😄.
|
||||
|
||||
We can start by describing what it means to parse a single row, first by parsing an integer off the
|
||||
front of the string, and then parsing a comma. We can do this by using the ``Parse`` type, which acts
|
||||
as an entry point into describing a list of parsers that you want to run one after the other to
|
||||
consume from an input:
|
||||
|
||||
```swift
|
||||
let user = Parse {
|
||||
Int.parser()
|
||||
","
|
||||
}
|
||||
```
|
||||
|
||||
Already this can consume the leading integer and comma from the beginning of the input:
|
||||
|
||||
```swift
|
||||
// Use a mutable substring to verify what is consumed
|
||||
var input = input[...]
|
||||
|
||||
try user.parse(&input) // 1
|
||||
input // "Blob,true\n2,Blob Jr.,false\n3,Blob Sr.,true"
|
||||
```
|
||||
|
||||
Next we want to take everything up until the next comma for the user's name, and then consume the
|
||||
comma:
|
||||
|
||||
```swift
|
||||
let user = Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }
|
||||
","
|
||||
}
|
||||
```
|
||||
|
||||
And then we want to take the boolean at the end of the row for the user's admin status:
|
||||
|
||||
```swift
|
||||
let user = Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
```
|
||||
|
||||
Currently this will parse a tuple `(Int, Substring, Bool)` from the input, and we can `.map` on
|
||||
that to turn it into a `User`:
|
||||
|
||||
```swift
|
||||
let user = Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
.map { User(id: $0, name: String($1), isAdmin: $2) }
|
||||
```
|
||||
|
||||
To make the data we are parsing to more prominent, we can instead pass the transform closure as the
|
||||
first argument to `Parse`:
|
||||
|
||||
```swift
|
||||
let user = Parse {
|
||||
User(id: $0, name: String($1), isAdmin: $2)
|
||||
} with: {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
```
|
||||
|
||||
Or we can pass the `User` initializer to `Parse` in a point-free style by first transforming the
|
||||
`Prefix` parser's output from a `Substring` to a `String`:
|
||||
|
||||
```swift
|
||||
let user = Parse(User.init(id:name:isAdmin:)) {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }.map(String.init)
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
```
|
||||
|
||||
That is enough to parse a single user from the input string, leaving behind a newline and the final
|
||||
two users:
|
||||
|
||||
```swift
|
||||
try user.parse(&input) // User(id: 1, name: "Blob", isAdmin: true)
|
||||
input // "\n2,Blob Jr.,false\n3,Blob Sr.,true"
|
||||
```
|
||||
|
||||
To parse multiple users from the input we can use the `Many` parser to run the user parser many
|
||||
times:
|
||||
|
||||
```swift
|
||||
let users = Many {
|
||||
user
|
||||
} separator: {
|
||||
"\n"
|
||||
}
|
||||
|
||||
try users.parse(&input) // [User(id: 1, name: "Blob", isAdmin: true), ...]
|
||||
input // ""
|
||||
```
|
||||
|
||||
Now this parser can process an entire document of users, and the code is simpler and more
|
||||
straightforward than the version that uses `.split` and `.compactMap`.
|
||||
|
||||
Even better, it's more performant. We've written [benchmarks][benchmarks-readme] for these two
|
||||
styles of parsing, and the `.split`-style of parsing is more than twice as slow:
|
||||
|
||||
```
|
||||
name time std iterations
|
||||
------------------------------------------------------------------
|
||||
README Example.Parser: Substring 3426.000 ns ± 63.40 % 385395
|
||||
README Example.Ad hoc 7631.000 ns ± 47.01 % 169332
|
||||
```
|
||||
|
||||
Further, if you are willing write your parsers against `UTF8View` instead of `Substring`, you can
|
||||
eke out even more performance, more than doubling the speed:
|
||||
|
||||
```
|
||||
name time std iterations
|
||||
------------------------------------------------------------------
|
||||
README Example.Parser: Substring 3693.000 ns ± 81.76 % 349763
|
||||
README Example.Parser: UTF8 1272.000 ns ± 128.16 % 999150
|
||||
README Example.Ad hoc 8504.000 ns ± 59.59 % 151417
|
||||
```
|
||||
|
||||
See the article <doc:StringAbstractions> for more info on how to write parsers against different
|
||||
string abstraction levels.
|
||||
|
||||
We can also compare these times to a tool that Apple's Foundation gives us: `Scanner`. It's a type
|
||||
that allows you to consume from the beginning of strings in order to produce values, and provides
|
||||
a nicer API than using `.split`:
|
||||
|
||||
```swift
|
||||
var users: [User] = []
|
||||
while scanner.currentIndex != input.endIndex {
|
||||
guard
|
||||
let id = scanner.scanInt(),
|
||||
let _ = scanner.scanString(","),
|
||||
let name = scanner.scanUpToString(","),
|
||||
let _ = scanner.scanString(","),
|
||||
let isAdmin = scanner.scanBool()
|
||||
else { break }
|
||||
|
||||
users.append(User(id: id, name: name, isAdmin: isAdmin))
|
||||
_ = scanner.scanString("\n")
|
||||
}
|
||||
```
|
||||
|
||||
However, the `Scanner` style of parsing is more than 5 times as slow as the substring parser written
|
||||
written above, and more than 15 times slower than the UTF-8 parser:
|
||||
|
||||
```
|
||||
name time std iterations
|
||||
-------------------------------------------------------------------
|
||||
README Example.Parser: Substring 3481.000 ns ± 65.04 % 376525
|
||||
README Example.Parser: UTF8 1207.000 ns ± 110.96 % 1000000
|
||||
README Example.Ad hoc 8029.000 ns ± 44.44 % 163719
|
||||
README Example.Scanner 19786.000 ns ± 35.26 % 62125
|
||||
```
|
||||
|
||||
Not only are parsers built with the library more succinct and many times more performant than ad hoc
|
||||
parsers, but they can also be easier to evolve to accommodate more features. For example, right now
|
||||
our parser does not work correctly when the user's name contains a comma, such as "Blob, Esq.":
|
||||
|
||||
```swift
|
||||
try user.parse("1,Blob, Esq.,true")
|
||||
|
||||
// error: unexpected input
|
||||
// --> input:1:8
|
||||
// 1 | 1,Blob, Esq.,true
|
||||
// | ^ expected "true" or "false"
|
||||
```
|
||||
|
||||
The problem is that we are using the comma as a reserved identifier for delineating between fields,
|
||||
and so a field cannot contain a comma. We can enhance the CSV format to allow for quoting fields
|
||||
so that they can contain quotes:
|
||||
|
||||
```
|
||||
1,"Blob, Esq.",true
|
||||
```
|
||||
|
||||
To parse quoted fields we can first try parsing a quote, then everything up to the next quote, and
|
||||
then the trailing quote:
|
||||
|
||||
```swift
|
||||
let quotedField = Parse {
|
||||
"\""
|
||||
Prefix { $0 != "\"" }
|
||||
"\""
|
||||
}
|
||||
```
|
||||
|
||||
And then to parse a field, in general, we can first try parsing a quoted field, and if that fails we
|
||||
will just take everything until the next comma. We can do this using the ``OneOf`` parser, which
|
||||
allows us to run multiple parsers on the same input, and it will take the first that succeeds:
|
||||
|
||||
```swift
|
||||
let field = OneOf {
|
||||
quotedField
|
||||
Prefix { $0 != "," }
|
||||
}
|
||||
.map(String.init)
|
||||
```
|
||||
|
||||
We can use this parser in the `user` parser, and now it properly handles quoted and non-quoted
|
||||
fields:
|
||||
|
||||
```swift
|
||||
let user = Parse(User.init) {
|
||||
Int.parser()
|
||||
","
|
||||
field
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
|
||||
try user.parse("1,\"Blob, Esq.\",true") // User(id: 1, name: "Blob, Esq.", admin: true)
|
||||
```
|
||||
|
||||
It was quite straightforward to improve the `user` parser to handle quoted fields. Doing the same
|
||||
with our ad hoc `split`/`compactMap` parser, and even the `Scanner`-based parser, would be a lot
|
||||
more difficult.
|
||||
|
||||
That's the basics of parsing a simple string format, but there's a lot more operators and tricks to
|
||||
learn in order to performantly parse larger inputs. View the [benchmarks][benchmarks] for examples
|
||||
of real-life parsing scenarios.
|
||||
|
||||
[benchmarks-readme]: https://github.com/pointfreeco/swift-parsing/blob/main/Sources/swift-parsing-benchmark/ReadmeExample.swift
|
||||
[benchmarks]: https://github.com/pointfreeco/swift-parsing/tree/main/Sources/swift-parsing-benchmark
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
# Bool
|
||||
|
||||
A parser that consumes a Boolean value from the beginning of a string.
|
||||
|
||||
This parser only recognizes the literal `"true"` and `"false"` sequence of characters:
|
||||
|
||||
```swift
|
||||
// Parses "true":
|
||||
var input = "true Hello"[...]
|
||||
try Bool.parser().parse(&input) // true
|
||||
input // " Hello"
|
||||
|
||||
// Parses "false":
|
||||
input = "false Hello"[...]
|
||||
try Bool.parser().parse(&input) // false
|
||||
input // " Hello"
|
||||
|
||||
// Otherwise fails:
|
||||
input = "1 Hello"[...]
|
||||
try Bool.parser().parse(&input)
|
||||
|
||||
// error: unexpected input
|
||||
// --> input:1:1
|
||||
// 1 | 1 Hello
|
||||
// ^ expected "true" or "false"
|
||||
```
|
||||
|
||||
The `Bool.parser()` method is overloaded to work on a variety of string representations in order
|
||||
to be as efficient as possible, including `Substring`, `UTF8View`, and more general collections of
|
||||
UTF-8 code units (see <doc:StringAbstractions> for more info).
|
||||
|
||||
Typically Swift can choose the correct overload by using type inference based on what other parsers
|
||||
you are combining `Bool.parser()` with. For example, if you use `Bool.parser()` with a
|
||||
`Substring` parser, say the literal `","` parser (see <doc:String> for more information), Swift
|
||||
will choose the overload that works on substrings:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Bool.parser()
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
|
||||
try parser.parse("true,false") // (true, false)
|
||||
```
|
||||
|
||||
On the other hand, if `Bool.parser()` is used in a context where the input type cannot be inferred,
|
||||
then you will get an compiler error:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Bool.parser()
|
||||
Bool.parser() // 🛑 Ambiguous use of 'parser(of:)'
|
||||
}
|
||||
|
||||
try parser.parse("truefalse")
|
||||
```
|
||||
|
||||
To fix this you can force one of the boolean parsers to be the `Substring` parser, and then the
|
||||
other will figure it out via type inference:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Bool.parser(of: Substring.self)
|
||||
Bool.parser() // ✅
|
||||
}
|
||||
|
||||
try parser.parse("truefalse")
|
||||
```
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# CaseIterable
|
||||
|
||||
A parser that consumes a case-iterable, raw representable value from the beginning of a string.
|
||||
|
||||
Given a type that conforms to `CaseIterable` and `RawRepresentable` with a `RawValue` of `String`
|
||||
or `Int`, we can incrementally parse a value of it.
|
||||
|
||||
Notably, raw enumerations that conform to `CaseIterable` meet this criteria, so cases of the
|
||||
following type can be parsed with no extra work:
|
||||
|
||||
```swift
|
||||
enum Role: String, CaseIterable {
|
||||
case admin
|
||||
case guest
|
||||
case member
|
||||
}
|
||||
|
||||
try Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Role.parser()
|
||||
}
|
||||
.parse("123,member") // (123, .member)
|
||||
```
|
||||
|
||||
This also works with raw enumerations that are backed by integers:
|
||||
|
||||
```swift
|
||||
enum Role: Int, CaseIterable {
|
||||
case admin = 1
|
||||
case guest = 2
|
||||
case member = 3
|
||||
}
|
||||
|
||||
try Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Role.parser()
|
||||
}
|
||||
.parse("123,1") // (123, .admin)
|
||||
```
|
||||
|
||||
The `parser()` method on `CaseIterable` is overloaded to work on a variety of string representations
|
||||
in order to be as efficient as possible, including `Substring`, `UTF8View`, and more general
|
||||
collections of UTF-8 code units (see <doc:StringAbstractions> for more info).
|
||||
|
||||
Typically Swift can choose the correct overload by using type inference based on what other parsers
|
||||
you are combining `parser()` with. For example, if you use `Role.parser()` with a
|
||||
`Substring` parser, like the literal "," parser in the above examples, Swift
|
||||
will choose the overload that works on substrings.
|
||||
|
||||
On the other hand, if `Role.parser()` is used in a context where the input type cannot be inferred,
|
||||
then you will get an compiler error:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Int.parser()
|
||||
Role.parser() // 🛑 Ambiguous use of 'parser(of:)'
|
||||
}
|
||||
|
||||
try parser.parse("123member")
|
||||
```
|
||||
|
||||
To fix this you can force one of the parsers to be the `Substring` parser, and then the
|
||||
other will figure it out via type inference:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Int.parser(of: Substring.self)
|
||||
Role.parser()
|
||||
}
|
||||
|
||||
try parser.parse("123member") // (123, .member)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# CharacterSet
|
||||
|
||||
A parser that consumes the characters contained in a `CharacterSet` from the beginning of a string.
|
||||
|
||||
For example:
|
||||
|
||||
```swift
|
||||
Parse {
|
||||
CharacterSet.alphanumerics
|
||||
CharacterSet.punctuationCharacters
|
||||
CharacterSet.alphanumerics
|
||||
}
|
||||
.parse("Hello...World") // ("Hello", "...", "World")
|
||||
```
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
# Float
|
||||
|
||||
A parser that consumes a floating-point number from the beginning of a string.
|
||||
|
||||
Supports any type that conforms to `BinaryFloatingPoint` and `LosslessStringConvertible`. This
|
||||
includes `Double`, `Float`, `Float16`, and `Float80`.
|
||||
|
||||
Parses the same format parsed by `LosslessStringConvertible.init(_:)` on `BinaryFloatingPoint`.
|
||||
|
||||
```swift
|
||||
var input = "123.45 Hello world"[...]
|
||||
try Double.parser().parse(&input) // 123.45
|
||||
input // " Hello world"
|
||||
|
||||
input = "-123. Hello world"[...]
|
||||
try Double.parser().parse(&input) // -123.0
|
||||
input // " Hello world"
|
||||
|
||||
|
||||
input = "123.123E+2 Hello world"[...]
|
||||
try Double.parser().parse(&input) // 12312.3
|
||||
input // " Hello world"
|
||||
```
|
||||
|
||||
The `parser()` static method is overloaded to work on a variety of string representations in order
|
||||
to be as efficient as possible, including `Substring`, `UTF8View`, and generally collections of
|
||||
UTF-8 code units (see <doc:StringAbstractions> for more info).
|
||||
|
||||
Typically Swift can choose the correct overload by using type inference based on what other parsers
|
||||
you are combining `parser()` with. For example, if you use `Double.parser()` with a `Substring`
|
||||
parser, say the literal `","` parser (see <doc:String> for more information), Swift will choose the
|
||||
overload that works on substrings:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Double.parser()
|
||||
","
|
||||
Double.parser()
|
||||
}
|
||||
|
||||
try parser.parse("1,-2") // (1.0, -2.0)
|
||||
```
|
||||
|
||||
On the other hand, if `Double.parser()` is used in a context where the input type cannot be
|
||||
inferred, then you will get an compiler error:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Double.parser()
|
||||
Double.parser() // 🛑 Ambiguous use of 'parser(of:)'
|
||||
}
|
||||
|
||||
try parser.parse(".1.2")
|
||||
```
|
||||
|
||||
To fix this you can force one of the double parsers to be the `Substring` parser, and then the
|
||||
other will figure it out via type inference:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Double.parser(of: Substring.self)
|
||||
Double.parser() // ✅
|
||||
}
|
||||
|
||||
try parser.parse(".1.2") // (0.1, 0.2)
|
||||
```
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
# Int
|
||||
|
||||
A parser that consumes an integer from the beginning of a string.
|
||||
|
||||
Supports any type that conforms to `FixedWidthInteger`. This includes `Int`, `UInt`, `UInt8`, and
|
||||
many more.
|
||||
|
||||
Parses the same format parsed by `FixedWidthInteger.init(_:radix:)`.
|
||||
|
||||
```swift
|
||||
var input = "123 Hello world"[...]
|
||||
try Int.parser().parse(&input) // 123
|
||||
input // " Hello world"
|
||||
|
||||
input = "-123 Hello world"
|
||||
try Int.parser().parse(&input) // -123
|
||||
input // " Hello world"
|
||||
```
|
||||
|
||||
This parser fails when it does not find an integer at the beginning of the collection:
|
||||
|
||||
```swift
|
||||
var input = "+Hello"[...]
|
||||
let number = try Int.parser().parse(&input)
|
||||
// error: unexpected input
|
||||
// --> input:1:2
|
||||
// 1 | +Hello
|
||||
// | ^ expected integer
|
||||
```
|
||||
|
||||
And it fails when the digits extracted from the beginning of the collection would cause the
|
||||
integer type to overflow:
|
||||
|
||||
```swift
|
||||
var input = "9999999999999999999 Hello"[...]
|
||||
let number = try Int.parser().parse(&input)
|
||||
// error: failed to process "Int"
|
||||
// --> input:1:1-19
|
||||
// 1 | 9999999999999999999 Hello
|
||||
// | ^^^^^^^^^^^^^^^^^^^ overflowed 9223372036854775807
|
||||
```
|
||||
|
||||
The static `parser()` method is overloaded to work on a variety of string representations in order
|
||||
to be as efficient as possible, including `Substring`, `UTF8View`, and generally collections of
|
||||
UTF-8 code units (see <doc:StringAbstractions> for more info).
|
||||
|
||||
Typically Swift can choose the correct overload by using type inference based on what other parsers
|
||||
you are combining `parser()` with. For example, if you use `Int.parser()` with a `Substring` parser,
|
||||
say the literal `","` parser (see <doc:String> for more information), Swift will choose the overload
|
||||
that works on substrings:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Int.parser()
|
||||
}
|
||||
|
||||
try parser.parse("123,456") // (123, 456)
|
||||
```
|
||||
|
||||
On the other hand, if `Int.parser()` is used in a context where the input type cannot be inferred,
|
||||
then you will get an compiler error:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Int.parser() // 🛑 Ambiguous use of 'parser(of:radix:)'
|
||||
Bool.parser()
|
||||
}
|
||||
|
||||
try parser.parse("123true")
|
||||
```
|
||||
|
||||
To fix this you can force one of the parsers to be the `Substring` parser, and then the
|
||||
other will figure it out via type inference:
|
||||
|
||||
```swift
|
||||
let parser = Parse {
|
||||
Int.parser() // ✅
|
||||
Bool.parser(of: Substring.self)
|
||||
}
|
||||
|
||||
try parser.parse("123true") // (123, true)
|
||||
```
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# String
|
||||
|
||||
A parser that consumes a string literal from the beginning of a string.
|
||||
|
||||
Many of Swift's string types conform to the ``Parser`` protocol, which allows you to use string types
|
||||
directly in a parser. For example, to parse two integers separated by a comma we can do:
|
||||
|
||||
```swift
|
||||
try Parse {
|
||||
Int.parser()
|
||||
","
|
||||
Int.parser()
|
||||
}
|
||||
.parse("123,456") // (123, 456)
|
||||
```
|
||||
|
||||
The string `","` acts as a parser that consumes a comma from the beginning of an input and fails
|
||||
if the input does not start with a comma.
|
||||
|
||||
Swift's other string representations also conform to ``Parser``, such as `UnicodeScalarView`
|
||||
and `UTF8View`. This allows you to consume strings from the beginning of an input in a more
|
||||
efficient manner than is possible with `Substring` (see <doc:StringAbstractions> for more info).
|
||||
|
||||
For example, we can conver the above parser to work on the level of `UTF8View`s, which is a
|
||||
collection of UTF-8 code units:
|
||||
|
||||
```swift
|
||||
try Parse {
|
||||
Int.parser()
|
||||
",".utf8
|
||||
Int.parser()
|
||||
}
|
||||
.parse("123,456") // (123, 456)
|
||||
```
|
||||
|
||||
Here `",".utf8` is a `String.UTF8View`, which conforms to the ``Parser`` protocol. Also, by type
|
||||
inference, Swift is choosing the overload of `Int.parser()` that now works on `UTF8View`s rather
|
||||
than `Substring`s. See <doc:Int> for more info.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# UUID
|
||||
|
||||
A parser that consumes a `UUID` value from the beginning of a string.
|
||||
|
||||
For example:
|
||||
|
||||
```swift
|
||||
try Parse {
|
||||
UUID.parser()
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
.parse("deadbeef-dead-beef-dead-beefdeadbeef,true")
|
||||
// (DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF, true)
|
||||
```
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
# String Abstractions
|
||||
|
||||
Learn how to write parsers on different levels of string abstractions, giving you the ability to
|
||||
trade performance for correctness where needed.
|
||||
|
||||
## Levels of abstraction
|
||||
|
||||
The parsers in the library do not work on `String`s directly, and instead operate on _views_ into a
|
||||
string, such as `Substring`, `UnicodeScalarView` and `UTF8View`. Each of these types represents a
|
||||
particular kind of "view" into some subset of a string, which means they are cheap to copy around,
|
||||
and it makes consuming elements from the beginning and end of the string very efficient since only
|
||||
their start and end index need to be mutated to point to different parts of the string.
|
||||
|
||||
However, there are tradeoffs to using each type:
|
||||
|
||||
* `Substring`, like `String`, is a collection of `Character`s, which are extended grapheme
|
||||
clusters that most closely represents a single visual character one can see on the screen. This
|
||||
type is easy to use and hides a lot of the complexities of UTF8 from you (such as multiple byte
|
||||
sequences that represent the same visual character), and as such it is less efficient to use.
|
||||
Its elements are variable width, which means scanning its elements is an O(n) operation.
|
||||
|
||||
* `UnicodeScalarView` is a collection of unicode scalars represented by the `Unicode.Scalar` type.
|
||||
Unicode scalars are 21-bit, and so not variable width like `Substring`, which makes scanning
|
||||
`UnicodeScalarView`s more efficient, but at the cost of some additional complexity in the API.
|
||||
|
||||
For example, complex elements that can be represented by a single `Character`, such as "🇺🇸",
|
||||
are represented by multiple `Unicode.Scalar` elements, "🇺" and "🇸". When put together they
|
||||
form the single extended grapheme cluster of the flag character.
|
||||
|
||||
Further, some `Character`s have multiple representations as collections of unicode scalars. For
|
||||
example, an "e" with an accute accent only has one visual representation, yet there are two
|
||||
different sequences of unicode scalars that can represent that character:
|
||||
|
||||
```swift
|
||||
Array("é".unicodeScalars) // [233]
|
||||
Array("é".unicodeScalars) // [101, 769]
|
||||
```
|
||||
|
||||
You can't tell from looking at the character, but the first "é" is a single unicode scalar
|
||||
called a "LATIN SMALL LETTER E WITH ACUTE" and the second "é" is two scalars, one just a plain
|
||||
"e" and the second a "COMBINING ACUTE ACCENT". Importantly, these two accented e's are equal as
|
||||
`Character`s but unequal as `UnicodeScalarView`s:
|
||||
|
||||
```swift
|
||||
let e1 = "\u{00E9}"
|
||||
let e2 = "e\u{0301}"
|
||||
e1 == e2 // true
|
||||
e1.unicodeScalars.elementsEqual(e2.unicodeScalars) // false
|
||||
```
|
||||
|
||||
So, when parsing on the level of `UnicodeScalarView` you have to be aware of these subtleties in
|
||||
order to form a correct parser.
|
||||
|
||||
* `UTF8View` is a collection of `Unicode.UTF8.CodeUnit`s, which is just a typealias for `UInt8`,
|
||||
_i.e._, a single byte. This is an even lower-level representation of strings than
|
||||
`UnicodeScalarView`, and scanning these collections is quite efficient, but at the cost of even
|
||||
more complexity.
|
||||
|
||||
For example, the non-ASCII characters described above have an even more complex representation
|
||||
has UTF8 bytes:
|
||||
|
||||
```swift
|
||||
Array("é".utf8) // [195, 169]
|
||||
Array("é".utf8) // [101, 204, 129]
|
||||
Array("🇺🇸".utf8) // [240, 159, 135, 186, 240, 159, 135, 184]
|
||||
```
|
||||
|
||||
* There's even `ArraySlice<UInt8>`, which is just a raw collection of bytes. This can be even more
|
||||
efficient to parse than `UTF8View` because it does not require representing a valid UTF-8
|
||||
string, but then you have no guarantees that you can losslessly convert it back into a `String`.
|
||||
|
||||
## Mixing and matching abstraction levels
|
||||
|
||||
It is possible to plug together parsers that work on different abstraction levels so that you can
|
||||
decide where you want to trade correctness for performance and vice-versa.
|
||||
|
||||
For example, suppose you have an enum representing a few cities that you want to parse a string
|
||||
into:
|
||||
|
||||
```swift
|
||||
enum City {
|
||||
case losAngeles
|
||||
case newYork
|
||||
case sanJose
|
||||
}
|
||||
|
||||
let city = OneOf {
|
||||
"Los Angeles".map { City.losAngeles }
|
||||
"New York".map { City.newYork }
|
||||
"San José".map { City.sanJose }
|
||||
}
|
||||
```
|
||||
|
||||
For the most part this parser could work on the level of UTF-8 because it is mostly dealing with
|
||||
plain ASCII characters for which there are not multiple ways of representing the same visual
|
||||
character. The only exception is "San José", which has an accented "e" that can be represented
|
||||
by two different sequences of bytes.
|
||||
|
||||
The `Substring` abstraction is hiding those details from us because this parser will happily parse
|
||||
both representations of "San José" from a string:
|
||||
|
||||
```swift
|
||||
city.parse("San Jos\u{00E9}") // ✅
|
||||
city.parse("San Jose\u{0301}") // ✅
|
||||
```
|
||||
|
||||
But, if we naively convert this parser to work on the level of `UTF8View`:
|
||||
|
||||
```swift
|
||||
let city = OneOf {
|
||||
"Los Angeles".utf8.map { City.losAngeles }
|
||||
"New York".utf8.map { City.newYork }
|
||||
"San José".utf8.map { City.sanJose }
|
||||
}
|
||||
```
|
||||
|
||||
We have accidentally introduced a bug into the parser in which it recognizes one version of
|
||||
"San José", but not the other:
|
||||
|
||||
```swift
|
||||
city.parse("San Jos\u{00E9}".utf8) // ✅
|
||||
city.parse("San Jose\u{0301}".utf8) // ❌
|
||||
```
|
||||
|
||||
One way to fix this would be to add another case to the `OneOf` for this alternate representation
|
||||
of "San José":
|
||||
|
||||
```swift
|
||||
let city = OneOf {
|
||||
"Los Angeles".utf8.map { City.losAngeles }
|
||||
"New York".utf8.map { City.newYork }
|
||||
"San Jos\u{00E9}".utf8.map { City.sanJose }
|
||||
"San Jose\u{0301}".utf8.map { City.sanJose }
|
||||
}
|
||||
|
||||
city.parse("San Jos\u{00E9}".utf8) // ✅
|
||||
city.parse("San Jose\u{0301}".utf8) // ✅
|
||||
```
|
||||
|
||||
This does work, but you are now responsible for understanding the ins and outs of UTF-8
|
||||
normalization. UTF-8 is incredibly complex and Swift does a lot of work to hide that complexity
|
||||
from you.
|
||||
|
||||
However, there's no need to parse everything on the level of `Substring` just because this one
|
||||
parser needs to. We can parse everything on the level of `UTF8View` and then parse just "San José"
|
||||
on the level of `Substring`. We do this by using the ``FromSubstring`` parser, which allows us to
|
||||
temporarily leave the `UTF8View` world to work in the `Substring` world:
|
||||
|
||||
```swift
|
||||
let city = OneOf {
|
||||
"Los Angeles".utf8.map { City.losAngeles }
|
||||
"New York".utf8.map { City.newYork }
|
||||
FromSubstring { "San José" }.map { City.sanJose }
|
||||
}
|
||||
|
||||
city.parse("San Jos\u{00E9}".utf8) // ✅
|
||||
city.parse("San Jose\u{0301}".utf8) // ✅
|
||||
```
|
||||
|
||||
This will run the "San José" parser on the level of `Substring`, meaning it will handle all the
|
||||
complexities of UTF8 normalization so that we don't have to think about it.
|
||||
|
||||
If we want to be _really_ pedantic we can even decide to parse only the "é" character on the
|
||||
level of `Substring` and leave everything else to `UTF8View`:
|
||||
|
||||
```swift
|
||||
let city = OneOf {
|
||||
"Los Angeles".utf8.map { City.losAngeles }
|
||||
"New York".utf8.map { City.newYork }
|
||||
Parse {
|
||||
"San Jos".utf8
|
||||
FromSubstring { "é" }
|
||||
}
|
||||
.map { City.sanJose }
|
||||
}
|
||||
|
||||
city.parse("San Jos\u{00E9}".utf8) // ✅
|
||||
city.parse("San Jose\u{0301}".utf8) // ✅
|
||||
```
|
||||
|
||||
We don't necessarily recommend being this pedantic in general, at least not without benchmarking to
|
||||
make sure it is worth it. But it does demonstrate how you can be very precise with which abstraction
|
||||
levels you want to work on.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# ``Parsing/OneOf``
|
||||
|
||||
## Topics
|
||||
|
||||
### Builder
|
||||
|
||||
- ``OneOfBuilder``
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# ``Parsing/Parse``
|
||||
|
||||
## Topics
|
||||
|
||||
### Builder
|
||||
|
||||
- ``ParserBuilder``
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# ``Parsing/Parser``
|
||||
|
||||
## Topics
|
||||
|
||||
### Diving deeper
|
||||
|
||||
* <doc:GettingStarted>
|
||||
* <doc:Design>
|
||||
* <doc:StringAbstractions>
|
||||
* <doc:ErrorMessages>
|
||||
* <doc:Backtracking>
|
||||
|
||||
### Running a parser
|
||||
|
||||
All of the ways to run a parser on an input.
|
||||
|
||||
- ``parse(_:)-717qw``
|
||||
- ``parse(_:)-6h1d0``
|
||||
- ``parse(_:)-2wzcq``
|
||||
|
||||
### Common parsers
|
||||
|
||||
Some of the most commonly used parsers in the library. Use these parsers with operators in order
|
||||
to build complex parsers from simpler pieces.
|
||||
|
||||
- <doc:Int>
|
||||
- <doc:String>
|
||||
- <doc:Bool>
|
||||
- <doc:Float>
|
||||
- <doc:CharacterSet>
|
||||
- <doc:UUID>
|
||||
- <doc:CaseIterable>
|
||||
- ``Parse``
|
||||
- ``OneOf``
|
||||
- ``Many``
|
||||
- ``Prefix``
|
||||
- ``PrefixThrough``
|
||||
- ``PrefixUpTo``
|
||||
- ``Optionally``
|
||||
- ``Always``
|
||||
- ``End``
|
||||
- ``Rest``
|
||||
- ``Fail``
|
||||
- ``FromSubstring``
|
||||
- ``FromUTF8View``
|
||||
- ``FromUnicodeScalarView``
|
||||
- ``First``
|
||||
- ``Skip``
|
||||
- ``Lazy``
|
||||
- ``Newline``
|
||||
- ``Whitespace``
|
||||
- ``AnyParser``
|
||||
- ``Peek``
|
||||
- ``Not``
|
||||
- ``StartsWith``
|
||||
- ``Stream``
|
||||
|
||||
### Parser operators
|
||||
|
||||
- ``map(_:)``
|
||||
- ``flatMap(_:)``
|
||||
- ``compactMap(_:)``
|
||||
- ``filter(_:)``
|
||||
- ``pipe(_:)``
|
||||
- ``pullback(_:)``
|
||||
- ``replaceError(with:)``
|
||||
- ``eraseToAnyParser()``
|
||||
- ``pipe(_:)``
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
# ``Parsing``
|
||||
|
||||
A library for turning nebulous data into well-structured data, with a focus on composition,
|
||||
performance, generality, and ergonomics.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [GitHub Repo](https://github.com/pointfreeco/swift-parsing/)
|
||||
- [Discussions](https://github.com/pointfreeco/swift-parsing/discussions)
|
||||
- [Point-Free Videos](https://www.pointfree.co/collections/parsing)
|
||||
|
||||
## Overview
|
||||
|
||||
Parsing with this library is performed by listing out many small parsers that describe how to
|
||||
incrementally consume small bits from the beginning of an input string. For example, suppose you
|
||||
have a string that holds some user data that you want to parse into an array of `User`s:
|
||||
|
||||
```swift
|
||||
var input = """
|
||||
1,Blob,true
|
||||
2,Blob Jr.,false
|
||||
3,Blob Sr.,true
|
||||
"""
|
||||
|
||||
struct User {
|
||||
var id: Int
|
||||
var name: String
|
||||
var isAdmin: Bool
|
||||
}
|
||||
```
|
||||
|
||||
A parser can be constructed for transforming the input string into an array of users in succinct
|
||||
and fluent API:
|
||||
|
||||
```swift
|
||||
let user = Parse(User.init) {
|
||||
Int.parser()
|
||||
","
|
||||
Prefix { $0 != "," }.map(String.init)
|
||||
","
|
||||
Bool.parser()
|
||||
}
|
||||
|
||||
let users = Many {
|
||||
user
|
||||
} separator: {
|
||||
"\n"
|
||||
} terminator: {
|
||||
End()
|
||||
}
|
||||
|
||||
try users.parse(input) // [User(id: 1, name: "Blob", isAdmin: true), ...]
|
||||
```
|
||||
|
||||
This says that to parse a user we:
|
||||
|
||||
* Parse and consume an integer from the beginning of the input
|
||||
* then a comma
|
||||
* then everything up to the next comma
|
||||
* then another comma
|
||||
* and finally a boolean.
|
||||
|
||||
And to parse an entire array of users we:
|
||||
|
||||
* Run the `user` parser many times
|
||||
* between each invocation of `user` we run the separator parser to consume a newline
|
||||
* and once the `user` and separator parsers have consumed all they can we run the terminator
|
||||
parser to verify there is no more input to consume.
|
||||
|
||||
Further, if the input is malformed, like say we mistyped one of the booleans, then the parser emits
|
||||
an error that describes exactly what went wrong:
|
||||
|
||||
```swift
|
||||
var input = """
|
||||
1,Blob,true
|
||||
2,Blob Jr.,false
|
||||
3,Blob Sr.,tru
|
||||
"""
|
||||
|
||||
try users.parse(input)
|
||||
|
||||
// error: unexpected input
|
||||
// --> input:3:11
|
||||
// 3 | 3,Blob Jr,tru
|
||||
// | ^ expected "true" or "false"
|
||||
```
|
||||
|
||||
That's the basics of parsing a simple string format, but there are a lot more operators and tricks
|
||||
to learn in order to performantly parse larger inputs.
|
||||
|
||||
## Topics
|
||||
|
||||
### Articles
|
||||
|
||||
* <doc:GettingStarted>
|
||||
* <doc:Design>
|
||||
* <doc:StringAbstractions>
|
||||
* <doc:ErrorMessages>
|
||||
* <doc:Backtracking>
|
||||
|
||||
## See Also
|
||||
|
||||
The collecton of videos from [Point-Free](https://www.pointfree.co) that dive deep into the
|
||||
development of the Parsing library.
|
||||
|
||||
* [Point-Free Videos](https://www.pointfree.co/collections/parsing)
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
#endif
|
||||
|
||||
/// Raises a debug breakpoint if a debugger is attached.
|
||||
@inline(__always)
|
||||
@usableFromInline
|
||||
func breakpoint(_ message: @autoclosure () -> String = "") {
|
||||
#if canImport(Darwin)
|
||||
// https://github.com/bitstadium/HockeySDK-iOS/blob/c6e8d1e940299bec0c0585b1f7b86baf3b17fc82/Classes/BITHockeyHelper.m#L346-L370
|
||||
var name: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
|
||||
var info: kinfo_proc = kinfo_proc()
|
||||
var info_size = MemoryLayout<kinfo_proc>.size
|
||||
|
||||
let isDebuggerAttached =
|
||||
sysctl(&name, 4, &info, &info_size, nil, 0) != -1
|
||||
&& info.kp_proc.p_flag & P_TRACED != 0
|
||||
|
||||
if isDebuggerAttached {
|
||||
fputs(
|
||||
"""
|
||||
\(message())
|
||||
|
||||
Caught debug breakpoint. Type "continue" ("c") to resume execution.
|
||||
|
||||
""",
|
||||
stderr
|
||||
)
|
||||
raise(SIGTRAP)
|
||||
}
|
||||
#else
|
||||
assertionFailure(message())
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// NB: Deprecated after 0.6.0
|
||||
|
||||
@available(*, deprecated, renamed: "Parsers.Conditional")
|
||||
public typealias Conditional = Parsers.Conditional
|
||||
204
build-system/SwiftTL/Sources/SwiftTL/Parser/Parser.swift
Normal file
204
build-system/SwiftTL/Sources/SwiftTL/Parser/Parser.swift
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/// Declares a type that can incrementally parse an `Output` value from an `Input` value.
|
||||
///
|
||||
/// A parser attempts to parse a nebulous piece of data, represented by the `Input` associated type,
|
||||
/// into something more well-structured, represented by the `Output` associated type. The parser
|
||||
/// implements the ``parse(_:)-76tcw`` method, which is handed an `inout Input`, and its job is to
|
||||
/// turn this into an `Output` if possible, or throw an error if it cannot.
|
||||
///
|
||||
/// The argument of the ``parse(_:)-76tcw`` function is `inout` because a parser will usually
|
||||
/// consume some of the input in order to produce an output. For example, we can use an
|
||||
/// `Int.parser()` parser to extract an integer from the beginning of a substring and consume that
|
||||
/// portion of the string:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input: Substring = "123 Hello world"
|
||||
///
|
||||
/// try Int.parser().parse(&input) // 123
|
||||
/// input // " Hello world"
|
||||
/// ```
|
||||
///
|
||||
/// Note that this parser works on `Substring` rather than `String` because substrings expose
|
||||
/// efficient ways of removing characters from its beginning. Substrings are "views" into a string,
|
||||
/// specified by start and end indices. Operations like `removeFirst`, `removeLast` and others can
|
||||
/// be implemented efficiently on substrings because they simply move the start and end indices,
|
||||
/// whereas their implementation on strings must make a copy of the string with the characters
|
||||
/// removed.
|
||||
@rethrows public protocol Parser {
|
||||
/// The type of values this parser parses from.
|
||||
associatedtype Input
|
||||
|
||||
/// The type of values parsed by this parser.
|
||||
associatedtype Output
|
||||
|
||||
/// Attempts to parse a nebulous piece of data into something more well-structured. Typically
|
||||
/// you only call this from other `Parser` conformances, not when you want to parse a concrete
|
||||
/// input.
|
||||
///
|
||||
/// - Parameter input: A nebulous, mutable piece of data to be incrementally parsed.
|
||||
/// - Returns: A more well-structured value parsed from the given input.
|
||||
func parse(_ input: inout Input) throws -> Output
|
||||
}
|
||||
|
||||
extension Parser {
|
||||
/// Parse an input value into an output. This method is more ergonomic to use than
|
||||
/// ``parse(_:)-76tcw`` because the input does not need to be inout.
|
||||
///
|
||||
/// Rather than having to create a mutable input value and feed it to the ``parse(_:)-76tcw``
|
||||
/// method like this:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = ...
|
||||
/// let output = try parser.parse(&input)
|
||||
/// ```
|
||||
///
|
||||
/// You can just feed the input directly:
|
||||
///
|
||||
/// ```swift
|
||||
/// let output = try parser.parse(input)
|
||||
/// ```
|
||||
///
|
||||
/// - Parameter input: A nebulous piece of data to be parsed.
|
||||
/// - Returns: A more well-structured value parsed from the given input.
|
||||
@inlinable
|
||||
public func parse(_ input: Input) rethrows -> Output {
|
||||
var input = input
|
||||
return try self.parse(&input)
|
||||
}
|
||||
|
||||
/// Parse a collection into an output using a parser that works on the collection's `SubSequence`.
|
||||
/// This method is more ergnomic to use than ``parse(_:)-76tcw`` because it accepts a
|
||||
/// collection directly rather than its subsequence, and the input does not need to be `inout`.
|
||||
///
|
||||
/// Rather than having to create a mutable subsequence value, such as a `Substring`, and feed it
|
||||
/// to the ``parse(_:)-76tcw`` method like this:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "123,true"[...]
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ","
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse(&input) // (123, true)
|
||||
/// ```
|
||||
///
|
||||
/// You can just feed a plain `String` input directly:
|
||||
///
|
||||
/// ```swift
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ","
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse("123,true") // (123, true)
|
||||
/// ```
|
||||
///
|
||||
/// This method will fail if the parser does not consume the entirety of the input.
|
||||
/// For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ","
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse("123,true ")
|
||||
///
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:9
|
||||
/// // 1 | 123,true␣␣␣␣
|
||||
/// // | ^ expected end of input
|
||||
/// ```
|
||||
///
|
||||
/// > Tip: If your input can have trailing whitespace that you would like to consume and discard
|
||||
/// > you can do so like this:
|
||||
/// > ```swift
|
||||
/// > let output = try Parse {
|
||||
/// > Int.parser()
|
||||
/// > ",".utf8
|
||||
/// > Bool.parser()
|
||||
/// > Skip { Whitespace() }
|
||||
/// > }
|
||||
/// > .parse("123,true ") // (123, true)
|
||||
/// > ```
|
||||
///
|
||||
/// - Parameter input: A nebulous collection of data to be parsed.
|
||||
/// - Returns: A more well-structured value parsed from the given input.
|
||||
@inlinable
|
||||
public func parse<C: Collection>(_ input: C) rethrows -> Output
|
||||
where Input == C.SubSequence {
|
||||
try Parse {
|
||||
self
|
||||
End<Input>()
|
||||
}.parse(input[...])
|
||||
}
|
||||
|
||||
/// Parse a `String` into an output using a UTF-8 parser. This method is more ergnomic to use
|
||||
/// than ``parse(_:)-76tcw`` because it accepts a plain string rather than a collection of
|
||||
/// UTF-8 code units, and the input does not need to be `inout`.
|
||||
///
|
||||
/// Rather than having to create a mutable UTF-8 value and feed it to the ``parse(_:)-76tcw``
|
||||
/// method like this:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "123,true"[...].utf8
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ",".utf8
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse(&input) // (123, true)
|
||||
/// ```
|
||||
///
|
||||
/// You can just feed a plain `String` input directly:
|
||||
///
|
||||
/// ```swift
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ",".utf8
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse("123,true") // (123, true)
|
||||
/// ```
|
||||
///
|
||||
/// This method will fail if the parser does not consume the entirety of the input.
|
||||
/// For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let output = try Parse {
|
||||
/// Int.parser()
|
||||
/// ",".utf8
|
||||
/// Bool.parser()
|
||||
/// }
|
||||
/// .parse("123,true ")
|
||||
///
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:9
|
||||
/// // 1 | 123,true␣␣␣␣
|
||||
/// // | ^ expected end of input
|
||||
/// ```
|
||||
///
|
||||
/// > Tip: If your input can have trailing whitespace that you would like to consume and discard
|
||||
/// > you can do so like this:
|
||||
/// > ```swift
|
||||
/// > let output = try Parse {
|
||||
/// > Int.parser()
|
||||
/// > ",".utf8
|
||||
/// > Bool.parser()
|
||||
/// > Skip { Whitespace() }
|
||||
/// > }
|
||||
/// > .parse("123,true ") // (123, true)
|
||||
/// > ```
|
||||
///
|
||||
/// - Parameter input: A nebulous collection of data to be parsed.
|
||||
/// - Returns: A more well-structured value parsed from the given input.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public func parse<S: StringProtocol>(_ input: S) rethrows -> Output
|
||||
where Input == S.SubSequence.UTF8View {
|
||||
try Parse {
|
||||
self
|
||||
End<Input>()
|
||||
}.parse(input[...].utf8)
|
||||
}
|
||||
}
|
||||
101
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Always.swift
Normal file
101
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Always.swift
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/// A parser that always succeeds with the given value, and does not consume any input.
|
||||
///
|
||||
/// While not very useful on its own, the `Always` parser can be helpful when combined with other
|
||||
/// parsers or operators.
|
||||
///
|
||||
/// When its `Output` is `Void`, it can be used as a "no-op" parser of sorts and be plugged into
|
||||
/// other parser operations. For example, the ``Many`` parser can be configured with separator and
|
||||
/// terminator parsers:
|
||||
///
|
||||
/// ```swift
|
||||
/// Many {
|
||||
/// Int.parser()
|
||||
/// } separator: {
|
||||
/// ","
|
||||
/// } terminator: {
|
||||
/// End()
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// But also exposes initializers that omit these parsers when there is no separator or terminator
|
||||
/// to be parsed:
|
||||
///
|
||||
/// ```swift
|
||||
/// Many {
|
||||
/// Prefix { $0 != "\n" }
|
||||
/// "\n"
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// To support this, `Many` plugs `Always<Input, Void>` into each omitted parser. As a simplified
|
||||
/// example:
|
||||
///
|
||||
/// ```swift
|
||||
/// struct Many<Element: Parser, Separator: Parser, Terminator: Parser>: Parser
|
||||
/// where Separator.Input == Element.Input, Terminator.Input == Element.Input {
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// extension Many where Separator == Always<Input, Void>, Terminator == Always<Input, Void> {
|
||||
/// init(@ParserBuilder element: () -> Element) {
|
||||
/// self.element = element()
|
||||
/// self.separator = Always(())
|
||||
/// self.terminator = Always(())
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This means the previous example is equivalent to:
|
||||
///
|
||||
/// ```swift
|
||||
/// Many {
|
||||
/// Prefix { $0 != "\n" }
|
||||
/// "\n"
|
||||
/// } separator: {
|
||||
/// Always(())
|
||||
/// } terminator: {
|
||||
/// Always(())
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// > Note: While `Always` can be used as the last alternative of a ``OneOf`` to specify a default
|
||||
/// > output, the resulting parser will be throwing. Instead, prefer ``Parser/replaceError(with:)``,
|
||||
/// > which returns a non-throwing parser.
|
||||
public struct Always<Input, Output>: Parser {
|
||||
public let output: Output
|
||||
|
||||
@inlinable
|
||||
public init(_ output: Output) {
|
||||
self.output = output
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) -> Output {
|
||||
self.output
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func map<NewOutput>(
|
||||
_ transform: @escaping (Output) -> NewOutput
|
||||
) -> Always<Input, NewOutput> {
|
||||
.init(transform(self.output))
|
||||
}
|
||||
}
|
||||
|
||||
extension Always where Input == Substring {
|
||||
@inlinable
|
||||
public init(_ output: Output) {
|
||||
self.output = output
|
||||
}
|
||||
}
|
||||
|
||||
extension Always where Input == Substring.UTF8View {
|
||||
@inlinable
|
||||
public init(_ output: Output) {
|
||||
self.output = output
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Always = SwiftTL.Always // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
extension Parser {
|
||||
/// Wraps this parser with a type eraser.
|
||||
///
|
||||
/// This form of _type erasure_ preserves abstraction across API boundaries, such as different
|
||||
/// modules.
|
||||
///
|
||||
/// When you expose your composed parsers as the ``AnyParser`` type, you can change the underlying
|
||||
/// implementation over time without affecting existing clients.
|
||||
///
|
||||
/// Equivalent to passing `self` to `AnyParser.init(_:)`.
|
||||
///
|
||||
/// - Returns: An ``AnyParser`` wrapping this publisher.
|
||||
@inlinable
|
||||
public func eraseToAnyParser() -> AnyParser<Input, Output> {
|
||||
.init(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// A type-erased parser of `Output` from `Input`.
|
||||
///
|
||||
/// This parser forwards its ``parse(_:)`` method to an arbitrary underlying parser having the same
|
||||
/// `Input` and `Output` types, hiding the specifics of the underlying ``Parser``.
|
||||
///
|
||||
/// Use ``AnyParser`` to wrap a parser whose type has details you don't want to expose across API
|
||||
/// boundaries, such as different modules. When you use type erasure this way, you can change the
|
||||
/// underlying parser over time without affecting existing clients.
|
||||
public struct AnyParser<Input, Output>: Parser {
|
||||
@usableFromInline
|
||||
let parser: (inout Input) throws -> Output
|
||||
|
||||
/// Creates a type-erasing parser to wrap the given parser.
|
||||
///
|
||||
/// Equivalent to calling ``Parser/eraseToAnyParser()`` on the parser.
|
||||
///
|
||||
/// - Parameter parser: A parser to wrap with a type eraser.
|
||||
@inlinable
|
||||
public init<P: Parser>(_ parser: P) where P.Input == Input, P.Output == Output {
|
||||
self.init(parser.parse)
|
||||
}
|
||||
|
||||
/// Creates a parser that wraps the given closure in its ``parse(_:)`` method.
|
||||
///
|
||||
/// - Parameter parse: A closure that attempts to parse an output from an input. `parse` is
|
||||
/// executed each time the ``parse(_:)`` method is called on the resulting parser.
|
||||
@inlinable
|
||||
public init(_ parse: @escaping (inout Input) throws -> Output) {
|
||||
self.parser = parse
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Output {
|
||||
try self.parser(&input)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func eraseToAnyParser() -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias AnyParser = SwiftTL.AnyParser // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
extension Bool {
|
||||
/// A parser that consumes a Boolean value from the beginning of a collection of UTF-8 code units.
|
||||
///
|
||||
/// See <doc:Bool> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - Returns: A parser that consumes a Boolean value from the beginning of a collection of UTF-8
|
||||
/// code units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self
|
||||
) -> Parsers.BoolParser<Input> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a Boolean value from the beginning of a substring's UTF-8 view.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is
|
||||
/// `Substring.UTF8View`.
|
||||
///
|
||||
/// See <doc:Bool> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring.UTF8View` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a Boolean value from the beginning of a substring's UTF-8
|
||||
/// view.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self
|
||||
) -> Parsers.BoolParser<Substring.UTF8View> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a Boolean value from the beginning of a substring.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is `Substring`.
|
||||
///
|
||||
/// See <doc:Bool> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a Boolean value from the beginning of a substring.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self
|
||||
) -> FromUTF8View<Substring, Parsers.BoolParser<Substring.UTF8View>> {
|
||||
.init { Parsers.BoolParser<Substring.UTF8View>() }
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that consumes a Boolean value from the beginning of a collection of UTF-8 code units.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// `Bool.parser()`, which constructs this type.
|
||||
///
|
||||
/// See <doc:Bool> for more information about this parser.
|
||||
public struct BoolParser<Input: Collection>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit
|
||||
{
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Bool {
|
||||
if input.starts(with: [116, 114, 117, 101] /*"true".utf8*/) {
|
||||
input.removeFirst(4)
|
||||
return true
|
||||
} else if input.starts(with: [102, 97, 108, 115, 101] /*"false".utf8*/) {
|
||||
input.removeFirst(5)
|
||||
return false
|
||||
}
|
||||
throw ParsingError.expectedInput("\"true\" or \"false\"", at: input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
extension CaseIterable where Self: RawRepresentable, RawValue == Int {
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of a substring.
|
||||
///
|
||||
/// See <doc:CaseIterable> for more info.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a substring.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Substring, Self, String> {
|
||||
.init(toPrefix: { String($0) }, areEquivalent: ==)
|
||||
}
|
||||
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of a substring's UTF-8 view.
|
||||
///
|
||||
/// See <doc:CaseIterable> for more info.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring.UTF8View` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a substring's UTF-8 view.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Substring.UTF8View, Self, String.UTF8View> {
|
||||
.init(toPrefix: { String($0).utf8 }, areEquivalent: ==)
|
||||
}
|
||||
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of UTF-8 code units.
|
||||
///
|
||||
/// - Parameter inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a collection of UTF-8 code units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Input, Self, String.UTF8View>
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit
|
||||
{
|
||||
.init(toPrefix: { String($0).utf8 }, areEquivalent: ==)
|
||||
}
|
||||
}
|
||||
|
||||
extension CaseIterable where Self: RawRepresentable, RawValue == String {
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of a substring.
|
||||
///
|
||||
/// See <doc:CaseIterable> for more info.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a substring.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Substring, Self, String> {
|
||||
.init(toPrefix: { $0 }, areEquivalent: ==)
|
||||
}
|
||||
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of a substring's UTF-8 view.
|
||||
///
|
||||
/// See <doc:CaseIterable> for more info.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring.UTF8View` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a substring's UTF-8 view.
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Substring.UTF8View, Self, String.UTF8View> {
|
||||
.init(toPrefix: { $0.utf8 }, areEquivalent: ==)
|
||||
}
|
||||
|
||||
/// A parser that consumes a case-iterable, raw representable value from the beginning of a
|
||||
/// collection of UTF-8 code units.
|
||||
///
|
||||
/// - Parameter inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - Returns: A parser that consumes a case-iterable, raw representable value from the beginning
|
||||
/// of a collection of UTF-8 code units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self
|
||||
) -> Parsers.CaseIterableRawRepresentableParser<Input, Self, String.UTF8View>
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit
|
||||
{
|
||||
.init(toPrefix: { $0.utf8 }, areEquivalent: ==)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public struct CaseIterableRawRepresentableParser<
|
||||
Input: Collection, Output: CaseIterable & RawRepresentable, Prefix: Collection
|
||||
>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Output.RawValue: Comparable,
|
||||
Prefix.Element == Input.Element
|
||||
{
|
||||
@usableFromInline
|
||||
let cases: [(case: Output, prefix: Prefix, count: Int)]
|
||||
|
||||
@usableFromInline
|
||||
let areEquivalent: (Input.Element, Input.Element) -> Bool
|
||||
|
||||
@usableFromInline
|
||||
init(
|
||||
toPrefix: @escaping (Output.RawValue) -> Prefix,
|
||||
areEquivalent: @escaping (Input.Element, Input.Element) -> Bool
|
||||
) {
|
||||
self.areEquivalent = areEquivalent
|
||||
self.cases = Output.allCases
|
||||
.map {
|
||||
let prefix = toPrefix($0.rawValue)
|
||||
return ($0, prefix, prefix.count)
|
||||
}
|
||||
.sorted(by: { $0.count > $1.count })
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Output {
|
||||
for (`case`, prefix, count) in self.cases {
|
||||
if input.starts(with: prefix, by: self.areEquivalent) {
|
||||
input.removeFirst(count)
|
||||
return `case`
|
||||
}
|
||||
}
|
||||
throw ParsingError.expectedInput("case of \"\(Output.self)\"", at: input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import Foundation
|
||||
|
||||
extension CharacterSet: Parser {
|
||||
@inlinable
|
||||
public func parse(_ input: inout Substring) -> Substring {
|
||||
let output = input.unicodeScalars.prefix(while: self.contains)
|
||||
input.unicodeScalars.removeFirst(output.count)
|
||||
return Substring(output)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
extension Parser {
|
||||
/// Returns a parser that outputs the non-`nil` result of calling the given closure with the
|
||||
/// output of this parser.
|
||||
///
|
||||
/// This method is similar to `Sequence.compactMap` in the Swift standard library, as well as
|
||||
/// `Publisher.compactMap` in the Combine framework.
|
||||
///
|
||||
/// ```swift
|
||||
/// let evenParser = Int.parser().compactMap { $0.isMultiple(of: 2) }
|
||||
///
|
||||
/// var input = "124 hello world"[...]
|
||||
/// try evenParser.parse(&input) // 124
|
||||
/// input // " hello world"
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails when the provided closure returns `nil`. For example, the following parser tries
|
||||
/// to convert two characters into a hex digit, but fails to do so because `"GG"` is not a valid
|
||||
/// hex number:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "GG0000"[...]
|
||||
/// let hex = try Prefix(2).compactMap { Int(String($0), radix: 16) }.parse(&input)
|
||||
/// // error: failed to process "Int" from "GG"
|
||||
/// // --> input:1:1-2
|
||||
/// // 1 | GG0000
|
||||
/// // | ^^
|
||||
/// ```
|
||||
///
|
||||
/// - Parameter transform: A closure that accepts output of this parser as its argument and
|
||||
/// returns an optional value.
|
||||
/// - Returns: A parser that outputs the non-`nil` result of calling the given transformation
|
||||
/// with the output of this parser.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public func compactMap<NewOutput>(
|
||||
_ transform: @escaping (Output) -> NewOutput?
|
||||
) -> Parsers.CompactMap<Self, NewOutput> {
|
||||
.init(upstream: self, transform: transform)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that outputs the non-`nil` result of calling the given transformation with the output
|
||||
/// of its upstream parser.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/compactMap(_:)`` operation, which constructs this type.
|
||||
public struct CompactMap<Upstream: Parser, Output>: Parser {
|
||||
public let upstream: Upstream
|
||||
public let transform: (Upstream.Output) -> Output?
|
||||
|
||||
@inlinable
|
||||
public init(
|
||||
upstream: Upstream,
|
||||
transform: @escaping (Upstream.Output) -> Output?
|
||||
) {
|
||||
self.upstream = upstream
|
||||
self.transform = transform
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) throws -> Output {
|
||||
let original = input
|
||||
let output = try self.upstream.parse(&input)
|
||||
guard let newOutput = self.transform(output)
|
||||
else {
|
||||
throw ParsingError.failed(
|
||||
summary: """
|
||||
failed to process "\(Output.self)" from \(formatValue(output))
|
||||
""",
|
||||
from: original,
|
||||
to: input
|
||||
)
|
||||
}
|
||||
return newOutput
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
extension Parsers {
|
||||
/// A parser that can parse output from two types of parsers.
|
||||
///
|
||||
/// This parser is useful for situations where you want to run one of two different parsers based on
|
||||
/// a condition, which typically would force you to perform ``Parser/eraseToAnyParser()`` and incur
|
||||
/// a performance penalty.
|
||||
///
|
||||
/// For example, you can use this parser in a ``Parser/flatMap(_:)`` operation to use the parsed
|
||||
/// output to determine what parser to run next:
|
||||
///
|
||||
/// ```swift
|
||||
/// versionParser.flatMap { version in
|
||||
/// version == "2.0"
|
||||
/// ? Conditional.first(V2Parser())
|
||||
/// : Conditional.second(LegacyParser())
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// You won't typically construct this parser directly, but instead will use standard `if`-`else`
|
||||
/// statements in a parser builder to automatically build conditional parsers:
|
||||
///
|
||||
/// ```swift
|
||||
/// versionParser.flatMap { version in
|
||||
/// if version == "2.0" {
|
||||
/// V2Parser()
|
||||
/// } else {
|
||||
/// LegacyParser()
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
public enum Conditional<First: Parser, Second: Parser>: Parser
|
||||
where
|
||||
First.Input == Second.Input,
|
||||
First.Output == Second.Output
|
||||
{
|
||||
case first(First)
|
||||
case second(Second)
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout First.Input) rethrows -> First.Output {
|
||||
switch self {
|
||||
case let .first(first):
|
||||
return try first.parse(&input)
|
||||
case let .second(second):
|
||||
return try second.parse(&input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/// A parser that succeeds if the input is empty, and fails otherwise.
|
||||
///
|
||||
/// Useful as a final parser in a long sequence of parsers to guarantee that all input has been
|
||||
/// consumed.
|
||||
///
|
||||
/// ```swift
|
||||
/// let parser = Parse {
|
||||
/// "Hello, "
|
||||
/// Prefix { $0 != "!" }
|
||||
/// "!"
|
||||
/// End() // NB: All input should be consumed.
|
||||
/// }
|
||||
///
|
||||
/// var input = "Hello, Blob!"[...]
|
||||
/// try parser.parse(&input) // "Blob"
|
||||
/// ```
|
||||
///
|
||||
/// This parser will fail if there are input elements that have not been consumed:
|
||||
///
|
||||
/// ```swift
|
||||
/// input = "Hello, Blob!!"
|
||||
/// try parser.parse(&input)
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:13
|
||||
/// // 1 | Hello, Blob!!
|
||||
/// // | ^ expected end of input
|
||||
/// ```
|
||||
public struct End<Input: Collection>: Parser {
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws {
|
||||
guard input.isEmpty else {
|
||||
throw ParsingError.expectedInput("end of input", at: input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension End where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}
|
||||
|
||||
/*extension End where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}*/
|
||||
|
||||
extension Parsers {
|
||||
public typealias End = SwiftTL.End // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/// A parser that always fails, no matter the input.
|
||||
///
|
||||
/// While not very useful on its own, this parser can be helpful when combined with other parsers or
|
||||
/// operators.
|
||||
///
|
||||
/// For example, it can be used to conditionally causing parsing to fail when used with
|
||||
/// ``Parser/flatMap(_:)``:
|
||||
///
|
||||
/// ```swift
|
||||
/// struct OddFailure: Error {}
|
||||
///
|
||||
/// let evens = Int.parser().flatMap {
|
||||
/// if $0.isMultiple(of: 2) {
|
||||
/// Always($0)
|
||||
/// } else {
|
||||
/// Fail<Substring, Int>(throwing: OddFailure())
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// try evens.parse("42") // 42
|
||||
///
|
||||
/// try evens.parse("123")
|
||||
/// // error: OddFailure()
|
||||
/// // --> input:1:1-3
|
||||
/// // 1 | 123
|
||||
/// // | ^^^
|
||||
/// ```
|
||||
public struct Fail<Input, Output>: Parser {
|
||||
@usableFromInline
|
||||
let error: Error
|
||||
|
||||
/// Creates a parser that throws an error when it runs.
|
||||
///
|
||||
/// - Parameter error: An error to throw when the parser is run.
|
||||
@inlinable
|
||||
public init(throwing error: Error) {
|
||||
self.error = error
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Output {
|
||||
switch self.error {
|
||||
case is ParsingError:
|
||||
throw self.error
|
||||
default:
|
||||
throw ParsingError.wrap(self.error, at: input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Fail {
|
||||
/// Creates a parser that throws an error when it runs.
|
||||
@inlinable
|
||||
public init() {
|
||||
self.init(throwing: DefaultError())
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
struct DefaultError: Error, CustomDebugStringConvertible {
|
||||
@usableFromInline
|
||||
init() {}
|
||||
|
||||
@usableFromInline
|
||||
var debugDescription: String {
|
||||
"failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Fail = SwiftTL.Fail // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
extension Parser {
|
||||
/// Returns a parser that filters output from this parser when its output does not satisfy the
|
||||
/// given predicate.
|
||||
///
|
||||
/// This method is similar to `Sequence.filter` in the Swift standard library, as well as
|
||||
/// `Publisher.filter` in the Combine framework.
|
||||
///
|
||||
/// This parser fails if the predicate is not satisfied on the output of the upstream parser. For example,
|
||||
/// the following parser consumes only even integers and so fails when an odd integer is used:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "43 Hello, world!"[...]
|
||||
/// let number = try Int.parser().filter { $0.isMultiple(of: 2) }.parse(&input)
|
||||
/// // error: processed value 43 failed to satisfy predicate
|
||||
/// // --> input:1:1-2
|
||||
/// // 1 | 43 Hello, world!
|
||||
/// // | ^^ processed input
|
||||
/// ```
|
||||
///
|
||||
/// - Parameter predicate: A closure that takes an output from this parser and returns a Boolean
|
||||
/// value indicating whether the output should be returned.
|
||||
/// - Returns: A parser that filters its output.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public func filter(_ predicate: @escaping (Output) -> Bool) -> Parsers.Filter<Self> {
|
||||
.init(upstream: self, predicate: predicate)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that filters the output of an upstream parser when it does not satisfy a predicate.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/filter(_:)`` operation, which constructs this type.
|
||||
public struct Filter<Upstream: Parser>: Parser {
|
||||
public let upstream: Upstream
|
||||
public let predicate: (Upstream.Output) -> Bool
|
||||
|
||||
@inlinable
|
||||
public init(upstream: Upstream, predicate: @escaping (Upstream.Output) -> Bool) {
|
||||
self.upstream = upstream
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) throws -> Upstream.Output {
|
||||
let original = input
|
||||
let output = try self.upstream.parse(&input)
|
||||
guard self.predicate(output)
|
||||
else {
|
||||
throw ParsingError.failed(
|
||||
summary: "processed value \(formatValue(output)) failed to satisfy predicate",
|
||||
label: "processed input",
|
||||
from: original,
|
||||
to: input
|
||||
)
|
||||
}
|
||||
return output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/// A parser that consumes the first element from a collection.
|
||||
///
|
||||
/// This parser is named after `Sequence.first`, and attempts to parse the first element from a
|
||||
/// collection of input by calling this property under the hood.
|
||||
///
|
||||
/// For example, it can parse the leading character off a substring:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Hello"[...]
|
||||
/// try First().parse(&input) // "H"
|
||||
/// input // "ello"
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails if the input collection is empty:
|
||||
///
|
||||
/// ```swift
|
||||
/// input = ""
|
||||
/// try First().parse(&input)
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 |
|
||||
/// // | ^ expected element
|
||||
/// ```
|
||||
public struct First<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Input.Element {
|
||||
guard let first = input.first else {
|
||||
throw ParsingError.expectedInput("element", at: input)
|
||||
}
|
||||
input.removeFirst()
|
||||
return first
|
||||
}
|
||||
}
|
||||
|
||||
extension First where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}
|
||||
|
||||
extension First where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias First = SwiftTL.First // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
extension Parser {
|
||||
/// Returns a parser that transforms the output of this parser into a new parser.
|
||||
///
|
||||
/// This method is similar to `Sequence.flatMap`, `Optional.flatMap`, and `Result.flatMap` in the
|
||||
/// Swift standard library, as well as `Publisher.flatMap` in the Combine framework.
|
||||
///
|
||||
/// - Parameter transform: A closure that transforms values of this parser's output and returns a
|
||||
/// new parser.
|
||||
/// - Returns: A parser that transforms output from an upstream parser into a new parser.
|
||||
@inlinable
|
||||
public func flatMap<NewParser>(
|
||||
@ParserBuilder _ transform: @escaping (Output) -> NewParser
|
||||
) -> Parsers.FlatMap<NewParser, Self> {
|
||||
.init(upstream: self, transform: transform)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that transforms the output of another parser into a new parser.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/flatMap(_:)`` operation, which constructs this type.
|
||||
public struct FlatMap<NewParser: Parser, Upstream: Parser>: Parser
|
||||
where NewParser.Input == Upstream.Input {
|
||||
public let upstream: Upstream
|
||||
public let transform: (Upstream.Output) -> NewParser
|
||||
|
||||
@inlinable
|
||||
public init(upstream: Upstream, transform: @escaping (Upstream.Output) -> NewParser) {
|
||||
self.upstream = upstream
|
||||
self.transform = transform
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) rethrows -> NewParser.Output {
|
||||
let original = input
|
||||
do {
|
||||
return try self.transform(self.upstream.parse(&input)).parse(&input)
|
||||
} catch let ParsingError.failed(reason, context) {
|
||||
throw ParsingError.failed(
|
||||
reason,
|
||||
.init(
|
||||
originalInput: original,
|
||||
remainingInput: input,
|
||||
debugDescription: context.debugDescription,
|
||||
underlyingError: ParsingError.failed(reason, context)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
172
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Float.swift
Normal file
172
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Float.swift
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
extension BinaryFloatingPoint where Self: LosslessStringConvertible {
|
||||
/// A parser that consumes a floating-point number from the beginning of a collection of UTF-8
|
||||
/// code units.
|
||||
///
|
||||
/// See <doc:Float> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - Returns: A parser that consumes a floating-point number from the beginning of a collection
|
||||
/// of UTF-8 code units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self
|
||||
) -> Parsers.FloatParser<Input, Self> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a floating-point number from the beginning of a substring's UTF-8 view.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is
|
||||
/// `Substring.UTF8View`.
|
||||
///
|
||||
/// See <doc:Float> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring.UTF8View` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a floating-point number from the beginning of a substring's
|
||||
/// UTF-8 view.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self
|
||||
) -> Parsers.FloatParser<Substring.UTF8View, Self> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a floating-point number from the beginning of a substring.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is `Substring`.
|
||||
///
|
||||
/// See <doc:Float> for more information about this parser.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a floating-point number from the beginning of a substring.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self
|
||||
) -> FromUTF8View<Substring, Parsers.FloatParser<Substring.UTF8View, Self>> {
|
||||
.init { Parsers.FloatParser<Substring.UTF8View, Self>() }
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that consumes a floating-point number from the beginning of a collection of UTF-8
|
||||
/// code units.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the static `parser()` method on the `BinaryFloatingPoint` of your choice, e.g.,
|
||||
/// `Double.parser()`, `Float80.parser()`, etc., all of which construct this type.
|
||||
///
|
||||
/// See <doc:Float> for more information about this parser.
|
||||
public struct FloatParser<Input: Collection, Output: BinaryFloatingPoint>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit,
|
||||
Output: LosslessStringConvertible
|
||||
{
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Output {
|
||||
let original = input
|
||||
let s = input.parseFloat()
|
||||
guard let n = Output(String(decoding: s, as: UTF8.self))
|
||||
else {
|
||||
throw ParsingError.expectedInput("\(Output.self)".lowercased(), from: original, to: input)
|
||||
}
|
||||
return n
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UTF8.CodeUnit {
|
||||
@usableFromInline
|
||||
var isDigit: Bool {
|
||||
(.init(ascii: "0") ... .init(ascii: "9")).contains(self)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
var isHexDigit: Bool {
|
||||
(.init(ascii: "0") ... .init(ascii: "9")).contains(self)
|
||||
|| (.init(ascii: "a") ... .init(ascii: "f")).contains(self)
|
||||
|| (.init(ascii: "A") ... .init(ascii: "F")).contains(self)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
var isSign: Bool {
|
||||
self == .init(ascii: "-") || self == .init(ascii: "+")
|
||||
}
|
||||
}
|
||||
|
||||
extension Collection where SubSequence == Self, Element == UTF8.CodeUnit {
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
mutating func parseFloat() -> SubSequence {
|
||||
let original = self
|
||||
if self.first?.isSign == true {
|
||||
self.removeFirst()
|
||||
}
|
||||
if self.first == .init(ascii: "0")
|
||||
&& (self.dropFirst().first == .init(ascii: "x")
|
||||
|| self.dropFirst().first == .init(ascii: "X"))
|
||||
{
|
||||
self.removeFirst(2)
|
||||
let integer = self.prefix(while: { $0.isHexDigit })
|
||||
self.removeFirst(integer.count)
|
||||
if self.first == .init(ascii: ".") {
|
||||
let fractional =
|
||||
self
|
||||
.dropFirst()
|
||||
.prefix(while: { $0.isHexDigit })
|
||||
self.removeFirst(1 + fractional.count)
|
||||
}
|
||||
if self.first == .init(ascii: "p") || self.first == .init(ascii: "P") {
|
||||
var n = 1
|
||||
if self.dropFirst().first?.isSign == true { n += 1 }
|
||||
let exponent =
|
||||
self
|
||||
.dropFirst(n)
|
||||
.prefix(while: { $0.isHexDigit })
|
||||
guard !exponent.isEmpty else { return original[..<self.startIndex] }
|
||||
self.removeFirst(n + exponent.count)
|
||||
}
|
||||
} else if self.first?.isDigit == true || self.first == .init(ascii: ".") {
|
||||
let integer = self.prefix(while: { $0.isDigit })
|
||||
self.removeFirst(integer.count)
|
||||
if self.first == .init(ascii: ".") {
|
||||
let fractional =
|
||||
self
|
||||
.dropFirst()
|
||||
.prefix(while: { $0.isDigit })
|
||||
self.removeFirst(1 + fractional.count)
|
||||
}
|
||||
if self.first == .init(ascii: "e") || self.first == .init(ascii: "E") {
|
||||
var n = 1
|
||||
if self.dropFirst().first?.isSign == true { n += 1 }
|
||||
let exponent =
|
||||
self
|
||||
.dropFirst(n)
|
||||
.prefix(while: { $0.isDigit })
|
||||
guard !exponent.isEmpty else { return original[..<self.startIndex] }
|
||||
self.removeFirst(n + exponent.count)
|
||||
}
|
||||
} else if self.prefix(8).caseInsensitiveElementsEqualLowercase("infinity".utf8) {
|
||||
self.removeFirst(8)
|
||||
} else if self.prefix(3).caseInsensitiveElementsEqualLowercase("inf".utf8)
|
||||
|| self.prefix(3).caseInsensitiveElementsEqualLowercase("nan".utf8)
|
||||
{
|
||||
self.removeFirst(3)
|
||||
}
|
||||
return original[..<self.startIndex]
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
func caseInsensitiveElementsEqualLowercase<S: Sequence>(_ other: S) -> Bool
|
||||
where S.Element == Element {
|
||||
self.elementsEqual(other, by: { $0 == $1 || $0 + 32 == $1 })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/// A parser that transforms a parser on `Substring` into a parser on another view.
|
||||
///
|
||||
/// The `FromSubstring` operator allows you to mix and match representation levels of strings
|
||||
/// so that you can maximize how much you parse on the faster, but more complex, lower level
|
||||
/// representations and then switch to slower, but safer, higher level representations for
|
||||
/// when you need that power.
|
||||
///
|
||||
/// For example, to parse "café" as a collection of UTF8 code units you must be careful to parse
|
||||
/// both representations of "é":
|
||||
///
|
||||
/// ```swift
|
||||
/// OneOf {
|
||||
/// "caf\u{00E9}".utf8 // LATIN SMALL LETTER E WITH ACUTE
|
||||
/// "cafe\u{0301}".utf8 // E + COMBINING ACUTE ACCENT
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Alternatively, you can parse the ASCII characters of "caf" as UTF8 code units, and then
|
||||
/// switch to the higher level substring representation to parse "é" so that you don't have
|
||||
/// to worry about UTF8 normalization:
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// "caf".utf8
|
||||
///
|
||||
/// // Parse any recognized "é" character, including:
|
||||
/// // - LATIN SMALL LETTER E WITH ACUTE ("\u{00E9}")
|
||||
/// // - E + COMBINING ACUTE ACCENT ("e\u{0301}")
|
||||
/// FromSubstring { "é" }
|
||||
/// }
|
||||
/// ```
|
||||
public struct FromSubstring<Input, SubstringParser: Parser>: Parser
|
||||
where SubstringParser.Input == Substring {
|
||||
public let substringParser: SubstringParser
|
||||
public let toSubstring: (Input) -> Substring
|
||||
public let fromSubstring: (Substring) -> Input
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) rethrows -> SubstringParser.Output {
|
||||
var substring = self.toSubstring(input)
|
||||
defer { input = self.fromSubstring(substring) }
|
||||
return try self.substringParser.parse(&substring)
|
||||
}
|
||||
}
|
||||
|
||||
extension FromSubstring where Input == ArraySlice<UInt8> {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> SubstringParser) {
|
||||
self.substringParser = build()
|
||||
self.toSubstring = { Substring(decoding: $0, as: UTF8.self) }
|
||||
self.fromSubstring = { ArraySlice($0.utf8) }
|
||||
}
|
||||
}
|
||||
|
||||
extension FromSubstring where Input == Substring.UnicodeScalarView {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> SubstringParser) {
|
||||
self.substringParser = build()
|
||||
self.toSubstring = Substring.init
|
||||
self.fromSubstring = \.unicodeScalars
|
||||
}
|
||||
}
|
||||
|
||||
extension FromSubstring where Input == Substring.UTF8View {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> SubstringParser) {
|
||||
self.substringParser = build()
|
||||
self.toSubstring = Substring.init
|
||||
self.fromSubstring = \.utf8
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
public struct FromUTF8View<Input, UTF8Parser: Parser>: Parser
|
||||
where UTF8Parser.Input == Substring.UTF8View {
|
||||
public let utf8Parser: UTF8Parser
|
||||
public let toUTF8: (Input) -> Substring.UTF8View
|
||||
public let fromUTF8: (Substring.UTF8View) -> Input
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) rethrows -> UTF8Parser.Output {
|
||||
var utf8 = self.toUTF8(input)
|
||||
defer { input = self.fromUTF8(utf8) }
|
||||
return try self.utf8Parser.parse(&utf8)
|
||||
}
|
||||
}
|
||||
|
||||
extension FromUTF8View where Input == Substring {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> UTF8Parser) {
|
||||
self.utf8Parser = build()
|
||||
self.toUTF8 = \.utf8
|
||||
self.fromUTF8 = Substring.init
|
||||
}
|
||||
}
|
||||
|
||||
extension FromUTF8View where Input == Substring.UnicodeScalarView {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> UTF8Parser) {
|
||||
self.utf8Parser = build()
|
||||
self.toUTF8 = { Substring($0).utf8 }
|
||||
self.fromUTF8 = { Substring($0).unicodeScalars }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/// A parser that transforms a parser on `Substring.UnicodeScalarView` into a parser on another
|
||||
/// view.
|
||||
public struct FromUnicodeScalarView<Input, UnicodeScalarsParser: Parser>: Parser
|
||||
where UnicodeScalarsParser.Input == Substring.UnicodeScalarView {
|
||||
public let unicodeScalarsParser: UnicodeScalarsParser
|
||||
public let toUnicodeScalars: (Input) -> Substring.UnicodeScalarView
|
||||
public let fromUnicodeScalars: (Substring.UnicodeScalarView) -> Input
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) rethrows -> UnicodeScalarsParser.Output {
|
||||
var unicodeScalars = self.toUnicodeScalars(input)
|
||||
defer { input = self.fromUnicodeScalars(unicodeScalars) }
|
||||
return try self.unicodeScalarsParser.parse(&unicodeScalars)
|
||||
}
|
||||
}
|
||||
|
||||
extension FromUnicodeScalarView where Input == ArraySlice<UInt8> {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> UnicodeScalarsParser) {
|
||||
self.unicodeScalarsParser = build()
|
||||
self.toUnicodeScalars = { Substring(decoding: $0, as: UTF8.self).unicodeScalars }
|
||||
self.fromUnicodeScalars = { ArraySlice(Substring($0).utf8) }
|
||||
}
|
||||
}
|
||||
|
||||
extension FromUnicodeScalarView where Input == Substring {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> UnicodeScalarsParser) {
|
||||
self.unicodeScalarsParser = build()
|
||||
self.toUnicodeScalars = \.unicodeScalars
|
||||
self.fromUnicodeScalars = Substring.init
|
||||
}
|
||||
}
|
||||
|
||||
extension FromUnicodeScalarView where Input == Substring.UTF8View {
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> UnicodeScalarsParser) {
|
||||
self.unicodeScalarsParser = build()
|
||||
self.toUnicodeScalars = { Substring($0).unicodeScalars }
|
||||
self.fromUnicodeScalars = { Substring($0).utf8 }
|
||||
}
|
||||
}
|
||||
163
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Int.swift
Normal file
163
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Int.swift
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
extension FixedWidthInteger {
|
||||
/// A parser that consumes an integer (with an optional leading `+` or `-` sign for signed integer
|
||||
/// types) from the beginning of a collection of UTF-8 code units.
|
||||
///
|
||||
/// See <doc:Int> for more information about this parser.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - radix: The radix, or base, to use for converting text to an integer value. `radix` must be
|
||||
/// in the range `2...36`.
|
||||
/// - Returns: A parser that consumes an integer from the beginning of a collection of UTF-8 code
|
||||
/// units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self,
|
||||
radix: Int = 10
|
||||
) -> Parsers.IntParser<Input, Self> {
|
||||
.init(radix: radix)
|
||||
}
|
||||
|
||||
/// A parser that consumes an integer (with an optional leading `+` or `-` sign for signed integer
|
||||
/// types) from the beginning of a collection of UTF-8 code units.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is
|
||||
/// `Substring.UTF8View`.
|
||||
///
|
||||
/// See <doc:Int> for more information about this parser.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputType: The `Substring.UTF8View` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - radix: The radix, or base, to use for converting text to an integer value. `radix` must be
|
||||
/// in the range `2...36`.
|
||||
/// - Returns: A parser that consumes an integer from the beginning of a substring's UTF-8 view.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self,
|
||||
radix: Int = 10
|
||||
) -> Parsers.IntParser<Substring.UTF8View, Self> {
|
||||
.init(radix: radix)
|
||||
}
|
||||
|
||||
/// A parser that consumes an integer (with an optional leading `+` or `-` sign for signed integer
|
||||
/// types) from the beginning of a collection of UTF-8 code units.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is `Substring`.
|
||||
///
|
||||
/// See <doc:Int> for more information about this parser.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputType: The `Substring` type. This parameter is included to mirror the interface that
|
||||
/// parses any collection of UTF-8 code units.
|
||||
/// - radix: The radix, or base, to use for converting text to an integer value. `radix` must be
|
||||
/// in the range `2...36`.
|
||||
/// - Returns: A parser that consumes an integer from the beginning of a substring.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self,
|
||||
radix: Int = 10
|
||||
) -> FromUTF8View<Substring, Parsers.IntParser<Substring.UTF8View, Self>> {
|
||||
.init { Parsers.IntParser<Substring.UTF8View, Self>(radix: radix) }
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that consumes an integer (with an optional leading `+` or `-` sign for signed integer
|
||||
/// types) from the beginning of a collection of UTF8 code units.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the static `parser()` method on the `FixedWidthInteger` of your choice, e.g. `Int.parser()`,
|
||||
/// `UInt8.parser()`, etc., all of which construct this type.
|
||||
///
|
||||
/// See <doc:Int> for more information about this parser.
|
||||
public struct IntParser<Input: Collection, Output: FixedWidthInteger>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit
|
||||
{
|
||||
/// The radix, or base, to use for converting text to an integer value.
|
||||
public let radix: Int
|
||||
|
||||
@inlinable
|
||||
public init(radix: Int = 10) {
|
||||
precondition((2...36).contains(radix), "Radix not in range 2...36")
|
||||
self.radix = radix
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Output {
|
||||
@inline(__always)
|
||||
func digit(for n: UTF8.CodeUnit) -> Output? {
|
||||
let output: Output
|
||||
switch n {
|
||||
case .init(ascii: "0") ... .init(ascii: "9"):
|
||||
output = Output(n - .init(ascii: "0"))
|
||||
case .init(ascii: "A") ... .init(ascii: "Z"):
|
||||
output = Output(n - .init(ascii: "A") + 10)
|
||||
case .init(ascii: "a") ... .init(ascii: "z"):
|
||||
output = Output(n - .init(ascii: "a") + 10)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return output < self.radix ? output : nil
|
||||
}
|
||||
var length = 0
|
||||
var iterator = input.makeIterator()
|
||||
guard let first = iterator.next() else {
|
||||
throw ParsingError.expectedInput("integer", at: input)
|
||||
}
|
||||
let isPositive: Bool
|
||||
let parsedSign: Bool
|
||||
var overflow = false
|
||||
var output: Output
|
||||
switch (Output.isSigned, first) {
|
||||
case (true, .init(ascii: "-")):
|
||||
parsedSign = true
|
||||
isPositive = false
|
||||
output = 0
|
||||
case (true, .init(ascii: "+")):
|
||||
parsedSign = true
|
||||
isPositive = true
|
||||
output = 0
|
||||
case let (_, n):
|
||||
guard let n = digit(for: n) else {
|
||||
throw ParsingError.expectedInput("integer", at: input)
|
||||
}
|
||||
parsedSign = false
|
||||
isPositive = true
|
||||
output = n
|
||||
}
|
||||
let original = input
|
||||
input.removeFirst()
|
||||
length += 1
|
||||
let radix = Output(self.radix)
|
||||
while let next = iterator.next(), let n = digit(for: next) {
|
||||
input.removeFirst()
|
||||
(output, overflow) = output.multipliedReportingOverflow(by: radix)
|
||||
func overflowError() -> Error {
|
||||
ParsingError.failed(
|
||||
summary: "failed to process \"\(Output.self)\"",
|
||||
label: "overflowed \(Output.max)",
|
||||
from: original,
|
||||
to: input
|
||||
)
|
||||
}
|
||||
guard !overflow else { throw overflowError() }
|
||||
(output, overflow) =
|
||||
isPositive
|
||||
? output.addingReportingOverflow(n)
|
||||
: output.subtractingReportingOverflow(n)
|
||||
guard !overflow else { throw overflowError() }
|
||||
length += 1
|
||||
}
|
||||
guard length > (parsedSign ? 1 : 0)
|
||||
else {
|
||||
throw ParsingError.expectedInput("integer", at: input)
|
||||
}
|
||||
return output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/// A parser that waits for a call to its ``parse(_:)`` method before running the given closure to
|
||||
/// create a parser for the given input.
|
||||
public final class Lazy<LazyParser: Parser>: Parser {
|
||||
@usableFromInline
|
||||
internal var lazyParser: LazyParser?
|
||||
|
||||
public let createParser: () -> LazyParser
|
||||
|
||||
@inlinable
|
||||
public init(@ParserBuilder createParser: @escaping () -> LazyParser) {
|
||||
self.createParser = createParser
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout LazyParser.Input) rethrows -> LazyParser.Output {
|
||||
guard let parser = self.lazyParser else {
|
||||
let parser = self.createParser()
|
||||
self.lazyParser = parser
|
||||
return try parser.parse(&input)
|
||||
}
|
||||
return try parser.parse(&input)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Lazy = SwiftTL.Lazy // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
extension Array: Parser where Element: Equatable {
|
||||
@inlinable
|
||||
public func parse(_ input: inout ArraySlice<Element>) throws {
|
||||
guard input.starts(with: self) else {
|
||||
throw ParsingError.expectedInput(self.debugDescription, at: input)
|
||||
}
|
||||
input.removeFirst(self.count)
|
||||
}
|
||||
}
|
||||
|
||||
extension String: Parser {
|
||||
@inlinable
|
||||
public func parse(_ input: inout Substring) throws {
|
||||
guard input.starts(with: self) else {
|
||||
throw ParsingError.expectedInput(self.debugDescription, at: input)
|
||||
}
|
||||
input.removeFirst(self.count)
|
||||
}
|
||||
}
|
||||
|
||||
extension String.UnicodeScalarView: Parser {
|
||||
@inlinable
|
||||
public func parse(_ input: inout Substring.UnicodeScalarView) throws {
|
||||
guard input.starts(with: self) else {
|
||||
throw ParsingError.expectedInput(String(self).debugDescription, at: input)
|
||||
}
|
||||
input.removeFirst(self.count)
|
||||
}
|
||||
}
|
||||
|
||||
extension String.UTF8View: Parser {
|
||||
@inlinable
|
||||
public func parse(_ input: inout Substring.UTF8View) throws {
|
||||
guard input.starts(with: self) else {
|
||||
throw ParsingError.expectedInput(String(self).debugDescription, at: input)
|
||||
}
|
||||
input.removeFirst(self.count)
|
||||
}
|
||||
}
|
||||
353
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Many.swift
Normal file
353
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Many.swift
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
import Foundation
|
||||
|
||||
/// A parser that attempts to run another parser as many times as specified, accumulating the result
|
||||
/// of the outputs.
|
||||
///
|
||||
/// For example, given a comma-separated string of numbers, one could parse out an array of
|
||||
/// integers:
|
||||
///
|
||||
/// ```swift
|
||||
/// let intsParser = Many {
|
||||
/// Int.parser()
|
||||
/// } separator: {
|
||||
/// ","
|
||||
/// }
|
||||
///
|
||||
/// var input = "1,2,3"[...]
|
||||
/// try intsParser.parse(&input) // [1, 2, 3]
|
||||
/// input // ""
|
||||
/// ```
|
||||
///
|
||||
/// In addition to an element and separator parser, a "terminator" parser that is run after the element
|
||||
/// parser has run as many times as possible. This can be useful for proving that the `Many` parser has
|
||||
/// consumed everything you expect:
|
||||
///
|
||||
/// ```swift
|
||||
/// let intsParser = Many {
|
||||
/// Int.parser()
|
||||
/// } separator: {
|
||||
/// ","
|
||||
/// } terminator: {
|
||||
/// "---"
|
||||
/// }
|
||||
///
|
||||
/// var input = "1,2,3---"[...]
|
||||
/// try intsParser.parse(&input) // [1, 2, 3]
|
||||
/// input // ""
|
||||
/// ```
|
||||
///
|
||||
/// The outputs of the element parser do not need to be accumulated in an array. More generally one can
|
||||
/// specify a closure that customizes how outputs are accumulated, much like `Sequence.reduce(into:_)`. We
|
||||
/// could, for example, sum the numbers as we parse them instead of accumulating each value in an array:
|
||||
///
|
||||
/// ```swift
|
||||
/// let sumParser = Many(into: 0, +=) {
|
||||
/// Int.parser()
|
||||
/// } separator: {
|
||||
/// ","
|
||||
/// }
|
||||
///
|
||||
/// var input = "1,2,3"[...]
|
||||
/// try sumParser.parse(&input) // 6
|
||||
/// input // ""
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails if the terminator parser fails. For example, if we required our comma-separated
|
||||
/// integer parser to be terminated by `"---"`, but we parsed a list that contained a non-integer we would
|
||||
/// get an error:
|
||||
///
|
||||
/// ```swift
|
||||
/// let intsParser = Many {
|
||||
/// Int.parser()
|
||||
/// } separator: {
|
||||
/// ","
|
||||
/// } terminator: {
|
||||
/// "---"
|
||||
/// }
|
||||
/// var input = "1,2,Hello---"[...]
|
||||
/// try intsParser.parse(&input)
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:5
|
||||
/// // 1 | 1,2,Hello---
|
||||
/// // | ^ expected integer
|
||||
/// ```
|
||||
public struct Many<Element: Parser, Result, Separator: Parser, Terminator: Parser>: Parser
|
||||
where
|
||||
Separator.Input == Element.Input,
|
||||
Terminator.Input == Element.Input
|
||||
{
|
||||
public let element: Element
|
||||
public let initialResult: Result
|
||||
public let maximum: Int
|
||||
public let minimum: Int
|
||||
public let separator: Separator
|
||||
public let terminator: Terminator
|
||||
public let updateAccumulatingResult: (inout Result, Element.Output) throws -> Void
|
||||
|
||||
/// Initializes a parser that attempts to run the given parser at least and at most the given
|
||||
/// number of times, accumulating the outputs into a result with a given closure.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - initialResult: The value to use as the initial accumulating value.
|
||||
/// - minimum: The minimum number of times to run this parser and consider parsing to be
|
||||
/// successful.
|
||||
/// - maximum: The maximum number of times to run this parser before returning the output.
|
||||
/// - updateAccumulatingResult: A closure that updates the accumulating result with each output
|
||||
/// of the element parser.
|
||||
/// - element: A parser to run multiple times to accumulate into a result.
|
||||
/// - separator: A parser that consumes input between each parsed output.
|
||||
@inlinable
|
||||
public init(
|
||||
into initialResult: Result,
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
_ updateAccumulatingResult: @escaping (inout Result, Element.Output) throws -> Void,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder separator: () -> Separator,
|
||||
@ParserBuilder terminator: () -> Terminator
|
||||
) {
|
||||
self.element = element()
|
||||
self.initialResult = initialResult
|
||||
self.maximum = maximum
|
||||
self.minimum = minimum
|
||||
self.separator = separator()
|
||||
self.terminator = terminator()
|
||||
self.updateAccumulatingResult = updateAccumulatingResult
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Element.Input) throws -> Result {
|
||||
var rest = input
|
||||
var previous = input
|
||||
var result = self.initialResult
|
||||
var count = 0
|
||||
var loopError: Error?
|
||||
while count < self.maximum {
|
||||
let output: Element.Output
|
||||
do {
|
||||
output = try self.element.parse(&input)
|
||||
} catch {
|
||||
loopError = error
|
||||
break
|
||||
}
|
||||
defer { previous = input }
|
||||
count += 1
|
||||
do {
|
||||
try self.updateAccumulatingResult(&result, output)
|
||||
} catch {
|
||||
throw ParsingError.failed(
|
||||
"",
|
||||
.init(
|
||||
originalInput: previous, remainingInput: input, debugDescription: "\(error)",
|
||||
underlyingError: error)
|
||||
)
|
||||
}
|
||||
rest = input
|
||||
do {
|
||||
_ = try self.separator.parse(&input)
|
||||
} catch {
|
||||
loopError = error
|
||||
break
|
||||
}
|
||||
if memcmp(&input, &previous, MemoryLayout<Element.Input>.size) == 0 {
|
||||
throw ParsingError.failed(
|
||||
"expected input to be consumed",
|
||||
.init(remainingInput: input, debugDescription: "infinite loop", underlyingError: nil)
|
||||
)
|
||||
}
|
||||
}
|
||||
input = rest
|
||||
do {
|
||||
_ = try self.terminator.parse(&input)
|
||||
} catch {
|
||||
if let loopError = loopError {
|
||||
throw ParsingError.manyFailed([loopError, error], at: input)
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
guard count >= self.minimum else {
|
||||
let atLeast = self.minimum - count
|
||||
throw ParsingError.expectedInput(
|
||||
"""
|
||||
\(atLeast) \(count == 0 ? "" : "more ")value\(atLeast == 1 ? "" : "s") of \
|
||||
"\(Element.Output.self)"
|
||||
""",
|
||||
at: rest
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Separator == Always<Input, Void>, Terminator == Always<Input, Void> {
|
||||
/// Initializes a parser that attempts to run the given parser at least and at most the given
|
||||
/// number of times, accumulating the outputs into a result with a given closure.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - initialResult: The value to use as the initial accumulating value.
|
||||
/// - minimum: The minimum number of times to run this parser and consider parsing to be
|
||||
/// successful.
|
||||
/// - maximum: The maximum number of times to run this parser before returning the output.
|
||||
/// - updateAccumulatingResult: A closure that updates the accumulating result with each output
|
||||
/// of the element parser.
|
||||
/// - element: A parser to run multiple times to accumulate into a result.
|
||||
@inlinable
|
||||
public init(
|
||||
into initialResult: Result,
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
_ updateAccumulatingResult: @escaping (inout Result, Element.Output) throws -> Void,
|
||||
@ParserBuilder element: () -> Element
|
||||
) {
|
||||
self.element = element()
|
||||
self.initialResult = initialResult
|
||||
self.maximum = maximum
|
||||
self.minimum = minimum
|
||||
self.separator = .init(())
|
||||
self.terminator = .init(())
|
||||
self.updateAccumulatingResult = updateAccumulatingResult
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Separator == Always<Input, Void> {
|
||||
@inlinable
|
||||
public init(
|
||||
into initialResult: Result,
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
_ updateAccumulatingResult: @escaping (inout Result, Element.Output) throws -> Void,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder terminator: () -> Terminator
|
||||
) {
|
||||
self.element = element()
|
||||
self.initialResult = initialResult
|
||||
self.maximum = maximum
|
||||
self.minimum = minimum
|
||||
self.separator = .init(())
|
||||
self.terminator = terminator()
|
||||
self.updateAccumulatingResult = updateAccumulatingResult
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Terminator == Always<Input, Void> {
|
||||
@inlinable
|
||||
public init(
|
||||
into initialResult: Result,
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
_ updateAccumulatingResult: @escaping (inout Result, Element.Output) throws -> Void,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder separator: () -> Separator
|
||||
) {
|
||||
self.element = element()
|
||||
self.initialResult = initialResult
|
||||
self.maximum = maximum
|
||||
self.minimum = minimum
|
||||
self.separator = separator()
|
||||
self.terminator = .init(())
|
||||
self.updateAccumulatingResult = updateAccumulatingResult
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Result == [Element.Output] {
|
||||
/// Initializes a parser that attempts to run the given parser at least and at most the given
|
||||
/// number of times, accumulating the outputs in an array.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - minimum: The minimum number of times to run this parser and consider parsing to be
|
||||
/// successful.
|
||||
/// - maximum: The maximum number of times to run this parser before returning the output.
|
||||
/// - element: A parser to run multiple times to accumulate into an array.
|
||||
/// - separator: A parser that consumes input between each parsed output.
|
||||
@inlinable
|
||||
public init(
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder separator: () -> Separator,
|
||||
@ParserBuilder terminator: () -> Terminator
|
||||
) {
|
||||
self.init(
|
||||
into: [],
|
||||
atLeast: minimum,
|
||||
atMost: maximum,
|
||||
{ $0.append($1) },
|
||||
element: element,
|
||||
separator: separator,
|
||||
terminator: terminator
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Many
|
||||
where
|
||||
Result == [Element.Output],
|
||||
Separator == Always<Input, Void>,
|
||||
Terminator == Always<Input, Void>
|
||||
{
|
||||
/// Initializes a parser that attempts to run the given parser at least and at most the given
|
||||
/// number of times, accumulating the outputs in an array.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - minimum: The minimum number of times to run this parser and consider parsing to be
|
||||
/// successful.
|
||||
/// - maximum: The maximum number of times to run this parser before returning the output.
|
||||
/// - element: A parser to run multiple times to accumulate into an array.
|
||||
@inlinable
|
||||
public init(
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
@ParserBuilder element: () -> Element
|
||||
) {
|
||||
self.init(
|
||||
into: [],
|
||||
atLeast: minimum,
|
||||
atMost: maximum,
|
||||
{ $0.append($1) },
|
||||
element: element
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Result == [Element.Output], Separator == Always<Input, Void> {
|
||||
@inlinable
|
||||
public init(
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder terminator: () -> Terminator
|
||||
) {
|
||||
self.init(
|
||||
into: [],
|
||||
atLeast: minimum,
|
||||
atMost: maximum,
|
||||
{ $0.append($1) },
|
||||
element: element,
|
||||
terminator: terminator
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Many where Result == [Element.Output], Terminator == Always<Input, Void> {
|
||||
@inlinable
|
||||
public init(
|
||||
atLeast minimum: Int = 0,
|
||||
atMost maximum: Int = .max,
|
||||
@ParserBuilder element: () -> Element,
|
||||
@ParserBuilder separator: () -> Separator
|
||||
) {
|
||||
self.init(
|
||||
into: [],
|
||||
atLeast: minimum,
|
||||
atMost: maximum,
|
||||
{ $0.append($1) },
|
||||
element: element,
|
||||
separator: separator
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Many = SwiftTL.Many // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
extension Parser {
|
||||
/// Returns a parser that transforms the output of this parser with a given closure.
|
||||
///
|
||||
/// This method is similar to `Sequence.map`, `Optional.map`, and `Result.map` in the Swift
|
||||
/// standard library, as well as `Publisher.map` in the Combine framework.
|
||||
///
|
||||
/// - Parameter transform: A closure that transforms values of this parser's output.
|
||||
/// - Returns: A parser of transformed outputs.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public func map<NewOutput>(
|
||||
_ transform: @escaping (Output) -> NewOutput
|
||||
) -> Parsers.Map<Self, NewOutput> {
|
||||
.init(upstream: self, transform: transform)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that transforms the output of another parser with a given closure.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/map(_:)`` operation, which constructs this type.
|
||||
public struct Map<Upstream: Parser, NewOutput>: Parser {
|
||||
/// The parser from which this parser receives output.
|
||||
public let upstream: Upstream
|
||||
|
||||
/// The closure that transforms output from the upstream parser.
|
||||
public let transform: (Upstream.Output) -> NewOutput
|
||||
|
||||
@inlinable
|
||||
public init(upstream: Upstream, transform: @escaping (Upstream.Output) -> NewOutput) {
|
||||
self.upstream = upstream
|
||||
self.transform = transform
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public func parse(_ input: inout Upstream.Input) rethrows -> NewOutput {
|
||||
self.transform(try self.upstream.parse(&input))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/// A parser that consumes a single newline from the beginning of the input.
|
||||
///
|
||||
/// - Note: This parser only consumes a line feed (`"\n"`) or a carriage returns with line feed
|
||||
/// (`"\r\n"`). If you need richer support that covers all unicode newline characters, use a
|
||||
/// ``Prefix`` parser that operates on the `Substring` level with a predicate that consumes a
|
||||
/// single newline:
|
||||
///
|
||||
/// ```swift
|
||||
/// Prefix(1) { $0.isNewline }
|
||||
/// ```
|
||||
/// It will consume both line feeds (`"\n"`) and carriage returns with line feeds (`"\r\n"`).
|
||||
public struct Newline<Input: Collection, Bytes: Collection>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Bytes.SubSequence == Bytes,
|
||||
Bytes.Element == UTF8.CodeUnit
|
||||
{
|
||||
@usableFromInline
|
||||
let toBytes: (Input) -> Bytes
|
||||
|
||||
@usableFromInline
|
||||
let fromBytes: (Bytes) -> Input
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws {
|
||||
var bytes = self.toBytes(input)
|
||||
if bytes.first == .init(ascii: "\n") {
|
||||
bytes.removeFirst()
|
||||
} else if bytes.first == .init(ascii: "\r"), bytes.dropFirst().first == .init(ascii: "\n") {
|
||||
bytes.removeFirst(2)
|
||||
} else {
|
||||
throw ParsingError.expectedInput(#""\n" or "\r\n""#, at: input)
|
||||
}
|
||||
input = self.fromBytes(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Swift 5.5.2 on Linux and Windows fails to build with a simpler `Bytes == Input` constraint
|
||||
extension Newline where Bytes == Input.SubSequence, Bytes.SubSequence == Input {
|
||||
@inlinable
|
||||
public init() {
|
||||
self.toBytes = { $0 }
|
||||
self.fromBytes = { $0 }
|
||||
}
|
||||
}
|
||||
|
||||
extension Newline where Input == Substring, Bytes == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {
|
||||
self.toBytes = { $0.utf8 }
|
||||
self.fromBytes = Substring.init
|
||||
}
|
||||
}
|
||||
|
||||
extension Newline where Input == Substring.UTF8View, Bytes == Input {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() { self.init() }
|
||||
}
|
||||
|
||||
extension Newline where Input == ArraySlice<UTF8.CodeUnit>, Bytes == Input {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() { self.init() }
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Newline = SwiftTL.Newline // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/// A parser that succeeds if the given parser fails, and does not consume any input.
|
||||
///
|
||||
/// For example, to parse a line from an input that does not start with "//" one can do:
|
||||
///
|
||||
/// ```swift
|
||||
/// let uncommentedLine = Parse {
|
||||
/// Not { "//" }
|
||||
/// PrefixUpTo("\n")
|
||||
/// }
|
||||
///
|
||||
/// try uncommentedLine.parse("let x = 1") // ✅ "let x = 1"
|
||||
///
|
||||
/// try uncommentedLine.parse("// let x = 1") // ❌
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1-2
|
||||
/// // 1 | // let x = 1
|
||||
/// // | ^^ expected not to be processed
|
||||
/// ```
|
||||
public struct Not<Upstream: Parser>: Parser {
|
||||
public let upstream: Upstream
|
||||
|
||||
/// Creates a parser that succeeds if the given parser fails, and does not consume any input.
|
||||
///
|
||||
/// - Parameter build: A parser that causes this parser to fail if it succeeds, or succeed if it
|
||||
/// fails.
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> Upstream) {
|
||||
self.upstream = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) throws {
|
||||
let original = input
|
||||
do {
|
||||
_ = try self.upstream.parse(&input)
|
||||
} catch {
|
||||
input = original
|
||||
return
|
||||
}
|
||||
throw ParsingError.expectedInput("not to be processed", from: original, to: input)
|
||||
}
|
||||
}
|
||||
166
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/OneOf.swift
Normal file
166
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/OneOf.swift
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/// A parser that attempts to run a number of parsers till one succeeds.
|
||||
///
|
||||
/// Use this parser to list out a number of parsers in a ``OneOfBuilder`` result builder block.
|
||||
///
|
||||
/// The following example uses ``OneOf`` to parse an enum value. To do so, it spells out a list of
|
||||
/// parsers to `OneOf`, one for each case:
|
||||
///
|
||||
/// ```swift
|
||||
/// enum Currency { case eur, gbp, usd }
|
||||
///
|
||||
/// let currency = OneOf {
|
||||
/// "€".map { Currency.eur }
|
||||
/// "£".map { Currency.gbp }
|
||||
/// "$".map { Currency.usd }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails if every parser inside fails:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "London, Hello!"[...]
|
||||
/// try OneOf { "New York"; "Berlin" }.parse(&input)
|
||||
///
|
||||
/// // error: multiple failures occurred
|
||||
/// //
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | London, Hello!
|
||||
/// // | ^ expected "New York"
|
||||
/// // | ^ expected "Berlin"
|
||||
/// ```
|
||||
///
|
||||
/// If you are parsing input that should coalesce into some default, avoid using a final ``Always``
|
||||
/// parser, and instead opt for a trailing ``replaceError(with:)``, which returns a parser that
|
||||
/// cannot fail:
|
||||
///
|
||||
/// ```swift
|
||||
/// enum Currency { case eur, gbp, usd, unknown }
|
||||
///
|
||||
/// let currency = OneOf {
|
||||
/// "€".map { Currency.eur }
|
||||
/// "£".map { Currency.gbp }
|
||||
/// "$".map { Currency.usd }
|
||||
/// }
|
||||
/// .replaceError(with: Currency.unknown)
|
||||
///
|
||||
/// currency.parse("$") // Currency.usd
|
||||
/// currency.parse("฿") // Currency.unknown
|
||||
/// ```
|
||||
///
|
||||
/// ## Specificity
|
||||
///
|
||||
/// The order of the parsers in the above ``OneOf`` does not matter because each of "€", "£" and "$"
|
||||
/// are mutually exclusive, i.e. at most one will succeed on any given input.
|
||||
///
|
||||
/// However, that is not always true, and when the parsers are not mutually exclusive (i.e. multiple
|
||||
/// can succeed on a given input) you must order them from most specific to least specific. That is,
|
||||
/// the first parser should succeed on the fewest number of inputs and the last parser should
|
||||
/// succeed on the most number of inputs.
|
||||
///
|
||||
/// For example, suppose you wanted to parse a simple CSV format into a doubly-nested array of
|
||||
/// strings, and the fields in the CSV are allowed to contain commas themselves as long as they
|
||||
/// are quoted:
|
||||
///
|
||||
/// ```swift
|
||||
/// let input = #"""
|
||||
/// lastName,firstName
|
||||
/// McBlob,Blob
|
||||
/// "McBlob, Esq.",Blob Jr.
|
||||
/// "McBlob, MD",Blob Sr.
|
||||
/// """#
|
||||
/// ```
|
||||
///
|
||||
/// Here we have a list of last and first names separated by a comma, and some of the last names are
|
||||
/// quoted because they contain commas.
|
||||
///
|
||||
/// In order to safely parse this we must first try parsing a field as a quoted field, and then only
|
||||
/// if that fails we can parse a plain field that takes everything up until the next comma or
|
||||
/// newline:
|
||||
///
|
||||
/// ```swift
|
||||
/// let quotedField = Parse {
|
||||
/// "\""
|
||||
/// Prefix { $0 != "\"" }
|
||||
/// "\""
|
||||
/// }
|
||||
/// let plainField = Prefix { $0 != "," && $0 != "\n" }
|
||||
///
|
||||
/// let field = OneOf {
|
||||
/// quotedField
|
||||
/// plainField
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Then we can parse many fields to form an array of fields making up a line, and then parse many
|
||||
/// lines to make up a full, doubly-nested array for the CSV:
|
||||
///
|
||||
/// ```swift
|
||||
/// let line = Many { field } separator: { "," }
|
||||
/// let csv = Many { line } separator: { "\n" }
|
||||
/// ```
|
||||
///
|
||||
/// Running this parser on the input shows that it properly isolates each field of the CSV, even
|
||||
/// fields that are quoted and contain a comma:
|
||||
///
|
||||
/// ```swift
|
||||
/// XCTAssertEqual(
|
||||
/// try csv.parse(input),
|
||||
/// [
|
||||
/// ["lastName", "firstName"],
|
||||
/// ["McBlob", "Blob"],
|
||||
/// ["McBlob, Esq.", "Blob Jr."],
|
||||
/// ["McBlob, MD", "Blob Sr."],
|
||||
/// ]
|
||||
/// )
|
||||
/// // ✅
|
||||
/// ```
|
||||
///
|
||||
/// The reason this parser works is because the `quotedField` and `plainField` parsers are listed in
|
||||
/// a very specific order inside the `OneOf`:
|
||||
///
|
||||
/// ```swift
|
||||
/// let field = OneOf {
|
||||
/// quotedField
|
||||
/// plainField
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// The `quotedField` parser is a _more_ specific parser in that it will succeed on fewer inputs
|
||||
/// than the `plainField` parser does. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// try quotedField.parse("Blob Jr.") // ❌
|
||||
/// try plainField.parse("Blob Jr.") // ✅
|
||||
/// ```
|
||||
///
|
||||
/// Whereas the `plainField` parser will happily succeed on anything the `quotedField` parser will
|
||||
/// succeed on:
|
||||
///
|
||||
/// ```swift
|
||||
/// try quotedField.parse("\"Blob, Esq\"") // ✅
|
||||
/// try plainField.parse("\"Blob, Esq\"") // ✅
|
||||
/// ```
|
||||
///
|
||||
/// For this reason the `quotedField` parser must be listed first so that it can try its logic
|
||||
/// first, which succeeds less frequently, before then trying the `plainField` parser, which
|
||||
/// succeeds more often.
|
||||
///
|
||||
/// ## Backtracking
|
||||
///
|
||||
/// The ``OneOf`` parser is the primary tool for introducing backtracking into your parsers,
|
||||
/// which means to undo the consumption of a parser when it fails. For more information, see the
|
||||
/// article <doc:Backtracking>.
|
||||
public struct OneOf<Parsers>: Parser where Parsers: Parser {
|
||||
public let parsers: Parsers
|
||||
|
||||
@inlinable
|
||||
public init(@OneOfBuilder _ build: () -> Parsers) {
|
||||
self.parsers = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Parsers.Input) rethrows -> Parsers.Output {
|
||||
try self.parsers.parse(&input)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
extension Parsers {
|
||||
/// A parser that attempts to run a number of parsers till one succeeds.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually loop
|
||||
/// over each parser in a builder block:
|
||||
///
|
||||
/// ```swift
|
||||
/// enum Role: String, CaseIterable {
|
||||
/// case admin
|
||||
/// case guest
|
||||
/// case member
|
||||
/// }
|
||||
///
|
||||
/// let roleParser = OneOf {
|
||||
/// for role in Role.allCases {
|
||||
/// status.rawValue.map { role }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
public struct OneOfMany<Parsers: Parser>: Parser {
|
||||
public let parsers: [Parsers]
|
||||
|
||||
@inlinable
|
||||
public init(_ parsers: [Parsers]) {
|
||||
self.parsers = parsers
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public func parse(_ input: inout Parsers.Input) throws -> Parsers.Output {
|
||||
let original = input
|
||||
var count = self.parsers.count
|
||||
var errors: [Error] = []
|
||||
errors.reserveCapacity(count)
|
||||
for parser in self.parsers {
|
||||
do {
|
||||
return try parser.parse(&input)
|
||||
} catch {
|
||||
count -= 1
|
||||
if count > 0 { input = original }
|
||||
errors.append(error)
|
||||
}
|
||||
}
|
||||
throw ParsingError.manyFailed(errors, at: original)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
extension Optional: Parser where Wrapped: Parser {
|
||||
public func parse(_ input: inout Wrapped.Input) rethrows -> Wrapped.Output? {
|
||||
guard let self = self
|
||||
else { return nil }
|
||||
|
||||
return try self.parse(&input)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that attempts to run a given void parser, succeeding with void.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// `if` statements in parser builder blocks:
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// "Hello"
|
||||
/// if useComma {
|
||||
/// ","
|
||||
/// }
|
||||
/// " "
|
||||
/// Rest()
|
||||
/// }
|
||||
/// ```
|
||||
public struct OptionalVoid<Wrapped: Parser>: Parser where Wrapped.Output == Void {
|
||||
let wrapped: Wrapped?
|
||||
|
||||
public init(wrapped: Wrapped?) {
|
||||
self.wrapped = wrapped
|
||||
}
|
||||
|
||||
public func parse(_ input: inout Wrapped.Input) rethrows {
|
||||
guard let wrapped = self.wrapped
|
||||
else { return }
|
||||
|
||||
try wrapped.parse(&input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/// A parser that runs the given parser and succeeds with `nil` if it fails.
|
||||
///
|
||||
/// Use this parser when you are parsing into an output data model that contains `nil`.
|
||||
///
|
||||
/// When the wrapped parser fails ``Optionally`` will backtrack any consumption of the input so
|
||||
/// that later parsers can attempt to parser the input:
|
||||
///
|
||||
/// ```swift
|
||||
/// let parser = Parse {
|
||||
/// "Hello,"
|
||||
/// Optionally { " "; Bool.parser() }
|
||||
/// " world!"
|
||||
/// }
|
||||
///
|
||||
/// try parser.parse("Hello, world!") // nil 1️⃣
|
||||
/// try parser.parse("Hello, true world!") // true
|
||||
/// ```
|
||||
///
|
||||
/// If ``Optionally`` did not backtrack then 1️⃣ would fail because it would consume a space,
|
||||
/// causing the `" world!"` parser to fail since there is no longer any space to consume.
|
||||
/// Read the article <doc:Backtracking> to learn more about how backtracking works.
|
||||
///
|
||||
/// If you are optionally parsing input that should coalesce into some default, you can skip the
|
||||
/// optionality and instead use ``replaceError(with:)`` with a default:
|
||||
///
|
||||
/// ```swift
|
||||
/// Optionally { Int.parser() }
|
||||
/// .map { $0 ?? 0 }
|
||||
///
|
||||
/// // vs.
|
||||
///
|
||||
/// Int.parser()
|
||||
/// .replaceError(with: 0)
|
||||
/// ```
|
||||
public struct Optionally<Wrapped: Parser>: Parser {
|
||||
public let wrapped: Wrapped
|
||||
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> Wrapped) {
|
||||
self.wrapped = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Wrapped.Input) -> Wrapped.Output? {
|
||||
let original = input
|
||||
do {
|
||||
return try self.wrapped.parse(&input)
|
||||
} catch {
|
||||
input = original
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/// A parser that attempts to run a number of parsers to accumulate their outputs.
|
||||
///
|
||||
/// A general entry point into ``ParserBuilder`` syntax, which can be used to build complex parsers
|
||||
/// from simpler ones.
|
||||
///
|
||||
/// ```swift
|
||||
/// let point = Parse {
|
||||
/// "("
|
||||
/// Int.parser()
|
||||
/// ","
|
||||
/// Int.parser()
|
||||
/// ")"
|
||||
/// }
|
||||
///
|
||||
/// try point.parse("(2,-4)") // (2, -4)
|
||||
///
|
||||
/// try point.parse("(42,blob)")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:5
|
||||
/// // 1 | (42,blob)
|
||||
/// // | ^ expected integer
|
||||
/// ```
|
||||
public struct Parse<Parsers: Parser>: Parser {
|
||||
public let parsers: Parsers
|
||||
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> Parsers) {
|
||||
self.parsers = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public init<Upstream, NewOutput>(
|
||||
_ transform: @escaping (Upstream.Output) -> NewOutput,
|
||||
@ParserBuilder with build: () -> Upstream
|
||||
) where Parsers == SwiftTL.Parsers.Map<Upstream, NewOutput> {
|
||||
self.parsers = build().map(transform)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public init<Upstream, NewOutput>(
|
||||
_ output: NewOutput,
|
||||
@ParserBuilder with build: () -> Upstream
|
||||
) where Upstream.Output == Void, Parsers == SwiftTL.Parsers.Map<Upstream, NewOutput> {
|
||||
self.parsers = build().map { output }
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Parsers.Input) rethrows -> Parsers.Output {
|
||||
try self.parsers.parse(&input)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
/// A namespace for types that serve as parsers.
|
||||
///
|
||||
/// The various operators defined as extensions on ``Parser`` implement their functionality as
|
||||
/// classes or structures that extend this enumeration. For example, the ``Parser/map(_:)`` operator
|
||||
/// returns a ``Map`` parser.
|
||||
public enum Parsers {}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/// A parser that runs the given parser, but does not consume any input.
|
||||
///
|
||||
/// It lets the upstream parser "peek" into the input without consuming it.
|
||||
///
|
||||
/// For example, identifiers (variables, functions, etc.) in Swift allow the first character to be a
|
||||
/// letter or underscore, but not a digit, but subsequent characters can be digits. _E.g._, `foo123`
|
||||
/// is a valid identifier, but `123foo` is not. We can create an identifier parser by using `Peek`
|
||||
/// to first check if the input starts with a letter or underscore, and if it does, return the
|
||||
/// remainder of the input up to the first character that is not a letter, a digit, or an
|
||||
/// underscore.
|
||||
///
|
||||
/// ```swift
|
||||
/// let identifier = Parse {
|
||||
/// Peek { Prefix(1) { $0.isLetter || $0 == "_" } }
|
||||
/// Prefix { $0.isNumber || $0.isLetter || $0 == "_" }
|
||||
/// }
|
||||
///
|
||||
/// try identifier.parse("foo123") // ✅ "foo123"
|
||||
/// try identifier.parse("_foo123") // ✅ "_foo123"
|
||||
/// try identifier.parse("1_foo123") // ❌
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | 1_foo123
|
||||
/// // | ^ expected 1 element satisfying predicate
|
||||
/// ```
|
||||
public struct Peek<Upstream: Parser>: Parser {
|
||||
public let upstream: Upstream
|
||||
|
||||
/// Construct a parser that runs the given parser, but does not consume any input.
|
||||
///
|
||||
/// - Parameter build: A parser this parser wants to inspect.
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> Upstream) {
|
||||
self.upstream = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) rethrows {
|
||||
let original = input
|
||||
_ = try self.upstream.parse(&input)
|
||||
input = original
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
extension Parser {
|
||||
/// Returns a parser that runs this parser, pipes its output into the given parser, and returns
|
||||
/// the output of the given parser.
|
||||
///
|
||||
/// For example, we can try to parse an integer of exactly 4 digits by piping the output of
|
||||
/// ``Prefix`` into an `Int.parser()`:
|
||||
///
|
||||
/// ```swift
|
||||
/// let year = Prefix(4).pipe { Int.parser() }
|
||||
///
|
||||
/// try year.parse("2022") // 2022
|
||||
/// try year.parse("0123") // 123
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails if either the upstream or downstream parser fails. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// try year.parse("123")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:4
|
||||
/// // 1 | 123
|
||||
/// // | ^ expected 1 more element
|
||||
///
|
||||
/// try year.parse("fail!")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1-4
|
||||
/// // 1 | fail!
|
||||
/// // | ^^^^ pipe: expected integer
|
||||
/// ```
|
||||
///
|
||||
/// - Parameter downstream: A parser that parses the output of this parser.
|
||||
/// - Returns: A parser that pipes this parser's output into another parser. @inlinable
|
||||
public func pipe<Downstream>(
|
||||
@ParserBuilder _ build: () -> Downstream
|
||||
) -> Parsers.Pipe<Self, Downstream> {
|
||||
.init(upstream: self, downstream: build())
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that runs this parser, pipes its output into the given parser, and returns the output
|
||||
/// of the given parser.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/pipe(_:)`` operation, which constructs this type.
|
||||
public struct Pipe<Upstream: Parser, Downstream: Parser>: Parser
|
||||
where Upstream.Output == Downstream.Input {
|
||||
public let upstream: Upstream
|
||||
public let downstream: Downstream
|
||||
|
||||
@inlinable
|
||||
public init(upstream: Upstream, downstream: Downstream) {
|
||||
self.upstream = upstream
|
||||
self.downstream = downstream
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) rethrows -> Downstream.Output {
|
||||
let original = input
|
||||
var downstreamInput = try self.upstream.parse(&input)
|
||||
do {
|
||||
return try self.downstream.parse(&downstreamInput)
|
||||
} catch let ParsingError.failed(reason, context) {
|
||||
throw ParsingError.failed(
|
||||
"pipe: \(reason)",
|
||||
.init(
|
||||
originalInput: original,
|
||||
remainingInput: input,
|
||||
debugDescription: context.debugDescription,
|
||||
underlyingError: ParsingError.failed(reason, context)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
286
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Prefix.swift
Normal file
286
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/Prefix.swift
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
/// A parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// This parser is named after `Sequence.prefix`, which it uses under the hood to consume a number
|
||||
/// of elements and return them as output. It can be configured with minimum and maximum lengths,
|
||||
/// as well as a predicate.
|
||||
///
|
||||
/// For example, to parse as many numbers off the beginning of a substring:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "123 hello world"[...]
|
||||
/// try Prefix { $0.isNumber }.parse(&input) // "123"
|
||||
/// input // " Hello world"
|
||||
/// ```
|
||||
///
|
||||
/// If you wanted this parser to fail if _no_ numbers are consumed, you could introduce a minimum
|
||||
/// length.
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "No numbers here"[...]
|
||||
/// try Prefix(1...) { $0.isNumber }.parse(&input)
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | No numbers here
|
||||
/// // | ^ expected 1 element satisfying predicate
|
||||
/// ```
|
||||
///
|
||||
/// If a predicate is not provided, the parser will simply consume the prefix within the minimum and
|
||||
/// maximum lengths provided:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Lorem ipsum dolor"[...]
|
||||
/// try Prefix(2).parse(&input) // "Lo"
|
||||
/// input // "rem ipsum dolor"
|
||||
/// ```
|
||||
public struct Prefix<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
public let maxLength: Int?
|
||||
public let minLength: Int
|
||||
public let predicate: ((Input.Element) -> Bool)?
|
||||
|
||||
/// Initializes a parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - minLength: The minimum number of elements to consume for parsing to be considered
|
||||
/// successful.
|
||||
/// - maxLength: The maximum number of elements to consume before the parser will return its
|
||||
/// output.
|
||||
/// - predicate: A closure that takes an element of the input sequence as its argument and
|
||||
/// returns `true` if the element should be included or `false` if it should be excluded. Once
|
||||
/// the predicate returns `false` it will not be called again.
|
||||
@inlinable
|
||||
public init(
|
||||
minLength: Int = 0,
|
||||
maxLength: Int? = nil,
|
||||
while predicate: @escaping (Input.Element) -> Bool
|
||||
) {
|
||||
self.minLength = minLength
|
||||
self.maxLength = maxLength
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
/// Initializes a parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// ```swift
|
||||
/// try Prefix(2...4, while: \.isNumber).parse("123456") // "1234"
|
||||
/// try Prefix(2...4, while: \.isNumber).parse("123") // "123"
|
||||
///
|
||||
/// try Prefix(2...4, while: \.isNumber).parse("1")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | 1
|
||||
/// // | ^ expected 1 more element satisfying predicate
|
||||
/// ```
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - length: A closed range that provides a minimum number and maximum of elements to consume
|
||||
/// for parsing to be considered successful.
|
||||
/// - predicate: An optional closure that takes an element of the input sequence as its argument
|
||||
/// and returns `true` if the element should be included or `false` if it should be excluded.
|
||||
/// Once the predicate returns `false` it will not be called again.
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: ClosedRange<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.minLength = length.lowerBound
|
||||
self.maxLength = length.upperBound
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
/// Initializes a parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// ```swift
|
||||
/// try Prefix(4, while: \.isNumber).parse("123456") // "1234"
|
||||
///
|
||||
/// try Prefix(4, while: \.isNumber).parse("123")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | 123
|
||||
/// // | ^ expected 1 more element satisfying predicate
|
||||
/// ```
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - length: An exact number of elements to consume for parsing to be considered successful.
|
||||
/// - predicate: An optional closure that takes an element of the input sequence as its argument
|
||||
/// and returns `true` if the element should be included or `false` if it should be excluded.
|
||||
/// Once the predicate returns `false` it will not be called again.
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: Int,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.minLength = length
|
||||
self.maxLength = length
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
/// Initializes a parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// ``` swift
|
||||
/// try Prefix(4..., while: \.isNumber).parse("123456") // "123456"
|
||||
///
|
||||
/// try Prefix(4..., while: \.isNumber).parse("123")
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | 123
|
||||
/// // | ^ expected 1 more element satisfying predicate
|
||||
/// ```
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - length: A partial range that provides a minimum number of elements to consume for
|
||||
/// parsing to be considered successful.
|
||||
/// - predicate: An optional closure that takes an element of the input sequence as its argument
|
||||
/// and returns `true` if the element should be included or `false` if it should be excluded.
|
||||
/// Once the predicate returns `false` it will not be called again.
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeFrom<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.minLength = length.lowerBound
|
||||
self.maxLength = nil
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
/// Initializes a parser that consumes a subsequence from the beginning of its input.
|
||||
///
|
||||
/// ```swift
|
||||
/// try Prefix(...4, while: \.isNumber).parse("123456") // "1234"
|
||||
/// try Prefix(...4, while: \.isNumber).parse("123") // "123"
|
||||
/// ```
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - length: A partial, inclusive range that provides a maximum number of elements to consume.
|
||||
/// - predicate: An optional closure that takes an element of the input sequence as its argument
|
||||
/// and returns `true` if the element should be included or `false` if it should be excluded.
|
||||
/// Once the predicate returns `false` it will not be called again.
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeThrough<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.minLength = 0
|
||||
self.maxLength = length.upperBound
|
||||
self.predicate = predicate
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public func parse(_ input: inout Input) throws -> Input {
|
||||
var prefix = maxLength.map(input.prefix) ?? input
|
||||
prefix = predicate.map { prefix.prefix(while: $0) } ?? prefix
|
||||
let count = prefix.count
|
||||
input.removeFirst(count)
|
||||
guard count >= self.minLength else {
|
||||
let atLeast = self.minLength - count
|
||||
throw ParsingError.expectedInput(
|
||||
"""
|
||||
\(self.minLength - count) \(count == 0 ? "" : "more ")element\(atLeast == 1 ? "" : "s")\
|
||||
\(predicate == nil ? "" : " satisfying predicate")
|
||||
""",
|
||||
at: input
|
||||
)
|
||||
}
|
||||
return prefix
|
||||
}
|
||||
}
|
||||
|
||||
extension Prefix where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
minLength: Int = 0,
|
||||
maxLength: Int? = nil,
|
||||
while predicate: @escaping (Input.Element) -> Bool
|
||||
) {
|
||||
self.init(minLength: minLength, maxLength: maxLength, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: ClosedRange<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: Int,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeFrom<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeThrough<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
}
|
||||
|
||||
extension Prefix where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
minLength: Int = 0,
|
||||
maxLength: Int? = nil,
|
||||
while predicate: @escaping (Input.Element) -> Bool
|
||||
) {
|
||||
self.init(minLength: minLength, maxLength: maxLength, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: ClosedRange<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: Int,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeFrom<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(
|
||||
_ length: PartialRangeThrough<Int>,
|
||||
while predicate: ((Input.Element) -> Bool)? = nil
|
||||
) {
|
||||
self.init(length, while: predicate)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Prefix = SwiftTL.Prefix // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/// A parser that consumes a subsequence from the beginning of its input through a given sequence of
|
||||
/// elements.
|
||||
///
|
||||
/// This parser is named after `Sequence.prefix(through:)`, and uses similar logic under the hood to
|
||||
/// consume and return input through a particular subsequence.
|
||||
///
|
||||
/// ```swift
|
||||
/// let lineParser = PrefixThrough("\n")
|
||||
///
|
||||
/// var input = "Hello\nworld\n"[...]
|
||||
/// try line.parse(&input) // "Hello\n"
|
||||
/// input // "world\n"
|
||||
/// ```
|
||||
public struct PrefixThrough<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
public let possibleMatch: Input
|
||||
public let areEquivalent: (Input.Element, Input.Element) -> Bool
|
||||
|
||||
@inlinable
|
||||
public init(
|
||||
_ possibleMatch: Input,
|
||||
by areEquivalent: @escaping (Input.Element, Input.Element) -> Bool
|
||||
) {
|
||||
self.possibleMatch = possibleMatch
|
||||
self.areEquivalent = areEquivalent
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public func parse(_ input: inout Input) throws -> Input {
|
||||
guard let first = self.possibleMatch.first else { return self.possibleMatch }
|
||||
let count = self.possibleMatch.count
|
||||
let original = input
|
||||
while let index = input.firstIndex(where: { self.areEquivalent(first, $0) }) {
|
||||
input = input[index...]
|
||||
if input.count >= count,
|
||||
zip(input[index...], self.possibleMatch).allSatisfy(self.areEquivalent)
|
||||
{
|
||||
let index = input.index(index, offsetBy: count)
|
||||
input = input[index...]
|
||||
return original[..<index]
|
||||
}
|
||||
input.removeFirst()
|
||||
}
|
||||
throw ParsingError.expectedInput("prefix through \(formatValue(self.possibleMatch))", at: input)
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixThrough where Input.Element: Equatable {
|
||||
@inlinable
|
||||
public init(_ possibleMatch: Input) {
|
||||
self.init(possibleMatch, by: ==)
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixThrough where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(_ possibleMatch: String) {
|
||||
self.init(possibleMatch[...])
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixThrough where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(_ possibleMatch: String.UTF8View) {
|
||||
self.init(String(possibleMatch)[...].utf8)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias PrefixThrough = SwiftTL.PrefixThrough // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/// A parser that consumes a subsequence from the beginning of its input up to a given sequence of
|
||||
/// elements.
|
||||
///
|
||||
/// This parser is named after `Sequence.prefix(upTo:)`, and uses similar logic under the hood to
|
||||
/// consume and return input up to a particular subsequence.
|
||||
///
|
||||
/// ```swift
|
||||
/// let lineParser = PrefixUpTo("\n")
|
||||
///
|
||||
/// var input = "Hello\nworld\n"[...]
|
||||
/// try line.parse(&input) // "Hello"
|
||||
/// input // "\nworld\n"
|
||||
/// ```
|
||||
public struct PrefixUpTo<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
public let possibleMatch: Input
|
||||
public let areEquivalent: (Input.Element, Input.Element) -> Bool
|
||||
|
||||
@inlinable
|
||||
public init(
|
||||
_ possibleMatch: Input,
|
||||
by areEquivalent: @escaping (Input.Element, Input.Element) -> Bool
|
||||
) {
|
||||
self.possibleMatch = possibleMatch
|
||||
self.areEquivalent = areEquivalent
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public func parse(_ input: inout Input) throws -> Input {
|
||||
guard let first = self.possibleMatch.first else { return self.possibleMatch }
|
||||
let count = self.possibleMatch.count
|
||||
let original = input
|
||||
while let index = input.firstIndex(where: { self.areEquivalent(first, $0) }) {
|
||||
input = input[index...]
|
||||
if input.count >= count,
|
||||
zip(input[index...], self.possibleMatch).allSatisfy(self.areEquivalent)
|
||||
{
|
||||
return original[..<index]
|
||||
}
|
||||
input.removeFirst()
|
||||
}
|
||||
throw ParsingError.expectedInput("prefix up to \(formatValue(self.possibleMatch))", at: input)
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixUpTo where Input.Element: Equatable {
|
||||
@inlinable
|
||||
public init(_ possibleMatch: Input) {
|
||||
self.init(possibleMatch, by: ==)
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixUpTo where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(_ possiblePrefix: String) {
|
||||
self.init(possiblePrefix[...])
|
||||
}
|
||||
}
|
||||
|
||||
extension PrefixUpTo where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init(_ possibleMatch: String.UTF8View) {
|
||||
self.init(String(possibleMatch)[...].utf8)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias PrefixUpTo = SwiftTL.PrefixUpTo // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
extension Parser {
|
||||
/// Transforms the `Input` of a parser.
|
||||
///
|
||||
/// This operator allows you to transform a parser of `Input`s into one on `NewInput`s, via a
|
||||
/// writable key path from `NewInput` to `Input`. Intuitively you can think of this as a way of
|
||||
/// transforming a parser on local data into one on more global data.
|
||||
///
|
||||
/// For example, the parser `Int.parser()` parses `Substring.UTF8View` collections into integers,
|
||||
/// and there's a key path from `Substring.UTF8View` to `Substring`, and so we can `pullback`:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "123 Hello world"[...]
|
||||
/// let output = try Int.parser().pullback(\.utf8).parse(&input) // 123
|
||||
/// input // " Hello world"
|
||||
/// ```
|
||||
///
|
||||
/// This has allowed us to parse `Substring`s with something that is only defined on
|
||||
/// `Substring.UTF8View`.
|
||||
///
|
||||
/// - Parameter keyPath: A key path to pull parsing back along from this parser's input to a new
|
||||
/// input.
|
||||
/// - Returns: A parser that parses new input.
|
||||
@inlinable
|
||||
public func pullback<NewInput>(
|
||||
_ keyPath: WritableKeyPath<NewInput, Input>
|
||||
) -> Parsers.Pullback<Self, NewInput> {
|
||||
.init(downstream: self, keyPath: keyPath)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// Transforms the `Input` of a downstream parser.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/pullback(_:)`` operator, which constructs this type.
|
||||
public struct Pullback<Downstream: Parser, Input>: Parser {
|
||||
public let downstream: Downstream
|
||||
public let keyPath: WritableKeyPath<Input, Downstream.Input>
|
||||
|
||||
@inlinable
|
||||
public init(downstream: Downstream, keyPath: WritableKeyPath<Input, Downstream.Input>) {
|
||||
self.downstream = downstream
|
||||
self.keyPath = keyPath
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) rethrows -> Downstream.Output {
|
||||
try self.downstream.parse(&input[keyPath: self.keyPath])
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func pullback<NewInput>(
|
||||
_ keyPath: WritableKeyPath<NewInput, Input>
|
||||
) -> Pullback<Downstream, NewInput> {
|
||||
.init(downstream: self.downstream, keyPath: keyPath.appending(path: self.keyPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
extension Parser {
|
||||
/// A parser that replaces its error with a provided output.
|
||||
///
|
||||
/// Useful for providing a default output for a parser.
|
||||
///
|
||||
/// For example, we could create a parser that parses a plus or minus sign and maps the result to
|
||||
/// a positive or negative multiplier respectively, or else defaults to a positive multiplier:
|
||||
///
|
||||
/// ```swift
|
||||
/// let sign = OneOf {
|
||||
/// "+".map { 1 }
|
||||
/// "-".map { -1 }
|
||||
/// }
|
||||
/// .replaceError(with: 1)
|
||||
/// ```
|
||||
///
|
||||
/// Notably this parser is non-throwing:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "-123"[...]
|
||||
///
|
||||
/// // No `try` required:
|
||||
/// sign.parse(&input) // -1
|
||||
/// input // "123"
|
||||
///
|
||||
/// // Simply returns the default when parsing fails:
|
||||
/// sign.parse(&input) // 1
|
||||
/// ```
|
||||
///
|
||||
/// This means it can be used to turn throwing parsers into non-throwing ones, which is important
|
||||
/// for building up complex parsers that cannot fail.
|
||||
///
|
||||
/// - Parameter output: An output to return should the upstream parser fail.
|
||||
/// - Returns: A parser that never fails.
|
||||
@inlinable
|
||||
public func replaceError(with output: Output) -> Parsers.ReplaceError<Self> {
|
||||
.init(output: output, upstream: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that replaces its error with a provided output.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// the ``Parser/replaceError(with:)`` operation, which constructs this type.
|
||||
public struct ReplaceError<Upstream: Parser>: Parser {
|
||||
@usableFromInline
|
||||
let output: Upstream.Output
|
||||
|
||||
@usableFromInline
|
||||
let upstream: Upstream
|
||||
|
||||
@usableFromInline
|
||||
init(output: Upstream.Output, upstream: Upstream) {
|
||||
self.output = output
|
||||
self.upstream = upstream
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Upstream.Input) -> Upstream.Output {
|
||||
let original = input
|
||||
do {
|
||||
return try self.upstream.parse(&input)
|
||||
} catch {
|
||||
input = original
|
||||
return self.output
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/// A parser that consumes everything to the end of the collection and returns this subsequence as
|
||||
/// its output.
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Hello"[...]
|
||||
/// Rest().parse(&input) // "Hello"
|
||||
/// input // ""
|
||||
/// ```
|
||||
///
|
||||
/// This parser fails if there is no input to consume:
|
||||
///
|
||||
/// ```swift
|
||||
/// try Rest().parse("")
|
||||
///
|
||||
/// /// error: unexpected input
|
||||
/// /// --> input:1:1
|
||||
/// /// 1 |
|
||||
/// /// | ^ expected a non-empty input
|
||||
/// ```
|
||||
///
|
||||
/// If you want to allow for the possibility of an empty remaining input you can use the
|
||||
/// ``Optionally`` parser to parse an optional output value, or the ``replaceError(with:)`` method
|
||||
/// to coalesce the error into a default output value.
|
||||
public struct Rest<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> Input {
|
||||
guard !input.isEmpty
|
||||
else { throw ParsingError.expectedInput("a non-empty input", at: input) }
|
||||
let output = input
|
||||
input.removeFirst(input.count)
|
||||
return output
|
||||
}
|
||||
}
|
||||
|
||||
extension Rest where Input == Substring {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}
|
||||
|
||||
extension Rest where Input == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Rest = SwiftTL.Rest // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/// A parser that discards the output of another parser.
|
||||
public struct Skip<Parsers: Parser>: Parser {
|
||||
/// The parser from which this parser receives output.
|
||||
public let parsers: Parsers
|
||||
|
||||
@inlinable
|
||||
public init(@ParserBuilder _ build: () -> Parsers) {
|
||||
self.parsers = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Parsers.Input) rethrows {
|
||||
_ = try self.parsers.parse(&input)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Skip = SwiftTL.Skip // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/// A parser that parses a sequence of elements from its input.
|
||||
///
|
||||
/// This parser is named after `Sequence.starts(with:)`, and tests that the input it is parsing
|
||||
/// starts with a given subsequence by calling this method under the hood.
|
||||
///
|
||||
/// If `true`, it consumes this prefix and returns `Void`:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Hello, Blob!"[...]
|
||||
///
|
||||
/// StartsWith("Hello, ").parse(&input) // ()
|
||||
/// input // "Blob!"
|
||||
/// ```
|
||||
///
|
||||
/// If `false`, it fails and leaves input intact:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Goodnight, Blob!"[...]
|
||||
/// try StartsWith("Hello, ").parse(&input)
|
||||
/// // error: unexpected input
|
||||
/// // --> input:1:1
|
||||
/// // 1 | Goodnight, Blob!
|
||||
/// // | ^ expected "Hello, "
|
||||
/// ```
|
||||
///
|
||||
/// This parser returns `Void` and _not_ the sequence of elements it consumes because the sequence
|
||||
/// is already known at the time the parser is created (it is the value quite literally passed to
|
||||
/// ``StartsWith/init(_:)``).
|
||||
///
|
||||
/// In many circumstances you can omit the `StartsWith` parser entirely and just use the collection
|
||||
/// as the parser. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "Hello, Blob!"[...]
|
||||
///
|
||||
/// try "Hello, ".parse(&input) // ()
|
||||
/// input // "Blob!"
|
||||
/// ```
|
||||
public struct StartsWith<Input: Collection>: Parser where Input.SubSequence == Input {
|
||||
public let count: Int
|
||||
public let possiblePrefix: AnyCollection<Input.Element>
|
||||
public let startsWith: (Input) -> Bool
|
||||
|
||||
/// Initializes a parser that successfully returns `Void` when the initial elements of its input
|
||||
/// are equivalent to the elements in another sequence, using the given predicate as the
|
||||
/// equivalence test.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - possiblePrefix: A sequence to compare to the start of an input sequence.
|
||||
/// - areEquivalent: A predicate that returns `true` if its two arguments are equivalent;
|
||||
/// otherwise, `false`.
|
||||
@inlinable
|
||||
public init<PossiblePrefix>(
|
||||
_ possiblePrefix: PossiblePrefix,
|
||||
by areEquivalent: @escaping (Input.Element, Input.Element) -> Bool
|
||||
)
|
||||
where
|
||||
PossiblePrefix: Collection,
|
||||
PossiblePrefix.Element == Input.Element
|
||||
{
|
||||
self.count = possiblePrefix.count
|
||||
self.possiblePrefix = AnyCollection(possiblePrefix)
|
||||
self.startsWith = { input in input.starts(with: possiblePrefix, by: areEquivalent) }
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws {
|
||||
guard self.startsWith(input) else {
|
||||
throw ParsingError.expectedInput(formatValue(self.possiblePrefix), at: input)
|
||||
}
|
||||
input.removeFirst(self.count)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers.StartsWith where Input.Element: Equatable {
|
||||
/// Initializes a parser that successfully returns `Void` when the initial elements of its input
|
||||
/// are equivalent to the elements in another sequence.
|
||||
///
|
||||
/// - Parameter possiblePrefix: A sequence to compare to the start of an input sequence.
|
||||
@inlinable
|
||||
public init<PossiblePrefix>(_ possiblePrefix: PossiblePrefix)
|
||||
where
|
||||
PossiblePrefix: Collection,
|
||||
PossiblePrefix.Element == Input.Element
|
||||
{
|
||||
self.init(possiblePrefix, by: ==)
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias StartsWith = SwiftTL.StartsWith // NB: Convenience type alias for discovery
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/// A parser that can parse streams of input.
|
||||
///
|
||||
/// For example, the following parser can parse an integer followed by a newline from a collection
|
||||
/// of UTF8 bytes:
|
||||
///
|
||||
/// ```swift
|
||||
/// Parse {
|
||||
/// Int.parser(of: ArraySlice<UInt8>.self)
|
||||
/// StartsWith("\n".utf8)
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This parser can be transformed into one that processes an incoming stream of UTF8 bytes:
|
||||
///
|
||||
/// ```swift
|
||||
/// Stream {
|
||||
/// Parse {
|
||||
/// Int.parser(of: ArraySlice<UInt8>.self)
|
||||
/// StartsWith("\n".utf8)
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// And then it can be used on a stream, such as values coming from standard in:
|
||||
///
|
||||
/// ```swift
|
||||
/// var stdin = AnyIterator {
|
||||
/// readLine().map { ArraySlice($0.utf8) }
|
||||
/// }
|
||||
///
|
||||
/// try newlineSeparatedIntegers.parse(&stdin)
|
||||
/// ```
|
||||
public struct Stream<Parsers: Parser>: Parser where Parsers.Input: RangeReplaceableCollection {
|
||||
public let parsers: Parsers
|
||||
|
||||
@inlinable
|
||||
public init(@ParserBuilder build: () -> Parsers) {
|
||||
self.parsers = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout AnyIterator<Parsers.Input>) rethrows -> [Parsers.Output] {
|
||||
var buffer = Parsers.Input()
|
||||
var outputs: Output = []
|
||||
while let chunk = input.next() {
|
||||
buffer.append(contentsOf: chunk)
|
||||
outputs.append(try self.parsers.parse(&buffer))
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
public typealias Stream = SwiftTL.Stream // NB: Convenience type alias for discovery
|
||||
}
|
||||
137
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/UUID.swift
Normal file
137
build-system/SwiftTL/Sources/SwiftTL/Parser/Parsers/UUID.swift
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
import Foundation
|
||||
|
||||
extension UUID {
|
||||
/// A parser that consumes a hexadecimal UUID from the beginning of a collection of UTF-8 code
|
||||
/// units.
|
||||
///
|
||||
/// ```swift
|
||||
/// var input = "deadbeef-dead-beef-dead-beefdeadbeef,"[...]
|
||||
/// try UUID.parser().parse(&input) // DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF
|
||||
/// input // ","
|
||||
/// ```
|
||||
///
|
||||
/// - Parameter inputType: The collection type of UTF-8 code units to parse.
|
||||
/// - Returns: A parser that consumes a hexadecimal UUID from the beginning of a collection of
|
||||
/// UTF-8 code units.
|
||||
@inlinable
|
||||
public static func parser<Input>(
|
||||
of inputType: Input.Type = Input.self
|
||||
) -> Parsers.UUIDParser<Input> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a hexadecimal UUID from the beginning of a substring's UTF-8 view.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is
|
||||
/// `Substring.UTF8View`.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a hexadecimal UUID from the beginning of a substring's UTF-8
|
||||
/// view.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.UTF8View.Type = Substring.UTF8View.self
|
||||
) -> Parsers.UUIDParser<Substring.UTF8View> {
|
||||
.init()
|
||||
}
|
||||
|
||||
/// A parser that consumes a hexadecimal UUID from the beginning of a substring.
|
||||
///
|
||||
/// This overload is provided to allow the `Input` generic to be inferred when it is `Substring`.
|
||||
///
|
||||
/// - Parameter inputType: The `Substring` type. This parameter is included to mirror the
|
||||
/// interface that parses any collection of UTF-8 code units.
|
||||
/// - Returns: A parser that consumes a hexadecimal UUID from the beginning of a substring.
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public static func parser(
|
||||
of inputType: Substring.Type = Substring.self
|
||||
) -> FromUTF8View<Substring, Parsers.UUIDParser<Substring.UTF8View>> {
|
||||
.init { Parsers.UUIDParser<Substring.UTF8View>() }
|
||||
}
|
||||
}
|
||||
|
||||
extension Parsers {
|
||||
/// A parser that consumes a UUID from the beginning of a collection of UTF8 code units.
|
||||
///
|
||||
/// You will not typically need to interact with this type directly. Instead you will usually use
|
||||
/// `UUID.parser()`, which constructs this type.
|
||||
public struct UUIDParser<Input: Collection>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Input.Element == UTF8.CodeUnit
|
||||
{
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) throws -> UUID {
|
||||
func parseHelp<C>(_ bytes: C) throws -> UUID where C: Collection, C.Element == UTF8.CodeUnit {
|
||||
var prefix = bytes.prefix(36)
|
||||
guard prefix.count == 36
|
||||
else { throw ParsingError.expectedInput("UUID", at: input) }
|
||||
|
||||
@inline(__always)
|
||||
func digit(for n: UTF8.CodeUnit) throws -> UTF8.CodeUnit {
|
||||
switch n {
|
||||
case .init(ascii: "0") ... .init(ascii: "9"):
|
||||
return UTF8.CodeUnit(n - .init(ascii: "0"))
|
||||
case .init(ascii: "A") ... .init(ascii: "F"):
|
||||
return UTF8.CodeUnit(n - .init(ascii: "A") + 10)
|
||||
case .init(ascii: "a") ... .init(ascii: "f"):
|
||||
return UTF8.CodeUnit(n - .init(ascii: "a") + 10)
|
||||
default:
|
||||
throw ParsingError.expectedInput("UUID", at: input)
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
func nextByte() throws -> UInt8 {
|
||||
try digit(for: prefix.removeFirst()) * 16 + digit(for: prefix.removeFirst())
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
func chompHyphen() throws {
|
||||
guard prefix.removeFirst() == .init(ascii: "-")
|
||||
else { throw ParsingError.expectedInput("UUID", at: input) }
|
||||
}
|
||||
|
||||
let _00 = try nextByte()
|
||||
let _01 = try nextByte()
|
||||
let _02 = try nextByte()
|
||||
let _03 = try nextByte()
|
||||
try chompHyphen()
|
||||
let _04 = try nextByte()
|
||||
let _05 = try nextByte()
|
||||
try chompHyphen()
|
||||
let _06 = try nextByte()
|
||||
let _07 = try nextByte()
|
||||
try chompHyphen()
|
||||
let _08 = try nextByte()
|
||||
let _09 = try nextByte()
|
||||
try chompHyphen()
|
||||
let _10 = try nextByte()
|
||||
let _11 = try nextByte()
|
||||
let _12 = try nextByte()
|
||||
let _13 = try nextByte()
|
||||
let _14 = try nextByte()
|
||||
let _15 = try nextByte()
|
||||
|
||||
input.removeFirst(36)
|
||||
return UUID(
|
||||
uuid: (
|
||||
_00, _01, _02, _03,
|
||||
_04, _05,
|
||||
_06, _07,
|
||||
_08, _09,
|
||||
_10, _11, _12, _13, _14, _15
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return try input.withContiguousStorageIfAvailable(parseHelp) ?? parseHelp(input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/// A parser that consumes all ASCII whitespace from the beginning of the input.
|
||||
///
|
||||
/// - Note: This parser only consumes ASCII spaces (`" "`), newlines (`"\n"` and `"\r"`), and tabs
|
||||
/// (`"\t"`). If you need richer support that covers all unicode whitespace, use a ``Prefix``
|
||||
/// parser that operates on the `Substring` level with a predicate that consumes whitespace:
|
||||
///
|
||||
/// ```swift
|
||||
/// Prefix { $0.isWhitespace }
|
||||
/// ```
|
||||
public struct Whitespace<Input: Collection, Bytes: Collection>: Parser
|
||||
where
|
||||
Input.SubSequence == Input,
|
||||
Bytes.SubSequence == Bytes,
|
||||
Bytes.Element == UTF8.CodeUnit
|
||||
{
|
||||
@usableFromInline
|
||||
let toBytes: (Input) -> Bytes
|
||||
|
||||
@usableFromInline
|
||||
let fromBytes: (Bytes) -> Input
|
||||
|
||||
@inlinable
|
||||
public func parse(_ input: inout Input) -> Input {
|
||||
let output = self.toBytes(input).prefix(while: { (byte: UTF8.CodeUnit) in
|
||||
byte == .init(ascii: " ")
|
||||
|| byte == .init(ascii: "\n")
|
||||
|| byte == .init(ascii: "\r")
|
||||
|| byte == .init(ascii: "\t")
|
||||
})
|
||||
input.removeFirst(output.count)
|
||||
return self.fromBytes(output)
|
||||
}
|
||||
}
|
||||
|
||||
extension Whitespace {
|
||||
@inlinable
|
||||
public init() where Bytes == Input {
|
||||
self.toBytes = { $0 }
|
||||
self.fromBytes = { $0 }
|
||||
}
|
||||
}
|
||||
|
||||
extension Whitespace where Input == Substring, Bytes == Substring.UTF8View {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() {
|
||||
self.toBytes = { $0.utf8 }
|
||||
self.fromBytes = Substring.init
|
||||
}
|
||||
}
|
||||
|
||||
/*extension Whitespace where Input == Substring.UTF8View, Bytes == Input {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() { self.init() }
|
||||
}
|
||||
|
||||
extension Whitespace where Input == ArraySlice<UTF8.CodeUnit>, Bytes == Input {
|
||||
@_disfavoredOverload
|
||||
@inlinable
|
||||
public init() { self.init() }
|
||||
}*/
|
||||
|
||||
extension Parsers {
|
||||
public typealias Whitespace = SwiftTL.Whitespace // NB: Convenience type alias for discovery
|
||||
}
|
||||
486
build-system/SwiftTL/Sources/SwiftTL/Parser/ParsingError.swift
Normal file
486
build-system/SwiftTL/Sources/SwiftTL/Parser/ParsingError.swift
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
import Foundation
|
||||
|
||||
@usableFromInline
|
||||
enum ParsingError: Error {
|
||||
case failed(String, Context)
|
||||
case manyFailed([Error], Context)
|
||||
|
||||
@usableFromInline
|
||||
static func expectedInput(_ description: String, at remainingInput: Any) -> Self {
|
||||
.failed(
|
||||
summary: "unexpected input",
|
||||
label: "expected \(description)",
|
||||
at: remainingInput
|
||||
)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
static func expectedInput(
|
||||
_ description: String,
|
||||
from originalInput: Any,
|
||||
to remainingInput: Any
|
||||
) -> Self {
|
||||
.failed(
|
||||
summary: "unexpected input",
|
||||
label: "expected \(description)",
|
||||
from: originalInput,
|
||||
to: remainingInput
|
||||
)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
static func failed(summary: String, label: String = "", at remainingInput: Any) -> Self {
|
||||
.failed(label, .init(remainingInput: remainingInput, debugDescription: summary))
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
static func failed(
|
||||
summary: String, label: String = "", from originalInput: Any, to remainingInput: Any
|
||||
) -> Self {
|
||||
.failed(
|
||||
label,
|
||||
.init(
|
||||
originalInput: originalInput,
|
||||
remainingInput: remainingInput,
|
||||
debugDescription: summary
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
static func manyFailed(_ errors: [Error], at remainingInput: Any) -> Self {
|
||||
.manyFailed(errors, .init(remainingInput: remainingInput, debugDescription: ""))
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
static func wrap(_ error: Error, at remainingInput: Any) -> Self {
|
||||
error as? ParsingError
|
||||
?? .failed(
|
||||
"",
|
||||
.init(
|
||||
remainingInput: remainingInput,
|
||||
debugDescription: formatError(error),
|
||||
underlyingError: error
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
func flattened() -> Self {
|
||||
func flatten(_ depth: Int = 0) -> (Error) -> [(depth: Int, error: Error)] {
|
||||
{ error in
|
||||
switch error {
|
||||
case let ParsingError.manyFailed(errors, _):
|
||||
return errors.flatMap(flatten(depth + 1))
|
||||
default:
|
||||
return [(depth, error)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch self {
|
||||
case .failed:
|
||||
return self
|
||||
case let .manyFailed(errors, context):
|
||||
return .manyFailed(
|
||||
errors.flatMap(flatten())
|
||||
.sorted {
|
||||
switch ($0.error, $1.error) {
|
||||
case let (lhs as ParsingError, rhs as ParsingError):
|
||||
return lhs.context > rhs.context
|
||||
default:
|
||||
return $0.depth > $1.depth
|
||||
}
|
||||
}
|
||||
.map { $0.error },
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
var context: Context {
|
||||
switch self {
|
||||
case let .failed(_, context), let .manyFailed(_, context):
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
struct Context {
|
||||
@usableFromInline
|
||||
var debugDescription: String
|
||||
|
||||
@usableFromInline
|
||||
var originalInput: Any
|
||||
|
||||
@usableFromInline
|
||||
var remainingInput: Any
|
||||
|
||||
@usableFromInline
|
||||
var underlyingError: Error?
|
||||
|
||||
@usableFromInline
|
||||
init(
|
||||
originalInput: Any,
|
||||
remainingInput: Any,
|
||||
debugDescription: String,
|
||||
underlyingError: Error? = nil
|
||||
) {
|
||||
self.originalInput = originalInput
|
||||
self.remainingInput = remainingInput
|
||||
self.debugDescription = debugDescription
|
||||
self.underlyingError = underlyingError
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
init(
|
||||
remainingInput: Any,
|
||||
debugDescription: String,
|
||||
underlyingError: Error? = nil
|
||||
) {
|
||||
self.originalInput = remainingInput
|
||||
self.remainingInput = remainingInput
|
||||
self.debugDescription = debugDescription
|
||||
self.underlyingError = underlyingError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ParsingError: CustomDebugStringConvertible {
|
||||
@usableFromInline
|
||||
var debugDescription: String {
|
||||
switch self.flattened() {
|
||||
case let .failed(label, context):
|
||||
return format(labels: [label], context: context)
|
||||
|
||||
case let .manyFailed(errors, context) where errors.isEmpty:
|
||||
return format(labels: [""], context: context)
|
||||
|
||||
case let .manyFailed(errors, _):
|
||||
return debugDescription(for: errors)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func debugDescription(for errors: [Error]) -> String {
|
||||
func failed(_ error: Error) -> (String, Context)? {
|
||||
guard
|
||||
let error = error as? ParsingError,
|
||||
case .failed(let label, let context) = error
|
||||
else { return nil }
|
||||
return (label, context)
|
||||
}
|
||||
|
||||
var count = 0
|
||||
var description = ""
|
||||
|
||||
func append(_ s: String) {
|
||||
count += 1
|
||||
if !description.isEmpty {
|
||||
description.append("\n\n")
|
||||
}
|
||||
description.append(s)
|
||||
}
|
||||
|
||||
var errors = errors[...]
|
||||
while let error = errors.popFirst() {
|
||||
guard case .some((let firstLabel, let firstContext)) = failed(error) else {
|
||||
append(formatError(error))
|
||||
continue
|
||||
}
|
||||
|
||||
var labels = [firstLabel]
|
||||
while case .some((let label, let context)) = errors.first.flatMap({ failed($0) }),
|
||||
firstContext.canGroup(with: context)
|
||||
{
|
||||
errors.removeFirst()
|
||||
labels.append(label)
|
||||
}
|
||||
|
||||
append(format(labels: labels, context: firstContext))
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
description = """
|
||||
error: multiple failures occurred
|
||||
|
||||
\(description)
|
||||
"""
|
||||
}
|
||||
|
||||
return description
|
||||
}
|
||||
}
|
||||
|
||||
extension ParsingError.Context {
|
||||
fileprivate func canGroup(with other: Self) -> Bool {
|
||||
func areSame(_ lhs: Any, _ rhs: Any) -> Bool {
|
||||
switch (normalize(lhs), normalize(rhs)) {
|
||||
case let (lhs as Substring, rhs as Substring):
|
||||
return lhs.startIndex == rhs.startIndex && lhs.endIndex == rhs.endIndex
|
||||
case let (lhs as Slice<[Substring]>, rhs as Slice<[Substring]>):
|
||||
return zip(lhs, rhs).allSatisfy { l, r in
|
||||
l.startIndex == r.startIndex && l.endIndex == r.endIndex
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
(areSame(self.remainingInput, other.remainingInput)
|
||||
&& areSame(self.originalInput, other.originalInput)
|
||||
&& self.underlyingError == nil && other.underlyingError == nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == (label: String, context: ParsingError.Context) {
|
||||
fileprivate func allSame(_ keyPath: KeyPath<ParsingError.Context, Any>) -> Bool {
|
||||
guard let first = self.first else { return true }
|
||||
guard let firstValue = first.context[keyPath: keyPath] as? AnyHashable else { return false }
|
||||
return self.dropFirst().allSatisfy {
|
||||
guard let value = $0.context[keyPath: keyPath] as? AnyHashable else { return false }
|
||||
return value == firstValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
func format(labels: [String], context: ParsingError.Context) -> String {
|
||||
func formatHelp<Input>(from originalInput: Input, to remainingInput: Input) -> String {
|
||||
switch (normalize(originalInput), normalize(remainingInput)) {
|
||||
case let (originalInput as Substring, remainingInput as Substring):
|
||||
let substring =
|
||||
originalInput.startIndex == remainingInput.startIndex
|
||||
? originalInput
|
||||
: originalInput.base[originalInput.startIndex..<remainingInput.startIndex]
|
||||
|
||||
let position = substring.base[..<substring.startIndex].reduce(
|
||||
into: (0, 0)
|
||||
) { (position: inout (line: Int, column: Int), character: Character) in
|
||||
if character.isNewline {
|
||||
position.line += 1
|
||||
position.column = 0
|
||||
} else {
|
||||
position.column += 1
|
||||
}
|
||||
}
|
||||
|
||||
let through = substring.reduce(
|
||||
into: position
|
||||
) { (position: inout (line: Int, column: Int), character: Character) in
|
||||
if character.isNewline {
|
||||
position.line += 1
|
||||
position.column = 0
|
||||
} else {
|
||||
position.column += 1
|
||||
}
|
||||
}
|
||||
|
||||
let offset = min(position.column, 20)
|
||||
let selectedLine = substring.base[
|
||||
substring.base.index(substring.startIndex, offsetBy: -offset)...
|
||||
]
|
||||
.prefix { !$0.isNewline }
|
||||
let isStartTruncated = offset != position.column
|
||||
var truncatedLine = selectedLine.prefix(79 - 4 - (isStartTruncated ? 1 : 0))
|
||||
let isEndTruncated = truncatedLine.endIndex != selectedLine.endIndex
|
||||
for index in truncatedLine.indices.reversed() {
|
||||
guard truncatedLine[index].isWhitespace
|
||||
else { break }
|
||||
truncatedLine.replaceSubrange(index...index, with: "␣")
|
||||
}
|
||||
|
||||
let diagnostic =
|
||||
("\(isStartTruncated ? "…" : "")\(truncatedLine)\(isEndTruncated ? "…" : "")\n"
|
||||
+ labels.map { label in
|
||||
"""
|
||||
\(String(repeating: " ", count: offset + (isStartTruncated ? 1 : 0)))\
|
||||
\(String(repeating: "^", count: max(1, substring.count)))\
|
||||
\(label.isEmpty ? "" : " \(label)")
|
||||
"""
|
||||
}.joined(separator: "\n"))
|
||||
|
||||
return formatError(
|
||||
summary: context.debugDescription,
|
||||
location: """
|
||||
input:\(position.line + 1):\(position.column + 1)\
|
||||
\(
|
||||
through.line == position.line
|
||||
? (through.column <= position.column + 1 ? "" : "-\(through.column)")
|
||||
: "-\(through.line + 1):\(through.column + 1)")
|
||||
""",
|
||||
prefix: "\(position.line + 1)",
|
||||
diagnostic: diagnostic
|
||||
)
|
||||
|
||||
case let (originalInput as Slice<[Substring]>, remainingInput as Slice<[Substring]>):
|
||||
let slice =
|
||||
originalInput.startIndex == remainingInput.startIndex
|
||||
? originalInput
|
||||
: Slice(
|
||||
base: originalInput.base,
|
||||
bounds: originalInput.startIndex..<remainingInput.startIndex
|
||||
)
|
||||
|
||||
let expectation: String
|
||||
if let error = context.underlyingError as? ParsingError,
|
||||
case let .failed(elementLabel, elementContext) = error,
|
||||
let originalInput = normalize(elementContext.originalInput) as? Substring,
|
||||
let remainingInput = normalize(elementContext.remainingInput) as? Substring
|
||||
{
|
||||
let substring =
|
||||
originalInput.startIndex == remainingInput.startIndex
|
||||
? originalInput
|
||||
: originalInput.base[originalInput.startIndex..<remainingInput.startIndex]
|
||||
let indent = String(
|
||||
repeating: " ",
|
||||
count: substring.distance(
|
||||
from: substring.base.startIndex,
|
||||
to: substring.startIndex
|
||||
)
|
||||
)
|
||||
expectation = """
|
||||
\(indent)\(String(repeating: "^", count: max(1, substring.count)))\
|
||||
\(elementLabel.isEmpty ? "" : " \(elementLabel)")
|
||||
"""
|
||||
} else {
|
||||
let count = slice.map(formatValue).joined(separator: ", ").count
|
||||
expectation = labels.map { label in
|
||||
"""
|
||||
\(String(repeating: "^", count: max(1, count)))\(label.isEmpty ? "" : " \(label)")
|
||||
"""
|
||||
}.joined(separator: "\n")
|
||||
}
|
||||
|
||||
let indent = slice.base[..<slice.startIndex].map { "\(formatValue($0.base)), " }.joined()
|
||||
return formatError(
|
||||
summary: context.debugDescription,
|
||||
location: "input[\(slice.startIndex)]",
|
||||
prefix: "\(slice.startIndex)",
|
||||
diagnostic: """
|
||||
\(slice.base)
|
||||
\(String(repeating: " ", count: indent.count + 1))\(expectation)
|
||||
"""
|
||||
)
|
||||
|
||||
default:
|
||||
return "error: \(context.debugDescription)"
|
||||
}
|
||||
}
|
||||
|
||||
return formatHelp(from: context.originalInput, to: context.remainingInput)
|
||||
}
|
||||
|
||||
private func formatError(_ error: Error) -> String {
|
||||
switch error {
|
||||
case let error as ParsingError:
|
||||
return error.debugDescription
|
||||
|
||||
case let error as LocalizedError:
|
||||
return error.localizedDescription
|
||||
|
||||
default:
|
||||
return "\(error)"
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
func formatValue<Input>(
|
||||
_ input: Input
|
||||
) -> String {
|
||||
switch input {
|
||||
case let input as String:
|
||||
return input.debugDescription
|
||||
|
||||
case let input as String.UnicodeScalarView:
|
||||
return String(input).debugDescription
|
||||
|
||||
case let input as String.UTF8View:
|
||||
return String(input).debugDescription
|
||||
|
||||
case let input as Substring:
|
||||
return input.debugDescription
|
||||
|
||||
case let input as Substring.UnicodeScalarView:
|
||||
return Substring(input).debugDescription
|
||||
|
||||
case let input as Substring.UTF8View:
|
||||
return Substring(input).debugDescription
|
||||
|
||||
default:
|
||||
return "\(input)"
|
||||
}
|
||||
}
|
||||
|
||||
private func formatError(
|
||||
summary: String,
|
||||
location: String,
|
||||
prefix: String,
|
||||
diagnostic: String
|
||||
) -> String {
|
||||
let indent = String(repeating: " ", count: prefix.count)
|
||||
var diagnostic =
|
||||
diagnostic
|
||||
.split(separator: "\n", omittingEmptySubsequences: false)
|
||||
.map { "\(indent) |\($0.isEmpty ? "" : " \($0)")" }
|
||||
.joined(separator: "\n")
|
||||
diagnostic.replaceSubrange(..<indent.endIndex, with: prefix)
|
||||
return """
|
||||
error: \(summary)
|
||||
\(indent)--> \(location)
|
||||
\(diagnostic)
|
||||
"""
|
||||
}
|
||||
|
||||
extension ParsingError.Context {
|
||||
fileprivate static func > (lhs: Self, rhs: Self) -> Bool {
|
||||
switch (normalize(lhs.remainingInput), normalize(rhs.remainingInput)) {
|
||||
case let (lhsInput as Substring, rhsInput as Substring):
|
||||
return lhsInput.endIndex > rhsInput.endIndex
|
||||
|
||||
case let (lhsInput as Slice<[Substring]>, rhsInput as Slice<[Substring]>):
|
||||
guard lhsInput.endIndex != rhsInput.endIndex else {
|
||||
switch (lhs.underlyingError, rhs.underlyingError) {
|
||||
case let (lhs as ParsingError, rhs as ParsingError):
|
||||
return lhs.context > rhs.context
|
||||
case (is ParsingError, _):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
return lhsInput.endIndex > rhsInput.endIndex
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func normalize(_ input: Any) -> Any {
|
||||
// TODO: Use `_openExistential` for `C: Collection where C == C.SubSequence` for index juggling?
|
||||
switch input {
|
||||
case let input as Substring:
|
||||
// NB: We want to ensure we are sliced at a character boundary and not a scalar boundary.
|
||||
let startIndex =
|
||||
input.startIndex == input.base.endIndex
|
||||
? input.startIndex
|
||||
: input.base.indices.last { $0 <= input.startIndex } ?? input.startIndex
|
||||
let endIndex = input.endIndex == input.base.endIndex ? startIndex : input.endIndex
|
||||
|
||||
return input.base[startIndex..<endIndex]
|
||||
|
||||
case let input as Substring.UnicodeScalarView:
|
||||
return normalize(Substring(input))
|
||||
|
||||
case let input as Substring.UTF8View:
|
||||
return normalize(Substring(input))
|
||||
|
||||
case let input as Slice<[Substring]>:
|
||||
return input.endIndex == input.base.endIndex ? input[..<input.startIndex] : input
|
||||
|
||||
default:
|
||||
return input
|
||||
}
|
||||
}
|
||||
284
build-system/SwiftTL/Sources/SwiftTL/Resolution.swift
Normal file
284
build-system/SwiftTL/Sources/SwiftTL/Resolution.swift
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
import Foundation
|
||||
|
||||
struct QualifiedName: Hashable, Comparable, CustomStringConvertible {
|
||||
var namespace: String?
|
||||
var value: String
|
||||
|
||||
var description: String {
|
||||
if let namespace = self.namespace {
|
||||
return "\(namespace).\(self.value)"
|
||||
} else {
|
||||
return self.value
|
||||
}
|
||||
}
|
||||
|
||||
static func <(lhs: QualifiedName, rhs: QualifiedName) -> Bool {
|
||||
return lhs.description < rhs.description
|
||||
}
|
||||
}
|
||||
|
||||
extension QualifiedName {
|
||||
init(string: String) {
|
||||
if let dotRange = string.range(of: ".") {
|
||||
self.init(namespace: String(string[string.startIndex ..< dotRange.lowerBound]), value: String(string[dotRange.upperBound...]))
|
||||
} else {
|
||||
self.init(namespace: nil, value: string)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Resolver {
|
||||
struct ResolutionError: Error, CustomStringConvertible {
|
||||
var text: String
|
||||
|
||||
var description: String {
|
||||
return self.text
|
||||
}
|
||||
}
|
||||
|
||||
indirect enum TypeReference {
|
||||
case int32
|
||||
case int64
|
||||
case int256
|
||||
case double
|
||||
case bytes
|
||||
case string
|
||||
case bool
|
||||
case boolTrue
|
||||
case bareVector(TypeReference)
|
||||
case boxedVector(TypeReference)
|
||||
case bareConstructor(typeName: QualifiedName, name: QualifiedName)
|
||||
case boxedType(QualifiedName)
|
||||
}
|
||||
|
||||
struct Argument {
|
||||
struct Condition {
|
||||
var fieldName: String
|
||||
var bitIndex: Int
|
||||
}
|
||||
|
||||
var name: String
|
||||
var type: TypeReference
|
||||
var condition: Condition?
|
||||
}
|
||||
|
||||
final class SumType {
|
||||
struct Constructor {
|
||||
var name: QualifiedName
|
||||
var id: UInt32
|
||||
var arguments: [Argument]
|
||||
}
|
||||
|
||||
let name: QualifiedName
|
||||
var constructors: [QualifiedName: Constructor] = [:]
|
||||
|
||||
init(name: QualifiedName) {
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
|
||||
struct Function {
|
||||
var name: QualifiedName
|
||||
var id: UInt32
|
||||
var arguments: [Argument]
|
||||
var result: TypeReference
|
||||
}
|
||||
|
||||
static func resolveBuiltinType(name: QualifiedName) -> TypeReference? {
|
||||
if name.namespace == nil {
|
||||
if name.value == "int" {
|
||||
return .int32
|
||||
} else if name.value == "long" {
|
||||
return .int64
|
||||
} else if name.value == "int256" {
|
||||
return .int256
|
||||
} else if name.value == "double" {
|
||||
return .double
|
||||
} else if name.value == "string" {
|
||||
return .string
|
||||
} else if name.value == "bytes" {
|
||||
return .bytes
|
||||
} else if name.value == "true" {
|
||||
return .boolTrue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
static func resolveTypes(constructors: [DescriptionParser.ConstructorDescription]) throws -> [SumType] {
|
||||
var constructedTypes: [QualifiedName: [DescriptionParser.ConstructorDescription]] = [:]
|
||||
var constructorNameToType: [QualifiedName: QualifiedName] = [:]
|
||||
|
||||
for constructorDescription in constructors {
|
||||
switch constructorDescription.type {
|
||||
case let .type(name):
|
||||
if !name.value[name.value.startIndex].isUppercase {
|
||||
throw ResolutionError(text: "Type constructor \(constructorDescription.name) -> \(name): the resulting type name should begin with a capital letter")
|
||||
}
|
||||
|
||||
constructedTypes[name, default: []].append(constructorDescription)
|
||||
|
||||
if let _ = constructorNameToType[constructorDescription.name] {
|
||||
throw ResolutionError(text: "Duplicate type constructor \(constructorDescription.name) found")
|
||||
}
|
||||
constructorNameToType[constructorDescription.name] = name
|
||||
case let .generic(name, argumentType):
|
||||
throw ResolutionError(text: "Type constructor \(constructorDescription.name) can not be used to construct a generic type \(name)<\(argumentType)>")
|
||||
}
|
||||
}
|
||||
|
||||
func resolveTypeReference(description: DescriptionParser.TypeReferenceDescription) throws -> TypeReference {
|
||||
switch description {
|
||||
case let .type(name):
|
||||
if let resolvedBuiltinType = resolveBuiltinType(name: name) {
|
||||
return resolvedBuiltinType
|
||||
}
|
||||
|
||||
if name.value[name.value.startIndex].isUppercase {
|
||||
if let _ = constructedTypes[name] {
|
||||
return .boxedType(name)
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved type \(name)")
|
||||
}
|
||||
} else {
|
||||
if let typeName = constructorNameToType[name] {
|
||||
return .bareConstructor(typeName: typeName, name: name)
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved type constructor \(name)")
|
||||
}
|
||||
}
|
||||
case let .generic(name, argumentType):
|
||||
if name == "vector" {
|
||||
return .bareVector(try resolveTypeReference(description: .type(name: argumentType)))
|
||||
} else if name == "Vector" {
|
||||
return .boxedVector(try resolveTypeReference(description: .type(name: argumentType)))
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved generic type \(name)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolveArgument(existingArguments: [Argument], description: DescriptionParser.ArgumentDescription) throws -> Argument {
|
||||
return Argument(
|
||||
name: description.name,
|
||||
type: try resolveTypeReference(description: description.type),
|
||||
condition: try description.condition.flatMap { condition -> Argument.Condition in
|
||||
if !existingArguments.contains(where: { $0.name == condition.fieldName }) {
|
||||
throw ResolutionError(text: "Unresolved conditional field reference to \(condition.fieldName)")
|
||||
}
|
||||
return Argument.Condition(fieldName: condition.fieldName, bitIndex: condition.bitIndex)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
var types: [QualifiedName: SumType] = [:]
|
||||
|
||||
for (typeName, constructorDescriptions) in constructedTypes {
|
||||
let type = SumType(name: typeName)
|
||||
|
||||
for constructorDescription in constructorDescriptions {
|
||||
var arguments: [Argument] = []
|
||||
|
||||
for argumentDescription in constructorDescription.arguments {
|
||||
arguments.append(try resolveArgument(existingArguments: arguments, description: argumentDescription))
|
||||
}
|
||||
|
||||
guard let id = constructorDescription.explicitId else {
|
||||
throw ResolutionError(text: "Constructor \(constructorDescription.name) does not have an id")
|
||||
}
|
||||
|
||||
type.constructors[constructorDescription.name] = SumType.Constructor(
|
||||
name: constructorDescription.name,
|
||||
id: id,
|
||||
arguments: arguments
|
||||
)
|
||||
}
|
||||
|
||||
types[type.name] = type
|
||||
}
|
||||
|
||||
return types.values.sorted(by: { $0.name < $1.name })
|
||||
}
|
||||
|
||||
static func resolveFunctions(types: [SumType], functionDescriptions: [DescriptionParser.ConstructorDescription]) throws -> [Function] {
|
||||
var functions: [QualifiedName: Function] = [:]
|
||||
|
||||
var typeMap: [QualifiedName: SumType] = [:]
|
||||
var constructorMap: [QualifiedName: SumType] = [:]
|
||||
|
||||
for type in types {
|
||||
typeMap[type.name] = type
|
||||
|
||||
for (_, constructor) in type.constructors {
|
||||
constructorMap[constructor.name] = type
|
||||
}
|
||||
}
|
||||
|
||||
func resolveTypeReference(description: DescriptionParser.TypeReferenceDescription) throws -> TypeReference {
|
||||
switch description {
|
||||
case let .type(name):
|
||||
if let resolvedBuiltinType = resolveBuiltinType(name: name) {
|
||||
return resolvedBuiltinType
|
||||
}
|
||||
|
||||
if name.value[name.value.startIndex].isUppercase {
|
||||
if let _ = typeMap[name] {
|
||||
return .boxedType(name)
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved type \(name)")
|
||||
}
|
||||
} else {
|
||||
if let type = constructorMap[name] {
|
||||
return .bareConstructor(typeName: type.name, name: name)
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved type constructor \(name)")
|
||||
}
|
||||
}
|
||||
case let .generic(name, argumentType):
|
||||
if name == "vector" {
|
||||
return .bareVector(try resolveTypeReference(description: .type(name: argumentType)))
|
||||
} else if name == "Vector" {
|
||||
return .boxedVector(try resolveTypeReference(description: .type(name: argumentType)))
|
||||
} else {
|
||||
throw ResolutionError(text: "Unresolved generic type \(name)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolveArgument(existingArguments: [Argument], description: DescriptionParser.ArgumentDescription) throws -> Argument {
|
||||
return Argument(
|
||||
name: description.name,
|
||||
type: try resolveTypeReference(description: description.type),
|
||||
condition: try description.condition.flatMap { condition -> Argument.Condition in
|
||||
if !existingArguments.contains(where: { $0.name == condition.fieldName }) {
|
||||
throw ResolutionError(text: "Unresolved conditional field reference to \(condition.fieldName)")
|
||||
}
|
||||
return Argument.Condition(fieldName: condition.fieldName, bitIndex: condition.bitIndex)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
for functionDescription in functionDescriptions {
|
||||
var arguments: [Argument] = []
|
||||
|
||||
for argumentDescription in functionDescription.arguments {
|
||||
arguments.append(try resolveArgument(existingArguments: arguments, description: argumentDescription))
|
||||
}
|
||||
|
||||
let result = try resolveTypeReference(description: functionDescription.type)
|
||||
|
||||
guard let id = functionDescription.explicitId else {
|
||||
throw ResolutionError(text: "Function \(functionDescription.name) does not have an id")
|
||||
}
|
||||
|
||||
functions[functionDescription.name] = Function(
|
||||
name: functionDescription.name,
|
||||
id: id,
|
||||
arguments: arguments,
|
||||
result: result
|
||||
)
|
||||
}
|
||||
|
||||
return functions.values.sorted(by: { $0.name < $1.name })
|
||||
}
|
||||
}
|
||||
130
build-system/SwiftTL/Sources/SwiftTL/main.swift
Normal file
130
build-system/SwiftTL/Sources/SwiftTL/main.swift
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
import Foundation
|
||||
|
||||
private extension String {
|
||||
var camelCased: String {
|
||||
var result = ""
|
||||
var capitalizeNext = false
|
||||
for c in self {
|
||||
if c == "_" {
|
||||
capitalizeNext = true
|
||||
} else {
|
||||
if capitalizeNext {
|
||||
capitalizeNext = false
|
||||
result.append(c.uppercased())
|
||||
} else {
|
||||
result.append(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
if CommandLine.arguments.count < 3 {
|
||||
print("Usage: SwiftTL path-to-scheme.tl path-to-output-folder [--stub-functions] [--print-constructors=N-M]")
|
||||
exit(0)
|
||||
}
|
||||
|
||||
let schemeFilePath = CommandLine.arguments[1]
|
||||
let outputDirectoryPath = CommandLine.arguments[2]
|
||||
|
||||
var stubFunctions = false
|
||||
var printConstructorsRange: (start: Int, end: Int)? = nil
|
||||
for arg in CommandLine.arguments {
|
||||
if arg == "--stub-functions" {
|
||||
stubFunctions = true
|
||||
}
|
||||
if arg.hasPrefix("--print-constructors=") {
|
||||
let value = String(arg.dropFirst("--print-constructors=".count))
|
||||
let parts = value.split(separator: "-")
|
||||
if parts.count == 2, let start = Int(parts[0]), let end = Int(parts[1]) {
|
||||
if start > end {
|
||||
print("Error: Invalid range for --print-constructors: start (\(start)) must be <= end (\(end))")
|
||||
exit(1)
|
||||
}
|
||||
printConstructorsRange = (start, end)
|
||||
} else {
|
||||
print("Error: Invalid format for --print-constructors. Expected: --print-constructors=N-M (e.g., --print-constructors=0-10)")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard let data = try? String(contentsOfFile: schemeFilePath) else {
|
||||
print("Could not open scheme file \(schemeFilePath)")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
do {
|
||||
let parsedData = try DescriptionParser.parse(data: data)
|
||||
let resolvedTypes = try Resolver.resolveTypes(constructors: parsedData.constructors)
|
||||
var resolvedFunctions = try Resolver.resolveFunctions(types: resolvedTypes, functionDescriptions: parsedData.functions)
|
||||
|
||||
resolvedFunctions.append(Resolver.Function(name: QualifiedName(namespace: "help", value: "test"), id: 0xc0e202f7, arguments: [], result: .boxedType(QualifiedName(namespace: nil, value: "Bool"))))
|
||||
|
||||
var constructorOrder: [(typeName: QualifiedName, constructorName: String)] = []
|
||||
var typeOrder: [(types: [(typeName: QualifiedName, constructorNames: [String])], functions: [QualifiedName])] = []
|
||||
|
||||
let sortedTypes = resolvedTypes.sorted(by: { $0.name < $1.name })
|
||||
|
||||
if let range = printConstructorsRange {
|
||||
print("--- CONSTRUCTORS ---")
|
||||
for (index, type) in sortedTypes.enumerated() {
|
||||
if index >= range.start && index < range.end {
|
||||
for constructor in type.constructors.values.sorted(by: { $0.name < $1.name }) {
|
||||
let storedArguments = constructor.arguments.filter {
|
||||
if case .boolTrue = $0.type { return false }
|
||||
return true
|
||||
}
|
||||
if !storedArguments.isEmpty {
|
||||
let fieldNames = storedArguments.map { $0.name.camelCased }
|
||||
print("\(constructor.name.value):\(fieldNames.joined(separator: ","))")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print("--- END CONSTRUCTORS ---")
|
||||
print("Total types: \(sortedTypes.count)")
|
||||
exit(0)
|
||||
}
|
||||
|
||||
for type in sortedTypes {
|
||||
for constructor in type.constructors.values.sorted(by: { $0.name < $1.name }) {
|
||||
constructorOrder.append((type.name, constructor.name.value))
|
||||
}
|
||||
}
|
||||
|
||||
var totalConstructorCount = 0
|
||||
var currentConstructorCount = 0
|
||||
for type in sortedTypes {
|
||||
if typeOrder.isEmpty || currentConstructorCount >= 32 {
|
||||
typeOrder.append(([], []))
|
||||
currentConstructorCount = 0
|
||||
}
|
||||
|
||||
typeOrder[typeOrder.count - 1].types.append((type.name, type.constructors.values.sorted(by: { $0.name < $1.name }).map(\.name.value)))
|
||||
|
||||
currentConstructorCount += type.constructors.count
|
||||
totalConstructorCount += type.constructors.count
|
||||
|
||||
if totalConstructorCount > 40 {
|
||||
}
|
||||
}
|
||||
|
||||
typeOrder.append(([], []))
|
||||
for function in resolvedFunctions.sorted(by: { $0.name < $1.name }) {
|
||||
typeOrder[typeOrder.count - 1].functions.append(function.name)
|
||||
}
|
||||
|
||||
try FileManager.default.createDirectory(at: URL(fileURLWithPath: outputDirectoryPath), withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
let generatedFiles = try CodeGenerator.generate(types: resolvedTypes, functions: resolvedFunctions, constructorOrder: constructorOrder, typeOrder: typeOrder, stubFunctions: stubFunctions)
|
||||
|
||||
for (name, fileData) in generatedFiles {
|
||||
let filePath = URL(fileURLWithPath: outputDirectoryPath).appendingPathComponent(name).path
|
||||
let _ = try? FileManager.default.removeItem(atPath: filePath)
|
||||
try fileData.write(toFile: filePath, atomically: true, encoding: .utf8)
|
||||
}
|
||||
} catch let e {
|
||||
print("\(e)")
|
||||
}
|
||||
|
|
@ -1408,7 +1408,7 @@ public protocol SharedAccountContext: AnyObject {
|
|||
func makeSetupTwoFactorAuthController(context: AccountContext) -> ViewController
|
||||
func makeStorageManagementController(context: AccountContext) -> ViewController
|
||||
func makeAttachmentFileController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, audio: Bool, bannedSendMedia: (Int32, Bool)?, presentGallery: @escaping () -> Void, presentFiles: @escaping () -> Void, presentDocumentScanner: (() -> Void)?, send: @escaping ([AnyMediaReference], Bool, Int32?, NSAttributedString?) -> Void) -> AttachmentFileController
|
||||
func makeGalleryCaptionPanelView(context: AccountContext, chatLocation: ChatLocation, isScheduledMessages: Bool, isFile: Bool, hasTimer: Bool, customEmojiAvailable: Bool, present: @escaping (ViewController) -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) -> NSObject?
|
||||
func makeGalleryCaptionPanelView(context: AccountContext, chatLocation: ChatLocation, isScheduledMessages: Bool, isFile: Bool, hasTimer: Bool, customEmojiAvailable: Bool, pushViewController: @escaping (ViewController) -> Void, present: @escaping (ViewController) -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) -> NSObject?
|
||||
func makeHashtagSearchController(context: AccountContext, peer: EnginePeer?, query: String, stories: Bool, forceDark: Bool) -> ViewController
|
||||
func makeStorySearchController(context: AccountContext, scope: StorySearchControllerScope, listContext: SearchStoryListContext?) -> ViewController
|
||||
func makeMyStoriesController(context: AccountContext, isArchive: Bool) -> ViewController
|
||||
|
|
@ -1560,6 +1560,7 @@ public protocol SharedAccountContext: AnyObject {
|
|||
func makeChatRankPreviewItem(context: AccountContext, peer: EnginePeer, rank: String, rankRole: ChatRankInfoScreenRole, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder, sectionId: Int32) -> ListViewItem
|
||||
func makeTextProcessingScreen(
|
||||
context: AccountContext,
|
||||
theme: PresentationTheme?,
|
||||
mode: TextProcessingScreenMode,
|
||||
ignoredTranslationLanguages: [String],
|
||||
inputText: TextWithEntities,
|
||||
|
|
|
|||
|
|
@ -771,6 +771,7 @@ public class AttachmentController: ViewController, MinimizableController {
|
|||
|
||||
let textProcessingScreen = await controller.context.sharedContext.makeTextProcessingScreen(
|
||||
context: controller.context,
|
||||
theme: self.presentationData.theme,
|
||||
mode: .edit(
|
||||
saveRestoreStateId: nil,
|
||||
completion: { [weak self] text in
|
||||
|
|
|
|||
|
|
@ -2226,7 +2226,10 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate, ASGestureRecog
|
|||
strongSelf.present(c)
|
||||
}
|
||||
}, makeEntityInputView: self.makeEntityInputView)
|
||||
textInputPanelNode.isAIEnabled = true
|
||||
if let data = self.context.currentAppConfiguration.with({ $0 }).data, let value = data["ios_disable_ai_chat"] as? Double, value == 1.0 {
|
||||
} else {
|
||||
textInputPanelNode.isAIEnabled = true
|
||||
}
|
||||
textInputPanelNode.interfaceInteraction = self.interfaceInteraction
|
||||
textInputPanelNode.sendMessage = { [weak self] mode, messageEffect in
|
||||
if let strongSelf = self {
|
||||
|
|
|
|||
|
|
@ -1191,6 +1191,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
draftState: nil,
|
||||
mediaDraftContentType: nil,
|
||||
inputActivities: nil,
|
||||
|
|
@ -5838,6 +5839,7 @@ public final class ChatListSearchShimmerNode: ASDisplayNode {
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
draftState: nil,
|
||||
mediaDraftContentType: nil,
|
||||
inputActivities: nil,
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ public final class ChatListShimmerNode: ASDisplayNode {
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
draftState: nil,
|
||||
mediaDraftContentType: nil,
|
||||
inputActivities: nil,
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ public enum ChatListItemContent {
|
|||
public var presence: EnginePeer.Presence?
|
||||
public var hasUnseenMentions: Bool
|
||||
public var hasUnseenReactions: Bool
|
||||
public var hasUnseenPollVotes: Bool
|
||||
public var draftState: DraftState?
|
||||
public var mediaDraftContentType: EngineChatList.MediaDraftContentType?
|
||||
public var inputActivities: [(EnginePeer, PeerInputActivity)]?
|
||||
|
|
@ -170,6 +171,7 @@ public enum ChatListItemContent {
|
|||
presence: EnginePeer.Presence?,
|
||||
hasUnseenMentions: Bool,
|
||||
hasUnseenReactions: Bool,
|
||||
hasUnseenPollVotes: Bool,
|
||||
draftState: DraftState?,
|
||||
mediaDraftContentType: EngineChatList.MediaDraftContentType?,
|
||||
inputActivities: [(EnginePeer, PeerInputActivity)]?,
|
||||
|
|
@ -194,6 +196,7 @@ public enum ChatListItemContent {
|
|||
self.presence = presence
|
||||
self.hasUnseenMentions = hasUnseenMentions
|
||||
self.hasUnseenReactions = hasUnseenReactions
|
||||
self.hasUnseenPollVotes = hasUnseenPollVotes
|
||||
self.draftState = draftState
|
||||
self.mediaDraftContentType = mediaDraftContentType
|
||||
self.inputActivities = inputActivities
|
||||
|
|
@ -2192,6 +2195,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
let mediaDraftContentType: EngineChatList.MediaDraftContentType?
|
||||
let hasUnseenMentions: Bool
|
||||
let hasUnseenReactions: Bool
|
||||
let hasUnseenPollVotes: Bool
|
||||
let inputActivities: [(EnginePeer, PeerInputActivity)]?
|
||||
let isPeerGroup: Bool
|
||||
let promoInfo: ChatListNodeEntryPromoInfo?
|
||||
|
|
@ -2217,6 +2221,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
mediaDraftContentType = nil
|
||||
hasUnseenMentions = false
|
||||
hasUnseenReactions = false
|
||||
hasUnseenPollVotes = false
|
||||
inputActivities = nil
|
||||
isPeerGroup = false
|
||||
promoInfo = nil
|
||||
|
|
@ -2231,6 +2236,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
let peerPresenceValue = peerData.presence
|
||||
let hasUnseenMentionsValue = peerData.hasUnseenMentions
|
||||
let hasUnseenReactionsValue = peerData.hasUnseenReactions
|
||||
let hasUnseenPollVotesValue = peerData.hasUnseenPollVotes
|
||||
let draftStateValue = peerData.draftState
|
||||
let inputActivitiesValue = peerData.inputActivities
|
||||
let promoInfoValue = peerData.promoInfo
|
||||
|
|
@ -2264,6 +2270,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
threadInfo = threadInfoValue
|
||||
hasUnseenMentions = hasUnseenMentionsValue
|
||||
hasUnseenReactions = hasUnseenReactionsValue
|
||||
hasUnseenPollVotes = hasUnseenPollVotesValue
|
||||
forumTopicData = forumTopicDataValue
|
||||
topForumTopicItems = topForumTopicItemsValue
|
||||
|
||||
|
|
@ -2318,6 +2325,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
mediaDraftContentType = nil
|
||||
hasUnseenMentions = false
|
||||
hasUnseenReactions = false
|
||||
hasUnseenPollVotes = false
|
||||
inputActivities = nil
|
||||
isPeerGroup = true
|
||||
groupHiddenByDefault = hiddenByDefault
|
||||
|
|
@ -3295,6 +3303,13 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundReactions(item.presentationData.theme, diameter: badgeDiameter)
|
||||
}
|
||||
mentionBadgeContent = .mention
|
||||
} else if hasUnseenPollVotes {
|
||||
if isRemovedFromTotalUnreadCount {
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactivePollVotes(item.presentationData.theme, diameter: badgeDiameter)
|
||||
} else {
|
||||
currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundPollVotes(item.presentationData.theme, diameter: badgeDiameter)
|
||||
}
|
||||
mentionBadgeContent = .mention
|
||||
} else if item.isPinned, promoInfo == nil, currentBadgeBackgroundImage == nil {
|
||||
currentPinnedIconImage = PresentationResourcesChatList.badgeBackgroundPinned(item.presentationData.theme, diameter: badgeDiameter)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
let presence = peerEntry.presence
|
||||
let hasUnseenMentions = peerEntry.hasUnseenMentions
|
||||
let hasUnseenReactions = peerEntry.hasUnseenReactions
|
||||
let hasUnseenPollVotes = peerEntry.hasUnseenPollVotes
|
||||
let editing = peerEntry.editing
|
||||
let hasActiveRevealControls = peerEntry.hasActiveRevealControls
|
||||
let selected = peerEntry.selected
|
||||
|
|
@ -437,6 +438,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
presence: presence,
|
||||
hasUnseenMentions: hasUnseenMentions,
|
||||
hasUnseenReactions: hasUnseenReactions,
|
||||
hasUnseenPollVotes: hasUnseenPollVotes,
|
||||
draftState: draftState,
|
||||
mediaDraftContentType: peerEntry.mediaDraftContentType,
|
||||
inputActivities: inputActivities,
|
||||
|
|
@ -768,6 +770,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
let presence = peerEntry.presence
|
||||
let hasUnseenMentions = peerEntry.hasUnseenMentions
|
||||
let hasUnseenReactions = peerEntry.hasUnseenReactions
|
||||
let hasUnseenPollVotes = peerEntry.hasUnseenPollVotes
|
||||
let editing = peerEntry.editing
|
||||
let hasActiveRevealControls = peerEntry.hasActiveRevealControls
|
||||
let selected = peerEntry.selected
|
||||
|
|
@ -796,6 +799,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
presence: presence,
|
||||
hasUnseenMentions: hasUnseenMentions,
|
||||
hasUnseenReactions: hasUnseenReactions,
|
||||
hasUnseenPollVotes: hasUnseenPollVotes,
|
||||
draftState: draftState,
|
||||
mediaDraftContentType: peerEntry.mediaDraftContentType,
|
||||
inputActivities: inputActivities,
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
|||
var presence: EnginePeer.Presence?
|
||||
var hasUnseenMentions: Bool
|
||||
var hasUnseenReactions: Bool
|
||||
var hasUnseenPollVotes: Bool
|
||||
var editing: Bool
|
||||
var hasActiveRevealControls: Bool
|
||||
var selected: Bool
|
||||
|
|
@ -121,6 +122,7 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
|||
presence: EnginePeer.Presence?,
|
||||
hasUnseenMentions: Bool,
|
||||
hasUnseenReactions: Bool,
|
||||
hasUnseenPollVotes: Bool,
|
||||
editing: Bool,
|
||||
hasActiveRevealControls: Bool,
|
||||
selected: Bool,
|
||||
|
|
@ -148,6 +150,7 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
|||
self.presence = presence
|
||||
self.hasUnseenMentions = hasUnseenMentions
|
||||
self.hasUnseenReactions = hasUnseenReactions
|
||||
self.hasUnseenPollVotes = hasUnseenPollVotes
|
||||
self.editing = editing
|
||||
self.hasActiveRevealControls = hasActiveRevealControls
|
||||
self.selected = selected
|
||||
|
|
@ -238,6 +241,9 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
|||
if lhs.hasUnseenReactions != rhs.hasUnseenReactions {
|
||||
return false
|
||||
}
|
||||
if lhs.hasUnseenPollVotes != rhs.hasUnseenPollVotes {
|
||||
return false
|
||||
}
|
||||
if let lhsInputActivities = lhs.inputActivities, let rhsInputActivities = rhs.inputActivities {
|
||||
if lhsInputActivities.count != rhsInputActivities.count {
|
||||
return false
|
||||
|
|
@ -706,6 +712,7 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState,
|
|||
presence: entry.presence,
|
||||
hasUnseenMentions: entry.hasUnseenMentions,
|
||||
hasUnseenReactions: entry.hasUnseenReactions,
|
||||
hasUnseenPollVotes: entry.hasUnseenPollVotes,
|
||||
editing: state.editing,
|
||||
hasActiveRevealControls: hasActiveRevealControls,
|
||||
selected: isSelected,
|
||||
|
|
@ -764,6 +771,7 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState,
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
editing: state.editing,
|
||||
hasActiveRevealControls: false,
|
||||
selected: state.selectedPeerIds.contains(peer.0.id),
|
||||
|
|
@ -799,6 +807,7 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState,
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
editing: state.editing,
|
||||
hasActiveRevealControls: false,
|
||||
selected: state.selectedPeerIds.contains(savedMessagesPeer.id),
|
||||
|
|
@ -855,6 +864,7 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState,
|
|||
presence: item.item.presence,
|
||||
hasUnseenMentions: item.item.hasUnseenMentions,
|
||||
hasUnseenReactions: item.item.hasUnseenReactions,
|
||||
hasUnseenPollVotes: item.item.hasUnseenPollVotes,
|
||||
editing: state.editing,
|
||||
hasActiveRevealControls: ChatListNodeState.ItemId(peerId: peerId, threadId: threadId) == state.peerIdWithRevealedOptions,
|
||||
selected: isSelected,
|
||||
|
|
|
|||
|
|
@ -190,7 +190,14 @@ public func chatListViewForLocation(chatListLocation: ChatListControllerLocation
|
|||
),
|
||||
ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenReaction,
|
||||
actionType: PendingMessageActionType.readReaction
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
): ChatListEntrySummaryComponents.Component(
|
||||
tagSummary: ChatListEntryMessageTagSummaryComponent(namespace: Namespaces.Message.Cloud),
|
||||
actionsSummary: ChatListEntryPendingMessageActionsSummaryComponent(namespace: Namespaces.Message.Cloud)
|
||||
),
|
||||
ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenPollVote,
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
): ChatListEntrySummaryComponents.Component(
|
||||
tagSummary: ChatListEntryMessageTagSummaryComponent(namespace: Namespaces.Message.Cloud),
|
||||
actionsSummary: ChatListEntryPendingMessageActionsSummaryComponent(namespace: Namespaces.Message.Cloud)
|
||||
|
|
@ -255,9 +262,17 @@ public func chatListViewForLocation(chatListLocation: ChatListControllerLocation
|
|||
var hasUnseenReactions = false
|
||||
if let info = item.tagSummaryInfo[ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenReaction,
|
||||
actionType: PendingMessageActionType.readReaction
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
)] {
|
||||
hasUnseenReactions = (info.tagSummaryCount ?? 0) != 0// > (info.actionsSummaryCount ?? 0)
|
||||
hasUnseenReactions = (info.tagSummaryCount ?? 0) != 0
|
||||
}
|
||||
|
||||
var hasUnseenPollVotes = false
|
||||
if let info = item.tagSummaryInfo[ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenPollVote,
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
)] {
|
||||
hasUnseenPollVotes = (info.tagSummaryCount ?? 0) != 0
|
||||
}
|
||||
|
||||
let pinnedIndex: EngineChatList.Item.PinnedIndex
|
||||
|
|
@ -295,6 +310,7 @@ public func chatListViewForLocation(chatListLocation: ChatListControllerLocation
|
|||
presence: nil,
|
||||
hasUnseenMentions: hasUnseenMentions,
|
||||
hasUnseenReactions: hasUnseenReactions,
|
||||
hasUnseenPollVotes: hasUnseenPollVotes,
|
||||
forumTopicData: nil,
|
||||
topForumTopicItems: [],
|
||||
hasFailed: false,
|
||||
|
|
@ -385,6 +401,7 @@ public func chatListViewForLocation(chatListLocation: ChatListControllerLocation
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
forumTopicData: nil,
|
||||
topForumTopicItems: [],
|
||||
hasFailed: false,
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ public final class ResizableSheetComponent<ChildEnvironmentType: Sendable & Equa
|
|||
topOffsetFraction = 1.0
|
||||
}
|
||||
|
||||
#if DEBUG && false
|
||||
#if DEBUG// && false
|
||||
if "".isEmpty {
|
||||
topOffsetFraction = 1.0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,9 +205,6 @@ class MessageHistoryTagsSummaryTable: Table {
|
|||
|
||||
private func set(_ key: MessageHistoryTagsSummaryKey, summary: MessageHistoryTagNamespaceSummary, updatedSummaries: inout [MessageHistoryTagsSummaryKey: MessageHistoryTagNamespaceSummary]) {
|
||||
if self.get(key) != summary {
|
||||
if key.tag.rawValue == 2048 {
|
||||
postboxLog("[MessageHistoryTagsSummaryTable] set \(key.tag.rawValue) for \(key.peerId) to \(summary.count)")
|
||||
}
|
||||
self.updatedKeys.insert(key)
|
||||
self.cachedSummaries[key] = CachedEntry(summary: summary)
|
||||
updatedSummaries[key] = summary
|
||||
|
|
|
|||
|
|
@ -307,6 +307,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, ASScrollView
|
|||
},
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
draftState: nil,
|
||||
mediaDraftContentType: nil,
|
||||
inputActivities: hasInputActivity ? [(author, .typingText)] : [],
|
||||
|
|
|
|||
|
|
@ -439,6 +439,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
},
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
draftState: nil,
|
||||
mediaDraftContentType: nil,
|
||||
inputActivities: hasInputActivity ? [(author, .typingText)] : [],
|
||||
|
|
|
|||
|
|
@ -2527,7 +2527,14 @@ public final class ShareController: ViewController {
|
|||
),
|
||||
ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenReaction,
|
||||
actionType: PendingMessageActionType.readReaction
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
): ChatListEntrySummaryComponents.Component(
|
||||
tagSummary: ChatListEntryMessageTagSummaryComponent(namespace: Namespaces.Message.Cloud),
|
||||
actionsSummary: ChatListEntryPendingMessageActionsSummaryComponent(namespace: Namespaces.Message.Cloud)
|
||||
),
|
||||
ChatListEntryMessageTagSummaryKey(
|
||||
tag: .unseenPollVote,
|
||||
actionType: PendingMessageActionType.readReactionOrPollVote
|
||||
): ChatListEntrySummaryComponents.Component(
|
||||
tagSummary: ChatListEntryMessageTagSummaryComponent(namespace: Namespaces.Message.Cloud),
|
||||
actionsSummary: ChatListEntryPendingMessageActionsSummaryComponent(namespace: Namespaces.Message.Cloud)
|
||||
|
|
|
|||
|
|
@ -2034,6 +2034,7 @@ private func threadList(accountPeerId: EnginePeer.Id, postbox: Postbox, peerId:
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
forumTopicData: nil,
|
||||
topForumTopicItems: [],
|
||||
hasFailed: false,
|
||||
|
|
@ -2109,6 +2110,7 @@ private func threadList(accountPeerId: EnginePeer.Id, postbox: Postbox, peerId:
|
|||
presence: nil,
|
||||
hasUnseenMentions: false,
|
||||
hasUnseenReactions: false,
|
||||
hasUnseenPollVotes: false,
|
||||
forumTopicData: nil,
|
||||
topForumTopicItems: [],
|
||||
hasFailed: false,
|
||||
|
|
|
|||
|
|
@ -198,7 +198,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-531931925] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsMentions($0) }
|
||||
dict[-566281095] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsRecent($0) }
|
||||
dict[106343499] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsSearch($0) }
|
||||
dict[-1817845901] = { return Api.ChannelTopic.parse_channelTopic($0) }
|
||||
dict[473084188] = { return Api.Chat.parse_channel($0) }
|
||||
dict[399807445] = { return Api.Chat.parse_channelForbidden($0) }
|
||||
dict[1103884886] = { return Api.Chat.parse_chat($0) }
|
||||
|
|
@ -799,7 +798,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-193510921] = { return Api.PeerSettings.parse_peerSettings($0) }
|
||||
dict[-1707742823] = { return Api.PeerStories.parse_peerStories($0) }
|
||||
dict[-404214254] = { return Api.PendingSuggestion.parse_pendingSuggestion($0) }
|
||||
dict[431767677] = { return Api.PersonalChannel.parse_personalChannel($0) }
|
||||
dict[810769141] = { return Api.PhoneCall.parse_phoneCall($0) }
|
||||
dict[912311057] = { return Api.PhoneCall.parse_phoneCallAccepted($0) }
|
||||
dict[1355435489] = { return Api.PhoneCall.parse_phoneCallDiscarded($0) }
|
||||
|
|
@ -1368,8 +1366,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
|
||||
dict[-1699676497] = { return Api.channels.ChannelParticipants.parse_channelParticipants($0) }
|
||||
dict[-266911767] = { return Api.channels.ChannelParticipants.parse_channelParticipantsNotModified($0) }
|
||||
dict[824755388] = { return Api.channels.Found.parse_found($0) }
|
||||
dict[-694491059] = { return Api.channels.PersonalChannels.parse_personalChannels($0) }
|
||||
dict[-191450938] = { return Api.channels.SendAsPeers.parse_sendAsPeers($0) }
|
||||
dict[1044107055] = { return Api.channels.SponsoredMessageReportResult.parse_sponsoredMessageReportResultAdsHidden($0) }
|
||||
dict[-2073059774] = { return Api.channels.SponsoredMessageReportResult.parse_sponsoredMessageReportResultChooseOption($0) }
|
||||
|
|
@ -1772,8 +1768,6 @@ public extension Api {
|
|||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.ChannelParticipantsFilter:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.ChannelTopic:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.Chat:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.ChatAdminRights:
|
||||
|
|
@ -2152,8 +2146,6 @@ public extension Api {
|
|||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PendingSuggestion:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PersonalChannel:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PhoneCall:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PhoneCallDiscardReason:
|
||||
|
|
@ -2512,10 +2504,6 @@ public extension Api {
|
|||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.channels.ChannelParticipants:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.channels.Found:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.channels.PersonalChannels:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.channels.SendAsPeers:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.channels.SponsoredMessageReportResult:
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ public extension Api {
|
|||
public init(days: Int32) {
|
||||
self.days = days
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("accountDaysTTL", [("days", self.days as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("accountDaysTTL", [("days", ConstructorParameterDescription(self.days))])
|
||||
}
|
||||
}
|
||||
case accountDaysTTL(Cons_accountDaysTTL)
|
||||
|
|
@ -22,10 +22,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .accountDaysTTL(let _data):
|
||||
return ("accountDaysTTL", [("days", _data.days as Any)])
|
||||
return ("accountDaysTTL", [("days", ConstructorParameterDescription(_data.days))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,8 +57,8 @@ public extension Api {
|
|||
self.peerTypes = peerTypes
|
||||
self.icons = icons
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("attachMenuBot", [("flags", self.flags as Any), ("botId", self.botId as Any), ("shortName", self.shortName as Any), ("peerTypes", self.peerTypes as Any), ("icons", self.icons as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("attachMenuBot", [("flags", ConstructorParameterDescription(self.flags)), ("botId", ConstructorParameterDescription(self.botId)), ("shortName", ConstructorParameterDescription(self.shortName)), ("peerTypes", ConstructorParameterDescription(self.peerTypes)), ("icons", ConstructorParameterDescription(self.icons))])
|
||||
}
|
||||
}
|
||||
case attachMenuBot(Cons_attachMenuBot)
|
||||
|
|
@ -88,10 +88,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuBot(let _data):
|
||||
return ("attachMenuBot", [("flags", _data.flags as Any), ("botId", _data.botId as Any), ("shortName", _data.shortName as Any), ("peerTypes", _data.peerTypes as Any), ("icons", _data.icons as Any)])
|
||||
return ("attachMenuBot", [("flags", ConstructorParameterDescription(_data.flags)), ("botId", ConstructorParameterDescription(_data.botId)), ("shortName", ConstructorParameterDescription(_data.shortName)), ("peerTypes", ConstructorParameterDescription(_data.peerTypes)), ("icons", ConstructorParameterDescription(_data.icons))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,8 +139,8 @@ public extension Api {
|
|||
self.icon = icon
|
||||
self.colors = colors
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("attachMenuBotIcon", [("flags", self.flags as Any), ("name", self.name as Any), ("icon", self.icon as Any), ("colors", self.colors as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("attachMenuBotIcon", [("flags", ConstructorParameterDescription(self.flags)), ("name", ConstructorParameterDescription(self.name)), ("icon", ConstructorParameterDescription(self.icon)), ("colors", ConstructorParameterDescription(self.colors))])
|
||||
}
|
||||
}
|
||||
case attachMenuBotIcon(Cons_attachMenuBotIcon)
|
||||
|
|
@ -165,10 +165,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuBotIcon(let _data):
|
||||
return ("attachMenuBotIcon", [("flags", _data.flags as Any), ("name", _data.name as Any), ("icon", _data.icon as Any), ("colors", _data.colors as Any)])
|
||||
return ("attachMenuBotIcon", [("flags", ConstructorParameterDescription(_data.flags)), ("name", ConstructorParameterDescription(_data.name)), ("icon", ConstructorParameterDescription(_data.icon)), ("colors", ConstructorParameterDescription(_data.colors))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,8 +209,8 @@ public extension Api {
|
|||
self.name = name
|
||||
self.color = color
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("attachMenuBotIconColor", [("name", self.name as Any), ("color", self.color as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("attachMenuBotIconColor", [("name", ConstructorParameterDescription(self.name)), ("color", ConstructorParameterDescription(self.color))])
|
||||
}
|
||||
}
|
||||
case attachMenuBotIconColor(Cons_attachMenuBotIconColor)
|
||||
|
|
@ -227,10 +227,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuBotIconColor(let _data):
|
||||
return ("attachMenuBotIconColor", [("name", _data.name as Any), ("color", _data.color as Any)])
|
||||
return ("attachMenuBotIconColor", [("name", ConstructorParameterDescription(_data.name)), ("color", ConstructorParameterDescription(_data.color))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,8 +261,8 @@ public extension Api {
|
|||
self.bots = bots
|
||||
self.users = users
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("attachMenuBots", [("hash", self.hash as Any), ("bots", self.bots as Any), ("users", self.users as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("attachMenuBots", [("hash", ConstructorParameterDescription(self.hash)), ("bots", ConstructorParameterDescription(self.bots)), ("users", ConstructorParameterDescription(self.users))])
|
||||
}
|
||||
}
|
||||
case attachMenuBots(Cons_attachMenuBots)
|
||||
|
|
@ -294,10 +294,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuBots(let _data):
|
||||
return ("attachMenuBots", [("hash", _data.hash as Any), ("bots", _data.bots as Any), ("users", _data.users as Any)])
|
||||
return ("attachMenuBots", [("hash", ConstructorParameterDescription(_data.hash)), ("bots", ConstructorParameterDescription(_data.bots)), ("users", ConstructorParameterDescription(_data.users))])
|
||||
case .attachMenuBotsNotModified:
|
||||
return ("attachMenuBotsNotModified", [])
|
||||
}
|
||||
|
|
@ -338,8 +338,8 @@ public extension Api {
|
|||
self.bot = bot
|
||||
self.users = users
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("attachMenuBotsBot", [("bot", self.bot as Any), ("users", self.users as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("attachMenuBotsBot", [("bot", ConstructorParameterDescription(self.bot)), ("users", ConstructorParameterDescription(self.users))])
|
||||
}
|
||||
}
|
||||
case attachMenuBotsBot(Cons_attachMenuBotsBot)
|
||||
|
|
@ -360,10 +360,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuBotsBot(let _data):
|
||||
return ("attachMenuBotsBot", [("bot", _data.bot as Any), ("users", _data.users as Any)])
|
||||
return ("attachMenuBotsBot", [("bot", ConstructorParameterDescription(_data.bot)), ("users", ConstructorParameterDescription(_data.users))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .attachMenuPeerTypeBotPM:
|
||||
return ("attachMenuPeerTypeBotPM", [])
|
||||
|
|
@ -468,8 +468,8 @@ public extension Api {
|
|||
self.amount = amount
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("auctionBidLevel", [("pos", self.pos as Any), ("amount", self.amount as Any), ("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("auctionBidLevel", [("pos", ConstructorParameterDescription(self.pos)), ("amount", ConstructorParameterDescription(self.amount)), ("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
case auctionBidLevel(Cons_auctionBidLevel)
|
||||
|
|
@ -487,10 +487,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .auctionBidLevel(let _data):
|
||||
return ("auctionBidLevel", [("pos", _data.pos as Any), ("amount", _data.amount as Any), ("date", _data.date as Any)])
|
||||
return ("auctionBidLevel", [("pos", ConstructorParameterDescription(_data.pos)), ("amount", ConstructorParameterDescription(_data.amount)), ("date", ConstructorParameterDescription(_data.date))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -544,8 +544,8 @@ public extension Api {
|
|||
self.country = country
|
||||
self.region = region
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("authorization", [("flags", self.flags as Any), ("hash", self.hash as Any), ("deviceModel", self.deviceModel as Any), ("platform", self.platform as Any), ("systemVersion", self.systemVersion as Any), ("apiId", self.apiId as Any), ("appName", self.appName as Any), ("appVersion", self.appVersion as Any), ("dateCreated", self.dateCreated as Any), ("dateActive", self.dateActive as Any), ("ip", self.ip as Any), ("country", self.country as Any), ("region", self.region as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("authorization", [("flags", ConstructorParameterDescription(self.flags)), ("hash", ConstructorParameterDescription(self.hash)), ("deviceModel", ConstructorParameterDescription(self.deviceModel)), ("platform", ConstructorParameterDescription(self.platform)), ("systemVersion", ConstructorParameterDescription(self.systemVersion)), ("apiId", ConstructorParameterDescription(self.apiId)), ("appName", ConstructorParameterDescription(self.appName)), ("appVersion", ConstructorParameterDescription(self.appVersion)), ("dateCreated", ConstructorParameterDescription(self.dateCreated)), ("dateActive", ConstructorParameterDescription(self.dateActive)), ("ip", ConstructorParameterDescription(self.ip)), ("country", ConstructorParameterDescription(self.country)), ("region", ConstructorParameterDescription(self.region))])
|
||||
}
|
||||
}
|
||||
case authorization(Cons_authorization)
|
||||
|
|
@ -573,10 +573,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .authorization(let _data):
|
||||
return ("authorization", [("flags", _data.flags as Any), ("hash", _data.hash as Any), ("deviceModel", _data.deviceModel as Any), ("platform", _data.platform as Any), ("systemVersion", _data.systemVersion as Any), ("apiId", _data.apiId as Any), ("appName", _data.appName as Any), ("appVersion", _data.appVersion as Any), ("dateCreated", _data.dateCreated as Any), ("dateActive", _data.dateActive as Any), ("ip", _data.ip as Any), ("country", _data.country as Any), ("region", _data.region as Any)])
|
||||
return ("authorization", [("flags", ConstructorParameterDescription(_data.flags)), ("hash", ConstructorParameterDescription(_data.hash)), ("deviceModel", ConstructorParameterDescription(_data.deviceModel)), ("platform", ConstructorParameterDescription(_data.platform)), ("systemVersion", ConstructorParameterDescription(_data.systemVersion)), ("apiId", ConstructorParameterDescription(_data.apiId)), ("appName", ConstructorParameterDescription(_data.appName)), ("appVersion", ConstructorParameterDescription(_data.appVersion)), ("dateCreated", ConstructorParameterDescription(_data.dateCreated)), ("dateActive", ConstructorParameterDescription(_data.dateActive)), ("ip", ConstructorParameterDescription(_data.ip)), ("country", ConstructorParameterDescription(_data.country)), ("region", ConstructorParameterDescription(_data.region))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -648,8 +648,8 @@ public extension Api {
|
|||
self.smallQueueActiveOperationsMax = smallQueueActiveOperationsMax
|
||||
self.largeQueueActiveOperationsMax = largeQueueActiveOperationsMax
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("autoDownloadSettings", [("flags", self.flags as Any), ("photoSizeMax", self.photoSizeMax as Any), ("videoSizeMax", self.videoSizeMax as Any), ("fileSizeMax", self.fileSizeMax as Any), ("videoUploadMaxbitrate", self.videoUploadMaxbitrate as Any), ("smallQueueActiveOperationsMax", self.smallQueueActiveOperationsMax as Any), ("largeQueueActiveOperationsMax", self.largeQueueActiveOperationsMax as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("autoDownloadSettings", [("flags", ConstructorParameterDescription(self.flags)), ("photoSizeMax", ConstructorParameterDescription(self.photoSizeMax)), ("videoSizeMax", ConstructorParameterDescription(self.videoSizeMax)), ("fileSizeMax", ConstructorParameterDescription(self.fileSizeMax)), ("videoUploadMaxbitrate", ConstructorParameterDescription(self.videoUploadMaxbitrate)), ("smallQueueActiveOperationsMax", ConstructorParameterDescription(self.smallQueueActiveOperationsMax)), ("largeQueueActiveOperationsMax", ConstructorParameterDescription(self.largeQueueActiveOperationsMax))])
|
||||
}
|
||||
}
|
||||
case autoDownloadSettings(Cons_autoDownloadSettings)
|
||||
|
|
@ -671,10 +671,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .autoDownloadSettings(let _data):
|
||||
return ("autoDownloadSettings", [("flags", _data.flags as Any), ("photoSizeMax", _data.photoSizeMax as Any), ("videoSizeMax", _data.videoSizeMax as Any), ("fileSizeMax", _data.fileSizeMax as Any), ("videoUploadMaxbitrate", _data.videoUploadMaxbitrate as Any), ("smallQueueActiveOperationsMax", _data.smallQueueActiveOperationsMax as Any), ("largeQueueActiveOperationsMax", _data.largeQueueActiveOperationsMax as Any)])
|
||||
return ("autoDownloadSettings", [("flags", ConstructorParameterDescription(_data.flags)), ("photoSizeMax", ConstructorParameterDescription(_data.photoSizeMax)), ("videoSizeMax", ConstructorParameterDescription(_data.videoSizeMax)), ("fileSizeMax", ConstructorParameterDescription(_data.fileSizeMax)), ("videoUploadMaxbitrate", ConstructorParameterDescription(_data.videoUploadMaxbitrate)), ("smallQueueActiveOperationsMax", ConstructorParameterDescription(_data.smallQueueActiveOperationsMax)), ("largeQueueActiveOperationsMax", ConstructorParameterDescription(_data.largeQueueActiveOperationsMax))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -718,8 +718,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.settings = settings
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("autoSaveException", [("peer", self.peer as Any), ("settings", self.settings as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("autoSaveException", [("peer", ConstructorParameterDescription(self.peer)), ("settings", ConstructorParameterDescription(self.settings))])
|
||||
}
|
||||
}
|
||||
case autoSaveException(Cons_autoSaveException)
|
||||
|
|
@ -736,10 +736,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .autoSaveException(let _data):
|
||||
return ("autoSaveException", [("peer", _data.peer as Any), ("settings", _data.settings as Any)])
|
||||
return ("autoSaveException", [("peer", ConstructorParameterDescription(_data.peer)), ("settings", ConstructorParameterDescription(_data.settings))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -772,8 +772,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.videoMaxSize = videoMaxSize
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("autoSaveSettings", [("flags", self.flags as Any), ("videoMaxSize", self.videoMaxSize as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("autoSaveSettings", [("flags", ConstructorParameterDescription(self.flags)), ("videoMaxSize", ConstructorParameterDescription(self.videoMaxSize))])
|
||||
}
|
||||
}
|
||||
case autoSaveSettings(Cons_autoSaveSettings)
|
||||
|
|
@ -792,10 +792,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .autoSaveSettings(let _data):
|
||||
return ("autoSaveSettings", [("flags", _data.flags as Any), ("videoMaxSize", _data.videoMaxSize as Any)])
|
||||
return ("autoSaveSettings", [("flags", ConstructorParameterDescription(_data.flags)), ("videoMaxSize", ConstructorParameterDescription(_data.videoMaxSize))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -834,8 +834,8 @@ public extension Api {
|
|||
self.effectStickerId = effectStickerId
|
||||
self.effectAnimationId = effectAnimationId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("availableEffect", [("flags", self.flags as Any), ("id", self.id as Any), ("emoticon", self.emoticon as Any), ("staticIconId", self.staticIconId as Any), ("effectStickerId", self.effectStickerId as Any), ("effectAnimationId", self.effectAnimationId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("availableEffect", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id)), ("emoticon", ConstructorParameterDescription(self.emoticon)), ("staticIconId", ConstructorParameterDescription(self.staticIconId)), ("effectStickerId", ConstructorParameterDescription(self.effectStickerId)), ("effectAnimationId", ConstructorParameterDescription(self.effectAnimationId))])
|
||||
}
|
||||
}
|
||||
case availableEffect(Cons_availableEffect)
|
||||
|
|
@ -860,10 +860,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .availableEffect(let _data):
|
||||
return ("availableEffect", [("flags", _data.flags as Any), ("id", _data.id as Any), ("emoticon", _data.emoticon as Any), ("staticIconId", _data.staticIconId as Any), ("effectStickerId", _data.effectStickerId as Any), ("effectAnimationId", _data.effectAnimationId as Any)])
|
||||
return ("availableEffect", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id)), ("emoticon", ConstructorParameterDescription(_data.emoticon)), ("staticIconId", ConstructorParameterDescription(_data.staticIconId)), ("effectStickerId", ConstructorParameterDescription(_data.effectStickerId)), ("effectAnimationId", ConstructorParameterDescription(_data.effectAnimationId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -924,8 +924,8 @@ public extension Api {
|
|||
self.aroundAnimation = aroundAnimation
|
||||
self.centerIcon = centerIcon
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("availableReaction", [("flags", self.flags as Any), ("reaction", self.reaction as Any), ("title", self.title as Any), ("staticIcon", self.staticIcon as Any), ("appearAnimation", self.appearAnimation as Any), ("selectAnimation", self.selectAnimation as Any), ("activateAnimation", self.activateAnimation as Any), ("effectAnimation", self.effectAnimation as Any), ("aroundAnimation", self.aroundAnimation as Any), ("centerIcon", self.centerIcon as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("availableReaction", [("flags", ConstructorParameterDescription(self.flags)), ("reaction", ConstructorParameterDescription(self.reaction)), ("title", ConstructorParameterDescription(self.title)), ("staticIcon", ConstructorParameterDescription(self.staticIcon)), ("appearAnimation", ConstructorParameterDescription(self.appearAnimation)), ("selectAnimation", ConstructorParameterDescription(self.selectAnimation)), ("activateAnimation", ConstructorParameterDescription(self.activateAnimation)), ("effectAnimation", ConstructorParameterDescription(self.effectAnimation)), ("aroundAnimation", ConstructorParameterDescription(self.aroundAnimation)), ("centerIcon", ConstructorParameterDescription(self.centerIcon))])
|
||||
}
|
||||
}
|
||||
case availableReaction(Cons_availableReaction)
|
||||
|
|
@ -954,10 +954,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .availableReaction(let _data):
|
||||
return ("availableReaction", [("flags", _data.flags as Any), ("reaction", _data.reaction as Any), ("title", _data.title as Any), ("staticIcon", _data.staticIcon as Any), ("appearAnimation", _data.appearAnimation as Any), ("selectAnimation", _data.selectAnimation as Any), ("activateAnimation", _data.activateAnimation as Any), ("effectAnimation", _data.effectAnimation as Any), ("aroundAnimation", _data.aroundAnimation as Any), ("centerIcon", _data.centerIcon as Any)])
|
||||
return ("availableReaction", [("flags", ConstructorParameterDescription(_data.flags)), ("reaction", ConstructorParameterDescription(_data.reaction)), ("title", ConstructorParameterDescription(_data.title)), ("staticIcon", ConstructorParameterDescription(_data.staticIcon)), ("appearAnimation", ConstructorParameterDescription(_data.appearAnimation)), ("selectAnimation", ConstructorParameterDescription(_data.selectAnimation)), ("activateAnimation", ConstructorParameterDescription(_data.activateAnimation)), ("effectAnimation", ConstructorParameterDescription(_data.effectAnimation)), ("aroundAnimation", ConstructorParameterDescription(_data.aroundAnimation)), ("centerIcon", ConstructorParameterDescription(_data.centerIcon))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1028,8 +1028,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.name = name
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("bankCardOpenUrl", [("url", self.url as Any), ("name", self.name as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("bankCardOpenUrl", [("url", ConstructorParameterDescription(self.url)), ("name", ConstructorParameterDescription(self.name))])
|
||||
}
|
||||
}
|
||||
case bankCardOpenUrl(Cons_bankCardOpenUrl)
|
||||
|
|
@ -1046,10 +1046,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .bankCardOpenUrl(let _data):
|
||||
return ("bankCardOpenUrl", [("url", _data.url as Any), ("name", _data.name as Any)])
|
||||
return ("bankCardOpenUrl", [("url", ConstructorParameterDescription(_data.url)), ("name", ConstructorParameterDescription(_data.name))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1107,7 +1107,7 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .baseThemeArctic:
|
||||
return ("baseThemeArctic", [])
|
||||
|
|
@ -1152,8 +1152,8 @@ public extension Api {
|
|||
self.month = month
|
||||
self.year = year
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("birthday", [("flags", self.flags as Any), ("day", self.day as Any), ("month", self.month as Any), ("year", self.year as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("birthday", [("flags", ConstructorParameterDescription(self.flags)), ("day", ConstructorParameterDescription(self.day)), ("month", ConstructorParameterDescription(self.month)), ("year", ConstructorParameterDescription(self.year))])
|
||||
}
|
||||
}
|
||||
case birthday(Cons_birthday)
|
||||
|
|
@ -1174,10 +1174,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .birthday(let _data):
|
||||
return ("birthday", [("flags", _data.flags as Any), ("day", _data.day as Any), ("month", _data.month as Any), ("year", _data.year as Any)])
|
||||
return ("birthday", [("flags", ConstructorParameterDescription(_data.flags)), ("day", ConstructorParameterDescription(_data.day)), ("month", ConstructorParameterDescription(_data.month)), ("year", ConstructorParameterDescription(_data.year))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1225,7 +1225,7 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .boolFalse:
|
||||
return ("boolFalse", [])
|
||||
|
|
@ -1265,8 +1265,8 @@ public extension Api {
|
|||
self.multiplier = multiplier
|
||||
self.stars = stars
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("boost", [("flags", self.flags as Any), ("id", self.id as Any), ("userId", self.userId as Any), ("giveawayMsgId", self.giveawayMsgId as Any), ("date", self.date as Any), ("expires", self.expires as Any), ("usedGiftSlug", self.usedGiftSlug as Any), ("multiplier", self.multiplier as Any), ("stars", self.stars as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("boost", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id)), ("userId", ConstructorParameterDescription(self.userId)), ("giveawayMsgId", ConstructorParameterDescription(self.giveawayMsgId)), ("date", ConstructorParameterDescription(self.date)), ("expires", ConstructorParameterDescription(self.expires)), ("usedGiftSlug", ConstructorParameterDescription(self.usedGiftSlug)), ("multiplier", ConstructorParameterDescription(self.multiplier)), ("stars", ConstructorParameterDescription(self.stars))])
|
||||
}
|
||||
}
|
||||
case boost(Cons_boost)
|
||||
|
|
@ -1300,10 +1300,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .boost(let _data):
|
||||
return ("boost", [("flags", _data.flags as Any), ("id", _data.id as Any), ("userId", _data.userId as Any), ("giveawayMsgId", _data.giveawayMsgId as Any), ("date", _data.date as Any), ("expires", _data.expires as Any), ("usedGiftSlug", _data.usedGiftSlug as Any), ("multiplier", _data.multiplier as Any), ("stars", _data.stars as Any)])
|
||||
return ("boost", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id)), ("userId", ConstructorParameterDescription(_data.userId)), ("giveawayMsgId", ConstructorParameterDescription(_data.giveawayMsgId)), ("date", ConstructorParameterDescription(_data.date)), ("expires", ConstructorParameterDescription(_data.expires)), ("usedGiftSlug", ConstructorParameterDescription(_data.usedGiftSlug)), ("multiplier", ConstructorParameterDescription(_data.multiplier)), ("stars", ConstructorParameterDescription(_data.stars))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1377,8 +1377,8 @@ public extension Api {
|
|||
self.document = document
|
||||
self.hash = hash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("botApp", [("flags", self.flags as Any), ("id", self.id as Any), ("accessHash", self.accessHash as Any), ("shortName", self.shortName as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("document", self.document as Any), ("hash", self.hash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("botApp", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("shortName", ConstructorParameterDescription(self.shortName)), ("title", ConstructorParameterDescription(self.title)), ("description", ConstructorParameterDescription(self.description)), ("photo", ConstructorParameterDescription(self.photo)), ("document", ConstructorParameterDescription(self.document)), ("hash", ConstructorParameterDescription(self.hash))])
|
||||
}
|
||||
}
|
||||
case botApp(Cons_botApp)
|
||||
|
|
@ -1410,10 +1410,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .botApp(let _data):
|
||||
return ("botApp", [("flags", _data.flags as Any), ("id", _data.id as Any), ("accessHash", _data.accessHash as Any), ("shortName", _data.shortName as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("document", _data.document as Any), ("hash", _data.hash as Any)])
|
||||
return ("botApp", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("shortName", ConstructorParameterDescription(_data.shortName)), ("title", ConstructorParameterDescription(_data.title)), ("description", ConstructorParameterDescription(_data.description)), ("photo", ConstructorParameterDescription(_data.photo)), ("document", ConstructorParameterDescription(_data.document)), ("hash", ConstructorParameterDescription(_data.hash))])
|
||||
case .botAppNotModified:
|
||||
return ("botAppNotModified", [])
|
||||
}
|
||||
|
|
@ -1482,8 +1482,8 @@ public extension Api {
|
|||
self.headerColor = headerColor
|
||||
self.headerDarkColor = headerDarkColor
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("botAppSettings", [("flags", self.flags as Any), ("placeholderPath", self.placeholderPath as Any), ("backgroundColor", self.backgroundColor as Any), ("backgroundDarkColor", self.backgroundDarkColor as Any), ("headerColor", self.headerColor as Any), ("headerDarkColor", self.headerDarkColor as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("botAppSettings", [("flags", ConstructorParameterDescription(self.flags)), ("placeholderPath", ConstructorParameterDescription(self.placeholderPath)), ("backgroundColor", ConstructorParameterDescription(self.backgroundColor)), ("backgroundDarkColor", ConstructorParameterDescription(self.backgroundDarkColor)), ("headerColor", ConstructorParameterDescription(self.headerColor)), ("headerDarkColor", ConstructorParameterDescription(self.headerDarkColor))])
|
||||
}
|
||||
}
|
||||
case botAppSettings(Cons_botAppSettings)
|
||||
|
|
@ -1514,10 +1514,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .botAppSettings(let _data):
|
||||
return ("botAppSettings", [("flags", _data.flags as Any), ("placeholderPath", _data.placeholderPath as Any), ("backgroundColor", _data.backgroundColor as Any), ("backgroundDarkColor", _data.backgroundDarkColor as Any), ("headerColor", _data.headerColor as Any), ("headerDarkColor", _data.headerDarkColor as Any)])
|
||||
return ("botAppSettings", [("flags", ConstructorParameterDescription(_data.flags)), ("placeholderPath", ConstructorParameterDescription(_data.placeholderPath)), ("backgroundColor", ConstructorParameterDescription(_data.backgroundColor)), ("backgroundDarkColor", ConstructorParameterDescription(_data.backgroundDarkColor)), ("headerColor", ConstructorParameterDescription(_data.headerColor)), ("headerDarkColor", ConstructorParameterDescription(_data.headerDarkColor))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public extension Api {
|
|||
self.fileReference = fileReference
|
||||
self.thumbSize = thumbSize
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputDocumentFileLocation", [("id", self.id as Any), ("accessHash", self.accessHash as Any), ("fileReference", self.fileReference as Any), ("thumbSize", self.thumbSize as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputDocumentFileLocation", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("fileReference", ConstructorParameterDescription(self.fileReference)), ("thumbSize", ConstructorParameterDescription(self.thumbSize))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputEncryptedFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -22,8 +22,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputEncryptedFileLocation", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputEncryptedFileLocation", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -37,8 +37,8 @@ public extension Api {
|
|||
self.secret = secret
|
||||
self.fileReference = fileReference
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputFileLocation", [("volumeId", self.volumeId as Any), ("localId", self.localId as Any), ("secret", self.secret as Any), ("fileReference", self.fileReference as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputFileLocation", [("volumeId", ConstructorParameterDescription(self.volumeId)), ("localId", ConstructorParameterDescription(self.localId)), ("secret", ConstructorParameterDescription(self.secret)), ("fileReference", ConstructorParameterDescription(self.fileReference))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputGroupCallStream: TypeConstructorDescription {
|
||||
|
|
@ -56,8 +56,8 @@ public extension Api {
|
|||
self.videoChannel = videoChannel
|
||||
self.videoQuality = videoQuality
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGroupCallStream", [("flags", self.flags as Any), ("call", self.call as Any), ("timeMs", self.timeMs as Any), ("scale", self.scale as Any), ("videoChannel", self.videoChannel as Any), ("videoQuality", self.videoQuality as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGroupCallStream", [("flags", ConstructorParameterDescription(self.flags)), ("call", ConstructorParameterDescription(self.call)), ("timeMs", ConstructorParameterDescription(self.timeMs)), ("scale", ConstructorParameterDescription(self.scale)), ("videoChannel", ConstructorParameterDescription(self.videoChannel)), ("videoQuality", ConstructorParameterDescription(self.videoQuality))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPeerPhotoFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -69,8 +69,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.photoId = photoId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerPhotoFileLocation", [("flags", self.flags as Any), ("peer", self.peer as Any), ("photoId", self.photoId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerPhotoFileLocation", [("flags", ConstructorParameterDescription(self.flags)), ("peer", ConstructorParameterDescription(self.peer)), ("photoId", ConstructorParameterDescription(self.photoId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPhotoFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -84,8 +84,8 @@ public extension Api {
|
|||
self.fileReference = fileReference
|
||||
self.thumbSize = thumbSize
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPhotoFileLocation", [("id", self.id as Any), ("accessHash", self.accessHash as Any), ("fileReference", self.fileReference as Any), ("thumbSize", self.thumbSize as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPhotoFileLocation", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("fileReference", ConstructorParameterDescription(self.fileReference)), ("thumbSize", ConstructorParameterDescription(self.thumbSize))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPhotoLegacyFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -103,8 +103,8 @@ public extension Api {
|
|||
self.localId = localId
|
||||
self.secret = secret
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPhotoLegacyFileLocation", [("id", self.id as Any), ("accessHash", self.accessHash as Any), ("fileReference", self.fileReference as Any), ("volumeId", self.volumeId as Any), ("localId", self.localId as Any), ("secret", self.secret as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPhotoLegacyFileLocation", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("fileReference", ConstructorParameterDescription(self.fileReference)), ("volumeId", ConstructorParameterDescription(self.volumeId)), ("localId", ConstructorParameterDescription(self.localId)), ("secret", ConstructorParameterDescription(self.secret))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputSecureFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -114,8 +114,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSecureFileLocation", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSecureFileLocation", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStickerSetThumb: TypeConstructorDescription {
|
||||
|
|
@ -125,8 +125,8 @@ public extension Api {
|
|||
self.stickerset = stickerset
|
||||
self.thumbVersion = thumbVersion
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickerSetThumb", [("stickerset", self.stickerset as Any), ("thumbVersion", self.thumbVersion as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickerSetThumb", [("stickerset", ConstructorParameterDescription(self.stickerset)), ("thumbVersion", ConstructorParameterDescription(self.thumbVersion))])
|
||||
}
|
||||
}
|
||||
case inputDocumentFileLocation(Cons_inputDocumentFileLocation)
|
||||
|
|
@ -232,26 +232,26 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputDocumentFileLocation(let _data):
|
||||
return ("inputDocumentFileLocation", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any), ("fileReference", _data.fileReference as Any), ("thumbSize", _data.thumbSize as Any)])
|
||||
return ("inputDocumentFileLocation", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("fileReference", ConstructorParameterDescription(_data.fileReference)), ("thumbSize", ConstructorParameterDescription(_data.thumbSize))])
|
||||
case .inputEncryptedFileLocation(let _data):
|
||||
return ("inputEncryptedFileLocation", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputEncryptedFileLocation", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputFileLocation(let _data):
|
||||
return ("inputFileLocation", [("volumeId", _data.volumeId as Any), ("localId", _data.localId as Any), ("secret", _data.secret as Any), ("fileReference", _data.fileReference as Any)])
|
||||
return ("inputFileLocation", [("volumeId", ConstructorParameterDescription(_data.volumeId)), ("localId", ConstructorParameterDescription(_data.localId)), ("secret", ConstructorParameterDescription(_data.secret)), ("fileReference", ConstructorParameterDescription(_data.fileReference))])
|
||||
case .inputGroupCallStream(let _data):
|
||||
return ("inputGroupCallStream", [("flags", _data.flags as Any), ("call", _data.call as Any), ("timeMs", _data.timeMs as Any), ("scale", _data.scale as Any), ("videoChannel", _data.videoChannel as Any), ("videoQuality", _data.videoQuality as Any)])
|
||||
return ("inputGroupCallStream", [("flags", ConstructorParameterDescription(_data.flags)), ("call", ConstructorParameterDescription(_data.call)), ("timeMs", ConstructorParameterDescription(_data.timeMs)), ("scale", ConstructorParameterDescription(_data.scale)), ("videoChannel", ConstructorParameterDescription(_data.videoChannel)), ("videoQuality", ConstructorParameterDescription(_data.videoQuality))])
|
||||
case .inputPeerPhotoFileLocation(let _data):
|
||||
return ("inputPeerPhotoFileLocation", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("photoId", _data.photoId as Any)])
|
||||
return ("inputPeerPhotoFileLocation", [("flags", ConstructorParameterDescription(_data.flags)), ("peer", ConstructorParameterDescription(_data.peer)), ("photoId", ConstructorParameterDescription(_data.photoId))])
|
||||
case .inputPhotoFileLocation(let _data):
|
||||
return ("inputPhotoFileLocation", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any), ("fileReference", _data.fileReference as Any), ("thumbSize", _data.thumbSize as Any)])
|
||||
return ("inputPhotoFileLocation", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("fileReference", ConstructorParameterDescription(_data.fileReference)), ("thumbSize", ConstructorParameterDescription(_data.thumbSize))])
|
||||
case .inputPhotoLegacyFileLocation(let _data):
|
||||
return ("inputPhotoLegacyFileLocation", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any), ("fileReference", _data.fileReference as Any), ("volumeId", _data.volumeId as Any), ("localId", _data.localId as Any), ("secret", _data.secret as Any)])
|
||||
return ("inputPhotoLegacyFileLocation", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("fileReference", ConstructorParameterDescription(_data.fileReference)), ("volumeId", ConstructorParameterDescription(_data.volumeId)), ("localId", ConstructorParameterDescription(_data.localId)), ("secret", ConstructorParameterDescription(_data.secret))])
|
||||
case .inputSecureFileLocation(let _data):
|
||||
return ("inputSecureFileLocation", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputSecureFileLocation", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputStickerSetThumb(let _data):
|
||||
return ("inputStickerSetThumb", [("stickerset", _data.stickerset as Any), ("thumbVersion", _data.thumbVersion as Any)])
|
||||
return ("inputStickerSetThumb", [("stickerset", ConstructorParameterDescription(_data.stickerset)), ("thumbVersion", ConstructorParameterDescription(_data.thumbVersion))])
|
||||
case .inputTakeoutFileLocation:
|
||||
return ("inputTakeoutFileLocation", [])
|
||||
}
|
||||
|
|
@ -452,8 +452,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.folderId = folderId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputFolderPeer", [("peer", self.peer as Any), ("folderId", self.folderId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputFolderPeer", [("peer", ConstructorParameterDescription(self.peer)), ("folderId", ConstructorParameterDescription(self.folderId))])
|
||||
}
|
||||
}
|
||||
case inputFolderPeer(Cons_inputFolderPeer)
|
||||
|
|
@ -470,10 +470,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputFolderPeer(let _data):
|
||||
return ("inputFolderPeer", [("peer", _data.peer as Any), ("folderId", _data.folderId as Any)])
|
||||
return ("inputFolderPeer", [("peer", ConstructorParameterDescription(_data.peer)), ("folderId", ConstructorParameterDescription(_data.folderId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,8 +504,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGameID", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGameID", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputGameShortName: TypeConstructorDescription {
|
||||
|
|
@ -515,8 +515,8 @@ public extension Api {
|
|||
self.botId = botId
|
||||
self.shortName = shortName
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGameShortName", [("botId", self.botId as Any), ("shortName", self.shortName as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGameShortName", [("botId", ConstructorParameterDescription(self.botId)), ("shortName", ConstructorParameterDescription(self.shortName))])
|
||||
}
|
||||
}
|
||||
case inputGameID(Cons_inputGameID)
|
||||
|
|
@ -541,12 +541,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputGameID(let _data):
|
||||
return ("inputGameID", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputGameID", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputGameShortName(let _data):
|
||||
return ("inputGameShortName", [("botId", _data.botId as Any), ("shortName", _data.shortName as Any)])
|
||||
return ("inputGameShortName", [("botId", ConstructorParameterDescription(_data.botId)), ("shortName", ConstructorParameterDescription(_data.shortName))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -595,8 +595,8 @@ public extension Api {
|
|||
self.long = long
|
||||
self.accuracyRadius = accuracyRadius
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGeoPoint", [("flags", self.flags as Any), ("lat", self.lat as Any), ("long", self.long as Any), ("accuracyRadius", self.accuracyRadius as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGeoPoint", [("flags", ConstructorParameterDescription(self.flags)), ("lat", ConstructorParameterDescription(self.lat)), ("long", ConstructorParameterDescription(self.long)), ("accuracyRadius", ConstructorParameterDescription(self.accuracyRadius))])
|
||||
}
|
||||
}
|
||||
case inputGeoPoint(Cons_inputGeoPoint)
|
||||
|
|
@ -623,10 +623,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputGeoPoint(let _data):
|
||||
return ("inputGeoPoint", [("flags", _data.flags as Any), ("lat", _data.lat as Any), ("long", _data.long as Any), ("accuracyRadius", _data.accuracyRadius as Any)])
|
||||
return ("inputGeoPoint", [("flags", ConstructorParameterDescription(_data.flags)), ("lat", ConstructorParameterDescription(_data.lat)), ("long", ConstructorParameterDescription(_data.long)), ("accuracyRadius", ConstructorParameterDescription(_data.accuracyRadius))])
|
||||
case .inputGeoPointEmpty:
|
||||
return ("inputGeoPointEmpty", [])
|
||||
}
|
||||
|
|
@ -668,8 +668,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGroupCall", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGroupCall", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputGroupCallInviteMessage: TypeConstructorDescription {
|
||||
|
|
@ -677,8 +677,8 @@ public extension Api {
|
|||
public init(msgId: Int32) {
|
||||
self.msgId = msgId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGroupCallInviteMessage", [("msgId", self.msgId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGroupCallInviteMessage", [("msgId", ConstructorParameterDescription(self.msgId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputGroupCallSlug: TypeConstructorDescription {
|
||||
|
|
@ -686,8 +686,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputGroupCallSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputGroupCallSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
case inputGroupCall(Cons_inputGroupCall)
|
||||
|
|
@ -718,14 +718,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputGroupCall(let _data):
|
||||
return ("inputGroupCall", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputGroupCall", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputGroupCallInviteMessage(let _data):
|
||||
return ("inputGroupCallInviteMessage", [("msgId", _data.msgId as Any)])
|
||||
return ("inputGroupCallInviteMessage", [("msgId", ConstructorParameterDescription(_data.msgId))])
|
||||
case .inputGroupCallSlug(let _data):
|
||||
return ("inputGroupCallSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputGroupCallSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -776,8 +776,8 @@ public extension Api {
|
|||
self.bot = bot
|
||||
self.stars = stars
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceBusinessBotTransferStars", [("bot", self.bot as Any), ("stars", self.stars as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceBusinessBotTransferStars", [("bot", ConstructorParameterDescription(self.bot)), ("stars", ConstructorParameterDescription(self.stars))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceChatInviteSubscription: TypeConstructorDescription {
|
||||
|
|
@ -785,8 +785,8 @@ public extension Api {
|
|||
public init(hash: String) {
|
||||
self.hash = hash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceChatInviteSubscription", [("hash", self.hash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceChatInviteSubscription", [("hash", ConstructorParameterDescription(self.hash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceMessage: TypeConstructorDescription {
|
||||
|
|
@ -796,8 +796,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.msgId = msgId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceMessage", [("peer", self.peer as Any), ("msgId", self.msgId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceMessage", [("peer", ConstructorParameterDescription(self.peer)), ("msgId", ConstructorParameterDescription(self.msgId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoicePremiumAuthCode: TypeConstructorDescription {
|
||||
|
|
@ -805,8 +805,8 @@ public extension Api {
|
|||
public init(purpose: Api.InputStorePaymentPurpose) {
|
||||
self.purpose = purpose
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoicePremiumAuthCode", [("purpose", self.purpose as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoicePremiumAuthCode", [("purpose", ConstructorParameterDescription(self.purpose))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoicePremiumGiftCode: TypeConstructorDescription {
|
||||
|
|
@ -816,8 +816,8 @@ public extension Api {
|
|||
self.purpose = purpose
|
||||
self.option = option
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoicePremiumGiftCode", [("purpose", self.purpose as Any), ("option", self.option as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoicePremiumGiftCode", [("purpose", ConstructorParameterDescription(self.purpose)), ("option", ConstructorParameterDescription(self.option))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoicePremiumGiftStars: TypeConstructorDescription {
|
||||
|
|
@ -831,8 +831,8 @@ public extension Api {
|
|||
self.months = months
|
||||
self.message = message
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoicePremiumGiftStars", [("flags", self.flags as Any), ("userId", self.userId as Any), ("months", self.months as Any), ("message", self.message as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoicePremiumGiftStars", [("flags", ConstructorParameterDescription(self.flags)), ("userId", ConstructorParameterDescription(self.userId)), ("months", ConstructorParameterDescription(self.months)), ("message", ConstructorParameterDescription(self.message))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceSlug: TypeConstructorDescription {
|
||||
|
|
@ -840,8 +840,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGift: TypeConstructorDescription {
|
||||
|
|
@ -855,8 +855,8 @@ public extension Api {
|
|||
self.giftId = giftId
|
||||
self.message = message
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGift", [("flags", self.flags as Any), ("peer", self.peer as Any), ("giftId", self.giftId as Any), ("message", self.message as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGift", [("flags", ConstructorParameterDescription(self.flags)), ("peer", ConstructorParameterDescription(self.peer)), ("giftId", ConstructorParameterDescription(self.giftId)), ("message", ConstructorParameterDescription(self.message))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftAuctionBid: TypeConstructorDescription {
|
||||
|
|
@ -872,8 +872,8 @@ public extension Api {
|
|||
self.bidAmount = bidAmount
|
||||
self.message = message
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftAuctionBid", [("flags", self.flags as Any), ("peer", self.peer as Any), ("giftId", self.giftId as Any), ("bidAmount", self.bidAmount as Any), ("message", self.message as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftAuctionBid", [("flags", ConstructorParameterDescription(self.flags)), ("peer", ConstructorParameterDescription(self.peer)), ("giftId", ConstructorParameterDescription(self.giftId)), ("bidAmount", ConstructorParameterDescription(self.bidAmount)), ("message", ConstructorParameterDescription(self.message))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftDropOriginalDetails: TypeConstructorDescription {
|
||||
|
|
@ -881,8 +881,8 @@ public extension Api {
|
|||
public init(stargift: Api.InputSavedStarGift) {
|
||||
self.stargift = stargift
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftDropOriginalDetails", [("stargift", self.stargift as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftDropOriginalDetails", [("stargift", ConstructorParameterDescription(self.stargift))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftPrepaidUpgrade: TypeConstructorDescription {
|
||||
|
|
@ -892,8 +892,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.hash = hash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftPrepaidUpgrade", [("peer", self.peer as Any), ("hash", self.hash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftPrepaidUpgrade", [("peer", ConstructorParameterDescription(self.peer)), ("hash", ConstructorParameterDescription(self.hash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftResale: TypeConstructorDescription {
|
||||
|
|
@ -905,8 +905,8 @@ public extension Api {
|
|||
self.slug = slug
|
||||
self.toId = toId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftResale", [("flags", self.flags as Any), ("slug", self.slug as Any), ("toId", self.toId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftResale", [("flags", ConstructorParameterDescription(self.flags)), ("slug", ConstructorParameterDescription(self.slug)), ("toId", ConstructorParameterDescription(self.toId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftTransfer: TypeConstructorDescription {
|
||||
|
|
@ -916,8 +916,8 @@ public extension Api {
|
|||
self.stargift = stargift
|
||||
self.toId = toId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftTransfer", [("stargift", self.stargift as Any), ("toId", self.toId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftTransfer", [("stargift", ConstructorParameterDescription(self.stargift)), ("toId", ConstructorParameterDescription(self.toId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStarGiftUpgrade: TypeConstructorDescription {
|
||||
|
|
@ -927,8 +927,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.stargift = stargift
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStarGiftUpgrade", [("flags", self.flags as Any), ("stargift", self.stargift as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStarGiftUpgrade", [("flags", ConstructorParameterDescription(self.flags)), ("stargift", ConstructorParameterDescription(self.stargift))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputInvoiceStars: TypeConstructorDescription {
|
||||
|
|
@ -936,8 +936,8 @@ public extension Api {
|
|||
public init(purpose: Api.InputStorePaymentPurpose) {
|
||||
self.purpose = purpose
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputInvoiceStars", [("purpose", self.purpose as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputInvoiceStars", [("purpose", ConstructorParameterDescription(self.purpose))])
|
||||
}
|
||||
}
|
||||
case inputInvoiceBusinessBotTransferStars(Cons_inputInvoiceBusinessBotTransferStars)
|
||||
|
|
@ -1077,38 +1077,38 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputInvoiceBusinessBotTransferStars(let _data):
|
||||
return ("inputInvoiceBusinessBotTransferStars", [("bot", _data.bot as Any), ("stars", _data.stars as Any)])
|
||||
return ("inputInvoiceBusinessBotTransferStars", [("bot", ConstructorParameterDescription(_data.bot)), ("stars", ConstructorParameterDescription(_data.stars))])
|
||||
case .inputInvoiceChatInviteSubscription(let _data):
|
||||
return ("inputInvoiceChatInviteSubscription", [("hash", _data.hash as Any)])
|
||||
return ("inputInvoiceChatInviteSubscription", [("hash", ConstructorParameterDescription(_data.hash))])
|
||||
case .inputInvoiceMessage(let _data):
|
||||
return ("inputInvoiceMessage", [("peer", _data.peer as Any), ("msgId", _data.msgId as Any)])
|
||||
return ("inputInvoiceMessage", [("peer", ConstructorParameterDescription(_data.peer)), ("msgId", ConstructorParameterDescription(_data.msgId))])
|
||||
case .inputInvoicePremiumAuthCode(let _data):
|
||||
return ("inputInvoicePremiumAuthCode", [("purpose", _data.purpose as Any)])
|
||||
return ("inputInvoicePremiumAuthCode", [("purpose", ConstructorParameterDescription(_data.purpose))])
|
||||
case .inputInvoicePremiumGiftCode(let _data):
|
||||
return ("inputInvoicePremiumGiftCode", [("purpose", _data.purpose as Any), ("option", _data.option as Any)])
|
||||
return ("inputInvoicePremiumGiftCode", [("purpose", ConstructorParameterDescription(_data.purpose)), ("option", ConstructorParameterDescription(_data.option))])
|
||||
case .inputInvoicePremiumGiftStars(let _data):
|
||||
return ("inputInvoicePremiumGiftStars", [("flags", _data.flags as Any), ("userId", _data.userId as Any), ("months", _data.months as Any), ("message", _data.message as Any)])
|
||||
return ("inputInvoicePremiumGiftStars", [("flags", ConstructorParameterDescription(_data.flags)), ("userId", ConstructorParameterDescription(_data.userId)), ("months", ConstructorParameterDescription(_data.months)), ("message", ConstructorParameterDescription(_data.message))])
|
||||
case .inputInvoiceSlug(let _data):
|
||||
return ("inputInvoiceSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputInvoiceSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
case .inputInvoiceStarGift(let _data):
|
||||
return ("inputInvoiceStarGift", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("giftId", _data.giftId as Any), ("message", _data.message as Any)])
|
||||
return ("inputInvoiceStarGift", [("flags", ConstructorParameterDescription(_data.flags)), ("peer", ConstructorParameterDescription(_data.peer)), ("giftId", ConstructorParameterDescription(_data.giftId)), ("message", ConstructorParameterDescription(_data.message))])
|
||||
case .inputInvoiceStarGiftAuctionBid(let _data):
|
||||
return ("inputInvoiceStarGiftAuctionBid", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("giftId", _data.giftId as Any), ("bidAmount", _data.bidAmount as Any), ("message", _data.message as Any)])
|
||||
return ("inputInvoiceStarGiftAuctionBid", [("flags", ConstructorParameterDescription(_data.flags)), ("peer", ConstructorParameterDescription(_data.peer)), ("giftId", ConstructorParameterDescription(_data.giftId)), ("bidAmount", ConstructorParameterDescription(_data.bidAmount)), ("message", ConstructorParameterDescription(_data.message))])
|
||||
case .inputInvoiceStarGiftDropOriginalDetails(let _data):
|
||||
return ("inputInvoiceStarGiftDropOriginalDetails", [("stargift", _data.stargift as Any)])
|
||||
return ("inputInvoiceStarGiftDropOriginalDetails", [("stargift", ConstructorParameterDescription(_data.stargift))])
|
||||
case .inputInvoiceStarGiftPrepaidUpgrade(let _data):
|
||||
return ("inputInvoiceStarGiftPrepaidUpgrade", [("peer", _data.peer as Any), ("hash", _data.hash as Any)])
|
||||
return ("inputInvoiceStarGiftPrepaidUpgrade", [("peer", ConstructorParameterDescription(_data.peer)), ("hash", ConstructorParameterDescription(_data.hash))])
|
||||
case .inputInvoiceStarGiftResale(let _data):
|
||||
return ("inputInvoiceStarGiftResale", [("flags", _data.flags as Any), ("slug", _data.slug as Any), ("toId", _data.toId as Any)])
|
||||
return ("inputInvoiceStarGiftResale", [("flags", ConstructorParameterDescription(_data.flags)), ("slug", ConstructorParameterDescription(_data.slug)), ("toId", ConstructorParameterDescription(_data.toId))])
|
||||
case .inputInvoiceStarGiftTransfer(let _data):
|
||||
return ("inputInvoiceStarGiftTransfer", [("stargift", _data.stargift as Any), ("toId", _data.toId as Any)])
|
||||
return ("inputInvoiceStarGiftTransfer", [("stargift", ConstructorParameterDescription(_data.stargift)), ("toId", ConstructorParameterDescription(_data.toId))])
|
||||
case .inputInvoiceStarGiftUpgrade(let _data):
|
||||
return ("inputInvoiceStarGiftUpgrade", [("flags", _data.flags as Any), ("stargift", _data.stargift as Any)])
|
||||
return ("inputInvoiceStarGiftUpgrade", [("flags", ConstructorParameterDescription(_data.flags)), ("stargift", ConstructorParameterDescription(_data.stargift))])
|
||||
case .inputInvoiceStars(let _data):
|
||||
return ("inputInvoiceStars", [("purpose", _data.purpose as Any)])
|
||||
return ("inputInvoiceStars", [("purpose", ConstructorParameterDescription(_data.purpose))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public extension Api {
|
|||
self.lastName = lastName
|
||||
self.vcard = vcard
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaContact", [("phoneNumber", self.phoneNumber as Any), ("firstName", self.firstName as Any), ("lastName", self.lastName as Any), ("vcard", self.vcard as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaContact", [("phoneNumber", ConstructorParameterDescription(self.phoneNumber)), ("firstName", ConstructorParameterDescription(self.firstName)), ("lastName", ConstructorParameterDescription(self.lastName)), ("vcard", ConstructorParameterDescription(self.vcard))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaDice: TypeConstructorDescription {
|
||||
|
|
@ -20,8 +20,8 @@ public extension Api {
|
|||
public init(emoticon: String) {
|
||||
self.emoticon = emoticon
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaDice", [("emoticon", self.emoticon as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaDice", [("emoticon", ConstructorParameterDescription(self.emoticon))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaDocument: TypeConstructorDescription {
|
||||
|
|
@ -39,8 +39,8 @@ public extension Api {
|
|||
self.ttlSeconds = ttlSeconds
|
||||
self.query = query
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaDocument", [("flags", self.flags as Any), ("id", self.id as Any), ("videoCover", self.videoCover as Any), ("videoTimestamp", self.videoTimestamp as Any), ("ttlSeconds", self.ttlSeconds as Any), ("query", self.query as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaDocument", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id)), ("videoCover", ConstructorParameterDescription(self.videoCover)), ("videoTimestamp", ConstructorParameterDescription(self.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds)), ("query", ConstructorParameterDescription(self.query))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaDocumentExternal: TypeConstructorDescription {
|
||||
|
|
@ -56,8 +56,8 @@ public extension Api {
|
|||
self.videoCover = videoCover
|
||||
self.videoTimestamp = videoTimestamp
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaDocumentExternal", [("flags", self.flags as Any), ("url", self.url as Any), ("ttlSeconds", self.ttlSeconds as Any), ("videoCover", self.videoCover as Any), ("videoTimestamp", self.videoTimestamp as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaDocumentExternal", [("flags", ConstructorParameterDescription(self.flags)), ("url", ConstructorParameterDescription(self.url)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds)), ("videoCover", ConstructorParameterDescription(self.videoCover)), ("videoTimestamp", ConstructorParameterDescription(self.videoTimestamp))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaGame: TypeConstructorDescription {
|
||||
|
|
@ -65,8 +65,8 @@ public extension Api {
|
|||
public init(id: Api.InputGame) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaGame", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaGame", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaGeoLive: TypeConstructorDescription {
|
||||
|
|
@ -82,8 +82,8 @@ public extension Api {
|
|||
self.period = period
|
||||
self.proximityNotificationRadius = proximityNotificationRadius
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaGeoLive", [("flags", self.flags as Any), ("geoPoint", self.geoPoint as Any), ("heading", self.heading as Any), ("period", self.period as Any), ("proximityNotificationRadius", self.proximityNotificationRadius as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaGeoLive", [("flags", ConstructorParameterDescription(self.flags)), ("geoPoint", ConstructorParameterDescription(self.geoPoint)), ("heading", ConstructorParameterDescription(self.heading)), ("period", ConstructorParameterDescription(self.period)), ("proximityNotificationRadius", ConstructorParameterDescription(self.proximityNotificationRadius))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaGeoPoint: TypeConstructorDescription {
|
||||
|
|
@ -91,8 +91,8 @@ public extension Api {
|
|||
public init(geoPoint: Api.InputGeoPoint) {
|
||||
self.geoPoint = geoPoint
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaGeoPoint", [("geoPoint", self.geoPoint as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaGeoPoint", [("geoPoint", ConstructorParameterDescription(self.geoPoint))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaInvoice: TypeConstructorDescription {
|
||||
|
|
@ -118,8 +118,8 @@ public extension Api {
|
|||
self.startParam = startParam
|
||||
self.extendedMedia = extendedMedia
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaInvoice", [("flags", self.flags as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("invoice", self.invoice as Any), ("payload", self.payload as Any), ("provider", self.provider as Any), ("providerData", self.providerData as Any), ("startParam", self.startParam as Any), ("extendedMedia", self.extendedMedia as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaInvoice", [("flags", ConstructorParameterDescription(self.flags)), ("title", ConstructorParameterDescription(self.title)), ("description", ConstructorParameterDescription(self.description)), ("photo", ConstructorParameterDescription(self.photo)), ("invoice", ConstructorParameterDescription(self.invoice)), ("payload", ConstructorParameterDescription(self.payload)), ("provider", ConstructorParameterDescription(self.provider)), ("providerData", ConstructorParameterDescription(self.providerData)), ("startParam", ConstructorParameterDescription(self.startParam)), ("extendedMedia", ConstructorParameterDescription(self.extendedMedia))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaPaidMedia: TypeConstructorDescription {
|
||||
|
|
@ -133,8 +133,8 @@ public extension Api {
|
|||
self.extendedMedia = extendedMedia
|
||||
self.payload = payload
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaPaidMedia", [("flags", self.flags as Any), ("starsAmount", self.starsAmount as Any), ("extendedMedia", self.extendedMedia as Any), ("payload", self.payload as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaPaidMedia", [("flags", ConstructorParameterDescription(self.flags)), ("starsAmount", ConstructorParameterDescription(self.starsAmount)), ("extendedMedia", ConstructorParameterDescription(self.extendedMedia)), ("payload", ConstructorParameterDescription(self.payload))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaPhoto: TypeConstructorDescription {
|
||||
|
|
@ -148,8 +148,8 @@ public extension Api {
|
|||
self.ttlSeconds = ttlSeconds
|
||||
self.video = video
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaPhoto", [("flags", self.flags as Any), ("id", self.id as Any), ("ttlSeconds", self.ttlSeconds as Any), ("video", self.video as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaPhoto", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds)), ("video", ConstructorParameterDescription(self.video))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaPhotoExternal: TypeConstructorDescription {
|
||||
|
|
@ -161,8 +161,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.ttlSeconds = ttlSeconds
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaPhotoExternal", [("flags", self.flags as Any), ("url", self.url as Any), ("ttlSeconds", self.ttlSeconds as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaPhotoExternal", [("flags", ConstructorParameterDescription(self.flags)), ("url", ConstructorParameterDescription(self.url)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaPoll: TypeConstructorDescription {
|
||||
|
|
@ -182,8 +182,8 @@ public extension Api {
|
|||
self.solutionEntities = solutionEntities
|
||||
self.solutionMedia = solutionMedia
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaPoll", [("flags", self.flags as Any), ("poll", self.poll as Any), ("correctAnswers", self.correctAnswers as Any), ("attachedMedia", self.attachedMedia as Any), ("solution", self.solution as Any), ("solutionEntities", self.solutionEntities as Any), ("solutionMedia", self.solutionMedia as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaPoll", [("flags", ConstructorParameterDescription(self.flags)), ("poll", ConstructorParameterDescription(self.poll)), ("correctAnswers", ConstructorParameterDescription(self.correctAnswers)), ("attachedMedia", ConstructorParameterDescription(self.attachedMedia)), ("solution", ConstructorParameterDescription(self.solution)), ("solutionEntities", ConstructorParameterDescription(self.solutionEntities)), ("solutionMedia", ConstructorParameterDescription(self.solutionMedia))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaStakeDice: TypeConstructorDescription {
|
||||
|
|
@ -195,8 +195,8 @@ public extension Api {
|
|||
self.tonAmount = tonAmount
|
||||
self.clientSeed = clientSeed
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaStakeDice", [("gameHash", self.gameHash as Any), ("tonAmount", self.tonAmount as Any), ("clientSeed", self.clientSeed as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaStakeDice", [("gameHash", ConstructorParameterDescription(self.gameHash)), ("tonAmount", ConstructorParameterDescription(self.tonAmount)), ("clientSeed", ConstructorParameterDescription(self.clientSeed))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaStory: TypeConstructorDescription {
|
||||
|
|
@ -206,8 +206,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaStory", [("peer", self.peer as Any), ("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaStory", [("peer", ConstructorParameterDescription(self.peer)), ("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaTodo: TypeConstructorDescription {
|
||||
|
|
@ -215,8 +215,8 @@ public extension Api {
|
|||
public init(todo: Api.TodoList) {
|
||||
self.todo = todo
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaTodo", [("todo", self.todo as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaTodo", [("todo", ConstructorParameterDescription(self.todo))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaUploadedDocument: TypeConstructorDescription {
|
||||
|
|
@ -240,8 +240,8 @@ public extension Api {
|
|||
self.videoTimestamp = videoTimestamp
|
||||
self.ttlSeconds = ttlSeconds
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaUploadedDocument", [("flags", self.flags as Any), ("file", self.file as Any), ("thumb", self.thumb as Any), ("mimeType", self.mimeType as Any), ("attributes", self.attributes as Any), ("stickers", self.stickers as Any), ("videoCover", self.videoCover as Any), ("videoTimestamp", self.videoTimestamp as Any), ("ttlSeconds", self.ttlSeconds as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaUploadedDocument", [("flags", ConstructorParameterDescription(self.flags)), ("file", ConstructorParameterDescription(self.file)), ("thumb", ConstructorParameterDescription(self.thumb)), ("mimeType", ConstructorParameterDescription(self.mimeType)), ("attributes", ConstructorParameterDescription(self.attributes)), ("stickers", ConstructorParameterDescription(self.stickers)), ("videoCover", ConstructorParameterDescription(self.videoCover)), ("videoTimestamp", ConstructorParameterDescription(self.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaUploadedPhoto: TypeConstructorDescription {
|
||||
|
|
@ -257,8 +257,8 @@ public extension Api {
|
|||
self.ttlSeconds = ttlSeconds
|
||||
self.video = video
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaUploadedPhoto", [("flags", self.flags as Any), ("file", self.file as Any), ("stickers", self.stickers as Any), ("ttlSeconds", self.ttlSeconds as Any), ("video", self.video as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaUploadedPhoto", [("flags", ConstructorParameterDescription(self.flags)), ("file", ConstructorParameterDescription(self.file)), ("stickers", ConstructorParameterDescription(self.stickers)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds)), ("video", ConstructorParameterDescription(self.video))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaVenue: TypeConstructorDescription {
|
||||
|
|
@ -276,8 +276,8 @@ public extension Api {
|
|||
self.venueId = venueId
|
||||
self.venueType = venueType
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaVenue", [("geoPoint", self.geoPoint as Any), ("title", self.title as Any), ("address", self.address as Any), ("provider", self.provider as Any), ("venueId", self.venueId as Any), ("venueType", self.venueType as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaVenue", [("geoPoint", ConstructorParameterDescription(self.geoPoint)), ("title", ConstructorParameterDescription(self.title)), ("address", ConstructorParameterDescription(self.address)), ("provider", ConstructorParameterDescription(self.provider)), ("venueId", ConstructorParameterDescription(self.venueId)), ("venueType", ConstructorParameterDescription(self.venueType))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaWebPage: TypeConstructorDescription {
|
||||
|
|
@ -287,8 +287,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.url = url
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaWebPage", [("flags", self.flags as Any), ("url", self.url as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMediaWebPage", [("flags", ConstructorParameterDescription(self.flags)), ("url", ConstructorParameterDescription(self.url))])
|
||||
}
|
||||
}
|
||||
case inputMediaContact(Cons_inputMediaContact)
|
||||
|
|
@ -582,48 +582,48 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputMediaContact(let _data):
|
||||
return ("inputMediaContact", [("phoneNumber", _data.phoneNumber as Any), ("firstName", _data.firstName as Any), ("lastName", _data.lastName as Any), ("vcard", _data.vcard as Any)])
|
||||
return ("inputMediaContact", [("phoneNumber", ConstructorParameterDescription(_data.phoneNumber)), ("firstName", ConstructorParameterDescription(_data.firstName)), ("lastName", ConstructorParameterDescription(_data.lastName)), ("vcard", ConstructorParameterDescription(_data.vcard))])
|
||||
case .inputMediaDice(let _data):
|
||||
return ("inputMediaDice", [("emoticon", _data.emoticon as Any)])
|
||||
return ("inputMediaDice", [("emoticon", ConstructorParameterDescription(_data.emoticon))])
|
||||
case .inputMediaDocument(let _data):
|
||||
return ("inputMediaDocument", [("flags", _data.flags as Any), ("id", _data.id as Any), ("videoCover", _data.videoCover as Any), ("videoTimestamp", _data.videoTimestamp as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("query", _data.query as Any)])
|
||||
return ("inputMediaDocument", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id)), ("videoCover", ConstructorParameterDescription(_data.videoCover)), ("videoTimestamp", ConstructorParameterDescription(_data.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds)), ("query", ConstructorParameterDescription(_data.query))])
|
||||
case .inputMediaDocumentExternal(let _data):
|
||||
return ("inputMediaDocumentExternal", [("flags", _data.flags as Any), ("url", _data.url as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("videoCover", _data.videoCover as Any), ("videoTimestamp", _data.videoTimestamp as Any)])
|
||||
return ("inputMediaDocumentExternal", [("flags", ConstructorParameterDescription(_data.flags)), ("url", ConstructorParameterDescription(_data.url)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds)), ("videoCover", ConstructorParameterDescription(_data.videoCover)), ("videoTimestamp", ConstructorParameterDescription(_data.videoTimestamp))])
|
||||
case .inputMediaEmpty:
|
||||
return ("inputMediaEmpty", [])
|
||||
case .inputMediaGame(let _data):
|
||||
return ("inputMediaGame", [("id", _data.id as Any)])
|
||||
return ("inputMediaGame", [("id", ConstructorParameterDescription(_data.id))])
|
||||
case .inputMediaGeoLive(let _data):
|
||||
return ("inputMediaGeoLive", [("flags", _data.flags as Any), ("geoPoint", _data.geoPoint as Any), ("heading", _data.heading as Any), ("period", _data.period as Any), ("proximityNotificationRadius", _data.proximityNotificationRadius as Any)])
|
||||
return ("inputMediaGeoLive", [("flags", ConstructorParameterDescription(_data.flags)), ("geoPoint", ConstructorParameterDescription(_data.geoPoint)), ("heading", ConstructorParameterDescription(_data.heading)), ("period", ConstructorParameterDescription(_data.period)), ("proximityNotificationRadius", ConstructorParameterDescription(_data.proximityNotificationRadius))])
|
||||
case .inputMediaGeoPoint(let _data):
|
||||
return ("inputMediaGeoPoint", [("geoPoint", _data.geoPoint as Any)])
|
||||
return ("inputMediaGeoPoint", [("geoPoint", ConstructorParameterDescription(_data.geoPoint))])
|
||||
case .inputMediaInvoice(let _data):
|
||||
return ("inputMediaInvoice", [("flags", _data.flags as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("invoice", _data.invoice as Any), ("payload", _data.payload as Any), ("provider", _data.provider as Any), ("providerData", _data.providerData as Any), ("startParam", _data.startParam as Any), ("extendedMedia", _data.extendedMedia as Any)])
|
||||
return ("inputMediaInvoice", [("flags", ConstructorParameterDescription(_data.flags)), ("title", ConstructorParameterDescription(_data.title)), ("description", ConstructorParameterDescription(_data.description)), ("photo", ConstructorParameterDescription(_data.photo)), ("invoice", ConstructorParameterDescription(_data.invoice)), ("payload", ConstructorParameterDescription(_data.payload)), ("provider", ConstructorParameterDescription(_data.provider)), ("providerData", ConstructorParameterDescription(_data.providerData)), ("startParam", ConstructorParameterDescription(_data.startParam)), ("extendedMedia", ConstructorParameterDescription(_data.extendedMedia))])
|
||||
case .inputMediaPaidMedia(let _data):
|
||||
return ("inputMediaPaidMedia", [("flags", _data.flags as Any), ("starsAmount", _data.starsAmount as Any), ("extendedMedia", _data.extendedMedia as Any), ("payload", _data.payload as Any)])
|
||||
return ("inputMediaPaidMedia", [("flags", ConstructorParameterDescription(_data.flags)), ("starsAmount", ConstructorParameterDescription(_data.starsAmount)), ("extendedMedia", ConstructorParameterDescription(_data.extendedMedia)), ("payload", ConstructorParameterDescription(_data.payload))])
|
||||
case .inputMediaPhoto(let _data):
|
||||
return ("inputMediaPhoto", [("flags", _data.flags as Any), ("id", _data.id as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("video", _data.video as Any)])
|
||||
return ("inputMediaPhoto", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds)), ("video", ConstructorParameterDescription(_data.video))])
|
||||
case .inputMediaPhotoExternal(let _data):
|
||||
return ("inputMediaPhotoExternal", [("flags", _data.flags as Any), ("url", _data.url as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
return ("inputMediaPhotoExternal", [("flags", ConstructorParameterDescription(_data.flags)), ("url", ConstructorParameterDescription(_data.url)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds))])
|
||||
case .inputMediaPoll(let _data):
|
||||
return ("inputMediaPoll", [("flags", _data.flags as Any), ("poll", _data.poll as Any), ("correctAnswers", _data.correctAnswers as Any), ("attachedMedia", _data.attachedMedia as Any), ("solution", _data.solution as Any), ("solutionEntities", _data.solutionEntities as Any), ("solutionMedia", _data.solutionMedia as Any)])
|
||||
return ("inputMediaPoll", [("flags", ConstructorParameterDescription(_data.flags)), ("poll", ConstructorParameterDescription(_data.poll)), ("correctAnswers", ConstructorParameterDescription(_data.correctAnswers)), ("attachedMedia", ConstructorParameterDescription(_data.attachedMedia)), ("solution", ConstructorParameterDescription(_data.solution)), ("solutionEntities", ConstructorParameterDescription(_data.solutionEntities)), ("solutionMedia", ConstructorParameterDescription(_data.solutionMedia))])
|
||||
case .inputMediaStakeDice(let _data):
|
||||
return ("inputMediaStakeDice", [("gameHash", _data.gameHash as Any), ("tonAmount", _data.tonAmount as Any), ("clientSeed", _data.clientSeed as Any)])
|
||||
return ("inputMediaStakeDice", [("gameHash", ConstructorParameterDescription(_data.gameHash)), ("tonAmount", ConstructorParameterDescription(_data.tonAmount)), ("clientSeed", ConstructorParameterDescription(_data.clientSeed))])
|
||||
case .inputMediaStory(let _data):
|
||||
return ("inputMediaStory", [("peer", _data.peer as Any), ("id", _data.id as Any)])
|
||||
return ("inputMediaStory", [("peer", ConstructorParameterDescription(_data.peer)), ("id", ConstructorParameterDescription(_data.id))])
|
||||
case .inputMediaTodo(let _data):
|
||||
return ("inputMediaTodo", [("todo", _data.todo as Any)])
|
||||
return ("inputMediaTodo", [("todo", ConstructorParameterDescription(_data.todo))])
|
||||
case .inputMediaUploadedDocument(let _data):
|
||||
return ("inputMediaUploadedDocument", [("flags", _data.flags as Any), ("file", _data.file as Any), ("thumb", _data.thumb as Any), ("mimeType", _data.mimeType as Any), ("attributes", _data.attributes as Any), ("stickers", _data.stickers as Any), ("videoCover", _data.videoCover as Any), ("videoTimestamp", _data.videoTimestamp as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
return ("inputMediaUploadedDocument", [("flags", ConstructorParameterDescription(_data.flags)), ("file", ConstructorParameterDescription(_data.file)), ("thumb", ConstructorParameterDescription(_data.thumb)), ("mimeType", ConstructorParameterDescription(_data.mimeType)), ("attributes", ConstructorParameterDescription(_data.attributes)), ("stickers", ConstructorParameterDescription(_data.stickers)), ("videoCover", ConstructorParameterDescription(_data.videoCover)), ("videoTimestamp", ConstructorParameterDescription(_data.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds))])
|
||||
case .inputMediaUploadedPhoto(let _data):
|
||||
return ("inputMediaUploadedPhoto", [("flags", _data.flags as Any), ("file", _data.file as Any), ("stickers", _data.stickers as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("video", _data.video as Any)])
|
||||
return ("inputMediaUploadedPhoto", [("flags", ConstructorParameterDescription(_data.flags)), ("file", ConstructorParameterDescription(_data.file)), ("stickers", ConstructorParameterDescription(_data.stickers)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds)), ("video", ConstructorParameterDescription(_data.video))])
|
||||
case .inputMediaVenue(let _data):
|
||||
return ("inputMediaVenue", [("geoPoint", _data.geoPoint as Any), ("title", _data.title as Any), ("address", _data.address as Any), ("provider", _data.provider as Any), ("venueId", _data.venueId as Any), ("venueType", _data.venueType as Any)])
|
||||
return ("inputMediaVenue", [("geoPoint", ConstructorParameterDescription(_data.geoPoint)), ("title", ConstructorParameterDescription(_data.title)), ("address", ConstructorParameterDescription(_data.address)), ("provider", ConstructorParameterDescription(_data.provider)), ("venueId", ConstructorParameterDescription(_data.venueId)), ("venueType", ConstructorParameterDescription(_data.venueType))])
|
||||
case .inputMediaWebPage(let _data):
|
||||
return ("inputMediaWebPage", [("flags", _data.flags as Any), ("url", _data.url as Any)])
|
||||
return ("inputMediaWebPage", [("flags", ConstructorParameterDescription(_data.flags)), ("url", ConstructorParameterDescription(_data.url))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1150,8 +1150,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.queryId = queryId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageCallbackQuery", [("id", self.id as Any), ("queryId", self.queryId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessageCallbackQuery", [("id", ConstructorParameterDescription(self.id)), ("queryId", ConstructorParameterDescription(self.queryId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMessageID: TypeConstructorDescription {
|
||||
|
|
@ -1159,8 +1159,8 @@ public extension Api {
|
|||
public init(id: Int32) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageID", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessageID", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMessageReplyTo: TypeConstructorDescription {
|
||||
|
|
@ -1168,8 +1168,8 @@ public extension Api {
|
|||
public init(id: Int32) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageReplyTo", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessageReplyTo", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
case inputMessageCallbackQuery(Cons_inputMessageCallbackQuery)
|
||||
|
|
@ -1206,16 +1206,16 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputMessageCallbackQuery(let _data):
|
||||
return ("inputMessageCallbackQuery", [("id", _data.id as Any), ("queryId", _data.queryId as Any)])
|
||||
return ("inputMessageCallbackQuery", [("id", ConstructorParameterDescription(_data.id)), ("queryId", ConstructorParameterDescription(_data.queryId))])
|
||||
case .inputMessageID(let _data):
|
||||
return ("inputMessageID", [("id", _data.id as Any)])
|
||||
return ("inputMessageID", [("id", ConstructorParameterDescription(_data.id))])
|
||||
case .inputMessagePinned:
|
||||
return ("inputMessagePinned", [])
|
||||
case .inputMessageReplyTo(let _data):
|
||||
return ("inputMessageReplyTo", [("id", _data.id as Any)])
|
||||
return ("inputMessageReplyTo", [("id", ConstructorParameterDescription(_data.id))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1277,8 +1277,8 @@ public extension Api {
|
|||
self.heightToViewportRatioPermille = heightToViewportRatioPermille
|
||||
self.seenRangeRatioPermille = seenRangeRatioPermille
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageReadMetric", [("msgId", self.msgId as Any), ("viewId", self.viewId as Any), ("timeInViewMs", self.timeInViewMs as Any), ("activeTimeInViewMs", self.activeTimeInViewMs as Any), ("heightToViewportRatioPermille", self.heightToViewportRatioPermille as Any), ("seenRangeRatioPermille", self.seenRangeRatioPermille as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessageReadMetric", [("msgId", ConstructorParameterDescription(self.msgId)), ("viewId", ConstructorParameterDescription(self.viewId)), ("timeInViewMs", ConstructorParameterDescription(self.timeInViewMs)), ("activeTimeInViewMs", ConstructorParameterDescription(self.activeTimeInViewMs)), ("heightToViewportRatioPermille", ConstructorParameterDescription(self.heightToViewportRatioPermille)), ("seenRangeRatioPermille", ConstructorParameterDescription(self.seenRangeRatioPermille))])
|
||||
}
|
||||
}
|
||||
case inputMessageReadMetric(Cons_inputMessageReadMetric)
|
||||
|
|
@ -1299,10 +1299,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputMessageReadMetric(let _data):
|
||||
return ("inputMessageReadMetric", [("msgId", _data.msgId as Any), ("viewId", _data.viewId as Any), ("timeInViewMs", _data.timeInViewMs as Any), ("activeTimeInViewMs", _data.activeTimeInViewMs as Any), ("heightToViewportRatioPermille", _data.heightToViewportRatioPermille as Any), ("seenRangeRatioPermille", _data.seenRangeRatioPermille as Any)])
|
||||
return ("inputMessageReadMetric", [("msgId", ConstructorParameterDescription(_data.msgId)), ("viewId", ConstructorParameterDescription(_data.viewId)), ("timeInViewMs", ConstructorParameterDescription(_data.timeInViewMs)), ("activeTimeInViewMs", ConstructorParameterDescription(_data.activeTimeInViewMs)), ("heightToViewportRatioPermille", ConstructorParameterDescription(_data.heightToViewportRatioPermille)), ("seenRangeRatioPermille", ConstructorParameterDescription(_data.seenRangeRatioPermille))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1343,8 +1343,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.topMsgId = topMsgId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputNotifyForumTopic", [("peer", self.peer as Any), ("topMsgId", self.topMsgId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputNotifyForumTopic", [("peer", ConstructorParameterDescription(self.peer)), ("topMsgId", ConstructorParameterDescription(self.topMsgId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputNotifyPeer: TypeConstructorDescription {
|
||||
|
|
@ -1352,8 +1352,8 @@ public extension Api {
|
|||
public init(peer: Api.InputPeer) {
|
||||
self.peer = peer
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputNotifyPeer", [("peer", self.peer as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputNotifyPeer", [("peer", ConstructorParameterDescription(self.peer))])
|
||||
}
|
||||
}
|
||||
case inputNotifyBroadcasts
|
||||
|
|
@ -1395,16 +1395,16 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputNotifyBroadcasts:
|
||||
return ("inputNotifyBroadcasts", [])
|
||||
case .inputNotifyChats:
|
||||
return ("inputNotifyChats", [])
|
||||
case .inputNotifyForumTopic(let _data):
|
||||
return ("inputNotifyForumTopic", [("peer", _data.peer as Any), ("topMsgId", _data.topMsgId as Any)])
|
||||
return ("inputNotifyForumTopic", [("peer", ConstructorParameterDescription(_data.peer)), ("topMsgId", ConstructorParameterDescription(_data.topMsgId))])
|
||||
case .inputNotifyPeer(let _data):
|
||||
return ("inputNotifyPeer", [("peer", _data.peer as Any)])
|
||||
return ("inputNotifyPeer", [("peer", ConstructorParameterDescription(_data.peer))])
|
||||
case .inputNotifyUsers:
|
||||
return ("inputNotifyUsers", [])
|
||||
}
|
||||
|
|
@ -1457,8 +1457,8 @@ public extension Api {
|
|||
public init(pnvToken: String) {
|
||||
self.pnvToken = pnvToken
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyCredentialFirebasePNV", [("pnvToken", self.pnvToken as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPasskeyCredentialFirebasePNV", [("pnvToken", ConstructorParameterDescription(self.pnvToken))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPasskeyCredentialPublicKey: TypeConstructorDescription {
|
||||
|
|
@ -1470,8 +1470,8 @@ public extension Api {
|
|||
self.rawId = rawId
|
||||
self.response = response
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyCredentialPublicKey", [("id", self.id as Any), ("rawId", self.rawId as Any), ("response", self.response as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPasskeyCredentialPublicKey", [("id", ConstructorParameterDescription(self.id)), ("rawId", ConstructorParameterDescription(self.rawId)), ("response", ConstructorParameterDescription(self.response))])
|
||||
}
|
||||
}
|
||||
case inputPasskeyCredentialFirebasePNV(Cons_inputPasskeyCredentialFirebasePNV)
|
||||
|
|
@ -1496,12 +1496,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPasskeyCredentialFirebasePNV(let _data):
|
||||
return ("inputPasskeyCredentialFirebasePNV", [("pnvToken", _data.pnvToken as Any)])
|
||||
return ("inputPasskeyCredentialFirebasePNV", [("pnvToken", ConstructorParameterDescription(_data.pnvToken))])
|
||||
case .inputPasskeyCredentialPublicKey(let _data):
|
||||
return ("inputPasskeyCredentialPublicKey", [("id", _data.id as Any), ("rawId", _data.rawId as Any), ("response", _data.response as Any)])
|
||||
return ("inputPasskeyCredentialPublicKey", [("id", ConstructorParameterDescription(_data.id)), ("rawId", ConstructorParameterDescription(_data.rawId)), ("response", ConstructorParameterDescription(_data.response))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public extension Api {
|
|||
self.signature = signature
|
||||
self.userHandle = userHandle
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseLogin", [("clientData", self.clientData as Any), ("authenticatorData", self.authenticatorData as Any), ("signature", self.signature as Any), ("userHandle", self.userHandle as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPasskeyResponseLogin", [("clientData", ConstructorParameterDescription(self.clientData)), ("authenticatorData", ConstructorParameterDescription(self.authenticatorData)), ("signature", ConstructorParameterDescription(self.signature)), ("userHandle", ConstructorParameterDescription(self.userHandle))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPasskeyResponseRegister: TypeConstructorDescription {
|
||||
|
|
@ -22,8 +22,8 @@ public extension Api {
|
|||
self.clientData = clientData
|
||||
self.attestationData = attestationData
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseRegister", [("clientData", self.clientData as Any), ("attestationData", self.attestationData as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPasskeyResponseRegister", [("clientData", ConstructorParameterDescription(self.clientData)), ("attestationData", ConstructorParameterDescription(self.attestationData))])
|
||||
}
|
||||
}
|
||||
case inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin)
|
||||
|
|
@ -50,12 +50,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPasskeyResponseLogin(let _data):
|
||||
return ("inputPasskeyResponseLogin", [("clientData", _data.clientData as Any), ("authenticatorData", _data.authenticatorData as Any), ("signature", _data.signature as Any), ("userHandle", _data.userHandle as Any)])
|
||||
return ("inputPasskeyResponseLogin", [("clientData", ConstructorParameterDescription(_data.clientData)), ("authenticatorData", ConstructorParameterDescription(_data.authenticatorData)), ("signature", ConstructorParameterDescription(_data.signature)), ("userHandle", ConstructorParameterDescription(_data.userHandle))])
|
||||
case .inputPasskeyResponseRegister(let _data):
|
||||
return ("inputPasskeyResponseRegister", [("clientData", _data.clientData as Any), ("attestationData", _data.attestationData as Any)])
|
||||
return ("inputPasskeyResponseRegister", [("clientData", ConstructorParameterDescription(_data.clientData)), ("attestationData", ConstructorParameterDescription(_data.attestationData))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +108,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.data = data
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPaymentCredentials", [("flags", self.flags as Any), ("data", self.data as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPaymentCredentials", [("flags", ConstructorParameterDescription(self.flags)), ("data", ConstructorParameterDescription(self.data))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPaymentCredentialsApplePay: TypeConstructorDescription {
|
||||
|
|
@ -117,8 +117,8 @@ public extension Api {
|
|||
public init(paymentData: Api.DataJSON) {
|
||||
self.paymentData = paymentData
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPaymentCredentialsApplePay", [("paymentData", self.paymentData as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPaymentCredentialsApplePay", [("paymentData", ConstructorParameterDescription(self.paymentData))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPaymentCredentialsGooglePay: TypeConstructorDescription {
|
||||
|
|
@ -126,8 +126,8 @@ public extension Api {
|
|||
public init(paymentToken: Api.DataJSON) {
|
||||
self.paymentToken = paymentToken
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPaymentCredentialsGooglePay", [("paymentToken", self.paymentToken as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPaymentCredentialsGooglePay", [("paymentToken", ConstructorParameterDescription(self.paymentToken))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPaymentCredentialsSaved: TypeConstructorDescription {
|
||||
|
|
@ -137,8 +137,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.tmpPassword = tmpPassword
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPaymentCredentialsSaved", [("id", self.id as Any), ("tmpPassword", self.tmpPassword as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPaymentCredentialsSaved", [("id", ConstructorParameterDescription(self.id)), ("tmpPassword", ConstructorParameterDescription(self.tmpPassword))])
|
||||
}
|
||||
}
|
||||
case inputPaymentCredentials(Cons_inputPaymentCredentials)
|
||||
|
|
@ -177,16 +177,16 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPaymentCredentials(let _data):
|
||||
return ("inputPaymentCredentials", [("flags", _data.flags as Any), ("data", _data.data as Any)])
|
||||
return ("inputPaymentCredentials", [("flags", ConstructorParameterDescription(_data.flags)), ("data", ConstructorParameterDescription(_data.data))])
|
||||
case .inputPaymentCredentialsApplePay(let _data):
|
||||
return ("inputPaymentCredentialsApplePay", [("paymentData", _data.paymentData as Any)])
|
||||
return ("inputPaymentCredentialsApplePay", [("paymentData", ConstructorParameterDescription(_data.paymentData))])
|
||||
case .inputPaymentCredentialsGooglePay(let _data):
|
||||
return ("inputPaymentCredentialsGooglePay", [("paymentToken", _data.paymentToken as Any)])
|
||||
return ("inputPaymentCredentialsGooglePay", [("paymentToken", ConstructorParameterDescription(_data.paymentToken))])
|
||||
case .inputPaymentCredentialsSaved(let _data):
|
||||
return ("inputPaymentCredentialsSaved", [("id", _data.id as Any), ("tmpPassword", _data.tmpPassword as Any)])
|
||||
return ("inputPaymentCredentialsSaved", [("id", ConstructorParameterDescription(_data.id)), ("tmpPassword", ConstructorParameterDescription(_data.tmpPassword))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,8 +257,8 @@ public extension Api {
|
|||
self.channelId = channelId
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerChannel", [("channelId", self.channelId as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerChannel", [("channelId", ConstructorParameterDescription(self.channelId)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPeerChannelFromMessage: TypeConstructorDescription {
|
||||
|
|
@ -270,8 +270,8 @@ public extension Api {
|
|||
self.msgId = msgId
|
||||
self.channelId = channelId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerChannelFromMessage", [("peer", self.peer as Any), ("msgId", self.msgId as Any), ("channelId", self.channelId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerChannelFromMessage", [("peer", ConstructorParameterDescription(self.peer)), ("msgId", ConstructorParameterDescription(self.msgId)), ("channelId", ConstructorParameterDescription(self.channelId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPeerChat: TypeConstructorDescription {
|
||||
|
|
@ -279,8 +279,8 @@ public extension Api {
|
|||
public init(chatId: Int64) {
|
||||
self.chatId = chatId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerChat", [("chatId", self.chatId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerChat", [("chatId", ConstructorParameterDescription(self.chatId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPeerUser: TypeConstructorDescription {
|
||||
|
|
@ -290,8 +290,8 @@ public extension Api {
|
|||
self.userId = userId
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerUser", [("userId", self.userId as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerUser", [("userId", ConstructorParameterDescription(self.userId)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPeerUserFromMessage: TypeConstructorDescription {
|
||||
|
|
@ -303,8 +303,8 @@ public extension Api {
|
|||
self.msgId = msgId
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerUserFromMessage", [("peer", self.peer as Any), ("msgId", self.msgId as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerUserFromMessage", [("peer", ConstructorParameterDescription(self.peer)), ("msgId", ConstructorParameterDescription(self.msgId)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
case inputPeerChannel(Cons_inputPeerChannel)
|
||||
|
|
@ -366,22 +366,22 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPeerChannel(let _data):
|
||||
return ("inputPeerChannel", [("channelId", _data.channelId as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputPeerChannel", [("channelId", ConstructorParameterDescription(_data.channelId)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputPeerChannelFromMessage(let _data):
|
||||
return ("inputPeerChannelFromMessage", [("peer", _data.peer as Any), ("msgId", _data.msgId as Any), ("channelId", _data.channelId as Any)])
|
||||
return ("inputPeerChannelFromMessage", [("peer", ConstructorParameterDescription(_data.peer)), ("msgId", ConstructorParameterDescription(_data.msgId)), ("channelId", ConstructorParameterDescription(_data.channelId))])
|
||||
case .inputPeerChat(let _data):
|
||||
return ("inputPeerChat", [("chatId", _data.chatId as Any)])
|
||||
return ("inputPeerChat", [("chatId", ConstructorParameterDescription(_data.chatId))])
|
||||
case .inputPeerEmpty:
|
||||
return ("inputPeerEmpty", [])
|
||||
case .inputPeerSelf:
|
||||
return ("inputPeerSelf", [])
|
||||
case .inputPeerUser(let _data):
|
||||
return ("inputPeerUser", [("userId", _data.userId as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputPeerUser", [("userId", ConstructorParameterDescription(_data.userId)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputPeerUserFromMessage(let _data):
|
||||
return ("inputPeerUserFromMessage", [("peer", _data.peer as Any), ("msgId", _data.msgId as Any), ("userId", _data.userId as Any)])
|
||||
return ("inputPeerUserFromMessage", [("peer", ConstructorParameterDescription(_data.peer)), ("msgId", ConstructorParameterDescription(_data.msgId)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -491,8 +491,8 @@ public extension Api {
|
|||
self.storiesHideSender = storiesHideSender
|
||||
self.storiesSound = storiesSound
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPeerNotifySettings", [("flags", self.flags as Any), ("showPreviews", self.showPreviews as Any), ("silent", self.silent as Any), ("muteUntil", self.muteUntil as Any), ("sound", self.sound as Any), ("storiesMuted", self.storiesMuted as Any), ("storiesHideSender", self.storiesHideSender as Any), ("storiesSound", self.storiesSound as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPeerNotifySettings", [("flags", ConstructorParameterDescription(self.flags)), ("showPreviews", ConstructorParameterDescription(self.showPreviews)), ("silent", ConstructorParameterDescription(self.silent)), ("muteUntil", ConstructorParameterDescription(self.muteUntil)), ("sound", ConstructorParameterDescription(self.sound)), ("storiesMuted", ConstructorParameterDescription(self.storiesMuted)), ("storiesHideSender", ConstructorParameterDescription(self.storiesHideSender)), ("storiesSound", ConstructorParameterDescription(self.storiesSound))])
|
||||
}
|
||||
}
|
||||
case inputPeerNotifySettings(Cons_inputPeerNotifySettings)
|
||||
|
|
@ -529,10 +529,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPeerNotifySettings(let _data):
|
||||
return ("inputPeerNotifySettings", [("flags", _data.flags as Any), ("showPreviews", _data.showPreviews as Any), ("silent", _data.silent as Any), ("muteUntil", _data.muteUntil as Any), ("sound", _data.sound as Any), ("storiesMuted", _data.storiesMuted as Any), ("storiesHideSender", _data.storiesHideSender as Any), ("storiesSound", _data.storiesSound as Any)])
|
||||
return ("inputPeerNotifySettings", [("flags", ConstructorParameterDescription(_data.flags)), ("showPreviews", ConstructorParameterDescription(_data.showPreviews)), ("silent", ConstructorParameterDescription(_data.silent)), ("muteUntil", ConstructorParameterDescription(_data.muteUntil)), ("sound", ConstructorParameterDescription(_data.sound)), ("storiesMuted", ConstructorParameterDescription(_data.storiesMuted)), ("storiesHideSender", ConstructorParameterDescription(_data.storiesHideSender)), ("storiesSound", ConstructorParameterDescription(_data.storiesSound))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -605,8 +605,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPhoneCall", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPhoneCall", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
case inputPhoneCall(Cons_inputPhoneCall)
|
||||
|
|
@ -623,10 +623,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPhoneCall(let _data):
|
||||
return ("inputPhoneCall", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputPhoneCall", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -657,8 +657,8 @@ public extension Api {
|
|||
self.accessHash = accessHash
|
||||
self.fileReference = fileReference
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPhoto", [("id", self.id as Any), ("accessHash", self.accessHash as Any), ("fileReference", self.fileReference as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPhoto", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("fileReference", ConstructorParameterDescription(self.fileReference))])
|
||||
}
|
||||
}
|
||||
case inputPhoto(Cons_inputPhoto)
|
||||
|
|
@ -682,10 +682,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPhoto(let _data):
|
||||
return ("inputPhoto", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any), ("fileReference", _data.fileReference as Any)])
|
||||
return ("inputPhoto", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("fileReference", ConstructorParameterDescription(_data.fileReference))])
|
||||
case .inputPhotoEmpty:
|
||||
return ("inputPhotoEmpty", [])
|
||||
}
|
||||
|
|
@ -805,7 +805,7 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPrivacyKeyAbout:
|
||||
return ("inputPrivacyKeyAbout", [])
|
||||
|
|
@ -889,8 +889,8 @@ public extension Api {
|
|||
public init(chats: [Int64]) {
|
||||
self.chats = chats
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", self.chats as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", ConstructorParameterDescription(self.chats))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPrivacyValueAllowUsers: TypeConstructorDescription {
|
||||
|
|
@ -898,8 +898,8 @@ public extension Api {
|
|||
public init(users: [Api.InputUser]) {
|
||||
self.users = users
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPrivacyValueAllowUsers", [("users", self.users as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPrivacyValueAllowUsers", [("users", ConstructorParameterDescription(self.users))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPrivacyValueDisallowChatParticipants: TypeConstructorDescription {
|
||||
|
|
@ -907,8 +907,8 @@ public extension Api {
|
|||
public init(chats: [Int64]) {
|
||||
self.chats = chats
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", self.chats as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", ConstructorParameterDescription(self.chats))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPrivacyValueDisallowUsers: TypeConstructorDescription {
|
||||
|
|
@ -916,8 +916,8 @@ public extension Api {
|
|||
public init(users: [Api.InputUser]) {
|
||||
self.users = users
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPrivacyValueDisallowUsers", [("users", self.users as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputPrivacyValueDisallowUsers", [("users", ConstructorParameterDescription(self.users))])
|
||||
}
|
||||
}
|
||||
case inputPrivacyValueAllowAll
|
||||
|
|
@ -1018,14 +1018,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputPrivacyValueAllowAll:
|
||||
return ("inputPrivacyValueAllowAll", [])
|
||||
case .inputPrivacyValueAllowBots:
|
||||
return ("inputPrivacyValueAllowBots", [])
|
||||
case .inputPrivacyValueAllowChatParticipants(let _data):
|
||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", _data.chats as Any)])
|
||||
return ("inputPrivacyValueAllowChatParticipants", [("chats", ConstructorParameterDescription(_data.chats))])
|
||||
case .inputPrivacyValueAllowCloseFriends:
|
||||
return ("inputPrivacyValueAllowCloseFriends", [])
|
||||
case .inputPrivacyValueAllowContacts:
|
||||
|
|
@ -1033,17 +1033,17 @@ public extension Api {
|
|||
case .inputPrivacyValueAllowPremium:
|
||||
return ("inputPrivacyValueAllowPremium", [])
|
||||
case .inputPrivacyValueAllowUsers(let _data):
|
||||
return ("inputPrivacyValueAllowUsers", [("users", _data.users as Any)])
|
||||
return ("inputPrivacyValueAllowUsers", [("users", ConstructorParameterDescription(_data.users))])
|
||||
case .inputPrivacyValueDisallowAll:
|
||||
return ("inputPrivacyValueDisallowAll", [])
|
||||
case .inputPrivacyValueDisallowBots:
|
||||
return ("inputPrivacyValueDisallowBots", [])
|
||||
case .inputPrivacyValueDisallowChatParticipants(let _data):
|
||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", _data.chats as Any)])
|
||||
return ("inputPrivacyValueDisallowChatParticipants", [("chats", ConstructorParameterDescription(_data.chats))])
|
||||
case .inputPrivacyValueDisallowContacts:
|
||||
return ("inputPrivacyValueDisallowContacts", [])
|
||||
case .inputPrivacyValueDisallowUsers(let _data):
|
||||
return ("inputPrivacyValueDisallowUsers", [("users", _data.users as Any)])
|
||||
return ("inputPrivacyValueDisallowUsers", [("users", ConstructorParameterDescription(_data.users))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ public extension Api {
|
|||
public init(shortcut: String) {
|
||||
self.shortcut = shortcut
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputQuickReplyShortcut", [("shortcut", self.shortcut as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputQuickReplyShortcut", [("shortcut", ConstructorParameterDescription(self.shortcut))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputQuickReplyShortcutId: TypeConstructorDescription {
|
||||
|
|
@ -14,8 +14,8 @@ public extension Api {
|
|||
public init(shortcutId: Int32) {
|
||||
self.shortcutId = shortcutId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputQuickReplyShortcutId", [("shortcutId", self.shortcutId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputQuickReplyShortcutId", [("shortcutId", ConstructorParameterDescription(self.shortcutId))])
|
||||
}
|
||||
}
|
||||
case inputQuickReplyShortcut(Cons_inputQuickReplyShortcut)
|
||||
|
|
@ -38,12 +38,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputQuickReplyShortcut(let _data):
|
||||
return ("inputQuickReplyShortcut", [("shortcut", _data.shortcut as Any)])
|
||||
return ("inputQuickReplyShortcut", [("shortcut", ConstructorParameterDescription(_data.shortcut))])
|
||||
case .inputQuickReplyShortcutId(let _data):
|
||||
return ("inputQuickReplyShortcutId", [("shortcutId", _data.shortcutId as Any)])
|
||||
return ("inputQuickReplyShortcutId", [("shortcutId", ConstructorParameterDescription(_data.shortcutId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +96,8 @@ public extension Api {
|
|||
self.todoItemId = todoItemId
|
||||
self.pollOption = pollOption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputReplyToMessage", [("flags", self.flags as Any), ("replyToMsgId", self.replyToMsgId as Any), ("topMsgId", self.topMsgId as Any), ("replyToPeerId", self.replyToPeerId as Any), ("quoteText", self.quoteText as Any), ("quoteEntities", self.quoteEntities as Any), ("quoteOffset", self.quoteOffset as Any), ("monoforumPeerId", self.monoforumPeerId as Any), ("todoItemId", self.todoItemId as Any), ("pollOption", self.pollOption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputReplyToMessage", [("flags", ConstructorParameterDescription(self.flags)), ("replyToMsgId", ConstructorParameterDescription(self.replyToMsgId)), ("topMsgId", ConstructorParameterDescription(self.topMsgId)), ("replyToPeerId", ConstructorParameterDescription(self.replyToPeerId)), ("quoteText", ConstructorParameterDescription(self.quoteText)), ("quoteEntities", ConstructorParameterDescription(self.quoteEntities)), ("quoteOffset", ConstructorParameterDescription(self.quoteOffset)), ("monoforumPeerId", ConstructorParameterDescription(self.monoforumPeerId)), ("todoItemId", ConstructorParameterDescription(self.todoItemId)), ("pollOption", ConstructorParameterDescription(self.pollOption))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputReplyToMonoForum: TypeConstructorDescription {
|
||||
|
|
@ -105,8 +105,8 @@ public extension Api {
|
|||
public init(monoforumPeerId: Api.InputPeer) {
|
||||
self.monoforumPeerId = monoforumPeerId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputReplyToMonoForum", [("monoforumPeerId", self.monoforumPeerId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputReplyToMonoForum", [("monoforumPeerId", ConstructorParameterDescription(self.monoforumPeerId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputReplyToStory: TypeConstructorDescription {
|
||||
|
|
@ -116,8 +116,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.storyId = storyId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputReplyToStory", [("peer", self.peer as Any), ("storyId", self.storyId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputReplyToStory", [("peer", ConstructorParameterDescription(self.peer)), ("storyId", ConstructorParameterDescription(self.storyId))])
|
||||
}
|
||||
}
|
||||
case inputReplyToMessage(Cons_inputReplyToMessage)
|
||||
|
|
@ -177,14 +177,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputReplyToMessage(let _data):
|
||||
return ("inputReplyToMessage", [("flags", _data.flags as Any), ("replyToMsgId", _data.replyToMsgId as Any), ("topMsgId", _data.topMsgId as Any), ("replyToPeerId", _data.replyToPeerId as Any), ("quoteText", _data.quoteText as Any), ("quoteEntities", _data.quoteEntities as Any), ("quoteOffset", _data.quoteOffset as Any), ("monoforumPeerId", _data.monoforumPeerId as Any), ("todoItemId", _data.todoItemId as Any), ("pollOption", _data.pollOption as Any)])
|
||||
return ("inputReplyToMessage", [("flags", ConstructorParameterDescription(_data.flags)), ("replyToMsgId", ConstructorParameterDescription(_data.replyToMsgId)), ("topMsgId", ConstructorParameterDescription(_data.topMsgId)), ("replyToPeerId", ConstructorParameterDescription(_data.replyToPeerId)), ("quoteText", ConstructorParameterDescription(_data.quoteText)), ("quoteEntities", ConstructorParameterDescription(_data.quoteEntities)), ("quoteOffset", ConstructorParameterDescription(_data.quoteOffset)), ("monoforumPeerId", ConstructorParameterDescription(_data.monoforumPeerId)), ("todoItemId", ConstructorParameterDescription(_data.todoItemId)), ("pollOption", ConstructorParameterDescription(_data.pollOption))])
|
||||
case .inputReplyToMonoForum(let _data):
|
||||
return ("inputReplyToMonoForum", [("monoforumPeerId", _data.monoforumPeerId as Any)])
|
||||
return ("inputReplyToMonoForum", [("monoforumPeerId", ConstructorParameterDescription(_data.monoforumPeerId))])
|
||||
case .inputReplyToStory(let _data):
|
||||
return ("inputReplyToStory", [("peer", _data.peer as Any), ("storyId", _data.storyId as Any)])
|
||||
return ("inputReplyToStory", [("peer", ConstructorParameterDescription(_data.peer)), ("storyId", ConstructorParameterDescription(_data.storyId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -288,8 +288,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.savedId = savedId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSavedStarGiftChat", [("peer", self.peer as Any), ("savedId", self.savedId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSavedStarGiftChat", [("peer", ConstructorParameterDescription(self.peer)), ("savedId", ConstructorParameterDescription(self.savedId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputSavedStarGiftSlug: TypeConstructorDescription {
|
||||
|
|
@ -297,8 +297,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSavedStarGiftSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSavedStarGiftSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputSavedStarGiftUser: TypeConstructorDescription {
|
||||
|
|
@ -306,8 +306,8 @@ public extension Api {
|
|||
public init(msgId: Int32) {
|
||||
self.msgId = msgId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSavedStarGiftUser", [("msgId", self.msgId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSavedStarGiftUser", [("msgId", ConstructorParameterDescription(self.msgId))])
|
||||
}
|
||||
}
|
||||
case inputSavedStarGiftChat(Cons_inputSavedStarGiftChat)
|
||||
|
|
@ -338,14 +338,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputSavedStarGiftChat(let _data):
|
||||
return ("inputSavedStarGiftChat", [("peer", _data.peer as Any), ("savedId", _data.savedId as Any)])
|
||||
return ("inputSavedStarGiftChat", [("peer", ConstructorParameterDescription(_data.peer)), ("savedId", ConstructorParameterDescription(_data.savedId))])
|
||||
case .inputSavedStarGiftSlug(let _data):
|
||||
return ("inputSavedStarGiftSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputSavedStarGiftSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
case .inputSavedStarGiftUser(let _data):
|
||||
return ("inputSavedStarGiftUser", [("msgId", _data.msgId as Any)])
|
||||
return ("inputSavedStarGiftUser", [("msgId", ConstructorParameterDescription(_data.msgId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,8 +398,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSecureFile", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSecureFile", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputSecureFileUploaded: TypeConstructorDescription {
|
||||
|
|
@ -415,8 +415,8 @@ public extension Api {
|
|||
self.fileHash = fileHash
|
||||
self.secret = secret
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSecureFileUploaded", [("id", self.id as Any), ("parts", self.parts as Any), ("md5Checksum", self.md5Checksum as Any), ("fileHash", self.fileHash as Any), ("secret", self.secret as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSecureFileUploaded", [("id", ConstructorParameterDescription(self.id)), ("parts", ConstructorParameterDescription(self.parts)), ("md5Checksum", ConstructorParameterDescription(self.md5Checksum)), ("fileHash", ConstructorParameterDescription(self.fileHash)), ("secret", ConstructorParameterDescription(self.secret))])
|
||||
}
|
||||
}
|
||||
case inputSecureFile(Cons_inputSecureFile)
|
||||
|
|
@ -444,12 +444,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputSecureFile(let _data):
|
||||
return ("inputSecureFile", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputSecureFile", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputSecureFileUploaded(let _data):
|
||||
return ("inputSecureFileUploaded", [("id", _data.id as Any), ("parts", _data.parts as Any), ("md5Checksum", _data.md5Checksum as Any), ("fileHash", _data.fileHash as Any), ("secret", _data.secret as Any)])
|
||||
return ("inputSecureFileUploaded", [("id", ConstructorParameterDescription(_data.id)), ("parts", ConstructorParameterDescription(_data.parts)), ("md5Checksum", ConstructorParameterDescription(_data.md5Checksum)), ("fileHash", ConstructorParameterDescription(_data.fileHash)), ("secret", ConstructorParameterDescription(_data.secret))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -515,8 +515,8 @@ public extension Api {
|
|||
self.files = files
|
||||
self.plainData = plainData
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSecureValue", [("flags", self.flags as Any), ("type", self.type as Any), ("data", self.data as Any), ("frontSide", self.frontSide as Any), ("reverseSide", self.reverseSide as Any), ("selfie", self.selfie as Any), ("translation", self.translation as Any), ("files", self.files as Any), ("plainData", self.plainData as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSecureValue", [("flags", ConstructorParameterDescription(self.flags)), ("type", ConstructorParameterDescription(self.type)), ("data", ConstructorParameterDescription(self.data)), ("frontSide", ConstructorParameterDescription(self.frontSide)), ("reverseSide", ConstructorParameterDescription(self.reverseSide)), ("selfie", ConstructorParameterDescription(self.selfie)), ("translation", ConstructorParameterDescription(self.translation)), ("files", ConstructorParameterDescription(self.files)), ("plainData", ConstructorParameterDescription(self.plainData))])
|
||||
}
|
||||
}
|
||||
case inputSecureValue(Cons_inputSecureValue)
|
||||
|
|
@ -562,10 +562,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputSecureValue(let _data):
|
||||
return ("inputSecureValue", [("flags", _data.flags as Any), ("type", _data.type as Any), ("data", _data.data as Any), ("frontSide", _data.frontSide as Any), ("reverseSide", _data.reverseSide as Any), ("selfie", _data.selfie as Any), ("translation", _data.translation as Any), ("files", _data.files as Any), ("plainData", _data.plainData as Any)])
|
||||
return ("inputSecureValue", [("flags", ConstructorParameterDescription(_data.flags)), ("type", ConstructorParameterDescription(_data.type)), ("data", ConstructorParameterDescription(_data.data)), ("frontSide", ConstructorParameterDescription(_data.frontSide)), ("reverseSide", ConstructorParameterDescription(_data.reverseSide)), ("selfie", ConstructorParameterDescription(_data.selfie)), ("translation", ConstructorParameterDescription(_data.translation)), ("files", ConstructorParameterDescription(_data.files)), ("plainData", ConstructorParameterDescription(_data.plainData))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -651,8 +651,8 @@ public extension Api {
|
|||
self.message = message
|
||||
self.entities = entities
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputSingleMedia", [("flags", self.flags as Any), ("media", self.media as Any), ("randomId", self.randomId as Any), ("message", self.message as Any), ("entities", self.entities as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputSingleMedia", [("flags", ConstructorParameterDescription(self.flags)), ("media", ConstructorParameterDescription(self.media)), ("randomId", ConstructorParameterDescription(self.randomId)), ("message", ConstructorParameterDescription(self.message)), ("entities", ConstructorParameterDescription(self.entities))])
|
||||
}
|
||||
}
|
||||
case inputSingleMedia(Cons_inputSingleMedia)
|
||||
|
|
@ -678,10 +678,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputSingleMedia(let _data):
|
||||
return ("inputSingleMedia", [("flags", _data.flags as Any), ("media", _data.media as Any), ("randomId", _data.randomId as Any), ("message", _data.message as Any), ("entities", _data.entities as Any)])
|
||||
return ("inputSingleMedia", [("flags", ConstructorParameterDescription(_data.flags)), ("media", ConstructorParameterDescription(_data.media)), ("randomId", ConstructorParameterDescription(_data.randomId)), ("message", ConstructorParameterDescription(_data.message)), ("entities", ConstructorParameterDescription(_data.entities))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -723,8 +723,8 @@ public extension Api {
|
|||
public init(giftId: Int64) {
|
||||
self.giftId = giftId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStarGiftAuction", [("giftId", self.giftId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStarGiftAuction", [("giftId", ConstructorParameterDescription(self.giftId))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStarGiftAuctionSlug: TypeConstructorDescription {
|
||||
|
|
@ -732,8 +732,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStarGiftAuctionSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStarGiftAuctionSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
case inputStarGiftAuction(Cons_inputStarGiftAuction)
|
||||
|
|
@ -756,12 +756,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStarGiftAuction(let _data):
|
||||
return ("inputStarGiftAuction", [("giftId", _data.giftId as Any)])
|
||||
return ("inputStarGiftAuction", [("giftId", ConstructorParameterDescription(_data.giftId))])
|
||||
case .inputStarGiftAuctionSlug(let _data):
|
||||
return ("inputStarGiftAuctionSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputStarGiftAuctionSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -798,8 +798,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStarsTransaction", [("flags", self.flags as Any), ("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStarsTransaction", [("flags", ConstructorParameterDescription(self.flags)), ("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
case inputStarsTransaction(Cons_inputStarsTransaction)
|
||||
|
|
@ -816,10 +816,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStarsTransaction(let _data):
|
||||
return ("inputStarsTransaction", [("flags", _data.flags as Any), ("id", _data.id as Any)])
|
||||
return ("inputStarsTransaction", [("flags", ConstructorParameterDescription(_data.flags)), ("id", ConstructorParameterDescription(_data.id))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -846,8 +846,8 @@ public extension Api {
|
|||
public init(emoticon: String) {
|
||||
self.emoticon = emoticon
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickerSetDice", [("emoticon", self.emoticon as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickerSetDice", [("emoticon", ConstructorParameterDescription(self.emoticon))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStickerSetID: TypeConstructorDescription {
|
||||
|
|
@ -857,8 +857,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickerSetID", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickerSetID", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStickerSetShortName: TypeConstructorDescription {
|
||||
|
|
@ -866,8 +866,8 @@ public extension Api {
|
|||
public init(shortName: String) {
|
||||
self.shortName = shortName
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickerSetShortName", [("shortName", self.shortName as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickerSetShortName", [("shortName", ConstructorParameterDescription(self.shortName))])
|
||||
}
|
||||
}
|
||||
case inputStickerSetAnimatedEmoji
|
||||
|
|
@ -952,14 +952,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStickerSetAnimatedEmoji:
|
||||
return ("inputStickerSetAnimatedEmoji", [])
|
||||
case .inputStickerSetAnimatedEmojiAnimations:
|
||||
return ("inputStickerSetAnimatedEmojiAnimations", [])
|
||||
case .inputStickerSetDice(let _data):
|
||||
return ("inputStickerSetDice", [("emoticon", _data.emoticon as Any)])
|
||||
return ("inputStickerSetDice", [("emoticon", ConstructorParameterDescription(_data.emoticon))])
|
||||
case .inputStickerSetEmojiChannelDefaultStatuses:
|
||||
return ("inputStickerSetEmojiChannelDefaultStatuses", [])
|
||||
case .inputStickerSetEmojiDefaultStatuses:
|
||||
|
|
@ -971,11 +971,11 @@ public extension Api {
|
|||
case .inputStickerSetEmpty:
|
||||
return ("inputStickerSetEmpty", [])
|
||||
case .inputStickerSetID(let _data):
|
||||
return ("inputStickerSetID", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputStickerSetID", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputStickerSetPremiumGifts:
|
||||
return ("inputStickerSetPremiumGifts", [])
|
||||
case .inputStickerSetShortName(let _data):
|
||||
return ("inputStickerSetShortName", [("shortName", _data.shortName as Any)])
|
||||
return ("inputStickerSetShortName", [("shortName", ConstructorParameterDescription(_data.shortName))])
|
||||
case .inputStickerSetTonGifts:
|
||||
return ("inputStickerSetTonGifts", [])
|
||||
}
|
||||
|
|
@ -1061,8 +1061,8 @@ public extension Api {
|
|||
self.maskCoords = maskCoords
|
||||
self.keywords = keywords
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickerSetItem", [("flags", self.flags as Any), ("document", self.document as Any), ("emoji", self.emoji as Any), ("maskCoords", self.maskCoords as Any), ("keywords", self.keywords as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickerSetItem", [("flags", ConstructorParameterDescription(self.flags)), ("document", ConstructorParameterDescription(self.document)), ("emoji", ConstructorParameterDescription(self.emoji)), ("maskCoords", ConstructorParameterDescription(self.maskCoords)), ("keywords", ConstructorParameterDescription(self.keywords))])
|
||||
}
|
||||
}
|
||||
case inputStickerSetItem(Cons_inputStickerSetItem)
|
||||
|
|
@ -1086,10 +1086,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStickerSetItem(let _data):
|
||||
return ("inputStickerSetItem", [("flags", _data.flags as Any), ("document", _data.document as Any), ("emoji", _data.emoji as Any), ("maskCoords", _data.maskCoords as Any), ("keywords", _data.keywords as Any)])
|
||||
return ("inputStickerSetItem", [("flags", ConstructorParameterDescription(_data.flags)), ("document", ConstructorParameterDescription(_data.document)), ("emoji", ConstructorParameterDescription(_data.emoji)), ("maskCoords", ConstructorParameterDescription(_data.maskCoords)), ("keywords", ConstructorParameterDescription(_data.keywords))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1133,8 +1133,8 @@ public extension Api {
|
|||
public init(id: Api.InputDocument) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickeredMediaDocument", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickeredMediaDocument", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStickeredMediaPhoto: TypeConstructorDescription {
|
||||
|
|
@ -1142,8 +1142,8 @@ public extension Api {
|
|||
public init(id: Api.InputPhoto) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStickeredMediaPhoto", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStickeredMediaPhoto", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
case inputStickeredMediaDocument(Cons_inputStickeredMediaDocument)
|
||||
|
|
@ -1166,12 +1166,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStickeredMediaDocument(let _data):
|
||||
return ("inputStickeredMediaDocument", [("id", _data.id as Any)])
|
||||
return ("inputStickeredMediaDocument", [("id", ConstructorParameterDescription(_data.id))])
|
||||
case .inputStickeredMediaPhoto(let _data):
|
||||
return ("inputStickeredMediaPhoto", [("id", _data.id as Any)])
|
||||
return ("inputStickeredMediaPhoto", [("id", ConstructorParameterDescription(_data.id))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1218,8 +1218,8 @@ public extension Api {
|
|||
self.currency = currency
|
||||
self.amount = amount
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentAuthCode", [("flags", self.flags as Any), ("phoneNumber", self.phoneNumber as Any), ("phoneCodeHash", self.phoneCodeHash as Any), ("currency", self.currency as Any), ("amount", self.amount as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentAuthCode", [("flags", ConstructorParameterDescription(self.flags)), ("phoneNumber", ConstructorParameterDescription(self.phoneNumber)), ("phoneCodeHash", ConstructorParameterDescription(self.phoneCodeHash)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentGiftPremium: TypeConstructorDescription {
|
||||
|
|
@ -1231,8 +1231,8 @@ public extension Api {
|
|||
self.currency = currency
|
||||
self.amount = amount
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentGiftPremium", [("userId", self.userId as Any), ("currency", self.currency as Any), ("amount", self.amount as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentGiftPremium", [("userId", ConstructorParameterDescription(self.userId)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentPremiumGiftCode: TypeConstructorDescription {
|
||||
|
|
@ -1250,8 +1250,8 @@ public extension Api {
|
|||
self.amount = amount
|
||||
self.message = message
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentPremiumGiftCode", [("flags", self.flags as Any), ("users", self.users as Any), ("boostPeer", self.boostPeer as Any), ("currency", self.currency as Any), ("amount", self.amount as Any), ("message", self.message as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentPremiumGiftCode", [("flags", ConstructorParameterDescription(self.flags)), ("users", ConstructorParameterDescription(self.users)), ("boostPeer", ConstructorParameterDescription(self.boostPeer)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount)), ("message", ConstructorParameterDescription(self.message))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentPremiumGiveaway: TypeConstructorDescription {
|
||||
|
|
@ -1275,8 +1275,8 @@ public extension Api {
|
|||
self.currency = currency
|
||||
self.amount = amount
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentPremiumGiveaway", [("flags", self.flags as Any), ("boostPeer", self.boostPeer as Any), ("additionalPeers", self.additionalPeers as Any), ("countriesIso2", self.countriesIso2 as Any), ("prizeDescription", self.prizeDescription as Any), ("randomId", self.randomId as Any), ("untilDate", self.untilDate as Any), ("currency", self.currency as Any), ("amount", self.amount as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentPremiumGiveaway", [("flags", ConstructorParameterDescription(self.flags)), ("boostPeer", ConstructorParameterDescription(self.boostPeer)), ("additionalPeers", ConstructorParameterDescription(self.additionalPeers)), ("countriesIso2", ConstructorParameterDescription(self.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(self.prizeDescription)), ("randomId", ConstructorParameterDescription(self.randomId)), ("untilDate", ConstructorParameterDescription(self.untilDate)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentPremiumSubscription: TypeConstructorDescription {
|
||||
|
|
@ -1284,8 +1284,8 @@ public extension Api {
|
|||
public init(flags: Int32) {
|
||||
self.flags = flags
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentPremiumSubscription", [("flags", self.flags as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentPremiumSubscription", [("flags", ConstructorParameterDescription(self.flags))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentStarsGift: TypeConstructorDescription {
|
||||
|
|
@ -1299,8 +1299,8 @@ public extension Api {
|
|||
self.currency = currency
|
||||
self.amount = amount
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentStarsGift", [("userId", self.userId as Any), ("stars", self.stars as Any), ("currency", self.currency as Any), ("amount", self.amount as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentStarsGift", [("userId", ConstructorParameterDescription(self.userId)), ("stars", ConstructorParameterDescription(self.stars)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentStarsGiveaway: TypeConstructorDescription {
|
||||
|
|
@ -1328,8 +1328,8 @@ public extension Api {
|
|||
self.amount = amount
|
||||
self.users = users
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentStarsGiveaway", [("flags", self.flags as Any), ("stars", self.stars as Any), ("boostPeer", self.boostPeer as Any), ("additionalPeers", self.additionalPeers as Any), ("countriesIso2", self.countriesIso2 as Any), ("prizeDescription", self.prizeDescription as Any), ("randomId", self.randomId as Any), ("untilDate", self.untilDate as Any), ("currency", self.currency as Any), ("amount", self.amount as Any), ("users", self.users as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentStarsGiveaway", [("flags", ConstructorParameterDescription(self.flags)), ("stars", ConstructorParameterDescription(self.stars)), ("boostPeer", ConstructorParameterDescription(self.boostPeer)), ("additionalPeers", ConstructorParameterDescription(self.additionalPeers)), ("countriesIso2", ConstructorParameterDescription(self.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(self.prizeDescription)), ("randomId", ConstructorParameterDescription(self.randomId)), ("untilDate", ConstructorParameterDescription(self.untilDate)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount)), ("users", ConstructorParameterDescription(self.users))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputStorePaymentStarsTopup: TypeConstructorDescription {
|
||||
|
|
@ -1345,8 +1345,8 @@ public extension Api {
|
|||
self.amount = amount
|
||||
self.spendPurposePeer = spendPurposePeer
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputStorePaymentStarsTopup", [("flags", self.flags as Any), ("stars", self.stars as Any), ("currency", self.currency as Any), ("amount", self.amount as Any), ("spendPurposePeer", self.spendPurposePeer as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputStorePaymentStarsTopup", [("flags", ConstructorParameterDescription(self.flags)), ("stars", ConstructorParameterDescription(self.stars)), ("currency", ConstructorParameterDescription(self.currency)), ("amount", ConstructorParameterDescription(self.amount)), ("spendPurposePeer", ConstructorParameterDescription(self.spendPurposePeer))])
|
||||
}
|
||||
}
|
||||
case inputStorePaymentAuthCode(Cons_inputStorePaymentAuthCode)
|
||||
|
|
@ -1485,24 +1485,24 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputStorePaymentAuthCode(let _data):
|
||||
return ("inputStorePaymentAuthCode", [("flags", _data.flags as Any), ("phoneNumber", _data.phoneNumber as Any), ("phoneCodeHash", _data.phoneCodeHash as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any)])
|
||||
return ("inputStorePaymentAuthCode", [("flags", ConstructorParameterDescription(_data.flags)), ("phoneNumber", ConstructorParameterDescription(_data.phoneNumber)), ("phoneCodeHash", ConstructorParameterDescription(_data.phoneCodeHash)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount))])
|
||||
case .inputStorePaymentGiftPremium(let _data):
|
||||
return ("inputStorePaymentGiftPremium", [("userId", _data.userId as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any)])
|
||||
return ("inputStorePaymentGiftPremium", [("userId", ConstructorParameterDescription(_data.userId)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount))])
|
||||
case .inputStorePaymentPremiumGiftCode(let _data):
|
||||
return ("inputStorePaymentPremiumGiftCode", [("flags", _data.flags as Any), ("users", _data.users as Any), ("boostPeer", _data.boostPeer as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any), ("message", _data.message as Any)])
|
||||
return ("inputStorePaymentPremiumGiftCode", [("flags", ConstructorParameterDescription(_data.flags)), ("users", ConstructorParameterDescription(_data.users)), ("boostPeer", ConstructorParameterDescription(_data.boostPeer)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount)), ("message", ConstructorParameterDescription(_data.message))])
|
||||
case .inputStorePaymentPremiumGiveaway(let _data):
|
||||
return ("inputStorePaymentPremiumGiveaway", [("flags", _data.flags as Any), ("boostPeer", _data.boostPeer as Any), ("additionalPeers", _data.additionalPeers as Any), ("countriesIso2", _data.countriesIso2 as Any), ("prizeDescription", _data.prizeDescription as Any), ("randomId", _data.randomId as Any), ("untilDate", _data.untilDate as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any)])
|
||||
return ("inputStorePaymentPremiumGiveaway", [("flags", ConstructorParameterDescription(_data.flags)), ("boostPeer", ConstructorParameterDescription(_data.boostPeer)), ("additionalPeers", ConstructorParameterDescription(_data.additionalPeers)), ("countriesIso2", ConstructorParameterDescription(_data.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(_data.prizeDescription)), ("randomId", ConstructorParameterDescription(_data.randomId)), ("untilDate", ConstructorParameterDescription(_data.untilDate)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount))])
|
||||
case .inputStorePaymentPremiumSubscription(let _data):
|
||||
return ("inputStorePaymentPremiumSubscription", [("flags", _data.flags as Any)])
|
||||
return ("inputStorePaymentPremiumSubscription", [("flags", ConstructorParameterDescription(_data.flags))])
|
||||
case .inputStorePaymentStarsGift(let _data):
|
||||
return ("inputStorePaymentStarsGift", [("userId", _data.userId as Any), ("stars", _data.stars as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any)])
|
||||
return ("inputStorePaymentStarsGift", [("userId", ConstructorParameterDescription(_data.userId)), ("stars", ConstructorParameterDescription(_data.stars)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount))])
|
||||
case .inputStorePaymentStarsGiveaway(let _data):
|
||||
return ("inputStorePaymentStarsGiveaway", [("flags", _data.flags as Any), ("stars", _data.stars as Any), ("boostPeer", _data.boostPeer as Any), ("additionalPeers", _data.additionalPeers as Any), ("countriesIso2", _data.countriesIso2 as Any), ("prizeDescription", _data.prizeDescription as Any), ("randomId", _data.randomId as Any), ("untilDate", _data.untilDate as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any), ("users", _data.users as Any)])
|
||||
return ("inputStorePaymentStarsGiveaway", [("flags", ConstructorParameterDescription(_data.flags)), ("stars", ConstructorParameterDescription(_data.stars)), ("boostPeer", ConstructorParameterDescription(_data.boostPeer)), ("additionalPeers", ConstructorParameterDescription(_data.additionalPeers)), ("countriesIso2", ConstructorParameterDescription(_data.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(_data.prizeDescription)), ("randomId", ConstructorParameterDescription(_data.randomId)), ("untilDate", ConstructorParameterDescription(_data.untilDate)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount)), ("users", ConstructorParameterDescription(_data.users))])
|
||||
case .inputStorePaymentStarsTopup(let _data):
|
||||
return ("inputStorePaymentStarsTopup", [("flags", _data.flags as Any), ("stars", _data.stars as Any), ("currency", _data.currency as Any), ("amount", _data.amount as Any), ("spendPurposePeer", _data.spendPurposePeer as Any)])
|
||||
return ("inputStorePaymentStarsTopup", [("flags", ConstructorParameterDescription(_data.flags)), ("stars", ConstructorParameterDescription(_data.stars)), ("currency", ConstructorParameterDescription(_data.currency)), ("amount", ConstructorParameterDescription(_data.amount)), ("spendPurposePeer", ConstructorParameterDescription(_data.spendPurposePeer))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputTheme", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputTheme", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputThemeSlug: TypeConstructorDescription {
|
||||
|
|
@ -16,8 +16,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputThemeSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputThemeSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
case inputTheme(Cons_inputTheme)
|
||||
|
|
@ -41,12 +41,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputTheme(let _data):
|
||||
return ("inputTheme", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputTheme", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputThemeSlug(let _data):
|
||||
return ("inputThemeSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputThemeSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +96,8 @@ public extension Api {
|
|||
self.wallpaper = wallpaper
|
||||
self.wallpaperSettings = wallpaperSettings
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputThemeSettings", [("flags", self.flags as Any), ("baseTheme", self.baseTheme as Any), ("accentColor", self.accentColor as Any), ("outboxAccentColor", self.outboxAccentColor as Any), ("messageColors", self.messageColors as Any), ("wallpaper", self.wallpaper as Any), ("wallpaperSettings", self.wallpaperSettings as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputThemeSettings", [("flags", ConstructorParameterDescription(self.flags)), ("baseTheme", ConstructorParameterDescription(self.baseTheme)), ("accentColor", ConstructorParameterDescription(self.accentColor)), ("outboxAccentColor", ConstructorParameterDescription(self.outboxAccentColor)), ("messageColors", ConstructorParameterDescription(self.messageColors)), ("wallpaper", ConstructorParameterDescription(self.wallpaper)), ("wallpaperSettings", ConstructorParameterDescription(self.wallpaperSettings))])
|
||||
}
|
||||
}
|
||||
case inputThemeSettings(Cons_inputThemeSettings)
|
||||
|
|
@ -131,10 +131,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputThemeSettings(let _data):
|
||||
return ("inputThemeSettings", [("flags", _data.flags as Any), ("baseTheme", _data.baseTheme as Any), ("accentColor", _data.accentColor as Any), ("outboxAccentColor", _data.outboxAccentColor as Any), ("messageColors", _data.messageColors as Any), ("wallpaper", _data.wallpaper as Any), ("wallpaperSettings", _data.wallpaperSettings as Any)])
|
||||
return ("inputThemeSettings", [("flags", ConstructorParameterDescription(_data.flags)), ("baseTheme", ConstructorParameterDescription(_data.baseTheme)), ("accentColor", ConstructorParameterDescription(_data.accentColor)), ("outboxAccentColor", ConstructorParameterDescription(_data.outboxAccentColor)), ("messageColors", ConstructorParameterDescription(_data.messageColors)), ("wallpaper", ConstructorParameterDescription(_data.wallpaper)), ("wallpaperSettings", ConstructorParameterDescription(_data.wallpaperSettings))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,8 +194,8 @@ public extension Api {
|
|||
self.userId = userId
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputUser", [("userId", self.userId as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputUser", [("userId", ConstructorParameterDescription(self.userId)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputUserFromMessage: TypeConstructorDescription {
|
||||
|
|
@ -207,8 +207,8 @@ public extension Api {
|
|||
self.msgId = msgId
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputUserFromMessage", [("peer", self.peer as Any), ("msgId", self.msgId as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputUserFromMessage", [("peer", ConstructorParameterDescription(self.peer)), ("msgId", ConstructorParameterDescription(self.msgId)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
case inputUser(Cons_inputUser)
|
||||
|
|
@ -246,14 +246,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputUser(let _data):
|
||||
return ("inputUser", [("userId", _data.userId as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputUser", [("userId", ConstructorParameterDescription(_data.userId)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputUserEmpty:
|
||||
return ("inputUserEmpty", [])
|
||||
case .inputUserFromMessage(let _data):
|
||||
return ("inputUserFromMessage", [("peer", _data.peer as Any), ("msgId", _data.msgId as Any), ("userId", _data.userId as Any)])
|
||||
return ("inputUserFromMessage", [("peer", ConstructorParameterDescription(_data.peer)), ("msgId", ConstructorParameterDescription(_data.msgId)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .inputUserSelf:
|
||||
return ("inputUserSelf", [])
|
||||
}
|
||||
|
|
@ -309,8 +309,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWallPaper", [("id", self.id as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWallPaper", [("id", ConstructorParameterDescription(self.id)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputWallPaperNoFile: TypeConstructorDescription {
|
||||
|
|
@ -318,8 +318,8 @@ public extension Api {
|
|||
public init(id: Int64) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWallPaperNoFile", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWallPaperNoFile", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputWallPaperSlug: TypeConstructorDescription {
|
||||
|
|
@ -327,8 +327,8 @@ public extension Api {
|
|||
public init(slug: String) {
|
||||
self.slug = slug
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWallPaperSlug", [("slug", self.slug as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWallPaperSlug", [("slug", ConstructorParameterDescription(self.slug))])
|
||||
}
|
||||
}
|
||||
case inputWallPaper(Cons_inputWallPaper)
|
||||
|
|
@ -359,14 +359,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputWallPaper(let _data):
|
||||
return ("inputWallPaper", [("id", _data.id as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputWallPaper", [("id", ConstructorParameterDescription(_data.id)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
case .inputWallPaperNoFile(let _data):
|
||||
return ("inputWallPaperNoFile", [("id", _data.id as Any)])
|
||||
return ("inputWallPaperNoFile", [("id", ConstructorParameterDescription(_data.id))])
|
||||
case .inputWallPaperSlug(let _data):
|
||||
return ("inputWallPaperSlug", [("slug", _data.slug as Any)])
|
||||
return ("inputWallPaperSlug", [("slug", ConstructorParameterDescription(_data.slug))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,8 +421,8 @@ public extension Api {
|
|||
self.mimeType = mimeType
|
||||
self.attributes = attributes
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWebDocument", [("url", self.url as Any), ("size", self.size as Any), ("mimeType", self.mimeType as Any), ("attributes", self.attributes as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWebDocument", [("url", ConstructorParameterDescription(self.url)), ("size", ConstructorParameterDescription(self.size)), ("mimeType", ConstructorParameterDescription(self.mimeType)), ("attributes", ConstructorParameterDescription(self.attributes))])
|
||||
}
|
||||
}
|
||||
case inputWebDocument(Cons_inputWebDocument)
|
||||
|
|
@ -445,10 +445,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputWebDocument(let _data):
|
||||
return ("inputWebDocument", [("url", _data.url as Any), ("size", _data.size as Any), ("mimeType", _data.mimeType as Any), ("attributes", _data.attributes as Any)])
|
||||
return ("inputWebDocument", [("url", ConstructorParameterDescription(_data.url)), ("size", ConstructorParameterDescription(_data.size)), ("mimeType", ConstructorParameterDescription(_data.mimeType)), ("attributes", ConstructorParameterDescription(_data.attributes))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -489,8 +489,8 @@ public extension Api {
|
|||
self.title = title
|
||||
self.performer = performer
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", self.flags as Any), ("document", self.document as Any), ("title", self.title as Any), ("performer", self.performer as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", ConstructorParameterDescription(self.flags)), ("document", ConstructorParameterDescription(self.document)), ("title", ConstructorParameterDescription(self.title)), ("performer", ConstructorParameterDescription(self.performer))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputWebFileGeoPointLocation: TypeConstructorDescription {
|
||||
|
|
@ -508,8 +508,8 @@ public extension Api {
|
|||
self.zoom = zoom
|
||||
self.scale = scale
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", self.geoPoint as Any), ("accessHash", self.accessHash as Any), ("w", self.w as Any), ("h", self.h as Any), ("zoom", self.zoom as Any), ("scale", self.scale as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", ConstructorParameterDescription(self.geoPoint)), ("accessHash", ConstructorParameterDescription(self.accessHash)), ("w", ConstructorParameterDescription(self.w)), ("h", ConstructorParameterDescription(self.h)), ("zoom", ConstructorParameterDescription(self.zoom)), ("scale", ConstructorParameterDescription(self.scale))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputWebFileLocation: TypeConstructorDescription {
|
||||
|
|
@ -519,8 +519,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.accessHash = accessHash
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputWebFileLocation", [("url", self.url as Any), ("accessHash", self.accessHash as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputWebFileLocation", [("url", ConstructorParameterDescription(self.url)), ("accessHash", ConstructorParameterDescription(self.accessHash))])
|
||||
}
|
||||
}
|
||||
case inputWebFileAudioAlbumThumbLocation(Cons_inputWebFileAudioAlbumThumbLocation)
|
||||
|
|
@ -565,14 +565,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputWebFileAudioAlbumThumbLocation(let _data):
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", _data.flags as Any), ("document", _data.document as Any), ("title", _data.title as Any), ("performer", _data.performer as Any)])
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", ConstructorParameterDescription(_data.flags)), ("document", ConstructorParameterDescription(_data.document)), ("title", ConstructorParameterDescription(_data.title)), ("performer", ConstructorParameterDescription(_data.performer))])
|
||||
case .inputWebFileGeoPointLocation(let _data):
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", _data.geoPoint as Any), ("accessHash", _data.accessHash as Any), ("w", _data.w as Any), ("h", _data.h as Any), ("zoom", _data.zoom as Any), ("scale", _data.scale as Any)])
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", ConstructorParameterDescription(_data.geoPoint)), ("accessHash", ConstructorParameterDescription(_data.accessHash)), ("w", ConstructorParameterDescription(_data.w)), ("h", ConstructorParameterDescription(_data.h)), ("zoom", ConstructorParameterDescription(_data.zoom)), ("scale", ConstructorParameterDescription(_data.scale))])
|
||||
case .inputWebFileLocation(let _data):
|
||||
return ("inputWebFileLocation", [("url", _data.url as Any), ("accessHash", _data.accessHash as Any)])
|
||||
return ("inputWebFileLocation", [("url", ConstructorParameterDescription(_data.url)), ("accessHash", ConstructorParameterDescription(_data.accessHash))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -667,8 +667,8 @@ public extension Api {
|
|||
self.termsUrl = termsUrl
|
||||
self.subscriptionPeriod = subscriptionPeriod
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("invoice", [("flags", self.flags as Any), ("currency", self.currency as Any), ("prices", self.prices as Any), ("maxTipAmount", self.maxTipAmount as Any), ("suggestedTipAmounts", self.suggestedTipAmounts as Any), ("termsUrl", self.termsUrl as Any), ("subscriptionPeriod", self.subscriptionPeriod as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("invoice", [("flags", ConstructorParameterDescription(self.flags)), ("currency", ConstructorParameterDescription(self.currency)), ("prices", ConstructorParameterDescription(self.prices)), ("maxTipAmount", ConstructorParameterDescription(self.maxTipAmount)), ("suggestedTipAmounts", ConstructorParameterDescription(self.suggestedTipAmounts)), ("termsUrl", ConstructorParameterDescription(self.termsUrl)), ("subscriptionPeriod", ConstructorParameterDescription(self.subscriptionPeriod))])
|
||||
}
|
||||
}
|
||||
case invoice(Cons_invoice)
|
||||
|
|
@ -706,10 +706,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .invoice(let _data):
|
||||
return ("invoice", [("flags", _data.flags as Any), ("currency", _data.currency as Any), ("prices", _data.prices as Any), ("maxTipAmount", _data.maxTipAmount as Any), ("suggestedTipAmounts", _data.suggestedTipAmounts as Any), ("termsUrl", _data.termsUrl as Any), ("subscriptionPeriod", _data.subscriptionPeriod as Any)])
|
||||
return ("invoice", [("flags", ConstructorParameterDescription(_data.flags)), ("currency", ConstructorParameterDescription(_data.currency)), ("prices", ConstructorParameterDescription(_data.prices)), ("maxTipAmount", ConstructorParameterDescription(_data.maxTipAmount)), ("suggestedTipAmounts", ConstructorParameterDescription(_data.suggestedTipAmounts)), ("termsUrl", ConstructorParameterDescription(_data.termsUrl)), ("subscriptionPeriod", ConstructorParameterDescription(_data.subscriptionPeriod))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -765,8 +765,8 @@ public extension Api {
|
|||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonObjectValue", [("key", self.key as Any), ("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonObjectValue", [("key", ConstructorParameterDescription(self.key)), ("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
case jsonObjectValue(Cons_jsonObjectValue)
|
||||
|
|
@ -783,10 +783,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .jsonObjectValue(let _data):
|
||||
return ("jsonObjectValue", [("key", _data.key as Any), ("value", _data.value as Any)])
|
||||
return ("jsonObjectValue", [("key", ConstructorParameterDescription(_data.key)), ("value", ConstructorParameterDescription(_data.value))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -815,8 +815,8 @@ public extension Api {
|
|||
public init(value: [Api.JSONValue]) {
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonArray", [("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonArray", [("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
public class Cons_jsonBool: TypeConstructorDescription {
|
||||
|
|
@ -824,8 +824,8 @@ public extension Api {
|
|||
public init(value: Api.Bool) {
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonBool", [("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonBool", [("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
public class Cons_jsonNumber: TypeConstructorDescription {
|
||||
|
|
@ -833,8 +833,8 @@ public extension Api {
|
|||
public init(value: Double) {
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonNumber", [("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonNumber", [("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
public class Cons_jsonObject: TypeConstructorDescription {
|
||||
|
|
@ -842,8 +842,8 @@ public extension Api {
|
|||
public init(value: [Api.JSONObjectValue]) {
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonObject", [("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonObject", [("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
public class Cons_jsonString: TypeConstructorDescription {
|
||||
|
|
@ -851,8 +851,8 @@ public extension Api {
|
|||
public init(value: String) {
|
||||
self.value = value
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("jsonString", [("value", self.value as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("jsonString", [("value", ConstructorParameterDescription(self.value))])
|
||||
}
|
||||
}
|
||||
case jsonArray(Cons_jsonArray)
|
||||
|
|
@ -910,20 +910,20 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .jsonArray(let _data):
|
||||
return ("jsonArray", [("value", _data.value as Any)])
|
||||
return ("jsonArray", [("value", ConstructorParameterDescription(_data.value))])
|
||||
case .jsonBool(let _data):
|
||||
return ("jsonBool", [("value", _data.value as Any)])
|
||||
return ("jsonBool", [("value", ConstructorParameterDescription(_data.value))])
|
||||
case .jsonNull:
|
||||
return ("jsonNull", [])
|
||||
case .jsonNumber(let _data):
|
||||
return ("jsonNumber", [("value", _data.value as Any)])
|
||||
return ("jsonNumber", [("value", ConstructorParameterDescription(_data.value))])
|
||||
case .jsonObject(let _data):
|
||||
return ("jsonObject", [("value", _data.value as Any)])
|
||||
return ("jsonObject", [("value", ConstructorParameterDescription(_data.value))])
|
||||
case .jsonString(let _data):
|
||||
return ("jsonString", [("value", _data.value as Any)])
|
||||
return ("jsonString", [("value", ConstructorParameterDescription(_data.value))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1010,8 +1010,8 @@ public extension Api {
|
|||
self.peerType = peerType
|
||||
self.maxQuantity = maxQuantity
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputKeyboardButtonRequestPeer", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("buttonId", self.buttonId as Any), ("peerType", self.peerType as Any), ("maxQuantity", self.maxQuantity as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputKeyboardButtonRequestPeer", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("buttonId", ConstructorParameterDescription(self.buttonId)), ("peerType", ConstructorParameterDescription(self.peerType)), ("maxQuantity", ConstructorParameterDescription(self.maxQuantity))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputKeyboardButtonUrlAuth: TypeConstructorDescription {
|
||||
|
|
@ -1029,8 +1029,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.bot = bot
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputKeyboardButtonUrlAuth", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("fwdText", self.fwdText as Any), ("url", self.url as Any), ("bot", self.bot as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputKeyboardButtonUrlAuth", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("fwdText", ConstructorParameterDescription(self.fwdText)), ("url", ConstructorParameterDescription(self.url)), ("bot", ConstructorParameterDescription(self.bot))])
|
||||
}
|
||||
}
|
||||
public class Cons_inputKeyboardButtonUserProfile: TypeConstructorDescription {
|
||||
|
|
@ -1044,8 +1044,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputKeyboardButtonUserProfile", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputKeyboardButtonUserProfile", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButton: TypeConstructorDescription {
|
||||
|
|
@ -1057,8 +1057,8 @@ public extension Api {
|
|||
self.style = style
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButton", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButton", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonBuy: TypeConstructorDescription {
|
||||
|
|
@ -1070,8 +1070,8 @@ public extension Api {
|
|||
self.style = style
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonBuy", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonBuy", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonCallback: TypeConstructorDescription {
|
||||
|
|
@ -1085,8 +1085,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.data = data
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonCallback", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("data", self.data as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonCallback", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("data", ConstructorParameterDescription(self.data))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonCopy: TypeConstructorDescription {
|
||||
|
|
@ -1100,8 +1100,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.copyText = copyText
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonCopy", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("copyText", self.copyText as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonCopy", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("copyText", ConstructorParameterDescription(self.copyText))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonGame: TypeConstructorDescription {
|
||||
|
|
@ -1113,8 +1113,8 @@ public extension Api {
|
|||
self.style = style
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonGame", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonGame", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonRequestGeoLocation: TypeConstructorDescription {
|
||||
|
|
@ -1126,8 +1126,8 @@ public extension Api {
|
|||
self.style = style
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonRequestGeoLocation", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonRequestGeoLocation", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonRequestPeer: TypeConstructorDescription {
|
||||
|
|
@ -1145,8 +1145,8 @@ public extension Api {
|
|||
self.peerType = peerType
|
||||
self.maxQuantity = maxQuantity
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonRequestPeer", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("buttonId", self.buttonId as Any), ("peerType", self.peerType as Any), ("maxQuantity", self.maxQuantity as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonRequestPeer", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("buttonId", ConstructorParameterDescription(self.buttonId)), ("peerType", ConstructorParameterDescription(self.peerType)), ("maxQuantity", ConstructorParameterDescription(self.maxQuantity))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonRequestPhone: TypeConstructorDescription {
|
||||
|
|
@ -1158,8 +1158,8 @@ public extension Api {
|
|||
self.style = style
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonRequestPhone", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonRequestPhone", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonRequestPoll: TypeConstructorDescription {
|
||||
|
|
@ -1173,8 +1173,8 @@ public extension Api {
|
|||
self.quiz = quiz
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonRequestPoll", [("flags", self.flags as Any), ("style", self.style as Any), ("quiz", self.quiz as Any), ("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonRequestPoll", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("quiz", ConstructorParameterDescription(self.quiz)), ("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonSimpleWebView: TypeConstructorDescription {
|
||||
|
|
@ -1188,8 +1188,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.url = url
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonSimpleWebView", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("url", self.url as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonSimpleWebView", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("url", ConstructorParameterDescription(self.url))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonSwitchInline: TypeConstructorDescription {
|
||||
|
|
@ -1205,8 +1205,8 @@ public extension Api {
|
|||
self.query = query
|
||||
self.peerTypes = peerTypes
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonSwitchInline", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("query", self.query as Any), ("peerTypes", self.peerTypes as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonSwitchInline", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("query", ConstructorParameterDescription(self.query)), ("peerTypes", ConstructorParameterDescription(self.peerTypes))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonUrl: TypeConstructorDescription {
|
||||
|
|
@ -1220,8 +1220,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.url = url
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonUrl", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("url", self.url as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonUrl", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("url", ConstructorParameterDescription(self.url))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonUrlAuth: TypeConstructorDescription {
|
||||
|
|
@ -1239,8 +1239,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.buttonId = buttonId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonUrlAuth", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("fwdText", self.fwdText as Any), ("url", self.url as Any), ("buttonId", self.buttonId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonUrlAuth", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("fwdText", ConstructorParameterDescription(self.fwdText)), ("url", ConstructorParameterDescription(self.url)), ("buttonId", ConstructorParameterDescription(self.buttonId))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonUserProfile: TypeConstructorDescription {
|
||||
|
|
@ -1254,8 +1254,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonUserProfile", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonUserProfile", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
public class Cons_keyboardButtonWebView: TypeConstructorDescription {
|
||||
|
|
@ -1269,8 +1269,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.url = url
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("keyboardButtonWebView", [("flags", self.flags as Any), ("style", self.style as Any), ("text", self.text as Any), ("url", self.url as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("keyboardButtonWebView", [("flags", ConstructorParameterDescription(self.flags)), ("style", ConstructorParameterDescription(self.style)), ("text", ConstructorParameterDescription(self.text)), ("url", ConstructorParameterDescription(self.url))])
|
||||
}
|
||||
}
|
||||
case inputKeyboardButtonRequestPeer(Cons_inputKeyboardButtonRequestPeer)
|
||||
|
|
@ -1511,44 +1511,44 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputKeyboardButtonRequestPeer(let _data):
|
||||
return ("inputKeyboardButtonRequestPeer", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("buttonId", _data.buttonId as Any), ("peerType", _data.peerType as Any), ("maxQuantity", _data.maxQuantity as Any)])
|
||||
return ("inputKeyboardButtonRequestPeer", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("buttonId", ConstructorParameterDescription(_data.buttonId)), ("peerType", ConstructorParameterDescription(_data.peerType)), ("maxQuantity", ConstructorParameterDescription(_data.maxQuantity))])
|
||||
case .inputKeyboardButtonUrlAuth(let _data):
|
||||
return ("inputKeyboardButtonUrlAuth", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("fwdText", _data.fwdText as Any), ("url", _data.url as Any), ("bot", _data.bot as Any)])
|
||||
return ("inputKeyboardButtonUrlAuth", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("fwdText", ConstructorParameterDescription(_data.fwdText)), ("url", ConstructorParameterDescription(_data.url)), ("bot", ConstructorParameterDescription(_data.bot))])
|
||||
case .inputKeyboardButtonUserProfile(let _data):
|
||||
return ("inputKeyboardButtonUserProfile", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("userId", _data.userId as Any)])
|
||||
return ("inputKeyboardButtonUserProfile", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .keyboardButton(let _data):
|
||||
return ("keyboardButton", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButton", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonBuy(let _data):
|
||||
return ("keyboardButtonBuy", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButtonBuy", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonCallback(let _data):
|
||||
return ("keyboardButtonCallback", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("data", _data.data as Any)])
|
||||
return ("keyboardButtonCallback", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("data", ConstructorParameterDescription(_data.data))])
|
||||
case .keyboardButtonCopy(let _data):
|
||||
return ("keyboardButtonCopy", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("copyText", _data.copyText as Any)])
|
||||
return ("keyboardButtonCopy", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("copyText", ConstructorParameterDescription(_data.copyText))])
|
||||
case .keyboardButtonGame(let _data):
|
||||
return ("keyboardButtonGame", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButtonGame", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonRequestGeoLocation(let _data):
|
||||
return ("keyboardButtonRequestGeoLocation", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButtonRequestGeoLocation", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonRequestPeer(let _data):
|
||||
return ("keyboardButtonRequestPeer", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("buttonId", _data.buttonId as Any), ("peerType", _data.peerType as Any), ("maxQuantity", _data.maxQuantity as Any)])
|
||||
return ("keyboardButtonRequestPeer", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("buttonId", ConstructorParameterDescription(_data.buttonId)), ("peerType", ConstructorParameterDescription(_data.peerType)), ("maxQuantity", ConstructorParameterDescription(_data.maxQuantity))])
|
||||
case .keyboardButtonRequestPhone(let _data):
|
||||
return ("keyboardButtonRequestPhone", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButtonRequestPhone", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonRequestPoll(let _data):
|
||||
return ("keyboardButtonRequestPoll", [("flags", _data.flags as Any), ("style", _data.style as Any), ("quiz", _data.quiz as Any), ("text", _data.text as Any)])
|
||||
return ("keyboardButtonRequestPoll", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("quiz", ConstructorParameterDescription(_data.quiz)), ("text", ConstructorParameterDescription(_data.text))])
|
||||
case .keyboardButtonSimpleWebView(let _data):
|
||||
return ("keyboardButtonSimpleWebView", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("url", _data.url as Any)])
|
||||
return ("keyboardButtonSimpleWebView", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("url", ConstructorParameterDescription(_data.url))])
|
||||
case .keyboardButtonSwitchInline(let _data):
|
||||
return ("keyboardButtonSwitchInline", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("query", _data.query as Any), ("peerTypes", _data.peerTypes as Any)])
|
||||
return ("keyboardButtonSwitchInline", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("query", ConstructorParameterDescription(_data.query)), ("peerTypes", ConstructorParameterDescription(_data.peerTypes))])
|
||||
case .keyboardButtonUrl(let _data):
|
||||
return ("keyboardButtonUrl", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("url", _data.url as Any)])
|
||||
return ("keyboardButtonUrl", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("url", ConstructorParameterDescription(_data.url))])
|
||||
case .keyboardButtonUrlAuth(let _data):
|
||||
return ("keyboardButtonUrlAuth", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("fwdText", _data.fwdText as Any), ("url", _data.url as Any), ("buttonId", _data.buttonId as Any)])
|
||||
return ("keyboardButtonUrlAuth", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("fwdText", ConstructorParameterDescription(_data.fwdText)), ("url", ConstructorParameterDescription(_data.url)), ("buttonId", ConstructorParameterDescription(_data.buttonId))])
|
||||
case .keyboardButtonUserProfile(let _data):
|
||||
return ("keyboardButtonUserProfile", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("userId", _data.userId as Any)])
|
||||
return ("keyboardButtonUserProfile", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .keyboardButtonWebView(let _data):
|
||||
return ("keyboardButtonWebView", [("flags", _data.flags as Any), ("style", _data.style as Any), ("text", _data.text as Any), ("url", _data.url as Any)])
|
||||
return ("keyboardButtonWebView", [("flags", ConstructorParameterDescription(_data.flags)), ("style", ConstructorParameterDescription(_data.style)), ("text", ConstructorParameterDescription(_data.text)), ("url", ConstructorParameterDescription(_data.url))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,8 +9,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageEntityMentionName", [("offset", self.offset as Any), ("length", self.length as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessageEntityMentionName", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityBankCard: TypeConstructorDescription {
|
||||
|
|
@ -20,8 +20,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityBankCard", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityBankCard", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityBlockquote: TypeConstructorDescription {
|
||||
|
|
@ -33,8 +33,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityBlockquote", [("flags", self.flags as Any), ("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityBlockquote", [("flags", ConstructorParameterDescription(self.flags)), ("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityBold: TypeConstructorDescription {
|
||||
|
|
@ -44,8 +44,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityBold", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityBold", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityBotCommand: TypeConstructorDescription {
|
||||
|
|
@ -55,8 +55,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityBotCommand", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityBotCommand", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityCashtag: TypeConstructorDescription {
|
||||
|
|
@ -66,8 +66,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityCashtag", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityCashtag", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityCode: TypeConstructorDescription {
|
||||
|
|
@ -77,8 +77,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityCode", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityCode", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityCustomEmoji: TypeConstructorDescription {
|
||||
|
|
@ -90,8 +90,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.documentId = documentId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityCustomEmoji", [("offset", self.offset as Any), ("length", self.length as Any), ("documentId", self.documentId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityCustomEmoji", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("documentId", ConstructorParameterDescription(self.documentId))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityDiffDelete: TypeConstructorDescription {
|
||||
|
|
@ -101,8 +101,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityDiffDelete", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityDiffDelete", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityDiffInsert: TypeConstructorDescription {
|
||||
|
|
@ -112,8 +112,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityDiffInsert", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityDiffInsert", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityDiffReplace: TypeConstructorDescription {
|
||||
|
|
@ -125,8 +125,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.oldText = oldText
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityDiffReplace", [("offset", self.offset as Any), ("length", self.length as Any), ("oldText", self.oldText as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityDiffReplace", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("oldText", ConstructorParameterDescription(self.oldText))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityEmail: TypeConstructorDescription {
|
||||
|
|
@ -136,8 +136,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityEmail", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityEmail", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityFormattedDate: TypeConstructorDescription {
|
||||
|
|
@ -151,8 +151,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityFormattedDate", [("flags", self.flags as Any), ("offset", self.offset as Any), ("length", self.length as Any), ("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityFormattedDate", [("flags", ConstructorParameterDescription(self.flags)), ("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityHashtag: TypeConstructorDescription {
|
||||
|
|
@ -162,8 +162,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityHashtag", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityHashtag", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityItalic: TypeConstructorDescription {
|
||||
|
|
@ -173,8 +173,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityItalic", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityItalic", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityMention: TypeConstructorDescription {
|
||||
|
|
@ -184,8 +184,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityMention", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityMention", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityMentionName: TypeConstructorDescription {
|
||||
|
|
@ -197,8 +197,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityMentionName", [("offset", self.offset as Any), ("length", self.length as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityMentionName", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityPhone: TypeConstructorDescription {
|
||||
|
|
@ -208,8 +208,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityPhone", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityPhone", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityPre: TypeConstructorDescription {
|
||||
|
|
@ -221,8 +221,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.language = language
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityPre", [("offset", self.offset as Any), ("length", self.length as Any), ("language", self.language as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityPre", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("language", ConstructorParameterDescription(self.language))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntitySpoiler: TypeConstructorDescription {
|
||||
|
|
@ -232,8 +232,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntitySpoiler", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntitySpoiler", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityStrike: TypeConstructorDescription {
|
||||
|
|
@ -243,8 +243,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityStrike", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityStrike", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityTextUrl: TypeConstructorDescription {
|
||||
|
|
@ -256,8 +256,8 @@ public extension Api {
|
|||
self.length = length
|
||||
self.url = url
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityTextUrl", [("offset", self.offset as Any), ("length", self.length as Any), ("url", self.url as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityTextUrl", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length)), ("url", ConstructorParameterDescription(self.url))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityUnderline: TypeConstructorDescription {
|
||||
|
|
@ -267,8 +267,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityUnderline", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityUnderline", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityUnknown: TypeConstructorDescription {
|
||||
|
|
@ -278,8 +278,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityUnknown", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityUnknown", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageEntityUrl: TypeConstructorDescription {
|
||||
|
|
@ -289,8 +289,8 @@ public extension Api {
|
|||
self.offset = offset
|
||||
self.length = length
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageEntityUrl", [("offset", self.offset as Any), ("length", self.length as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageEntityUrl", [("offset", ConstructorParameterDescription(self.offset)), ("length", ConstructorParameterDescription(self.length))])
|
||||
}
|
||||
}
|
||||
case inputMessageEntityMentionName(Cons_inputMessageEntityMentionName)
|
||||
|
|
@ -508,58 +508,58 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputMessageEntityMentionName(let _data):
|
||||
return ("inputMessageEntityMentionName", [("offset", _data.offset as Any), ("length", _data.length as Any), ("userId", _data.userId as Any)])
|
||||
return ("inputMessageEntityMentionName", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .messageEntityBankCard(let _data):
|
||||
return ("messageEntityBankCard", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityBankCard", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityBlockquote(let _data):
|
||||
return ("messageEntityBlockquote", [("flags", _data.flags as Any), ("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityBlockquote", [("flags", ConstructorParameterDescription(_data.flags)), ("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityBold(let _data):
|
||||
return ("messageEntityBold", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityBold", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityBotCommand(let _data):
|
||||
return ("messageEntityBotCommand", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityBotCommand", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityCashtag(let _data):
|
||||
return ("messageEntityCashtag", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityCashtag", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityCode(let _data):
|
||||
return ("messageEntityCode", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityCode", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityCustomEmoji(let _data):
|
||||
return ("messageEntityCustomEmoji", [("offset", _data.offset as Any), ("length", _data.length as Any), ("documentId", _data.documentId as Any)])
|
||||
return ("messageEntityCustomEmoji", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("documentId", ConstructorParameterDescription(_data.documentId))])
|
||||
case .messageEntityDiffDelete(let _data):
|
||||
return ("messageEntityDiffDelete", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityDiffDelete", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityDiffInsert(let _data):
|
||||
return ("messageEntityDiffInsert", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityDiffInsert", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityDiffReplace(let _data):
|
||||
return ("messageEntityDiffReplace", [("offset", _data.offset as Any), ("length", _data.length as Any), ("oldText", _data.oldText as Any)])
|
||||
return ("messageEntityDiffReplace", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("oldText", ConstructorParameterDescription(_data.oldText))])
|
||||
case .messageEntityEmail(let _data):
|
||||
return ("messageEntityEmail", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityEmail", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityFormattedDate(let _data):
|
||||
return ("messageEntityFormattedDate", [("flags", _data.flags as Any), ("offset", _data.offset as Any), ("length", _data.length as Any), ("date", _data.date as Any)])
|
||||
return ("messageEntityFormattedDate", [("flags", ConstructorParameterDescription(_data.flags)), ("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("date", ConstructorParameterDescription(_data.date))])
|
||||
case .messageEntityHashtag(let _data):
|
||||
return ("messageEntityHashtag", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityHashtag", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityItalic(let _data):
|
||||
return ("messageEntityItalic", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityItalic", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityMention(let _data):
|
||||
return ("messageEntityMention", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityMention", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityMentionName(let _data):
|
||||
return ("messageEntityMentionName", [("offset", _data.offset as Any), ("length", _data.length as Any), ("userId", _data.userId as Any)])
|
||||
return ("messageEntityMentionName", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .messageEntityPhone(let _data):
|
||||
return ("messageEntityPhone", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityPhone", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityPre(let _data):
|
||||
return ("messageEntityPre", [("offset", _data.offset as Any), ("length", _data.length as Any), ("language", _data.language as Any)])
|
||||
return ("messageEntityPre", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("language", ConstructorParameterDescription(_data.language))])
|
||||
case .messageEntitySpoiler(let _data):
|
||||
return ("messageEntitySpoiler", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntitySpoiler", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityStrike(let _data):
|
||||
return ("messageEntityStrike", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityStrike", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityTextUrl(let _data):
|
||||
return ("messageEntityTextUrl", [("offset", _data.offset as Any), ("length", _data.length as Any), ("url", _data.url as Any)])
|
||||
return ("messageEntityTextUrl", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length)), ("url", ConstructorParameterDescription(_data.url))])
|
||||
case .messageEntityUnderline(let _data):
|
||||
return ("messageEntityUnderline", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityUnderline", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityUnknown(let _data):
|
||||
return ("messageEntityUnknown", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityUnknown", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
case .messageEntityUrl(let _data):
|
||||
return ("messageEntityUrl", [("offset", _data.offset as Any), ("length", _data.length as Any)])
|
||||
return ("messageEntityUrl", [("offset", ConstructorParameterDescription(_data.offset)), ("length", ConstructorParameterDescription(_data.length))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -951,8 +951,8 @@ public extension Api {
|
|||
public init(media: Api.MessageMedia) {
|
||||
self.media = media
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageExtendedMedia", [("media", self.media as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageExtendedMedia", [("media", ConstructorParameterDescription(self.media))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageExtendedMediaPreview: TypeConstructorDescription {
|
||||
|
|
@ -968,8 +968,8 @@ public extension Api {
|
|||
self.thumb = thumb
|
||||
self.videoDuration = videoDuration
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageExtendedMediaPreview", [("flags", self.flags as Any), ("w", self.w as Any), ("h", self.h as Any), ("thumb", self.thumb as Any), ("videoDuration", self.videoDuration as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageExtendedMediaPreview", [("flags", ConstructorParameterDescription(self.flags)), ("w", ConstructorParameterDescription(self.w)), ("h", ConstructorParameterDescription(self.h)), ("thumb", ConstructorParameterDescription(self.thumb)), ("videoDuration", ConstructorParameterDescription(self.videoDuration))])
|
||||
}
|
||||
}
|
||||
case messageExtendedMedia(Cons_messageExtendedMedia)
|
||||
|
|
@ -1004,12 +1004,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageExtendedMedia(let _data):
|
||||
return ("messageExtendedMedia", [("media", _data.media as Any)])
|
||||
return ("messageExtendedMedia", [("media", ConstructorParameterDescription(_data.media))])
|
||||
case .messageExtendedMediaPreview(let _data):
|
||||
return ("messageExtendedMediaPreview", [("flags", _data.flags as Any), ("w", _data.w as Any), ("h", _data.h as Any), ("thumb", _data.thumb as Any), ("videoDuration", _data.videoDuration as Any)])
|
||||
return ("messageExtendedMediaPreview", [("flags", ConstructorParameterDescription(_data.flags)), ("w", ConstructorParameterDescription(_data.w)), ("h", ConstructorParameterDescription(_data.h)), ("thumb", ConstructorParameterDescription(_data.thumb)), ("videoDuration", ConstructorParameterDescription(_data.videoDuration))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1090,8 +1090,8 @@ public extension Api {
|
|||
self.savedDate = savedDate
|
||||
self.psaType = psaType
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageFwdHeader", [("flags", self.flags as Any), ("fromId", self.fromId as Any), ("fromName", self.fromName as Any), ("date", self.date as Any), ("channelPost", self.channelPost as Any), ("postAuthor", self.postAuthor as Any), ("savedFromPeer", self.savedFromPeer as Any), ("savedFromMsgId", self.savedFromMsgId as Any), ("savedFromId", self.savedFromId as Any), ("savedFromName", self.savedFromName as Any), ("savedDate", self.savedDate as Any), ("psaType", self.psaType as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageFwdHeader", [("flags", ConstructorParameterDescription(self.flags)), ("fromId", ConstructorParameterDescription(self.fromId)), ("fromName", ConstructorParameterDescription(self.fromName)), ("date", ConstructorParameterDescription(self.date)), ("channelPost", ConstructorParameterDescription(self.channelPost)), ("postAuthor", ConstructorParameterDescription(self.postAuthor)), ("savedFromPeer", ConstructorParameterDescription(self.savedFromPeer)), ("savedFromMsgId", ConstructorParameterDescription(self.savedFromMsgId)), ("savedFromId", ConstructorParameterDescription(self.savedFromId)), ("savedFromName", ConstructorParameterDescription(self.savedFromName)), ("savedDate", ConstructorParameterDescription(self.savedDate)), ("psaType", ConstructorParameterDescription(self.psaType))])
|
||||
}
|
||||
}
|
||||
case messageFwdHeader(Cons_messageFwdHeader)
|
||||
|
|
@ -1138,10 +1138,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageFwdHeader(let _data):
|
||||
return ("messageFwdHeader", [("flags", _data.flags as Any), ("fromId", _data.fromId as Any), ("fromName", _data.fromName as Any), ("date", _data.date as Any), ("channelPost", _data.channelPost as Any), ("postAuthor", _data.postAuthor as Any), ("savedFromPeer", _data.savedFromPeer as Any), ("savedFromMsgId", _data.savedFromMsgId as Any), ("savedFromId", _data.savedFromId as Any), ("savedFromName", _data.savedFromName as Any), ("savedDate", _data.savedDate as Any), ("psaType", _data.psaType as Any)])
|
||||
return ("messageFwdHeader", [("flags", ConstructorParameterDescription(_data.flags)), ("fromId", ConstructorParameterDescription(_data.fromId)), ("fromName", ConstructorParameterDescription(_data.fromName)), ("date", ConstructorParameterDescription(_data.date)), ("channelPost", ConstructorParameterDescription(_data.channelPost)), ("postAuthor", ConstructorParameterDescription(_data.postAuthor)), ("savedFromPeer", ConstructorParameterDescription(_data.savedFromPeer)), ("savedFromMsgId", ConstructorParameterDescription(_data.savedFromMsgId)), ("savedFromId", ConstructorParameterDescription(_data.savedFromId)), ("savedFromName", ConstructorParameterDescription(_data.savedFromName)), ("savedDate", ConstructorParameterDescription(_data.savedDate)), ("psaType", ConstructorParameterDescription(_data.psaType))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1232,8 +1232,8 @@ public extension Api {
|
|||
self.vcard = vcard
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaContact", [("phoneNumber", self.phoneNumber as Any), ("firstName", self.firstName as Any), ("lastName", self.lastName as Any), ("vcard", self.vcard as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaContact", [("phoneNumber", ConstructorParameterDescription(self.phoneNumber)), ("firstName", ConstructorParameterDescription(self.firstName)), ("lastName", ConstructorParameterDescription(self.lastName)), ("vcard", ConstructorParameterDescription(self.vcard)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaDice: TypeConstructorDescription {
|
||||
|
|
@ -1247,8 +1247,8 @@ public extension Api {
|
|||
self.emoticon = emoticon
|
||||
self.gameOutcome = gameOutcome
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaDice", [("flags", self.flags as Any), ("value", self.value as Any), ("emoticon", self.emoticon as Any), ("gameOutcome", self.gameOutcome as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaDice", [("flags", ConstructorParameterDescription(self.flags)), ("value", ConstructorParameterDescription(self.value)), ("emoticon", ConstructorParameterDescription(self.emoticon)), ("gameOutcome", ConstructorParameterDescription(self.gameOutcome))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaDocument: TypeConstructorDescription {
|
||||
|
|
@ -1266,8 +1266,8 @@ public extension Api {
|
|||
self.videoTimestamp = videoTimestamp
|
||||
self.ttlSeconds = ttlSeconds
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaDocument", [("flags", self.flags as Any), ("document", self.document as Any), ("altDocuments", self.altDocuments as Any), ("videoCover", self.videoCover as Any), ("videoTimestamp", self.videoTimestamp as Any), ("ttlSeconds", self.ttlSeconds as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaDocument", [("flags", ConstructorParameterDescription(self.flags)), ("document", ConstructorParameterDescription(self.document)), ("altDocuments", ConstructorParameterDescription(self.altDocuments)), ("videoCover", ConstructorParameterDescription(self.videoCover)), ("videoTimestamp", ConstructorParameterDescription(self.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaGame: TypeConstructorDescription {
|
||||
|
|
@ -1275,8 +1275,8 @@ public extension Api {
|
|||
public init(game: Api.Game) {
|
||||
self.game = game
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaGame", [("game", self.game as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaGame", [("game", ConstructorParameterDescription(self.game))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaGeo: TypeConstructorDescription {
|
||||
|
|
@ -1284,8 +1284,8 @@ public extension Api {
|
|||
public init(geo: Api.GeoPoint) {
|
||||
self.geo = geo
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaGeo", [("geo", self.geo as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaGeo", [("geo", ConstructorParameterDescription(self.geo))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaGeoLive: TypeConstructorDescription {
|
||||
|
|
@ -1301,8 +1301,8 @@ public extension Api {
|
|||
self.period = period
|
||||
self.proximityNotificationRadius = proximityNotificationRadius
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaGeoLive", [("flags", self.flags as Any), ("geo", self.geo as Any), ("heading", self.heading as Any), ("period", self.period as Any), ("proximityNotificationRadius", self.proximityNotificationRadius as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaGeoLive", [("flags", ConstructorParameterDescription(self.flags)), ("geo", ConstructorParameterDescription(self.geo)), ("heading", ConstructorParameterDescription(self.heading)), ("period", ConstructorParameterDescription(self.period)), ("proximityNotificationRadius", ConstructorParameterDescription(self.proximityNotificationRadius))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaGiveaway: TypeConstructorDescription {
|
||||
|
|
@ -1324,8 +1324,8 @@ public extension Api {
|
|||
self.stars = stars
|
||||
self.untilDate = untilDate
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaGiveaway", [("flags", self.flags as Any), ("channels", self.channels as Any), ("countriesIso2", self.countriesIso2 as Any), ("prizeDescription", self.prizeDescription as Any), ("quantity", self.quantity as Any), ("months", self.months as Any), ("stars", self.stars as Any), ("untilDate", self.untilDate as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaGiveaway", [("flags", ConstructorParameterDescription(self.flags)), ("channels", ConstructorParameterDescription(self.channels)), ("countriesIso2", ConstructorParameterDescription(self.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(self.prizeDescription)), ("quantity", ConstructorParameterDescription(self.quantity)), ("months", ConstructorParameterDescription(self.months)), ("stars", ConstructorParameterDescription(self.stars)), ("untilDate", ConstructorParameterDescription(self.untilDate))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaGiveawayResults: TypeConstructorDescription {
|
||||
|
|
@ -1353,8 +1353,8 @@ public extension Api {
|
|||
self.prizeDescription = prizeDescription
|
||||
self.untilDate = untilDate
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaGiveawayResults", [("flags", self.flags as Any), ("channelId", self.channelId as Any), ("additionalPeersCount", self.additionalPeersCount as Any), ("launchMsgId", self.launchMsgId as Any), ("winnersCount", self.winnersCount as Any), ("unclaimedCount", self.unclaimedCount as Any), ("winners", self.winners as Any), ("months", self.months as Any), ("stars", self.stars as Any), ("prizeDescription", self.prizeDescription as Any), ("untilDate", self.untilDate as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaGiveawayResults", [("flags", ConstructorParameterDescription(self.flags)), ("channelId", ConstructorParameterDescription(self.channelId)), ("additionalPeersCount", ConstructorParameterDescription(self.additionalPeersCount)), ("launchMsgId", ConstructorParameterDescription(self.launchMsgId)), ("winnersCount", ConstructorParameterDescription(self.winnersCount)), ("unclaimedCount", ConstructorParameterDescription(self.unclaimedCount)), ("winners", ConstructorParameterDescription(self.winners)), ("months", ConstructorParameterDescription(self.months)), ("stars", ConstructorParameterDescription(self.stars)), ("prizeDescription", ConstructorParameterDescription(self.prizeDescription)), ("untilDate", ConstructorParameterDescription(self.untilDate))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaInvoice: TypeConstructorDescription {
|
||||
|
|
@ -1378,8 +1378,8 @@ public extension Api {
|
|||
self.startParam = startParam
|
||||
self.extendedMedia = extendedMedia
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaInvoice", [("flags", self.flags as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("receiptMsgId", self.receiptMsgId as Any), ("currency", self.currency as Any), ("totalAmount", self.totalAmount as Any), ("startParam", self.startParam as Any), ("extendedMedia", self.extendedMedia as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaInvoice", [("flags", ConstructorParameterDescription(self.flags)), ("title", ConstructorParameterDescription(self.title)), ("description", ConstructorParameterDescription(self.description)), ("photo", ConstructorParameterDescription(self.photo)), ("receiptMsgId", ConstructorParameterDescription(self.receiptMsgId)), ("currency", ConstructorParameterDescription(self.currency)), ("totalAmount", ConstructorParameterDescription(self.totalAmount)), ("startParam", ConstructorParameterDescription(self.startParam)), ("extendedMedia", ConstructorParameterDescription(self.extendedMedia))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaPaidMedia: TypeConstructorDescription {
|
||||
|
|
@ -1389,8 +1389,8 @@ public extension Api {
|
|||
self.starsAmount = starsAmount
|
||||
self.extendedMedia = extendedMedia
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaPaidMedia", [("starsAmount", self.starsAmount as Any), ("extendedMedia", self.extendedMedia as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaPaidMedia", [("starsAmount", ConstructorParameterDescription(self.starsAmount)), ("extendedMedia", ConstructorParameterDescription(self.extendedMedia))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaPhoto: TypeConstructorDescription {
|
||||
|
|
@ -1404,8 +1404,8 @@ public extension Api {
|
|||
self.ttlSeconds = ttlSeconds
|
||||
self.video = video
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaPhoto", [("flags", self.flags as Any), ("photo", self.photo as Any), ("ttlSeconds", self.ttlSeconds as Any), ("video", self.video as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaPhoto", [("flags", ConstructorParameterDescription(self.flags)), ("photo", ConstructorParameterDescription(self.photo)), ("ttlSeconds", ConstructorParameterDescription(self.ttlSeconds)), ("video", ConstructorParameterDescription(self.video))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaPoll: TypeConstructorDescription {
|
||||
|
|
@ -1419,8 +1419,8 @@ public extension Api {
|
|||
self.results = results
|
||||
self.attachedMedia = attachedMedia
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaPoll", [("flags", self.flags as Any), ("poll", self.poll as Any), ("results", self.results as Any), ("attachedMedia", self.attachedMedia as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaPoll", [("flags", ConstructorParameterDescription(self.flags)), ("poll", ConstructorParameterDescription(self.poll)), ("results", ConstructorParameterDescription(self.results)), ("attachedMedia", ConstructorParameterDescription(self.attachedMedia))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaStory: TypeConstructorDescription {
|
||||
|
|
@ -1434,8 +1434,8 @@ public extension Api {
|
|||
self.id = id
|
||||
self.story = story
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaStory", [("flags", self.flags as Any), ("peer", self.peer as Any), ("id", self.id as Any), ("story", self.story as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaStory", [("flags", ConstructorParameterDescription(self.flags)), ("peer", ConstructorParameterDescription(self.peer)), ("id", ConstructorParameterDescription(self.id)), ("story", ConstructorParameterDescription(self.story))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaToDo: TypeConstructorDescription {
|
||||
|
|
@ -1447,8 +1447,8 @@ public extension Api {
|
|||
self.todo = todo
|
||||
self.completions = completions
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaToDo", [("flags", self.flags as Any), ("todo", self.todo as Any), ("completions", self.completions as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaToDo", [("flags", ConstructorParameterDescription(self.flags)), ("todo", ConstructorParameterDescription(self.todo)), ("completions", ConstructorParameterDescription(self.completions))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaVenue: TypeConstructorDescription {
|
||||
|
|
@ -1466,8 +1466,8 @@ public extension Api {
|
|||
self.venueId = venueId
|
||||
self.venueType = venueType
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaVenue", [("geo", self.geo as Any), ("title", self.title as Any), ("address", self.address as Any), ("provider", self.provider as Any), ("venueId", self.venueId as Any), ("venueType", self.venueType as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaVenue", [("geo", ConstructorParameterDescription(self.geo)), ("title", ConstructorParameterDescription(self.title)), ("address", ConstructorParameterDescription(self.address)), ("provider", ConstructorParameterDescription(self.provider)), ("venueId", ConstructorParameterDescription(self.venueId)), ("venueType", ConstructorParameterDescription(self.venueType))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaVideoStream: TypeConstructorDescription {
|
||||
|
|
@ -1477,8 +1477,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.call = call
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaVideoStream", [("flags", self.flags as Any), ("call", self.call as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaVideoStream", [("flags", ConstructorParameterDescription(self.flags)), ("call", ConstructorParameterDescription(self.call))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaWebPage: TypeConstructorDescription {
|
||||
|
|
@ -1488,8 +1488,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.webpage = webpage
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaWebPage", [("flags", self.flags as Any), ("webpage", self.webpage as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageMediaWebPage", [("flags", ConstructorParameterDescription(self.flags)), ("webpage", ConstructorParameterDescription(self.webpage))])
|
||||
}
|
||||
}
|
||||
case messageMediaContact(Cons_messageMediaContact)
|
||||
|
|
@ -1763,46 +1763,46 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageMediaContact(let _data):
|
||||
return ("messageMediaContact", [("phoneNumber", _data.phoneNumber as Any), ("firstName", _data.firstName as Any), ("lastName", _data.lastName as Any), ("vcard", _data.vcard as Any), ("userId", _data.userId as Any)])
|
||||
return ("messageMediaContact", [("phoneNumber", ConstructorParameterDescription(_data.phoneNumber)), ("firstName", ConstructorParameterDescription(_data.firstName)), ("lastName", ConstructorParameterDescription(_data.lastName)), ("vcard", ConstructorParameterDescription(_data.vcard)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
case .messageMediaDice(let _data):
|
||||
return ("messageMediaDice", [("flags", _data.flags as Any), ("value", _data.value as Any), ("emoticon", _data.emoticon as Any), ("gameOutcome", _data.gameOutcome as Any)])
|
||||
return ("messageMediaDice", [("flags", ConstructorParameterDescription(_data.flags)), ("value", ConstructorParameterDescription(_data.value)), ("emoticon", ConstructorParameterDescription(_data.emoticon)), ("gameOutcome", ConstructorParameterDescription(_data.gameOutcome))])
|
||||
case .messageMediaDocument(let _data):
|
||||
return ("messageMediaDocument", [("flags", _data.flags as Any), ("document", _data.document as Any), ("altDocuments", _data.altDocuments as Any), ("videoCover", _data.videoCover as Any), ("videoTimestamp", _data.videoTimestamp as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
return ("messageMediaDocument", [("flags", ConstructorParameterDescription(_data.flags)), ("document", ConstructorParameterDescription(_data.document)), ("altDocuments", ConstructorParameterDescription(_data.altDocuments)), ("videoCover", ConstructorParameterDescription(_data.videoCover)), ("videoTimestamp", ConstructorParameterDescription(_data.videoTimestamp)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds))])
|
||||
case .messageMediaEmpty:
|
||||
return ("messageMediaEmpty", [])
|
||||
case .messageMediaGame(let _data):
|
||||
return ("messageMediaGame", [("game", _data.game as Any)])
|
||||
return ("messageMediaGame", [("game", ConstructorParameterDescription(_data.game))])
|
||||
case .messageMediaGeo(let _data):
|
||||
return ("messageMediaGeo", [("geo", _data.geo as Any)])
|
||||
return ("messageMediaGeo", [("geo", ConstructorParameterDescription(_data.geo))])
|
||||
case .messageMediaGeoLive(let _data):
|
||||
return ("messageMediaGeoLive", [("flags", _data.flags as Any), ("geo", _data.geo as Any), ("heading", _data.heading as Any), ("period", _data.period as Any), ("proximityNotificationRadius", _data.proximityNotificationRadius as Any)])
|
||||
return ("messageMediaGeoLive", [("flags", ConstructorParameterDescription(_data.flags)), ("geo", ConstructorParameterDescription(_data.geo)), ("heading", ConstructorParameterDescription(_data.heading)), ("period", ConstructorParameterDescription(_data.period)), ("proximityNotificationRadius", ConstructorParameterDescription(_data.proximityNotificationRadius))])
|
||||
case .messageMediaGiveaway(let _data):
|
||||
return ("messageMediaGiveaway", [("flags", _data.flags as Any), ("channels", _data.channels as Any), ("countriesIso2", _data.countriesIso2 as Any), ("prizeDescription", _data.prizeDescription as Any), ("quantity", _data.quantity as Any), ("months", _data.months as Any), ("stars", _data.stars as Any), ("untilDate", _data.untilDate as Any)])
|
||||
return ("messageMediaGiveaway", [("flags", ConstructorParameterDescription(_data.flags)), ("channels", ConstructorParameterDescription(_data.channels)), ("countriesIso2", ConstructorParameterDescription(_data.countriesIso2)), ("prizeDescription", ConstructorParameterDescription(_data.prizeDescription)), ("quantity", ConstructorParameterDescription(_data.quantity)), ("months", ConstructorParameterDescription(_data.months)), ("stars", ConstructorParameterDescription(_data.stars)), ("untilDate", ConstructorParameterDescription(_data.untilDate))])
|
||||
case .messageMediaGiveawayResults(let _data):
|
||||
return ("messageMediaGiveawayResults", [("flags", _data.flags as Any), ("channelId", _data.channelId as Any), ("additionalPeersCount", _data.additionalPeersCount as Any), ("launchMsgId", _data.launchMsgId as Any), ("winnersCount", _data.winnersCount as Any), ("unclaimedCount", _data.unclaimedCount as Any), ("winners", _data.winners as Any), ("months", _data.months as Any), ("stars", _data.stars as Any), ("prizeDescription", _data.prizeDescription as Any), ("untilDate", _data.untilDate as Any)])
|
||||
return ("messageMediaGiveawayResults", [("flags", ConstructorParameterDescription(_data.flags)), ("channelId", ConstructorParameterDescription(_data.channelId)), ("additionalPeersCount", ConstructorParameterDescription(_data.additionalPeersCount)), ("launchMsgId", ConstructorParameterDescription(_data.launchMsgId)), ("winnersCount", ConstructorParameterDescription(_data.winnersCount)), ("unclaimedCount", ConstructorParameterDescription(_data.unclaimedCount)), ("winners", ConstructorParameterDescription(_data.winners)), ("months", ConstructorParameterDescription(_data.months)), ("stars", ConstructorParameterDescription(_data.stars)), ("prizeDescription", ConstructorParameterDescription(_data.prizeDescription)), ("untilDate", ConstructorParameterDescription(_data.untilDate))])
|
||||
case .messageMediaInvoice(let _data):
|
||||
return ("messageMediaInvoice", [("flags", _data.flags as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("receiptMsgId", _data.receiptMsgId as Any), ("currency", _data.currency as Any), ("totalAmount", _data.totalAmount as Any), ("startParam", _data.startParam as Any), ("extendedMedia", _data.extendedMedia as Any)])
|
||||
return ("messageMediaInvoice", [("flags", ConstructorParameterDescription(_data.flags)), ("title", ConstructorParameterDescription(_data.title)), ("description", ConstructorParameterDescription(_data.description)), ("photo", ConstructorParameterDescription(_data.photo)), ("receiptMsgId", ConstructorParameterDescription(_data.receiptMsgId)), ("currency", ConstructorParameterDescription(_data.currency)), ("totalAmount", ConstructorParameterDescription(_data.totalAmount)), ("startParam", ConstructorParameterDescription(_data.startParam)), ("extendedMedia", ConstructorParameterDescription(_data.extendedMedia))])
|
||||
case .messageMediaPaidMedia(let _data):
|
||||
return ("messageMediaPaidMedia", [("starsAmount", _data.starsAmount as Any), ("extendedMedia", _data.extendedMedia as Any)])
|
||||
return ("messageMediaPaidMedia", [("starsAmount", ConstructorParameterDescription(_data.starsAmount)), ("extendedMedia", ConstructorParameterDescription(_data.extendedMedia))])
|
||||
case .messageMediaPhoto(let _data):
|
||||
return ("messageMediaPhoto", [("flags", _data.flags as Any), ("photo", _data.photo as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("video", _data.video as Any)])
|
||||
return ("messageMediaPhoto", [("flags", ConstructorParameterDescription(_data.flags)), ("photo", ConstructorParameterDescription(_data.photo)), ("ttlSeconds", ConstructorParameterDescription(_data.ttlSeconds)), ("video", ConstructorParameterDescription(_data.video))])
|
||||
case .messageMediaPoll(let _data):
|
||||
return ("messageMediaPoll", [("flags", _data.flags as Any), ("poll", _data.poll as Any), ("results", _data.results as Any), ("attachedMedia", _data.attachedMedia as Any)])
|
||||
return ("messageMediaPoll", [("flags", ConstructorParameterDescription(_data.flags)), ("poll", ConstructorParameterDescription(_data.poll)), ("results", ConstructorParameterDescription(_data.results)), ("attachedMedia", ConstructorParameterDescription(_data.attachedMedia))])
|
||||
case .messageMediaStory(let _data):
|
||||
return ("messageMediaStory", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("id", _data.id as Any), ("story", _data.story as Any)])
|
||||
return ("messageMediaStory", [("flags", ConstructorParameterDescription(_data.flags)), ("peer", ConstructorParameterDescription(_data.peer)), ("id", ConstructorParameterDescription(_data.id)), ("story", ConstructorParameterDescription(_data.story))])
|
||||
case .messageMediaToDo(let _data):
|
||||
return ("messageMediaToDo", [("flags", _data.flags as Any), ("todo", _data.todo as Any), ("completions", _data.completions as Any)])
|
||||
return ("messageMediaToDo", [("flags", ConstructorParameterDescription(_data.flags)), ("todo", ConstructorParameterDescription(_data.todo)), ("completions", ConstructorParameterDescription(_data.completions))])
|
||||
case .messageMediaUnsupported:
|
||||
return ("messageMediaUnsupported", [])
|
||||
case .messageMediaVenue(let _data):
|
||||
return ("messageMediaVenue", [("geo", _data.geo as Any), ("title", _data.title as Any), ("address", _data.address as Any), ("provider", _data.provider as Any), ("venueId", _data.venueId as Any), ("venueType", _data.venueType as Any)])
|
||||
return ("messageMediaVenue", [("geo", ConstructorParameterDescription(_data.geo)), ("title", ConstructorParameterDescription(_data.title)), ("address", ConstructorParameterDescription(_data.address)), ("provider", ConstructorParameterDescription(_data.provider)), ("venueId", ConstructorParameterDescription(_data.venueId)), ("venueType", ConstructorParameterDescription(_data.venueType))])
|
||||
case .messageMediaVideoStream(let _data):
|
||||
return ("messageMediaVideoStream", [("flags", _data.flags as Any), ("call", _data.call as Any)])
|
||||
return ("messageMediaVideoStream", [("flags", ConstructorParameterDescription(_data.flags)), ("call", ConstructorParameterDescription(_data.call))])
|
||||
case .messageMediaWebPage(let _data):
|
||||
return ("messageMediaWebPage", [("flags", _data.flags as Any), ("webpage", _data.webpage as Any)])
|
||||
return ("messageMediaWebPage", [("flags", ConstructorParameterDescription(_data.flags)), ("webpage", ConstructorParameterDescription(_data.webpage))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public extension Api {
|
|||
self.date = date
|
||||
self.reaction = reaction
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messagePeerReaction", [("flags", self.flags as Any), ("peerId", self.peerId as Any), ("date", self.date as Any), ("reaction", self.reaction as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messagePeerReaction", [("flags", ConstructorParameterDescription(self.flags)), ("peerId", ConstructorParameterDescription(self.peerId)), ("date", ConstructorParameterDescription(self.date)), ("reaction", ConstructorParameterDescription(self.reaction))])
|
||||
}
|
||||
}
|
||||
case messagePeerReaction(Cons_messagePeerReaction)
|
||||
|
|
@ -31,10 +31,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messagePeerReaction(let _data):
|
||||
return ("messagePeerReaction", [("flags", _data.flags as Any), ("peerId", _data.peerId as Any), ("date", _data.date as Any), ("reaction", _data.reaction as Any)])
|
||||
return ("messagePeerReaction", [("flags", ConstructorParameterDescription(_data.flags)), ("peerId", ConstructorParameterDescription(_data.peerId)), ("date", ConstructorParameterDescription(_data.date)), ("reaction", ConstructorParameterDescription(_data.reaction))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +75,8 @@ public extension Api {
|
|||
self.option = option
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messagePeerVote", [("peer", self.peer as Any), ("option", self.option as Any), ("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messagePeerVote", [("peer", ConstructorParameterDescription(self.peer)), ("option", ConstructorParameterDescription(self.option)), ("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
public class Cons_messagePeerVoteInputOption: TypeConstructorDescription {
|
||||
|
|
@ -86,8 +86,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messagePeerVoteInputOption", [("peer", self.peer as Any), ("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messagePeerVoteInputOption", [("peer", ConstructorParameterDescription(self.peer)), ("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
public class Cons_messagePeerVoteMultiple: TypeConstructorDescription {
|
||||
|
|
@ -99,8 +99,8 @@ public extension Api {
|
|||
self.options = options
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messagePeerVoteMultiple", [("peer", self.peer as Any), ("options", self.options as Any), ("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messagePeerVoteMultiple", [("peer", ConstructorParameterDescription(self.peer)), ("options", ConstructorParameterDescription(self.options)), ("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
case messagePeerVote(Cons_messagePeerVote)
|
||||
|
|
@ -139,14 +139,14 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messagePeerVote(let _data):
|
||||
return ("messagePeerVote", [("peer", _data.peer as Any), ("option", _data.option as Any), ("date", _data.date as Any)])
|
||||
return ("messagePeerVote", [("peer", ConstructorParameterDescription(_data.peer)), ("option", ConstructorParameterDescription(_data.option)), ("date", ConstructorParameterDescription(_data.date))])
|
||||
case .messagePeerVoteInputOption(let _data):
|
||||
return ("messagePeerVoteInputOption", [("peer", _data.peer as Any), ("date", _data.date as Any)])
|
||||
return ("messagePeerVoteInputOption", [("peer", ConstructorParameterDescription(_data.peer)), ("date", ConstructorParameterDescription(_data.date))])
|
||||
case .messagePeerVoteMultiple(let _data):
|
||||
return ("messagePeerVoteMultiple", [("peer", _data.peer as Any), ("options", _data.options as Any), ("date", _data.date as Any)])
|
||||
return ("messagePeerVoteMultiple", [("peer", ConstructorParameterDescription(_data.peer)), ("options", ConstructorParameterDescription(_data.options)), ("date", ConstructorParameterDescription(_data.date))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,8 +217,8 @@ public extension Api {
|
|||
self.minId = minId
|
||||
self.maxId = maxId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageRange", [("minId", self.minId as Any), ("maxId", self.maxId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageRange", [("minId", ConstructorParameterDescription(self.minId)), ("maxId", ConstructorParameterDescription(self.maxId))])
|
||||
}
|
||||
}
|
||||
case messageRange(Cons_messageRange)
|
||||
|
|
@ -235,10 +235,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageRange(let _data):
|
||||
return ("messageRange", [("minId", _data.minId as Any), ("maxId", _data.maxId as Any)])
|
||||
return ("messageRange", [("minId", ConstructorParameterDescription(_data.minId)), ("maxId", ConstructorParameterDescription(_data.maxId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,8 +271,8 @@ public extension Api {
|
|||
self.recentReactions = recentReactions
|
||||
self.topReactors = topReactors
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReactions", [("flags", self.flags as Any), ("results", self.results as Any), ("recentReactions", self.recentReactions as Any), ("topReactors", self.topReactors as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReactions", [("flags", ConstructorParameterDescription(self.flags)), ("results", ConstructorParameterDescription(self.results)), ("recentReactions", ConstructorParameterDescription(self.recentReactions)), ("topReactors", ConstructorParameterDescription(self.topReactors))])
|
||||
}
|
||||
}
|
||||
case messageReactions(Cons_messageReactions)
|
||||
|
|
@ -307,10 +307,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageReactions(let _data):
|
||||
return ("messageReactions", [("flags", _data.flags as Any), ("results", _data.results as Any), ("recentReactions", _data.recentReactions as Any), ("topReactors", _data.topReactors as Any)])
|
||||
return ("messageReactions", [("flags", ConstructorParameterDescription(_data.flags)), ("results", ConstructorParameterDescription(_data.results)), ("recentReactions", ConstructorParameterDescription(_data.recentReactions)), ("topReactors", ConstructorParameterDescription(_data.topReactors))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -357,8 +357,8 @@ public extension Api {
|
|||
self.peerId = peerId
|
||||
self.count = count
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReactor", [("flags", self.flags as Any), ("peerId", self.peerId as Any), ("count", self.count as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReactor", [("flags", ConstructorParameterDescription(self.flags)), ("peerId", ConstructorParameterDescription(self.peerId)), ("count", ConstructorParameterDescription(self.count))])
|
||||
}
|
||||
}
|
||||
case messageReactor(Cons_messageReactor)
|
||||
|
|
@ -378,10 +378,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageReactor(let _data):
|
||||
return ("messageReactor", [("flags", _data.flags as Any), ("peerId", _data.peerId as Any), ("count", _data.count as Any)])
|
||||
return ("messageReactor", [("flags", ConstructorParameterDescription(_data.flags)), ("peerId", ConstructorParameterDescription(_data.peerId)), ("count", ConstructorParameterDescription(_data.count))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -427,8 +427,8 @@ public extension Api {
|
|||
self.maxId = maxId
|
||||
self.readMaxId = readMaxId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReplies", [("flags", self.flags as Any), ("replies", self.replies as Any), ("repliesPts", self.repliesPts as Any), ("recentRepliers", self.recentRepliers as Any), ("channelId", self.channelId as Any), ("maxId", self.maxId as Any), ("readMaxId", self.readMaxId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReplies", [("flags", ConstructorParameterDescription(self.flags)), ("replies", ConstructorParameterDescription(self.replies)), ("repliesPts", ConstructorParameterDescription(self.repliesPts)), ("recentRepliers", ConstructorParameterDescription(self.recentRepliers)), ("channelId", ConstructorParameterDescription(self.channelId)), ("maxId", ConstructorParameterDescription(self.maxId)), ("readMaxId", ConstructorParameterDescription(self.readMaxId))])
|
||||
}
|
||||
}
|
||||
case messageReplies(Cons_messageReplies)
|
||||
|
|
@ -462,10 +462,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageReplies(let _data):
|
||||
return ("messageReplies", [("flags", _data.flags as Any), ("replies", _data.replies as Any), ("repliesPts", _data.repliesPts as Any), ("recentRepliers", _data.recentRepliers as Any), ("channelId", _data.channelId as Any), ("maxId", _data.maxId as Any), ("readMaxId", _data.readMaxId as Any)])
|
||||
return ("messageReplies", [("flags", ConstructorParameterDescription(_data.flags)), ("replies", ConstructorParameterDescription(_data.replies)), ("repliesPts", ConstructorParameterDescription(_data.repliesPts)), ("recentRepliers", ConstructorParameterDescription(_data.recentRepliers)), ("channelId", ConstructorParameterDescription(_data.channelId)), ("maxId", ConstructorParameterDescription(_data.maxId)), ("readMaxId", ConstructorParameterDescription(_data.readMaxId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -537,8 +537,8 @@ public extension Api {
|
|||
self.todoItemId = todoItemId
|
||||
self.pollOption = pollOption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReplyHeader", [("flags", self.flags as Any), ("replyToMsgId", self.replyToMsgId as Any), ("replyToPeerId", self.replyToPeerId as Any), ("replyFrom", self.replyFrom as Any), ("replyMedia", self.replyMedia as Any), ("replyToTopId", self.replyToTopId as Any), ("quoteText", self.quoteText as Any), ("quoteEntities", self.quoteEntities as Any), ("quoteOffset", self.quoteOffset as Any), ("todoItemId", self.todoItemId as Any), ("pollOption", self.pollOption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReplyHeader", [("flags", ConstructorParameterDescription(self.flags)), ("replyToMsgId", ConstructorParameterDescription(self.replyToMsgId)), ("replyToPeerId", ConstructorParameterDescription(self.replyToPeerId)), ("replyFrom", ConstructorParameterDescription(self.replyFrom)), ("replyMedia", ConstructorParameterDescription(self.replyMedia)), ("replyToTopId", ConstructorParameterDescription(self.replyToTopId)), ("quoteText", ConstructorParameterDescription(self.quoteText)), ("quoteEntities", ConstructorParameterDescription(self.quoteEntities)), ("quoteOffset", ConstructorParameterDescription(self.quoteOffset)), ("todoItemId", ConstructorParameterDescription(self.todoItemId)), ("pollOption", ConstructorParameterDescription(self.pollOption))])
|
||||
}
|
||||
}
|
||||
public class Cons_messageReplyStoryHeader: TypeConstructorDescription {
|
||||
|
|
@ -548,8 +548,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.storyId = storyId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReplyStoryHeader", [("peer", self.peer as Any), ("storyId", self.storyId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReplyStoryHeader", [("peer", ConstructorParameterDescription(self.peer)), ("storyId", ConstructorParameterDescription(self.storyId))])
|
||||
}
|
||||
}
|
||||
case messageReplyHeader(Cons_messageReplyHeader)
|
||||
|
|
@ -607,12 +607,12 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageReplyHeader(let _data):
|
||||
return ("messageReplyHeader", [("flags", _data.flags as Any), ("replyToMsgId", _data.replyToMsgId as Any), ("replyToPeerId", _data.replyToPeerId as Any), ("replyFrom", _data.replyFrom as Any), ("replyMedia", _data.replyMedia as Any), ("replyToTopId", _data.replyToTopId as Any), ("quoteText", _data.quoteText as Any), ("quoteEntities", _data.quoteEntities as Any), ("quoteOffset", _data.quoteOffset as Any), ("todoItemId", _data.todoItemId as Any), ("pollOption", _data.pollOption as Any)])
|
||||
return ("messageReplyHeader", [("flags", ConstructorParameterDescription(_data.flags)), ("replyToMsgId", ConstructorParameterDescription(_data.replyToMsgId)), ("replyToPeerId", ConstructorParameterDescription(_data.replyToPeerId)), ("replyFrom", ConstructorParameterDescription(_data.replyFrom)), ("replyMedia", ConstructorParameterDescription(_data.replyMedia)), ("replyToTopId", ConstructorParameterDescription(_data.replyToTopId)), ("quoteText", ConstructorParameterDescription(_data.quoteText)), ("quoteEntities", ConstructorParameterDescription(_data.quoteEntities)), ("quoteOffset", ConstructorParameterDescription(_data.quoteOffset)), ("todoItemId", ConstructorParameterDescription(_data.todoItemId)), ("pollOption", ConstructorParameterDescription(_data.pollOption))])
|
||||
case .messageReplyStoryHeader(let _data):
|
||||
return ("messageReplyStoryHeader", [("peer", _data.peer as Any), ("storyId", _data.storyId as Any)])
|
||||
return ("messageReplyStoryHeader", [("peer", ConstructorParameterDescription(_data.peer)), ("storyId", ConstructorParameterDescription(_data.storyId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -712,8 +712,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.option = option
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageReportOption", [("text", self.text as Any), ("option", self.option as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageReportOption", [("text", ConstructorParameterDescription(self.text)), ("option", ConstructorParameterDescription(self.option))])
|
||||
}
|
||||
}
|
||||
case messageReportOption(Cons_messageReportOption)
|
||||
|
|
@ -730,10 +730,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageReportOption(let _data):
|
||||
return ("messageReportOption", [("text", _data.text as Any), ("option", _data.option as Any)])
|
||||
return ("messageReportOption", [("text", ConstructorParameterDescription(_data.text)), ("option", ConstructorParameterDescription(_data.option))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -766,8 +766,8 @@ public extension Api {
|
|||
self.forwards = forwards
|
||||
self.replies = replies
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageViews", [("flags", self.flags as Any), ("views", self.views as Any), ("forwards", self.forwards as Any), ("replies", self.replies as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("messageViews", [("flags", ConstructorParameterDescription(self.flags)), ("views", ConstructorParameterDescription(self.views)), ("forwards", ConstructorParameterDescription(self.forwards)), ("replies", ConstructorParameterDescription(self.replies))])
|
||||
}
|
||||
}
|
||||
case messageViews(Cons_messageViews)
|
||||
|
|
@ -792,10 +792,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .messageViews(let _data):
|
||||
return ("messageViews", [("flags", _data.flags as Any), ("views", _data.views as Any), ("forwards", _data.forwards as Any), ("replies", _data.replies as Any)])
|
||||
return ("messageViews", [("flags", ConstructorParameterDescription(_data.flags)), ("views", ConstructorParameterDescription(_data.views)), ("forwards", ConstructorParameterDescription(_data.forwards)), ("replies", ConstructorParameterDescription(_data.replies))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -836,8 +836,8 @@ public extension Api {
|
|||
public init(flags: Int32) {
|
||||
self.flags = flags
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessagesFilterPhoneCalls", [("flags", self.flags as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("inputMessagesFilterPhoneCalls", [("flags", ConstructorParameterDescription(self.flags))])
|
||||
}
|
||||
}
|
||||
case inputMessagesFilterChatPhotos
|
||||
|
|
@ -955,7 +955,7 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .inputMessagesFilterChatPhotos:
|
||||
return ("inputMessagesFilterChatPhotos", [])
|
||||
|
|
@ -974,7 +974,7 @@ public extension Api {
|
|||
case .inputMessagesFilterMyMentions:
|
||||
return ("inputMessagesFilterMyMentions", [])
|
||||
case .inputMessagesFilterPhoneCalls(let _data):
|
||||
return ("inputMessagesFilterPhoneCalls", [("flags", _data.flags as Any)])
|
||||
return ("inputMessagesFilterPhoneCalls", [("flags", ConstructorParameterDescription(_data.flags))])
|
||||
case .inputMessagesFilterPhotoVideo:
|
||||
return ("inputMessagesFilterPhotoVideo", [])
|
||||
case .inputMessagesFilterPhotos:
|
||||
|
|
@ -1069,8 +1069,8 @@ public extension Api {
|
|||
self.flags = flags
|
||||
self.userId = userId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("missingInvitee", [("flags", self.flags as Any), ("userId", self.userId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("missingInvitee", [("flags", ConstructorParameterDescription(self.flags)), ("userId", ConstructorParameterDescription(self.userId))])
|
||||
}
|
||||
}
|
||||
case missingInvitee(Cons_missingInvitee)
|
||||
|
|
@ -1087,10 +1087,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .missingInvitee(let _data):
|
||||
return ("missingInvitee", [("flags", _data.flags as Any), ("userId", _data.userId as Any)])
|
||||
return ("missingInvitee", [("flags", ConstructorParameterDescription(_data.flags)), ("userId", ConstructorParameterDescription(_data.userId))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1127,8 +1127,8 @@ public extension Api {
|
|||
self.expires = expires
|
||||
self.cooldownUntilDate = cooldownUntilDate
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("myBoost", [("flags", self.flags as Any), ("slot", self.slot as Any), ("peer", self.peer as Any), ("date", self.date as Any), ("expires", self.expires as Any), ("cooldownUntilDate", self.cooldownUntilDate as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("myBoost", [("flags", ConstructorParameterDescription(self.flags)), ("slot", ConstructorParameterDescription(self.slot)), ("peer", ConstructorParameterDescription(self.peer)), ("date", ConstructorParameterDescription(self.date)), ("expires", ConstructorParameterDescription(self.expires)), ("cooldownUntilDate", ConstructorParameterDescription(self.cooldownUntilDate))])
|
||||
}
|
||||
}
|
||||
case myBoost(Cons_myBoost)
|
||||
|
|
@ -1153,10 +1153,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .myBoost(let _data):
|
||||
return ("myBoost", [("flags", _data.flags as Any), ("slot", _data.slot as Any), ("peer", _data.peer as Any), ("date", _data.date as Any), ("expires", _data.expires as Any), ("cooldownUntilDate", _data.cooldownUntilDate as Any)])
|
||||
return ("myBoost", [("flags", ConstructorParameterDescription(_data.flags)), ("slot", ConstructorParameterDescription(_data.slot)), ("peer", ConstructorParameterDescription(_data.peer)), ("date", ConstructorParameterDescription(_data.date)), ("expires", ConstructorParameterDescription(_data.expires)), ("cooldownUntilDate", ConstructorParameterDescription(_data.cooldownUntilDate))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ public extension Api {
|
|||
self.thisDc = thisDc
|
||||
self.nearestDc = nearestDc
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("nearestDc", [("country", self.country as Any), ("thisDc", self.thisDc as Any), ("nearestDc", self.nearestDc as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("nearestDc", [("country", ConstructorParameterDescription(self.country)), ("thisDc", ConstructorParameterDescription(self.thisDc)), ("nearestDc", ConstructorParameterDescription(self.nearestDc))])
|
||||
}
|
||||
}
|
||||
case nearestDc(Cons_nearestDc)
|
||||
|
|
@ -28,10 +28,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .nearestDc(let _data):
|
||||
return ("nearestDc", [("country", _data.country as Any), ("thisDc", _data.thisDc as Any), ("nearestDc", _data.nearestDc as Any)])
|
||||
return ("nearestDc", [("country", ConstructorParameterDescription(_data.country)), ("thisDc", ConstructorParameterDescription(_data.thisDc)), ("nearestDc", ConstructorParameterDescription(_data.nearestDc))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +63,8 @@ public extension Api {
|
|||
self.title = title
|
||||
self.data = data
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("notificationSoundLocal", [("title", self.title as Any), ("data", self.data as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("notificationSoundLocal", [("title", ConstructorParameterDescription(self.title)), ("data", ConstructorParameterDescription(self.data))])
|
||||
}
|
||||
}
|
||||
public class Cons_notificationSoundRingtone: TypeConstructorDescription {
|
||||
|
|
@ -72,8 +72,8 @@ public extension Api {
|
|||
public init(id: Int64) {
|
||||
self.id = id
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("notificationSoundRingtone", [("id", self.id as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("notificationSoundRingtone", [("id", ConstructorParameterDescription(self.id))])
|
||||
}
|
||||
}
|
||||
case notificationSoundDefault
|
||||
|
|
@ -109,16 +109,16 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .notificationSoundDefault:
|
||||
return ("notificationSoundDefault", [])
|
||||
case .notificationSoundLocal(let _data):
|
||||
return ("notificationSoundLocal", [("title", _data.title as Any), ("data", _data.data as Any)])
|
||||
return ("notificationSoundLocal", [("title", ConstructorParameterDescription(_data.title)), ("data", ConstructorParameterDescription(_data.data))])
|
||||
case .notificationSoundNone:
|
||||
return ("notificationSoundNone", [])
|
||||
case .notificationSoundRingtone(let _data):
|
||||
return ("notificationSoundRingtone", [("id", _data.id as Any)])
|
||||
return ("notificationSoundRingtone", [("id", ConstructorParameterDescription(_data.id))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,8 +164,8 @@ public extension Api {
|
|||
self.peer = peer
|
||||
self.topMsgId = topMsgId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("notifyForumTopic", [("peer", self.peer as Any), ("topMsgId", self.topMsgId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("notifyForumTopic", [("peer", ConstructorParameterDescription(self.peer)), ("topMsgId", ConstructorParameterDescription(self.topMsgId))])
|
||||
}
|
||||
}
|
||||
public class Cons_notifyPeer: TypeConstructorDescription {
|
||||
|
|
@ -173,8 +173,8 @@ public extension Api {
|
|||
public init(peer: Api.Peer) {
|
||||
self.peer = peer
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("notifyPeer", [("peer", self.peer as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("notifyPeer", [("peer", ConstructorParameterDescription(self.peer))])
|
||||
}
|
||||
}
|
||||
case notifyBroadcasts
|
||||
|
|
@ -216,16 +216,16 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .notifyBroadcasts:
|
||||
return ("notifyBroadcasts", [])
|
||||
case .notifyChats:
|
||||
return ("notifyChats", [])
|
||||
case .notifyForumTopic(let _data):
|
||||
return ("notifyForumTopic", [("peer", _data.peer as Any), ("topMsgId", _data.topMsgId as Any)])
|
||||
return ("notifyForumTopic", [("peer", ConstructorParameterDescription(_data.peer)), ("topMsgId", ConstructorParameterDescription(_data.topMsgId))])
|
||||
case .notifyPeer(let _data):
|
||||
return ("notifyPeer", [("peer", _data.peer as Any)])
|
||||
return ("notifyPeer", [("peer", ConstructorParameterDescription(_data.peer))])
|
||||
case .notifyUsers:
|
||||
return ("notifyUsers", [])
|
||||
}
|
||||
|
|
@ -278,8 +278,8 @@ public extension Api {
|
|||
public init(date: Int32) {
|
||||
self.date = date
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("outboxReadDate", [("date", self.date as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("outboxReadDate", [("date", ConstructorParameterDescription(self.date))])
|
||||
}
|
||||
}
|
||||
case outboxReadDate(Cons_outboxReadDate)
|
||||
|
|
@ -295,10 +295,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .outboxReadDate(let _data):
|
||||
return ("outboxReadDate", [("date", _data.date as Any)])
|
||||
return ("outboxReadDate", [("date", ConstructorParameterDescription(_data.date))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,8 +332,8 @@ public extension Api {
|
|||
self.documents = documents
|
||||
self.views = views
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("page", [("flags", self.flags as Any), ("url", self.url as Any), ("blocks", self.blocks as Any), ("photos", self.photos as Any), ("documents", self.documents as Any), ("views", self.views as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("page", [("flags", ConstructorParameterDescription(self.flags)), ("url", ConstructorParameterDescription(self.url)), ("blocks", ConstructorParameterDescription(self.blocks)), ("photos", ConstructorParameterDescription(self.photos)), ("documents", ConstructorParameterDescription(self.documents)), ("views", ConstructorParameterDescription(self.views))])
|
||||
}
|
||||
}
|
||||
case page(Cons_page)
|
||||
|
|
@ -368,10 +368,10 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .page(let _data):
|
||||
return ("page", [("flags", _data.flags as Any), ("url", _data.url as Any), ("blocks", _data.blocks as Any), ("photos", _data.photos as Any), ("documents", _data.documents as Any), ("views", _data.views as Any)])
|
||||
return ("page", [("flags", ConstructorParameterDescription(_data.flags)), ("url", ConstructorParameterDescription(_data.url)), ("blocks", ConstructorParameterDescription(_data.blocks)), ("photos", ConstructorParameterDescription(_data.photos)), ("documents", ConstructorParameterDescription(_data.documents)), ("views", ConstructorParameterDescription(_data.views))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -418,8 +418,8 @@ public extension Api {
|
|||
public init(name: String) {
|
||||
self.name = name
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockAnchor", [("name", self.name as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockAnchor", [("name", ConstructorParameterDescription(self.name))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockAudio: TypeConstructorDescription {
|
||||
|
|
@ -429,8 +429,8 @@ public extension Api {
|
|||
self.audioId = audioId
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockAudio", [("audioId", self.audioId as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockAudio", [("audioId", ConstructorParameterDescription(self.audioId)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockAuthorDate: TypeConstructorDescription {
|
||||
|
|
@ -440,8 +440,8 @@ public extension Api {
|
|||
self.author = author
|
||||
self.publishedDate = publishedDate
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockAuthorDate", [("author", self.author as Any), ("publishedDate", self.publishedDate as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockAuthorDate", [("author", ConstructorParameterDescription(self.author)), ("publishedDate", ConstructorParameterDescription(self.publishedDate))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockBlockquote: TypeConstructorDescription {
|
||||
|
|
@ -451,8 +451,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockBlockquote", [("text", self.text as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockBlockquote", [("text", ConstructorParameterDescription(self.text)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockChannel: TypeConstructorDescription {
|
||||
|
|
@ -460,8 +460,8 @@ public extension Api {
|
|||
public init(channel: Api.Chat) {
|
||||
self.channel = channel
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockChannel", [("channel", self.channel as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockChannel", [("channel", ConstructorParameterDescription(self.channel))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockCollage: TypeConstructorDescription {
|
||||
|
|
@ -471,8 +471,8 @@ public extension Api {
|
|||
self.items = items
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockCollage", [("items", self.items as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockCollage", [("items", ConstructorParameterDescription(self.items)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockCover: TypeConstructorDescription {
|
||||
|
|
@ -480,8 +480,8 @@ public extension Api {
|
|||
public init(cover: Api.PageBlock) {
|
||||
self.cover = cover
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockCover", [("cover", self.cover as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockCover", [("cover", ConstructorParameterDescription(self.cover))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockDetails: TypeConstructorDescription {
|
||||
|
|
@ -493,8 +493,8 @@ public extension Api {
|
|||
self.blocks = blocks
|
||||
self.title = title
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockDetails", [("flags", self.flags as Any), ("blocks", self.blocks as Any), ("title", self.title as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockDetails", [("flags", ConstructorParameterDescription(self.flags)), ("blocks", ConstructorParameterDescription(self.blocks)), ("title", ConstructorParameterDescription(self.title))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockEmbed: TypeConstructorDescription {
|
||||
|
|
@ -514,8 +514,8 @@ public extension Api {
|
|||
self.h = h
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockEmbed", [("flags", self.flags as Any), ("url", self.url as Any), ("html", self.html as Any), ("posterPhotoId", self.posterPhotoId as Any), ("w", self.w as Any), ("h", self.h as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockEmbed", [("flags", ConstructorParameterDescription(self.flags)), ("url", ConstructorParameterDescription(self.url)), ("html", ConstructorParameterDescription(self.html)), ("posterPhotoId", ConstructorParameterDescription(self.posterPhotoId)), ("w", ConstructorParameterDescription(self.w)), ("h", ConstructorParameterDescription(self.h)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockEmbedPost: TypeConstructorDescription {
|
||||
|
|
@ -535,8 +535,8 @@ public extension Api {
|
|||
self.blocks = blocks
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockEmbedPost", [("url", self.url as Any), ("webpageId", self.webpageId as Any), ("authorPhotoId", self.authorPhotoId as Any), ("author", self.author as Any), ("date", self.date as Any), ("blocks", self.blocks as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockEmbedPost", [("url", ConstructorParameterDescription(self.url)), ("webpageId", ConstructorParameterDescription(self.webpageId)), ("authorPhotoId", ConstructorParameterDescription(self.authorPhotoId)), ("author", ConstructorParameterDescription(self.author)), ("date", ConstructorParameterDescription(self.date)), ("blocks", ConstructorParameterDescription(self.blocks)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockFooter: TypeConstructorDescription {
|
||||
|
|
@ -544,8 +544,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockFooter", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockFooter", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockHeader: TypeConstructorDescription {
|
||||
|
|
@ -553,8 +553,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockHeader", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockHeader", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockKicker: TypeConstructorDescription {
|
||||
|
|
@ -562,8 +562,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockKicker", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockKicker", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockList: TypeConstructorDescription {
|
||||
|
|
@ -571,8 +571,8 @@ public extension Api {
|
|||
public init(items: [Api.PageListItem]) {
|
||||
self.items = items
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockList", [("items", self.items as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockList", [("items", ConstructorParameterDescription(self.items))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockMap: TypeConstructorDescription {
|
||||
|
|
@ -588,8 +588,8 @@ public extension Api {
|
|||
self.h = h
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockMap", [("geo", self.geo as Any), ("zoom", self.zoom as Any), ("w", self.w as Any), ("h", self.h as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockMap", [("geo", ConstructorParameterDescription(self.geo)), ("zoom", ConstructorParameterDescription(self.zoom)), ("w", ConstructorParameterDescription(self.w)), ("h", ConstructorParameterDescription(self.h)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockOrderedList: TypeConstructorDescription {
|
||||
|
|
@ -597,8 +597,8 @@ public extension Api {
|
|||
public init(items: [Api.PageListOrderedItem]) {
|
||||
self.items = items
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockOrderedList", [("items", self.items as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockOrderedList", [("items", ConstructorParameterDescription(self.items))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockParagraph: TypeConstructorDescription {
|
||||
|
|
@ -606,8 +606,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockParagraph", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockParagraph", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockPhoto: TypeConstructorDescription {
|
||||
|
|
@ -623,8 +623,8 @@ public extension Api {
|
|||
self.url = url
|
||||
self.webpageId = webpageId
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockPhoto", [("flags", self.flags as Any), ("photoId", self.photoId as Any), ("caption", self.caption as Any), ("url", self.url as Any), ("webpageId", self.webpageId as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockPhoto", [("flags", ConstructorParameterDescription(self.flags)), ("photoId", ConstructorParameterDescription(self.photoId)), ("caption", ConstructorParameterDescription(self.caption)), ("url", ConstructorParameterDescription(self.url)), ("webpageId", ConstructorParameterDescription(self.webpageId))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockPreformatted: TypeConstructorDescription {
|
||||
|
|
@ -634,8 +634,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.language = language
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockPreformatted", [("text", self.text as Any), ("language", self.language as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockPreformatted", [("text", ConstructorParameterDescription(self.text)), ("language", ConstructorParameterDescription(self.language))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockPullquote: TypeConstructorDescription {
|
||||
|
|
@ -645,8 +645,8 @@ public extension Api {
|
|||
self.text = text
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockPullquote", [("text", self.text as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockPullquote", [("text", ConstructorParameterDescription(self.text)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockRelatedArticles: TypeConstructorDescription {
|
||||
|
|
@ -656,8 +656,8 @@ public extension Api {
|
|||
self.title = title
|
||||
self.articles = articles
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockRelatedArticles", [("title", self.title as Any), ("articles", self.articles as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockRelatedArticles", [("title", ConstructorParameterDescription(self.title)), ("articles", ConstructorParameterDescription(self.articles))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockSlideshow: TypeConstructorDescription {
|
||||
|
|
@ -667,8 +667,8 @@ public extension Api {
|
|||
self.items = items
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockSlideshow", [("items", self.items as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockSlideshow", [("items", ConstructorParameterDescription(self.items)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockSubheader: TypeConstructorDescription {
|
||||
|
|
@ -676,8 +676,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockSubheader", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockSubheader", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockSubtitle: TypeConstructorDescription {
|
||||
|
|
@ -685,8 +685,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockSubtitle", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockSubtitle", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockTable: TypeConstructorDescription {
|
||||
|
|
@ -698,8 +698,8 @@ public extension Api {
|
|||
self.title = title
|
||||
self.rows = rows
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockTable", [("flags", self.flags as Any), ("title", self.title as Any), ("rows", self.rows as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockTable", [("flags", ConstructorParameterDescription(self.flags)), ("title", ConstructorParameterDescription(self.title)), ("rows", ConstructorParameterDescription(self.rows))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockTitle: TypeConstructorDescription {
|
||||
|
|
@ -707,8 +707,8 @@ public extension Api {
|
|||
public init(text: Api.RichText) {
|
||||
self.text = text
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockTitle", [("text", self.text as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockTitle", [("text", ConstructorParameterDescription(self.text))])
|
||||
}
|
||||
}
|
||||
public class Cons_pageBlockVideo: TypeConstructorDescription {
|
||||
|
|
@ -720,8 +720,8 @@ public extension Api {
|
|||
self.videoId = videoId
|
||||
self.caption = caption
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("pageBlockVideo", [("flags", self.flags as Any), ("videoId", self.videoId as Any), ("caption", self.caption as Any)])
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
return ("pageBlockVideo", [("flags", ConstructorParameterDescription(self.flags)), ("videoId", ConstructorParameterDescription(self.videoId)), ("caption", ConstructorParameterDescription(self.caption))])
|
||||
}
|
||||
}
|
||||
case pageBlockAnchor(Cons_pageBlockAnchor)
|
||||
|
|
@ -1011,66 +1011,66 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
public func descriptionFields() -> (String, [(String, ConstructorParameterDescription)]) {
|
||||
switch self {
|
||||
case .pageBlockAnchor(let _data):
|
||||
return ("pageBlockAnchor", [("name", _data.name as Any)])
|
||||
return ("pageBlockAnchor", [("name", ConstructorParameterDescription(_data.name))])
|
||||
case .pageBlockAudio(let _data):
|
||||
return ("pageBlockAudio", [("audioId", _data.audioId as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockAudio", [("audioId", ConstructorParameterDescription(_data.audioId)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockAuthorDate(let _data):
|
||||
return ("pageBlockAuthorDate", [("author", _data.author as Any), ("publishedDate", _data.publishedDate as Any)])
|
||||
return ("pageBlockAuthorDate", [("author", ConstructorParameterDescription(_data.author)), ("publishedDate", ConstructorParameterDescription(_data.publishedDate))])
|
||||
case .pageBlockBlockquote(let _data):
|
||||
return ("pageBlockBlockquote", [("text", _data.text as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockBlockquote", [("text", ConstructorParameterDescription(_data.text)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockChannel(let _data):
|
||||
return ("pageBlockChannel", [("channel", _data.channel as Any)])
|
||||
return ("pageBlockChannel", [("channel", ConstructorParameterDescription(_data.channel))])
|
||||
case .pageBlockCollage(let _data):
|
||||
return ("pageBlockCollage", [("items", _data.items as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockCollage", [("items", ConstructorParameterDescription(_data.items)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockCover(let _data):
|
||||
return ("pageBlockCover", [("cover", _data.cover as Any)])
|
||||
return ("pageBlockCover", [("cover", ConstructorParameterDescription(_data.cover))])
|
||||
case .pageBlockDetails(let _data):
|
||||
return ("pageBlockDetails", [("flags", _data.flags as Any), ("blocks", _data.blocks as Any), ("title", _data.title as Any)])
|
||||
return ("pageBlockDetails", [("flags", ConstructorParameterDescription(_data.flags)), ("blocks", ConstructorParameterDescription(_data.blocks)), ("title", ConstructorParameterDescription(_data.title))])
|
||||
case .pageBlockDivider:
|
||||
return ("pageBlockDivider", [])
|
||||
case .pageBlockEmbed(let _data):
|
||||
return ("pageBlockEmbed", [("flags", _data.flags as Any), ("url", _data.url as Any), ("html", _data.html as Any), ("posterPhotoId", _data.posterPhotoId as Any), ("w", _data.w as Any), ("h", _data.h as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockEmbed", [("flags", ConstructorParameterDescription(_data.flags)), ("url", ConstructorParameterDescription(_data.url)), ("html", ConstructorParameterDescription(_data.html)), ("posterPhotoId", ConstructorParameterDescription(_data.posterPhotoId)), ("w", ConstructorParameterDescription(_data.w)), ("h", ConstructorParameterDescription(_data.h)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockEmbedPost(let _data):
|
||||
return ("pageBlockEmbedPost", [("url", _data.url as Any), ("webpageId", _data.webpageId as Any), ("authorPhotoId", _data.authorPhotoId as Any), ("author", _data.author as Any), ("date", _data.date as Any), ("blocks", _data.blocks as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockEmbedPost", [("url", ConstructorParameterDescription(_data.url)), ("webpageId", ConstructorParameterDescription(_data.webpageId)), ("authorPhotoId", ConstructorParameterDescription(_data.authorPhotoId)), ("author", ConstructorParameterDescription(_data.author)), ("date", ConstructorParameterDescription(_data.date)), ("blocks", ConstructorParameterDescription(_data.blocks)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockFooter(let _data):
|
||||
return ("pageBlockFooter", [("text", _data.text as Any)])
|
||||
return ("pageBlockFooter", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockHeader(let _data):
|
||||
return ("pageBlockHeader", [("text", _data.text as Any)])
|
||||
return ("pageBlockHeader", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockKicker(let _data):
|
||||
return ("pageBlockKicker", [("text", _data.text as Any)])
|
||||
return ("pageBlockKicker", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockList(let _data):
|
||||
return ("pageBlockList", [("items", _data.items as Any)])
|
||||
return ("pageBlockList", [("items", ConstructorParameterDescription(_data.items))])
|
||||
case .pageBlockMap(let _data):
|
||||
return ("pageBlockMap", [("geo", _data.geo as Any), ("zoom", _data.zoom as Any), ("w", _data.w as Any), ("h", _data.h as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockMap", [("geo", ConstructorParameterDescription(_data.geo)), ("zoom", ConstructorParameterDescription(_data.zoom)), ("w", ConstructorParameterDescription(_data.w)), ("h", ConstructorParameterDescription(_data.h)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockOrderedList(let _data):
|
||||
return ("pageBlockOrderedList", [("items", _data.items as Any)])
|
||||
return ("pageBlockOrderedList", [("items", ConstructorParameterDescription(_data.items))])
|
||||
case .pageBlockParagraph(let _data):
|
||||
return ("pageBlockParagraph", [("text", _data.text as Any)])
|
||||
return ("pageBlockParagraph", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockPhoto(let _data):
|
||||
return ("pageBlockPhoto", [("flags", _data.flags as Any), ("photoId", _data.photoId as Any), ("caption", _data.caption as Any), ("url", _data.url as Any), ("webpageId", _data.webpageId as Any)])
|
||||
return ("pageBlockPhoto", [("flags", ConstructorParameterDescription(_data.flags)), ("photoId", ConstructorParameterDescription(_data.photoId)), ("caption", ConstructorParameterDescription(_data.caption)), ("url", ConstructorParameterDescription(_data.url)), ("webpageId", ConstructorParameterDescription(_data.webpageId))])
|
||||
case .pageBlockPreformatted(let _data):
|
||||
return ("pageBlockPreformatted", [("text", _data.text as Any), ("language", _data.language as Any)])
|
||||
return ("pageBlockPreformatted", [("text", ConstructorParameterDescription(_data.text)), ("language", ConstructorParameterDescription(_data.language))])
|
||||
case .pageBlockPullquote(let _data):
|
||||
return ("pageBlockPullquote", [("text", _data.text as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockPullquote", [("text", ConstructorParameterDescription(_data.text)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockRelatedArticles(let _data):
|
||||
return ("pageBlockRelatedArticles", [("title", _data.title as Any), ("articles", _data.articles as Any)])
|
||||
return ("pageBlockRelatedArticles", [("title", ConstructorParameterDescription(_data.title)), ("articles", ConstructorParameterDescription(_data.articles))])
|
||||
case .pageBlockSlideshow(let _data):
|
||||
return ("pageBlockSlideshow", [("items", _data.items as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockSlideshow", [("items", ConstructorParameterDescription(_data.items)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
case .pageBlockSubheader(let _data):
|
||||
return ("pageBlockSubheader", [("text", _data.text as Any)])
|
||||
return ("pageBlockSubheader", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockSubtitle(let _data):
|
||||
return ("pageBlockSubtitle", [("text", _data.text as Any)])
|
||||
return ("pageBlockSubtitle", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockTable(let _data):
|
||||
return ("pageBlockTable", [("flags", _data.flags as Any), ("title", _data.title as Any), ("rows", _data.rows as Any)])
|
||||
return ("pageBlockTable", [("flags", ConstructorParameterDescription(_data.flags)), ("title", ConstructorParameterDescription(_data.title)), ("rows", ConstructorParameterDescription(_data.rows))])
|
||||
case .pageBlockTitle(let _data):
|
||||
return ("pageBlockTitle", [("text", _data.text as Any)])
|
||||
return ("pageBlockTitle", [("text", ConstructorParameterDescription(_data.text))])
|
||||
case .pageBlockUnsupported:
|
||||
return ("pageBlockUnsupported", [])
|
||||
case .pageBlockVideo(let _data):
|
||||
return ("pageBlockVideo", [("flags", _data.flags as Any), ("videoId", _data.videoId as Any), ("caption", _data.caption as Any)])
|
||||
return ("pageBlockVideo", [("flags", ConstructorParameterDescription(_data.flags)), ("videoId", ConstructorParameterDescription(_data.videoId)), ("caption", ConstructorParameterDescription(_data.caption))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue