Files
divkit/client/ios/DivKit/generated_sources/DivLayoutProviderTemplate.swift
T
feldspar ce9af20a5b Revert parsing logic update
commit_hash:c9419f063b7f8c5df41675acc9ed49d862850a2c
2026-01-16 23:06:00 +03:00

78 lines
3.5 KiB
Swift

// Generated code. Do not modify.
import Foundation
import Serialization
import VGSL
public final class DivLayoutProviderTemplate: TemplateValue, Sendable {
public let heightVariableName: Field<String>?
public let widthVariableName: Field<String>?
public convenience init(dictionary: [String: Any], templateToType: [TemplateName: String]) throws {
self.init(
heightVariableName: dictionary.getOptionalField("height_variable_name"),
widthVariableName: dictionary.getOptionalField("width_variable_name")
)
}
init(
heightVariableName: Field<String>? = nil,
widthVariableName: Field<String>? = nil
) {
self.heightVariableName = heightVariableName
self.widthVariableName = widthVariableName
}
private static func resolveOnlyLinks(context: TemplatesContext, parent: DivLayoutProviderTemplate?) -> DeserializationResult<DivLayoutProvider> {
let heightVariableNameValue = parent?.heightVariableName?.resolveOptionalValue(context: context) ?? .noValue
let widthVariableNameValue = parent?.widthVariableName?.resolveOptionalValue(context: context) ?? .noValue
let errors = mergeErrors(
heightVariableNameValue.errorsOrWarnings?.map { .nestedObjectError(field: "height_variable_name", error: $0) },
widthVariableNameValue.errorsOrWarnings?.map { .nestedObjectError(field: "width_variable_name", error: $0) }
)
let result = DivLayoutProvider(
heightVariableName: heightVariableNameValue.value,
widthVariableName: widthVariableNameValue.value
)
return errors.isEmpty ? .success(result) : .partialSuccess(result, warnings: NonEmptyArray(errors)!)
}
public static func resolveValue(context: TemplatesContext, parent: DivLayoutProviderTemplate?, useOnlyLinks: Bool) -> DeserializationResult<DivLayoutProvider> {
if useOnlyLinks {
return resolveOnlyLinks(context: context, parent: parent)
}
var heightVariableNameValue: DeserializationResult<String> = parent?.heightVariableName?.value() ?? .noValue
var widthVariableNameValue: DeserializationResult<String> = parent?.widthVariableName?.value() ?? .noValue
context.templateData.forEach { key, __dictValue in
switch key {
case "height_variable_name":
heightVariableNameValue = deserialize(__dictValue).merged(with: heightVariableNameValue)
case "width_variable_name":
widthVariableNameValue = deserialize(__dictValue).merged(with: widthVariableNameValue)
case parent?.heightVariableName?.link:
heightVariableNameValue = heightVariableNameValue.merged(with: { deserialize(__dictValue) })
case parent?.widthVariableName?.link:
widthVariableNameValue = widthVariableNameValue.merged(with: { deserialize(__dictValue) })
default: break
}
}
let errors = mergeErrors(
heightVariableNameValue.errorsOrWarnings?.map { .nestedObjectError(field: "height_variable_name", error: $0) },
widthVariableNameValue.errorsOrWarnings?.map { .nestedObjectError(field: "width_variable_name", error: $0) }
)
let result = DivLayoutProvider(
heightVariableName: heightVariableNameValue.value,
widthVariableName: widthVariableNameValue.value
)
return errors.isEmpty ? .success(result) : .partialSuccess(result, warnings: NonEmptyArray(errors)!)
}
private func mergedWithParent(templates: [TemplateName: Any]) throws -> DivLayoutProviderTemplate {
return self
}
public func resolveParent(templates: [TemplateName: Any]) throws -> DivLayoutProviderTemplate {
return try mergedWithParent(templates: templates)
}
}