mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
b61426304b
commit_hash:30fce799ccb23434f200edd0798b01f7c17754a7
103 lines
2.0 KiB
Swift
103 lines
2.0 KiB
Swift
import Foundation
|
|
import Serialization
|
|
import VGSL
|
|
|
|
extension Expression where T == Bool {
|
|
func toValidSerializationValue() -> ValidSerializationValue {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == Double {
|
|
func toValidSerializationValue() -> ValidSerializationValue {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == Int {
|
|
func toValidSerializationValue() -> ValidSerializationValue {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == Color {
|
|
func toValidSerializationValue() -> String {
|
|
switch self {
|
|
case let .value(value):
|
|
value.hexString
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == String {
|
|
func toValidSerializationValue() -> String {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == URL {
|
|
func toValidSerializationValue() -> String {
|
|
switch self {
|
|
case let .value(value):
|
|
value.absoluteString
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == [Any] {
|
|
func toValidSerializationValue() -> ValidSerializationValue {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T: RawRepresentable, T.RawValue == String {
|
|
func toValidSerializationValue() -> String {
|
|
switch self {
|
|
case let .value(value):
|
|
value.rawValue
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Expression where T == [String: Any] {
|
|
func toValidSerializationValue() -> ValidSerializationValue {
|
|
switch self {
|
|
case let .value(value):
|
|
value
|
|
case let .link(link):
|
|
link.rawValue
|
|
}
|
|
}
|
|
}
|