Skip to content

Commit ee0b74b

Browse files
temp
1 parent b3789f8 commit ee0b74b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Sources/DynamicCodable/DynamicCodableDecoder.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
129129
is Primitive.UInt32.Type,
130130
is Primitive.UInt64.Type,
131131
is Primitive.Empty.Type: return try value.unwrap { throw error }
132+
// Special Cases
133+
// case is Date.Type: return unwrapDate() as! T
134+
// case is Data.Type: return unwrapData() as! T
135+
// case is URL.Type: return unwrapURL() as! T
136+
// case is Decimal.Type: return unwrapDecimal() as! T
137+
// case is _JSONStringDictionaryDecodableMarker.Type: return unwrapDictionary(as: T.self) as! T
132138
// Decodable Types
133139
default: return try T(from: self)
134140
}
@@ -150,6 +156,7 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
150156
return floatingPoint
151157
}
152158

159+
// may want to support both strict numeric checks as well as loose numeric checks (used below).
153160
switch representation {
154161
case .float64(let number): return try validate(T(number), originalValue: number)
155162
case .float32(let number): return try validate(T(number), originalValue: number)
@@ -164,6 +171,17 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
164171
case .uint32(let number): return try validate(T(number), originalValue: number)
165172
case .uint64(let number): return try validate(T(number), originalValue: number)
166173

174+
// case .string(let string):
175+
// if case .convertFromString(let posInfString, let negInfString, let nanString) = self.options.nonConformingFloatDecodingStrategy {
176+
// if string == posInfString {
177+
// return T.infinity
178+
// } else if string == negInfString {
179+
// return -T.infinity
180+
// } else if string == nanString {
181+
// return T.nan
182+
// }
183+
// }
184+
//
167185
case .string,
168186
.bool,
169187
.keyed,
@@ -190,6 +208,7 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
190208
return fixedWidthInteger
191209
}
192210

211+
// may want to support both strict numeric checks as well as loose numeric checks (used below).
193212
switch representation {
194213
case .int(let number): return try validate(T(exactly: number), originalValue: number)
195214
case .int8(let number): return try validate(T(exactly: number), originalValue: number)
@@ -231,6 +250,39 @@ extension DynamicCodableDecoder.Decoder {
231250

232251
var codingPath: [CodingKey] { decoder.codingPath }
233252

253+
// init(
254+
// decoder: DynamicCodableDecoder.Decoder,
255+
// codingPath: [CodingKey],
256+
// representation: [DynamicCodable.Key : DynamicCodable]
257+
// ) {
258+
// self.decoder = decoder
259+
// self.codingPath = codingPath
260+
//
261+
//// switch impl.options.keyDecodingStrategy {
262+
//// case .useDefaultKeys:
263+
//// self.dictionary = dictionary
264+
//// case .convertFromSnakeCase:
265+
//// // Convert the snake case keys in the container to camel case.
266+
//// // If we hit a duplicate key after conversion, then we'll use the first one we saw.
267+
//// // Effectively an undefined behavior with JSON dictionaries.
268+
//// var converted = [String: JSONValue]()
269+
//// converted.reserveCapacity(dictionary.count)
270+
//// dictionary.forEach { (key, value) in
271+
//// converted[JSONDecoder.KeyDecodingStrategy._convertFromSnakeCase(key)] = value
272+
//// }
273+
//// self.dictionary = converted
274+
//// case .custom(let converter):
275+
//// var converted = [String: JSONValue]()
276+
//// converted.reserveCapacity(dictionary.count)
277+
//// dictionary.forEach { (key, value) in
278+
//// var pathForKey = codingPath
279+
//// pathForKey.append(_JSONKey(stringValue: key)!)
280+
//// converted[converter(pathForKey).stringValue] = value
281+
//// }
282+
//// self.dictionary = converted
283+
//// }
284+
// }
285+
234286
var allKeys: [Key] {
235287
representation.keys.compactMap { dynamicKey in
236288
switch dynamicKey {

0 commit comments

Comments
 (0)