Skip to content

Commit

Permalink
Revert "修复iOS12上的encode问题"
Browse files Browse the repository at this point in the history
This reverts commit 9ab82ed.
  • Loading branch information
Mccc committed Dec 6, 2024
1 parent 9ab82ed commit b66977b
Show file tree
Hide file tree
Showing 9 changed files with 488 additions and 851 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- FBSnapshotTestCase/SwiftSupport (2.1.4):
- FBSnapshotTestCase/Core
- HandyJSON (5.0.0-beta.1)
- SmartCodable (4.3.1)
- SmartCodable (4.3.0-beta)
- SnapKit (5.6.0)

DEPENDENCIES:
Expand Down Expand Up @@ -39,7 +39,7 @@ SPEC CHECKSUMS:
CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978
SmartCodable: ff1dbe00d0b52644fb0cdc8e90258591a9dd1cf4
SmartCodable: 8985750f1bb521bf7f94ab898260d77f4dc32f24
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25

PODFILE CHECKSUM: 7f3af03f81934df0c035518074a7abbec8fa9d3f
Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/SmartCodable.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

928 changes: 462 additions & 466 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SmartCodable.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Pod::Spec.new do |s|
s.name = 'SmartCodable'
s.version = '4.3.1'
s.version = '4.3.0'
s.summary = '数据解析库'

s.homepage = 'https://github.com/intsig171'
Expand Down
21 changes: 2 additions & 19 deletions SmartCodable/Classes/JSONValue/JSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Mccc on 2024/5/17.
//

import Foundation
internal struct JSONParser {
var reader: DocumentReader
var depth: Int = 0
Expand Down Expand Up @@ -90,7 +91,7 @@ internal struct JSONParser {
self.depth += 1
defer { depth -= 1 }

// parse first value or end immediately
// parse first value or end immediatly
switch try reader.consumeWhitespace() {
case ._space, ._return, ._newline, ._tab:
preconditionFailure("Expected that all white space is consumed")
Expand Down Expand Up @@ -633,28 +634,10 @@ extension UInt8 {
internal static let _backslash = UInt8(ascii: "\\")

}

extension Array where Element == UInt8 {

internal static let _true = [UInt8(ascii: "t"), UInt8(ascii: "r"), UInt8(ascii: "u"), UInt8(ascii: "e")]
internal static let _false = [UInt8(ascii: "f"), UInt8(ascii: "a"), UInt8(ascii: "l"), UInt8(ascii: "s"), UInt8(ascii: "e")]
internal static let _null = [UInt8(ascii: "n"), UInt8(ascii: "u"), UInt8(ascii: "l"), UInt8(ascii: "l")]

}

enum JSONError: Swift.Error, Equatable {
case cannotConvertInputDataToUTF8
case unexpectedCharacter(ascii: UInt8, characterIndex: Int)
case unexpectedEndOfFile
case tooManyNestedArraysOrDictionaries(characterIndex: Int)
case invalidHexDigitSequence(String, index: Int)
case unexpectedEscapedCharacter(ascii: UInt8, in: String, index: Int)
case unescapedControlCharacterInString(ascii: UInt8, in: String, index: Int)
case expectedLowSurrogateUTF8SequenceAfterHighSurrogate(in: String, index: Int)
case couldNotCreateUnicodeScalarFromUInt32(in: String, index: Int, unicodeScalarValue: UInt32)
case numberWithLeadingZero(index: Int)
case numberIsNotRepresentableInSwift(parsed: String)
case singleFragmentFoundButNotAllowed
case invalidUTF8Sequence(Data, characterIndex: Int)
}

22 changes: 16 additions & 6 deletions SmartCodable/Classes/JSONValue/JSONValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ extension NSNumber {
return nil
}
}
enum JSONError: Swift.Error, Equatable {
case cannotConvertInputDataToUTF8
case unexpectedCharacter(ascii: UInt8, characterIndex: Int)
case unexpectedEndOfFile
case tooManyNestedArraysOrDictionaries(characterIndex: Int)
case invalidHexDigitSequence(String, index: Int)
case unexpectedEscapedCharacter(ascii: UInt8, in: String, index: Int)
case unescapedControlCharacterInString(ascii: UInt8, in: String, index: Int)
case expectedLowSurrogateUTF8SequenceAfterHighSurrogate(in: String, index: Int)
case couldNotCreateUnicodeScalarFromUInt32(in: String, index: Int, unicodeScalarValue: UInt32)
case numberWithLeadingZero(index: Int)
case numberIsNotRepresentableInSwift(parsed: String)
case singleFragmentFoundButNotAllowed
case invalidUTF8Sequence(Data, characterIndex: Int)
}



// for encdoe
Expand Down Expand Up @@ -378,12 +394,6 @@ extension JSONValue {
bytes.append(contentsOf: [._backslash, UInt8(ascii: "/")])
nextIndex = stringBytes.index(after: nextIndex)
startCopyIndex = nextIndex
} else {
// 如果不满足条件,直接把字符添加到 bytes 中
bytes.append(contentsOf: stringBytes[startCopyIndex ..< nextIndex])
bytes.append(stringBytes[nextIndex])
nextIndex = stringBytes.index(after: nextIndex)
startCopyIndex = nextIndex
}

default:
Expand Down
Loading

0 comments on commit b66977b

Please sign in to comment.